summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2019-11-25 18:05:46 +0100
committernsensfel <SpamShield0@noot-noot.org>2019-11-25 18:05:46 +0100
commit4094b24940779d298a3ff97525ac40deac093cab (patch)
tree43584afa8b22e571c4de0a0876381a1de7e96e06 /src
parenta2bac44a4c8abc064de55d0779edcb07aaa86e62 (diff)
...
Diffstat (limited to 'src')
-rw-r--r--src/map-editor/src/Comm/LoadMap.elm15
-rw-r--r--src/map-editor/src/Comm/Send.elm28
-rw-r--r--src/map-editor/src/Comm/SendMapUpdate.elm15
-rw-r--r--src/map-editor/src/Struct/Model.elm39
-rw-r--r--src/map-editor/src/Struct/ServerReply.elm4
-rw-r--r--src/map-editor/src/Update/HandleServerReply.elm29
-rw-r--r--src/map-editor/src/Update/SetToolboxTemplate.elm10
-rw-r--r--src/map-editor/src/View/SubMenu/TileStatus.elm97
-rw-r--r--src/map-editor/src/View/SubMenu/Tiles.elm20
-rw-r--r--src/roster-editor/src/Comm/JoinBattle.elm12
-rw-r--r--src/roster-editor/src/Comm/LoadRoster.elm15
-rw-r--r--src/roster-editor/src/Comm/Send.elm31
-rw-r--r--src/roster-editor/src/Comm/UpdateRoster.elm15
-rw-r--r--src/roster-editor/src/Struct/Model.elm5
-rw-r--r--src/roster-editor/src/Update/SetArmor.elm20
-rw-r--r--src/roster-editor/src/Update/SetGlyph.elm16
-rw-r--r--src/roster-editor/src/Update/SetGlyphBoard.elm12
-rw-r--r--src/roster-editor/src/Update/SetPortrait.elm12
-rw-r--r--src/roster-editor/src/Update/SetWeapon.elm20
-rw-r--r--src/roster-editor/src/View/ArmorSelection.elm29
-rw-r--r--src/roster-editor/src/View/GlyphBoardSelection.elm28
-rw-r--r--src/roster-editor/src/View/GlyphSelection.elm58
-rw-r--r--src/roster-editor/src/View/PortraitSelection.elm25
-rw-r--r--src/roster-editor/src/View/WeaponSelection.elm95
-rw-r--r--src/shared/battle-characters/BattleCharacters/Struct/DataSet.elm60
-rw-r--r--src/shared/battle-map/BattleMap/Comm/AddDataSetItem.elm (renamed from src/map-editor/src/Comm/AddTile.elm)24
-rw-r--r--src/shared/battle-map/BattleMap/Comm/AddTile.elm4
-rw-r--r--src/shared/battle-map/BattleMap/Struct/DataSet.elm7
-rw-r--r--src/shared/battle-map/BattleMap/Struct/DataSetItem.elm (renamed from src/map-editor/src/Comm/SetMap.elm)25
-rw-r--r--src/shared/battle-map/BattleMap/Struct/Map.elm10
-rw-r--r--src/shared/battle-map/BattleMap/Struct/TileInstance.elm27
31 files changed, 502 insertions, 305 deletions
diff --git a/src/map-editor/src/Comm/LoadMap.elm b/src/map-editor/src/Comm/LoadMap.elm
index b420d26..fb6e597 100644
--- a/src/map-editor/src/Comm/LoadMap.elm
+++ b/src/map-editor/src/Comm/LoadMap.elm
@@ -3,6 +3,9 @@ module Comm.LoadMap exposing (try)
-- Elm -------------------------------------------------------------------------
import Json.Encode
+-- Shared ----------------------------------------------------------------------
+import Struct.Flags
+
-- Local Module ----------------------------------------------------------------
import Comm.Send
@@ -23,8 +26,16 @@ try_encoding model =
(Just
(Json.Encode.object
[
- ("stk", (Json.Encode.string model.session_token)),
- ("pid", (Json.Encode.string model.player_id)),
+ ("stk",
+ (Json.Encode.string
+ (Struct.Flags.get_session_token model.flags)
+ )
+ ),
+ ("pid",
+ (Json.Encode.string
+ (Struct.Flags.get_user_id model.flags)
+ )
+ ),
("mid", (Json.Encode.string model.map_id))
]
)
diff --git a/src/map-editor/src/Comm/Send.elm b/src/map-editor/src/Comm/Send.elm
index c7b2f39..69e977d 100644
--- a/src/map-editor/src/Comm/Send.elm
+++ b/src/map-editor/src/Comm/Send.elm
@@ -6,11 +6,13 @@ import Http
import Json.Decode
import Json.Encode
+-- Battle Map ------------------------------------------------------------------
+import BattleMap.Comm.AddDataSetItem
+import BattleMap.Comm.SetMap
+
-- Local Module ----------------------------------------------------------------
-import Comm.AddTile
import Comm.AddTilePattern
import Comm.Okay
-import Comm.SetMap
import Struct.Event
import Struct.ServerReply
@@ -26,19 +28,25 @@ import Struct.Model
internal_decoder : String -> (Json.Decode.Decoder Struct.ServerReply.Type)
internal_decoder reply_type =
case reply_type of
- "add_tile" -> (Comm.AddTile.decode)
"add_tile_pattern" -> (Comm.AddTilePattern.decode)
- "set_map" -> (Comm.SetMap.decode)
+ "set_map" -> (BattleMap.Comm.SetMap.decode)
"okay" -> (Comm.Okay.decode)
"disconnected" -> (Json.Decode.succeed Struct.ServerReply.Disconnected)
other ->
- (Json.Decode.fail
- (
- "Unknown server command \""
- ++ other
- ++ "\""
- )
+ if
+ (String.startsWith
+ (BattleMap.Comm.AddDataSetItem.prefix)
+ reply_type
)
+ then (BattleMap.Comm.AddDataSetItem.get_decoder_for reply_type)
+ else
+ (Json.Decode.fail
+ (
+ "Unknown server command \""
+ ++ other
+ ++ "\""
+ )
+ )
decode : (Json.Decode.Decoder Struct.ServerReply.Type)
decode =
diff --git a/src/map-editor/src/Comm/SendMapUpdate.elm b/src/map-editor/src/Comm/SendMapUpdate.elm
index 023f24c..d7c149d 100644
--- a/src/map-editor/src/Comm/SendMapUpdate.elm
+++ b/src/map-editor/src/Comm/SendMapUpdate.elm
@@ -5,6 +5,9 @@ import Array
import Json.Encode
+-- Shared ----------------------------------------------------------------------
+import Struct.Flags
+
-- Battle Map ------------------------------------------------------------------
import BattleMap.Struct.Map
import BattleMap.Struct.TileInstance
@@ -29,8 +32,16 @@ encode_map model =
(Just
(Json.Encode.object
[
- ("stk", (Json.Encode.string model.session_token)),
- ("pid", (Json.Encode.string model.player_id)),
+ ("stk",
+ (Json.Encode.string
+ (Struct.Flags.get_session_token model.flags)
+ )
+ ),
+ ("pid",
+ (Json.Encode.string
+ (Struct.Flags.get_user_id model.flags)
+ )
+ ),
("mid", (Json.Encode.string model.map_id)),
("w", (Json.Encode.int (BattleMap.Struct.Map.get_width model.map))),
(
diff --git a/src/map-editor/src/Struct/Model.elm b/src/map-editor/src/Struct/Model.elm
index f5fb55e..141a9c2 100644
--- a/src/map-editor/src/Struct/Model.elm
+++ b/src/map-editor/src/Struct/Model.elm
@@ -1,10 +1,8 @@
module Struct.Model exposing
(
Type,
- tile_omnimods_fun,
new,
invalidate,
- add_tile,
add_tile_pattern,
reset,
clear_error
@@ -20,6 +18,7 @@ import Struct.Flags
import Battle.Struct.Omnimods
-- Battle Map ------------------------------------------------------------------
+import BattleMap.Struct.DataSet
import BattleMap.Struct.Location
import BattleMap.Struct.Map
import BattleMap.Struct.Tile
@@ -46,12 +45,11 @@ type alias Type =
BattleMap.Struct.Tile.VariantID
),
wild_tile_patterns : (List Struct.TilePattern.Type),
- tiles : (Dict.Dict BattleMap.Struct.Tile.Ref BattleMap.Struct.Tile.Type),
error : (Maybe Struct.Error.Type),
- player_id : String,
map_id : String,
- session_token : String,
- ui : Struct.UI.Type
+ ui : Struct.UI.Type,
+
+ map_dataset : (BattleMap.Struct.DataSet.Type)
}
--------------------------------------------------------------------------------
@@ -61,13 +59,6 @@ type alias Type =
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-tile_omnimods_fun : (
- Type ->
- (BattleMap.Struct.Location.Type -> Battle.Struct.Omnimods.Type)
- )
-tile_omnimods_fun model =
- (\loc -> (BattleMap.Struct.Map.get_omnimods_at loc model.tiles model.map))
-
new : Struct.Flags.Type -> Type
new flags =
let
@@ -78,19 +69,12 @@ new flags =
toolbox = (Struct.Toolbox.default),
help_request = Struct.HelpRequest.None,
map = (BattleMap.Struct.Map.empty),
- tiles = (Dict.empty),
tile_patterns = (Dict.empty),
wild_tile_patterns = [],
error = Nothing,
map_id = "",
- player_id =
- (
- if (flags.user_id == "")
- then "0"
- else flags.user_id
- ),
- session_token = flags.token,
- ui = (Struct.UI.default)
+ ui = (Struct.UI.default),
+ map_dataset = (BattleMap.Struct.DataSet.new)
}
in
case maybe_map_id of
@@ -105,17 +89,6 @@ new flags =
(Just id) -> {model | map_id = id}
-add_tile : BattleMap.Struct.Tile.Type -> Type -> Type
-add_tile tl model =
- {model |
- tiles =
- (Dict.insert
- (BattleMap.Struct.Tile.get_id tl)
- tl
- model.tiles
- )
- }
-
add_tile_pattern : Struct.TilePattern.Type -> Type -> Type
add_tile_pattern tp model =
if (Struct.TilePattern.is_wild tp)
diff --git a/src/map-editor/src/Struct/ServerReply.elm b/src/map-editor/src/Struct/ServerReply.elm
index 079b472..943706f 100644
--- a/src/map-editor/src/Struct/ServerReply.elm
+++ b/src/map-editor/src/Struct/ServerReply.elm
@@ -2,7 +2,7 @@ module Struct.ServerReply exposing (Type(..))
-- Battle Map ------------------------------------------------------------------
import BattleMap.Struct.Map
-import BattleMap.Struct.Tile
+import BattleMap.Struct.DataSetItem
-- Local Module ----------------------------------------------------------------
import Struct.TilePattern
@@ -14,7 +14,7 @@ import Struct.TilePattern
type Type =
Okay
| Disconnected
- | AddTile BattleMap.Struct.Tile.Type
+ | AddMapDataSetItem BattleMap.Struct.DataSetItem.Type
| AddTilePattern Struct.TilePattern.Type
| SetMap BattleMap.Struct.Map.Type
diff --git a/src/map-editor/src/Update/HandleServerReply.elm b/src/map-editor/src/Update/HandleServerReply.elm
index 80ca116..3caf506 100644
--- a/src/map-editor/src/Update/HandleServerReply.elm
+++ b/src/map-editor/src/Update/HandleServerReply.elm
@@ -14,7 +14,7 @@ import Util.Http
-- Battle Map ------------------------------------------------------------------
import BattleMap.Struct.Map
-import BattleMap.Struct.Tile
+import BattleMap.Struct.DataSetItem
-- Local Module ----------------------------------------------------------------
import Constants.IO
@@ -57,14 +57,20 @@ disconnected current_state =
]
)
-add_tile : (
- BattleMap.Struct.Tile.Type ->
+add_map_dataset_item : (
+ BattleMap.Struct.DataSetItem.Type ->
(Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
(Struct.Model.Type, (List (Cmd Struct.Event.Type)))
)
-add_tile tl current_state =
+add_map_dataset_item item current_state =
let (model, cmds) = current_state in
- ((Struct.Model.add_tile tl model), cmds)
+ (
+ {model |
+ map_dataset =
+ (BattleMap.Struct.DataSetItem.add_to item model.map_dataset)
+ },
+ cmds
+ )
add_tile_pattern : (
Struct.TilePattern.Type ->
@@ -82,7 +88,12 @@ set_map : (
)
set_map map current_state =
let (model, cmds) = current_state in
- ({model | map = (BattleMap.Struct.Map.solve_tiles model.tiles map)}, cmds)
+ (
+ {model |
+ map = (BattleMap.Struct.Map.solve_tiles model.map_dataset model.map)
+ },
+ cmds
+ )
refresh_map : (
(Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
@@ -92,7 +103,7 @@ refresh_map current_state =
let (model, cmds) = current_state in
(
{model |
- map = (BattleMap.Struct.Map.solve_tiles model.tiles model.map)
+ map = (BattleMap.Struct.Map.solve_tiles model.map_dataset model.map)
},
cmds
)
@@ -106,8 +117,8 @@ apply_command command current_state =
case command of
Struct.ServerReply.Disconnected -> (disconnected current_state)
- (Struct.ServerReply.AddTile tl) ->
- (add_tile tl current_state)
+ (Struct.ServerReply.AddMapDataSetItem it) ->
+ (add_map_dataset_item it current_state)
(Struct.ServerReply.AddTilePattern tp) ->
(add_tile_pattern tp current_state)
diff --git a/src/map-editor/src/Update/SetToolboxTemplate.elm b/src/map-editor/src/Update/SetToolboxTemplate.elm
index 621a8fe..0ad34e6 100644
--- a/src/map-editor/src/Update/SetToolboxTemplate.elm
+++ b/src/map-editor/src/Update/SetToolboxTemplate.elm
@@ -4,6 +4,7 @@ module Update.SetToolboxTemplate exposing (apply_to)
import Dict
-- Battle Map ------------------------------------------------------------------
+import BattleMap.Struct.DataSet
import BattleMap.Struct.TileInstance
-- Local Module ----------------------------------------------------------------
@@ -29,10 +30,11 @@ apply_to model main_class_id variant_id =
{model |
toolbox =
(Struct.Toolbox.set_template
- (
- case (Dict.get main_class_id model.tiles) of
- (Just tile) -> (BattleMap.Struct.TileInstance.default tile)
- _ -> (BattleMap.Struct.TileInstance.error 0 0)
+ (BattleMap.Struct.TileInstance.default
+ (BattleMap.Struct.DataSet.get_tile
+ main_class_id
+ model.map_dataset
+ )
)
model.toolbox
)
diff --git a/src/map-editor/src/View/SubMenu/TileStatus.elm b/src/map-editor/src/View/SubMenu/TileStatus.elm
index 0ef4590..eb61a2f 100644
--- a/src/map-editor/src/View/SubMenu/TileStatus.elm
+++ b/src/map-editor/src/View/SubMenu/TileStatus.elm
@@ -10,9 +10,10 @@ import Html.Attributes
import Util.Html
-- Battle ----------------------------------------------------------------------
-import Battle.Struct.Omnimods
+import Battle.View.Omnimods
-- Battle Map ------------------------------------------------------------------
+import BattleMap.Struct.DataSet
import BattleMap.Struct.Location
import BattleMap.Struct.Map
import BattleMap.Struct.Tile
@@ -50,29 +51,28 @@ get_icon tile =
)
get_name : (
- Struct.Model.Type ->
+ BattleMap.Struct.DataSet.Type ->
BattleMap.Struct.TileInstance.Type ->
(Html.Html Struct.Event.Type)
)
-get_name model tile_inst =
- case
- (Dict.get
- (BattleMap.Struct.TileInstance.get_class_id tile_inst)
- model.tiles
- )
- of
- Nothing -> (Util.Html.nothing)
- (Just tile) ->
- (Html.div
- [
- (Html.Attributes.class "info-card-name"),
- (Html.Attributes.class "info-card-text-field"),
- (Html.Attributes.class "tile-card-name")
- ]
- [
- (Html.text (BattleMap.Struct.Tile.get_name tile))
- ]
+get_name dataset tile_inst =
+ (Html.div
+ [
+ (Html.Attributes.class "info-card-name"),
+ (Html.Attributes.class "info-card-text-field"),
+ (Html.Attributes.class "tile-card-name")
+ ]
+ [
+ (Html.text
+ (BattleMap.Struct.Tile.get_name
+ (BattleMap.Struct.DataSet.get_tile
+ (BattleMap.Struct.TileInstance.get_class_id tile_inst)
+ dataset
+ )
+ )
)
+ ]
+ )
get_cost : BattleMap.Struct.TileInstance.Type -> (Html.Html Struct.Event.Type)
get_cost tile_inst =
@@ -121,53 +121,6 @@ get_location tile_inst =
]
)
-get_mod_html : (String, Int) -> (Html.Html Struct.Event.Type)
-get_mod_html mod =
- let
- (category, value) = mod
- in
- (Html.div
- [
- (Html.Attributes.class "info-card-mod")
- ]
- [
- (Html.text
- (category ++ ": " ++ (String.fromInt value))
- )
- ]
- )
-
-get_omnimods_listing : (List (String, Int)) -> (Html.Html Struct.Event.Type)
-get_omnimods_listing mod_list =
- (Html.div
- [
- (Html.Attributes.class "info-card-omnimods-listing")
- ]
- (List.map (get_mod_html) mod_list)
- )
-
-get_omnimods : Battle.Struct.Omnimods.Type -> (Html.Html Struct.Event.Type)
-get_omnimods omnimods =
- (Html.div
- [
- (Html.Attributes.class "info-card-omnimods")
- ]
- [
- (Html.text "Attributes Modifiers"),
- (get_omnimods_listing
- (Battle.Struct.Omnimods.get_attribute_mods omnimods)
- ),
- (Html.text "Attack Modifiers"),
- (get_omnimods_listing
- (Battle.Struct.Omnimods.get_attack_mods omnimods)
- ),
- (Html.text "Defense Modifiers"),
- (get_omnimods_listing
- (Battle.Struct.Omnimods.get_defense_mods omnimods)
- )
- ]
- )
-
get_tile_info_html : (
Struct.Model.Type ->
BattleMap.Struct.Location.Type ->
@@ -182,7 +135,7 @@ get_tile_info_html model loc =
(Html.Attributes.class "tile-card")
]
[
- (get_name model tile),
+ (get_name model.map_dataset tile),
(Html.div
[
(Html.Attributes.class "info-card-top"),
@@ -194,7 +147,13 @@ get_tile_info_html model loc =
(get_cost tile)
]
),
- (get_omnimods ((Struct.Model.tile_omnimods_fun model) loc))
+ (Battle.View.Omnimods.get_signed_html
+ (BattleMap.Struct.Map.get_omnimods_at
+ loc
+ model.map_dataset
+ model.map
+ )
+ )
]
)
diff --git a/src/map-editor/src/View/SubMenu/Tiles.elm b/src/map-editor/src/View/SubMenu/Tiles.elm
index 16b147e..a9136ff 100644
--- a/src/map-editor/src/View/SubMenu/Tiles.elm
+++ b/src/map-editor/src/View/SubMenu/Tiles.elm
@@ -4,11 +4,13 @@ module View.SubMenu.Tiles exposing (get_html)
import Dict
import Html
+import Html.Lazy
import Html.Attributes
import Html.Events
-- Battle Map ------------------------------------------------------------------
import BattleMap.Struct.Tile
+import BattleMap.Struct.DataSet
import BattleMap.Struct.TileInstance
import BattleMap.View.Tile
@@ -42,11 +44,8 @@ get_icon_html (ref, tile) =
)
)
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
-get_html model =
+true_get_html : BattleMap.Struct.DataSet.Type -> (Html.Html Struct.Event.Type)
+true_get_html dataset =
(Html.div
[
(Html.Attributes.class "tabmenu-content"),
@@ -54,6 +53,15 @@ get_html model =
]
(List.map
(get_icon_html)
- (Dict.toList model.tiles)
+ (Dict.toList (BattleMap.Struct.DataSet.get_tiles dataset))
)
)
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
+get_html model =
+ (Html.Lazy.lazy
+ (true_get_html)
+ model.map_dataset
+ )
diff --git a/src/roster-editor/src/Comm/JoinBattle.elm b/src/roster-editor/src/Comm/JoinBattle.elm
index eb204df..90978a9 100644
--- a/src/roster-editor/src/Comm/JoinBattle.elm
+++ b/src/roster-editor/src/Comm/JoinBattle.elm
@@ -28,8 +28,16 @@ try_encoding model =
(Just
(Json.Encode.object
[
- ("stk", (Json.Encode.string model.session_token)),
- ("pid", (Json.Encode.string model.player_id)),
+ ("stk",
+ (Json.Encode.string
+ (Struct.Flags.get_session_token model.flags)
+ )
+ ),
+ ("pid",
+ (Json.Encode.string
+ (Struct.Flags.get_user_id model.flags)
+ )
+ ),
(
"six",
(Json.Encode.int
diff --git a/src/roster-editor/src/Comm/LoadRoster.elm b/src/roster-editor/src/Comm/LoadRoster.elm
index babe0f6..062caf2 100644
--- a/src/roster-editor/src/Comm/LoadRoster.elm
+++ b/src/roster-editor/src/Comm/LoadRoster.elm
@@ -3,6 +3,9 @@ module Comm.LoadRoster exposing (try)
-- Elm -------------------------------------------------------------------------
import Json.Encode
+-- Shared ----------------------------------------------------------------------
+import Struct.Flags
+
-- Local Module ----------------------------------------------------------------
import Comm.Send
@@ -23,8 +26,16 @@ try_encoding model =
(Just
(Json.Encode.object
[
- ("stk", (Json.Encode.string model.session_token)),
- ("pid", (Json.Encode.string model.player_id)),
+ ("stk",
+ (Json.Encode.string
+ (Struct.Flags.get_session_token model.flags)
+ )
+ ),
+ ("pid",
+ (Json.Encode.string
+ (Struct.Flags.get_user_id model.flags)
+ )
+ ),
("rid", (Json.Encode.string model.roster_id))
]
)
diff --git a/src/roster-editor/src/Comm/Send.elm b/src/roster-editor/src/Comm/Send.elm
index 3253f96..f6e9847 100644
--- a/src/roster-editor/src/Comm/Send.elm
+++ b/src/roster-editor/src/Comm/Send.elm
@@ -7,11 +7,7 @@ import Json.Decode
import Json.Encode
--- Battle Characters ----------------------------------------------------------
-import BattleCharacters.Comm.AddArmor
-import BattleCharacters.Comm.AddGlyph
-import BattleCharacters.Comm.AddGlyphBoard
-import BattleCharacters.Comm.AddPortrait
-import BattleCharacters.Comm.AddWeapon
+import BattleCharacters.Comm.AddDataSetItem
--- Local Module ---------------------------------------------------------------
import Comm.GoTo
@@ -36,24 +32,25 @@ internal_decoder reply_type =
"add_char" -> (Comm.AddChar.decode)
- "add_armor" -> (BattleCharacters.Comm.AddArmor.decode)
- "add_weapon" -> (BattleCharacters.Comm.AddWeapon.decode)
- "add_portrait" -> (BattleCharacters.Comm.AddPortrait.decode)
- "add_glyph" -> (BattleCharacters.Comm.AddGlyph.decode)
- "add_glyph_board" -> (BattleCharacters.Comm.AddGlyphBoard.decode)
-
"disconnected" -> (Json.Decode.succeed Struct.ServerReply.Disconnected)
"goto" -> (Comm.GoTo.decode)
"okay" -> (Json.Decode.succeed Struct.ServerReply.Okay)
other ->
- (Json.Decode.fail
- (
- "Unknown server command \""
- ++ other
- ++ "\""
- )
+ if
+ (String.startsWith
+ (BattleCharacters.Comm.AddDataSetItem.prefix)
+ reply_type
)
+ then (BattleCharacters.Comm.AddDataSetItem.get_decoder_for reply_type)
+ else
+ (Json.Decode.fail
+ (
+ "Unknown server command \""
+ ++ other
+ ++ "\""
+ )
+ )
decode : (Json.Decode.Decoder Struct.ServerReply.Type)
decode =
diff --git a/src/roster-editor/src/Comm/UpdateRoster.elm b/src/roster-editor/src/Comm/UpdateRoster.elm
index 9f77fc4..a635359 100644
--- a/src/roster-editor/src/Comm/UpdateRoster.elm
+++ b/src/roster-editor/src/Comm/UpdateRoster.elm
@@ -7,6 +7,9 @@ import List
import Json.Encode
+-- Shared ----------------------------------------------------------------------
+import Struct.Flags
+
-- Local Module ----------------------------------------------------------------
import Comm.Send
@@ -28,8 +31,16 @@ try_encoding model =
(Just
(Json.Encode.object
[
- ("stk", (Json.Encode.string model.session_token)),
- ("pid", (Json.Encode.string model.player_id)),
+ ("stk",
+ (Json.Encode.string
+ (Struct.Flags.get_session_token model.flags)
+ )
+ ),
+ ("pid",
+ (Json.Encode.string
+ (Struct.Flags.get_user_id model.flags)
+ )
+ ),
(
"rst",
(Json.Encode.list
diff --git a/src/roster-editor/src/Struct/Model.elm b/src/roster-editor/src/Struct/Model.elm
index e345aaa..c3903d7 100644
--- a/src/roster-editor/src/Struct/Model.elm
+++ b/src/roster-editor/src/Struct/Model.elm
@@ -24,13 +24,8 @@ import Struct.Flags
import Util.Array
-- Battle Characters -----------------------------------------------------------
-import BattleCharacters.Struct.Armor
import BattleCharacters.Struct.DataSet
import BattleCharacters.Struct.Equipment
-import BattleCharacters.Struct.Glyph
-import BattleCharacters.Struct.GlyphBoard
-import BattleCharacters.Struct.Portrait
-import BattleCharacters.Struct.Weapon
-- Local Module ----------------------------------------------------------------
import Struct.Character
diff --git a/src/roster-editor/src/Update/SetArmor.elm b/src/roster-editor/src/Update/SetArmor.elm
index 3dc899c..310ffaa 100644
--- a/src/roster-editor/src/Update/SetArmor.elm
+++ b/src/roster-editor/src/Update/SetArmor.elm
@@ -6,6 +6,7 @@ import Dict
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Armor
import BattleCharacters.Struct.Character
+import BattleCharacters.Struct.DataSet
import BattleCharacters.Struct.Equipment
-- Local Module ----------------------------------------------------------------
@@ -46,12 +47,23 @@ apply_to : (
BattleCharacters.Struct.Armor.Ref ->
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
-apply_to model ref =
+apply_to model armor_id =
(
(
- case (model.edited_char, (Dict.get ref model.armors)) of
- ((Just char), (Just armor)) ->
- {model | edited_char = (Just (equip armor char)) }
+ case model.edited_char of
+ (Just char) ->
+ {model |
+ edited_char =
+ (Just
+ (equip
+ (BattleCharacters.Struct.DataSet.get_armor
+ armor_id
+ model.characters_dataset
+ )
+ char
+ )
+ )
+ }
_ -> model
),
diff --git a/src/roster-editor/src/Update/SetGlyph.elm b/src/roster-editor/src/Update/SetGlyph.elm
index 067cf7c..9c00fcd 100644
--- a/src/roster-editor/src/Update/SetGlyph.elm
+++ b/src/roster-editor/src/Update/SetGlyph.elm
@@ -4,9 +4,10 @@ module Update.SetGlyph exposing (apply_to)
import Dict
-- Battle Characters -----------------------------------------------------------
-import BattleCharacters.Struct.Glyph
-import BattleCharacters.Struct.Equipment
import BattleCharacters.Struct.Character
+import BattleCharacters.Struct.DataSet
+import BattleCharacters.Struct.Equipment
+import BattleCharacters.Struct.Glyph
-- Local Module ----------------------------------------------------------------
import Struct.Character
@@ -26,11 +27,11 @@ apply_to : (
BattleCharacters.Struct.Glyph.Ref ->
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
-apply_to model ref =
+apply_to model glyph_id =
(
(
- case (model.edited_char, (Dict.get ref model.glyphs)) of
- ((Just char), (Just glyph)) ->
+ case model.edited_char of
+ (Just char) ->
let
base_char = (Struct.Character.get_base_character char)
(glyph_slot, glyph_modifier) =
@@ -38,7 +39,10 @@ apply_to model ref =
updated_equipment =
(BattleCharacters.Struct.Equipment.set_glyph
glyph_slot
- glyph
+ (BattleCharacters.Struct.DataSet.get_glyph
+ glyph_id
+ model.characters_dataset
+ )
(BattleCharacters.Struct.Character.get_equipment
base_char
)
diff --git a/src/roster-editor/src/Update/SetGlyphBoard.elm b/src/roster-editor/src/Update/SetGlyphBoard.elm
index 9f0f452..c7f1f5b 100644
--- a/src/roster-editor/src/Update/SetGlyphBoard.elm
+++ b/src/roster-editor/src/Update/SetGlyphBoard.elm
@@ -5,6 +5,7 @@ import Dict
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Character
+import BattleCharacters.Struct.DataSet
import BattleCharacters.Struct.Equipment
import BattleCharacters.Struct.GlyphBoard
@@ -25,16 +26,19 @@ apply_to : (
BattleCharacters.Struct.GlyphBoard.Ref ->
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
-apply_to model ref =
+apply_to model glyph_board_id =
(
(
- case (model.edited_char, (Dict.get ref model.glyph_boards)) of
- ((Just char), (Just glyph_board)) ->
+ case model.edited_char of
+ (Just char) ->
let
base_char = (Struct.Character.get_base_character char)
updated_equipment =
(BattleCharacters.Struct.Equipment.set_glyph_board
- glyph_board
+ (BattleCharacters.Struct.DataSet.get_glyph_board
+ glyph_board_id
+ model.characters_dataset
+ )
(BattleCharacters.Struct.Character.get_equipment
base_char
)
diff --git a/src/roster-editor/src/Update/SetPortrait.elm b/src/roster-editor/src/Update/SetPortrait.elm
index 369d644..a296d77 100644
--- a/src/roster-editor/src/Update/SetPortrait.elm
+++ b/src/roster-editor/src/Update/SetPortrait.elm
@@ -5,6 +5,7 @@ import Dict
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Character
+import BattleCharacters.Struct.DataSet
import BattleCharacters.Struct.Equipment
import BattleCharacters.Struct.Portrait
@@ -25,11 +26,11 @@ apply_to : (
BattleCharacters.Struct.Portrait.Ref ->
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
-apply_to model ref =
+apply_to model portrait_id =
(
(
- case (model.edited_char, (Dict.get ref model.portraits)) of
- ((Just char), (Just portrait)) ->
+ case model.edited_char of
+ (Just char) ->
let base_char = (Struct.Character.get_base_character char) in
{model |
edited_char =
@@ -37,7 +38,10 @@ apply_to model ref =
(Struct.Character.set_base_character
(BattleCharacters.Struct.Character.set_equipment
(BattleCharacters.Struct.Equipment.set_portrait
- portrait
+ (BattleCharacters.Struct.DataSet.get_portrait
+ portrait_id
+ model.characters_dataset
+ )
(BattleCharacters.Struct.Character.get_equipment
base_char
)
diff --git a/src/roster-editor/src/Update/SetWeapon.elm b/src/roster-editor/src/Update/SetWeapon.elm
index 56ded72..20d3797 100644
--- a/src/roster-editor/src/Update/SetWeapon.elm
+++ b/src/roster-editor/src/Update/SetWeapon.elm
@@ -5,6 +5,7 @@ import Dict
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Character
+import BattleCharacters.Struct.DataSet
import BattleCharacters.Struct.Equipment
import BattleCharacters.Struct.Weapon
@@ -57,12 +58,23 @@ apply_to : (
BattleCharacters.Struct.Weapon.Ref ->
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
-apply_to model ref =
+apply_to model weapon_id =
(
(
- case (model.edited_char, (Dict.get ref model.weapons)) of
- ((Just char), (Just weapon)) ->
- {model | edited_char = (Just (equip weapon char)) }
+ case model.edited_char of
+ (Just char) ->
+ {model |
+ edited_char =
+ (Just
+ (equip
+ (BattleCharacters.Struct.DataSet.get_weapon
+ weapon_id
+ model.characters_dataset
+ )
+ char
+ )
+ )
+ }
_ -> model
),
diff --git a/src/roster-editor/src/View/ArmorSelection.elm b/src/roster-editor/src/View/ArmorSelection.elm
index 671e56e..ae54d5c 100644
--- a/src/roster-editor/src/View/ArmorSelection.elm
+++ b/src/roster-editor/src/View/ArmorSelection.elm
@@ -6,12 +6,14 @@ import Dict
import Html
import Html.Attributes
import Html.Events
+import Html.Lazy
-- Battle ----------------------------------------------------------------------
import Battle.View.Omnimods
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Armor
+import BattleCharacters.Struct.DataSet
-- Local Module ----------------------------------------------------------------
import Struct.Event
@@ -68,11 +70,11 @@ get_armor_html armor =
]
)
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
-get_html model =
+true_get_html : (
+ BattleCharacters.Struct.DataSet.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+true_get_html dataset =
(Html.div
[
(Html.Attributes.class "selection-window"),
@@ -84,7 +86,22 @@ get_html model =
[
(Html.Attributes.class "selection-window-listing")
]
- (List.map (get_armor_html) (Dict.values model.armors))
+ (List.map
+ (get_armor_html)
+ (Dict.values
+ (BattleCharacters.Struct.DataSet.get_armors dataset)
+ )
+ )
)
]
)
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
+get_html model =
+ (Html.Lazy.lazy
+ (true_get_html)
+ model.characters_dataset
+ )
diff --git a/src/roster-editor/src/View/GlyphBoardSelection.elm b/src/roster-editor/src/View/GlyphBoardSelection.elm
index b9edfa8..775a13a 100644
--- a/src/roster-editor/src/View/GlyphBoardSelection.elm
+++ b/src/roster-editor/src/View/GlyphBoardSelection.elm
@@ -4,10 +4,12 @@ module View.GlyphBoardSelection exposing (get_html)
import Dict
import Html
+import Html.Lazy
import Html.Attributes
import Html.Events
-- Battle Characters -----------------------------------------------------------
+import BattleCharacters.Struct.DataSet
import BattleCharacters.Struct.GlyphBoard
-- Local Module ----------------------------------------------------------------
@@ -46,11 +48,11 @@ get_glyph_board_html glyph_board =
]
)
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
-get_html model =
+true_get_html : (
+ BattleCharacters.Struct.DataSet.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+true_get_html dataset =
(Html.div
[
(Html.Attributes.class "selection-window"),
@@ -62,7 +64,21 @@ get_html model =
[
(Html.Attributes.class "selection-window-listing")
]
- (List.map (get_glyph_board_html) (Dict.values model.glyph_boards))
+ (List.map
+ (get_glyph_board_html)
+ (Dict.values
+ (BattleCharacters.Struct.DataSet.get_glyph_boards dataset)
+ )
+ )
)
]
)
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
+get_html model =
+ (Html.Lazy.lazy
+ (true_get_html)
+ model.characters_dataset
+ )
diff --git a/src/roster-editor/src/View/GlyphSelection.elm b/src/roster-editor/src/View/GlyphSelection.elm
index 9cc825d..8d4ef84 100644
--- a/src/roster-editor/src/View/GlyphSelection.elm
+++ b/src/roster-editor/src/View/GlyphSelection.elm
@@ -8,15 +8,20 @@ import Set
import Dict
import Html
+import Html.Lazy
import Html.Attributes
import Html.Events
+-- Shared ----------------------------------------------------------------------
+import Util.Html
+
-- Battle ----------------------------------------------------------------------
import Battle.Struct.Omnimods
import Battle.View.Omnimods
-- Battle Characters -----------------------------------------------------------
+import BattleCharacters.Struct.DataSet
import BattleCharacters.Struct.Character
import BattleCharacters.Struct.Equipment
import BattleCharacters.Struct.Glyph
@@ -84,23 +89,23 @@ get_glyph_html invalid_family_ids factor glyph =
]
)
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
-get_html model =
- (Html.div
- [
- (Html.Attributes.class "selection-window"),
- (Html.Attributes.class "glyph-management")
- ]
- (
- case model.edited_char of
- Nothing -> [ (Html.text "Choose a character first.") ]
- (Just char) ->
+true_get_html : (
+ (Maybe Struct.Character.Type) ->
+ Int ->
+ BattleCharacters.Struct.DataSet.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+true_get_html maybe_char glyph_modifier dataset =
+ case maybe_char of
+ Nothing -> (Util.Html.nothing)
+ (Just char) ->
+ (Html.div
+ [
+ (Html.Attributes.class "selection-window"),
+ (Html.Attributes.class "glyph-management")
+ ]
+ (
let
- (slot_index, glyph_modifier) =
- (Struct.UI.get_glyph_slot model.ui)
glyph_multiplier =
((toFloat glyph_modifier) / 100.0)
used_glyph_family_indices =
@@ -117,9 +122,26 @@ get_html model =
used_glyph_family_indices
glyph_multiplier
)
- (Dict.values model.glyphs)
+ (Dict.values
+ (BattleCharacters.Struct.DataSet.get_glyphs
+ dataset
+ )
+ )
)
)
]
+ )
+ )
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
+get_html model =
+ let (slot_index, glyph_modifier) = (Struct.UI.get_glyph_slot model.ui) in
+ (Html.Lazy.lazy3
+ (true_get_html)
+ model.edited_char
+ glyph_modifier
+ model.characters_dataset
)
- )
diff --git a/src/roster-editor/src/View/PortraitSelection.elm b/src/roster-editor/src/View/PortraitSelection.elm
index 9065c9d..fbed67b 100644
--- a/src/roster-editor/src/View/PortraitSelection.elm
+++ b/src/roster-editor/src/View/PortraitSelection.elm
@@ -6,11 +6,13 @@ import Dict
import Html
import Html.Attributes
import Html.Events
+import Html.Lazy
import List
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Portrait
+import BattleCharacters.Struct.DataSet
-- Local Module ----------------------------------------------------------------
import Struct.Event
@@ -88,11 +90,11 @@ get_portrait_html pt =
]
)
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
-get_html model =
+true_get_html : (
+ BattleCharacters.Struct.DataSet.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+true_get_html dataset =
(Html.div
[
(Html.Attributes.class "selection-window"),
@@ -106,8 +108,19 @@ get_html model =
]
(List.map
(get_portrait_html)
- (Dict.values model.portraits)
+ (Dict.values
+ (BattleCharacters.Struct.DataSet.get_portraits dataset)
+ )
)
)
]
)
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
+get_html model =
+ (Html.Lazy.lazy
+ (true_get_html)
+ model.characters_dataset
+ )
diff --git a/src/roster-editor/src/View/WeaponSelection.elm b/src/roster-editor/src/View/WeaponSelection.elm
index a5a8293..830ec72 100644
--- a/src/roster-editor/src/View/WeaponSelection.elm
+++ b/src/roster-editor/src/View/WeaponSelection.elm
@@ -4,6 +4,7 @@ module View.WeaponSelection exposing (get_html)
import Dict
import Html
+import Html.Lazy
import Html.Attributes
import Html.Events
@@ -15,6 +16,7 @@ import Battle.View.Omnimods
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Character
+import BattleCharacters.Struct.DataSet
import BattleCharacters.Struct.Weapon
-- Local Module ----------------------------------------------------------------
@@ -87,6 +89,59 @@ get_weapon_html weapon =
]
)
+get_weapon_htmls : (
+ Bool ->
+ BattleCharacters.Struct.DataSet.Type ->
+ (List (Html.Html Struct.Event.Type))
+ )
+get_weapon_htmls is_selecting_secondary dataset =
+ if (is_selecting_secondary)
+ then
+ (List.filterMap
+ (\wp ->
+ if (BattleCharacters.Struct.Weapon.get_is_primary wp)
+ then Nothing
+ else (Just (get_weapon_html wp))
+ )
+ (Dict.values
+ (BattleCharacters.Struct.DataSet.get_weapons dataset)
+ )
+ )
+ else
+ (List.map
+ (get_weapon_html)
+ (Dict.values
+ (BattleCharacters.Struct.DataSet.get_weapons dataset)
+ )
+ )
+
+true_get_html : (
+ Bool ->
+ BattleCharacters.Struct.DataSet.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+true_get_html is_selecting_secondary dataset =
+ (Html.div
+ [
+ (Html.Attributes.class "selection-window"),
+ (Html.Attributes.class "weapon-selection")
+ ]
+ [
+ (Html.text
+ (
+ if (is_selecting_secondary)
+ then "Secondary Weapon Selection"
+ else "Primary Weapon Selection"
+ )
+ ),
+ (Html.div
+ [
+ (Html.Attributes.class "selection-window-listing")
+ ]
+ (get_weapon_htmls is_selecting_secondary dataset)
+ )
+ ]
+ )
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -101,40 +156,8 @@ get_html model =
(Struct.Character.get_base_character char)
)
in
- (Html.div
- [
- (Html.Attributes.class "selection-window"),
- (Html.Attributes.class "weapon-selection")
- ]
- [
- (Html.text
- (
- if (is_selecting_secondary)
- then "Secondary Weapon Selection"
- else "Primary Weapon Selection"
- )
- ),
- (Html.div
- [
- (Html.Attributes.class "selection-window-listing")
- ]
- (List.map
- (get_weapon_html)
- (List.filter
- (\e ->
- (not
- (
- is_selecting_secondary
- &&
- (BattleCharacters.Struct.Weapon.get_is_primary
- e
- )
- )
- )
- )
- (Dict.values model.weapons)
- )
- )
- )
- ]
+ (Html.Lazy.lazy2
+ (true_get_html)
+ is_selecting_secondary
+ model.characters_dataset
)
diff --git a/src/shared/battle-characters/BattleCharacters/Struct/DataSet.elm b/src/shared/battle-characters/BattleCharacters/Struct/DataSet.elm
index 3e938a2..2e87342 100644
--- a/src/shared/battle-characters/BattleCharacters/Struct/DataSet.elm
+++ b/src/shared/battle-characters/BattleCharacters/Struct/DataSet.elm
@@ -4,16 +4,22 @@ module BattleCharacters.Struct.DataSet exposing
new,
is_ready,
get_weapon,
+ get_weapons,
add_weapon,
get_armor,
+ get_armors,
add_armor,
get_portrait,
+ get_portraits,
add_portrait,
get_glyph,
+ get_glyphs,
add_glyph,
get_glyph_board,
+ get_glyph_boards,
add_glyph_board,
get_skill,
+ get_skills,
add_skill
)
@@ -99,6 +105,15 @@ is_ready data_set =
----------------
---- Weapon ----
----------------
+get_weapons : (
+ Type ->
+ (Dict.Dict
+ BattleCharacters.Struct.Weapon.Ref
+ BattleCharacters.Struct.Weapon.Type
+ )
+ )
+get_weapons data_set = data_set.weapons
+
get_weapon : (
BattleCharacters.Struct.Weapon.Ref ->
Type ->
@@ -123,6 +138,15 @@ add_weapon wp data_set =
---------------
---- Armor ----
---------------
+get_armors : (
+ Type ->
+ (Dict.Dict
+ BattleCharacters.Struct.Armor.Ref
+ BattleCharacters.Struct.Armor.Type
+ )
+ )
+get_armors data_set = data_set.armors
+
get_armor : (
BattleCharacters.Struct.Armor.Ref ->
Type ->
@@ -147,6 +171,15 @@ add_armor ar data_set =
------------------
---- Portrait ----
------------------
+get_portraits : (
+ Type ->
+ (Dict.Dict
+ BattleCharacters.Struct.Portrait.Ref
+ BattleCharacters.Struct.Portrait.Type
+ )
+ )
+get_portraits data_set = data_set.portraits
+
get_portrait : (
BattleCharacters.Struct.Portrait.Ref ->
Type ->
@@ -171,6 +204,15 @@ add_portrait pt data_set =
---------------
---- Glyph ----
---------------
+get_glyphs : (
+ Type ->
+ (Dict.Dict
+ BattleCharacters.Struct.Glyph.Ref
+ BattleCharacters.Struct.Glyph.Type
+ )
+ )
+get_glyphs data_set = data_set.glyphs
+
get_glyph : (
BattleCharacters.Struct.Glyph.Ref ->
Type ->
@@ -195,6 +237,15 @@ add_glyph gl data_set =
---------------------
---- Glyph Board ----
---------------------
+get_glyph_boards : (
+ Type ->
+ (Dict.Dict
+ BattleCharacters.Struct.GlyphBoard.Ref
+ BattleCharacters.Struct.GlyphBoard.Type
+ )
+ )
+get_glyph_boards data_set = data_set.glyph_boards
+
get_glyph_board : (
BattleCharacters.Struct.GlyphBoard.Ref ->
Type ->
@@ -219,6 +270,15 @@ add_glyph_board glb data_set =
---------------
---- Skill ----
---------------
+get_skills : (
+ Type ->
+ (Dict.Dict
+ BattleCharacters.Struct.Skill.Ref
+ BattleCharacters.Struct.Skill.Type
+ )
+ )
+get_skills data_set = data_set.skills
+
get_skill : (
BattleCharacters.Struct.Skill.Ref ->
Type ->
diff --git a/src/map-editor/src/Comm/AddTile.elm b/src/shared/battle-map/BattleMap/Comm/AddDataSetItem.elm
index 797731b..bdc4238 100644
--- a/src/map-editor/src/Comm/AddTile.elm
+++ b/src/shared/battle-map/BattleMap/Comm/AddDataSetItem.elm
@@ -1,10 +1,10 @@
-module Comm.AddTile exposing (decode)
+module BattleMap.Comm.AddDataSetItem exposing (prefix, get_decoder_for)
-- Elm -------------------------------------------------------------------------
import Json.Decode
-- Battle Map ------------------------------------------------------------------
-import BattleMap.Struct.Tile
+import BattleMap.Comm.AddTile
-- Local Module ----------------------------------------------------------------
import Struct.ServerReply
@@ -16,11 +16,23 @@ import Struct.ServerReply
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-internal_decoder : BattleMap.Struct.Tile.Type -> Struct.ServerReply.Type
-internal_decoder wp = (Struct.ServerReply.AddTile wp)
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-decode : (Json.Decode.Decoder Struct.ServerReply.Type)
-decode = (Json.Decode.map (internal_decoder) (BattleMap.Struct.Tile.decoder))
+prefix : String
+prefix = "amds"
+
+get_decoder_for : String -> (Json.Decode.Decoder Struct.ServerReply.Type)
+get_decoder_for reply_type =
+ case reply_type of
+ "amds_tile" -> (BattleMap.Comm.AddTile.decode)
+
+ other ->
+ (Json.Decode.fail
+ (
+ "Unknown server command \""
+ ++ other
+ ++ "\""
+ )
+ )
diff --git a/src/shared/battle-map/BattleMap/Comm/AddTile.elm b/src/shared/battle-map/BattleMap/Comm/AddTile.elm
index e904362..d896643 100644
--- a/src/shared/battle-map/BattleMap/Comm/AddTile.elm
+++ b/src/shared/battle-map/BattleMap/Comm/AddTile.elm
@@ -4,6 +4,7 @@ module BattleMap.Comm.AddTile exposing (decode)
import Json.Decode
-- Battle Map ------------------------------------------------------------------
+import BattleMap.Struct.DataSetItem
import BattleMap.Struct.Tile
-- Local Module ----------------------------------------------------------------
@@ -17,7 +18,8 @@ import Struct.ServerReply
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
internal_decoder : BattleMap.Struct.Tile.Type -> Struct.ServerReply.Type
-internal_decoder wp = (Struct.ServerReply.AddTile wp)
+internal_decoder tl =
+ (Struct.ServerReply.AddMapDataSetItem (BattleMap.Struct.DataSetItem.Tile tl))
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
diff --git a/src/shared/battle-map/BattleMap/Struct/DataSet.elm b/src/shared/battle-map/BattleMap/Struct/DataSet.elm
index d81daaf..33ac224 100644
--- a/src/shared/battle-map/BattleMap/Struct/DataSet.elm
+++ b/src/shared/battle-map/BattleMap/Struct/DataSet.elm
@@ -4,6 +4,7 @@ module BattleMap.Struct.DataSet exposing
new,
is_ready,
get_tile,
+ get_tiles,
add_tile
)
@@ -45,6 +46,12 @@ is_ready data_set =
--------------
---- Tile ----
--------------
+get_tiles : (
+ Type ->
+ (Dict.Dict BattleMap.Struct.Tile.Ref BattleMap.Struct.Tile.Type)
+ )
+get_tiles dataset = dataset.tiles
+
get_tile : (
BattleMap.Struct.Tile.Ref ->
Type ->
diff --git a/src/map-editor/src/Comm/SetMap.elm b/src/shared/battle-map/BattleMap/Struct/DataSetItem.elm
index 80f6db1..c36906f 100644
--- a/src/map-editor/src/Comm/SetMap.elm
+++ b/src/shared/battle-map/BattleMap/Struct/DataSetItem.elm
@@ -1,17 +1,14 @@
-module Comm.SetMap exposing (decode)
-
--- Elm -------------------------------------------------------------------------
-import Json.Decode
+module BattleMap.Struct.DataSetItem exposing (Type(..), add_to)
-- Battle Map ------------------------------------------------------------------
-import BattleMap.Struct.Map
-
--- Local Module ----------------------------------------------------------------
-import Struct.ServerReply
+import BattleMap.Struct.DataSet
+import BattleMap.Struct.Tile
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
--------------------------------------------------------------------------------
+type Type =
+ Tile BattleMap.Struct.Tile.Type
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
@@ -20,9 +17,11 @@ import Struct.ServerReply
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-decode : (Json.Decode.Decoder Struct.ServerReply.Type)
-decode =
- (Json.Decode.map
- (\map -> (Struct.ServerReply.SetMap map))
- (BattleMap.Struct.Map.decoder)
+add_to : (
+ Type ->
+ BattleMap.Struct.DataSet.Type ->
+ BattleMap.Struct.DataSet.Type
)
+add_to item dataset =
+ case item of
+ (Tile tl) -> (BattleMap.Struct.DataSet.add_tile tl dataset)
diff --git a/src/shared/battle-map/BattleMap/Struct/Map.elm b/src/shared/battle-map/BattleMap/Struct/Map.elm
index 35b8a1f..1f254ac 100644
--- a/src/shared/battle-map/BattleMap/Struct/Map.elm
+++ b/src/shared/battle-map/BattleMap/Struct/Map.elm
@@ -169,16 +169,12 @@ try_getting_tile_at loc map =
then (Array.get (location_to_index loc map) map.content)
else Nothing
-solve_tiles : (
- (Dict.Dict BattleMap.Struct.Tile.Ref BattleMap.Struct.Tile.Type) ->
- Type ->
- Type
- )
-solve_tiles tiles map =
+solve_tiles : BattleMap.Struct.DataSet.Type -> Type -> Type
+solve_tiles dataset map =
{map |
content =
(Array.map
- (BattleMap.Struct.TileInstance.solve tiles) map.content
+ (BattleMap.Struct.TileInstance.solve dataset) map.content
)
}
diff --git a/src/shared/battle-map/BattleMap/Struct/TileInstance.elm b/src/shared/battle-map/BattleMap/Struct/TileInstance.elm
index 87d2762..aca7f49 100644
--- a/src/shared/battle-map/BattleMap/Struct/TileInstance.elm
+++ b/src/shared/battle-map/BattleMap/Struct/TileInstance.elm
@@ -36,6 +36,7 @@ import Json.Decode
import Json.Decode.Pipeline
-- Battle Map ------------------------------------------------------------------
+import BattleMap.Struct.DataSet
import BattleMap.Struct.Tile
import BattleMap.Struct.Location
@@ -147,25 +148,13 @@ get_local_variant_ix tile_inst =
)
)
-solve : (
- (Dict.Dict BattleMap.Struct.Tile.Ref BattleMap.Struct.Tile.Type) ->
- Type ->
- Type
- )
-solve tiles tile_inst =
- case (Dict.get tile_inst.class_id tiles) of
- (Just tile) ->
- {tile_inst |
- crossing_cost = (BattleMap.Struct.Tile.get_cost tile),
- family = (BattleMap.Struct.Tile.get_family tile)
- }
-
- Nothing ->
- {tile_inst |
- crossing_cost = -1,
- family = "-1"
- }
-
+solve : BattleMap.Struct.DataSet.Type -> Type -> Type
+solve dataset tile_inst =
+ let tile = (BattleMap.Struct.DataSet.get_tile tile_inst.class_id dataset) in
+ {tile_inst |
+ crossing_cost = (BattleMap.Struct.Tile.get_cost tile),
+ family = (BattleMap.Struct.Tile.get_family tile)
+ }
list_to_borders : (
(List String) ->