summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/battle-characters/BattleCharacters/Struct/DataSet.elm60
-rw-r--r--src/shared/battle-map/BattleMap/Comm/AddDataSetItem.elm38
-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.elm27
-rw-r--r--src/shared/battle-map/BattleMap/Struct/Map.elm10
-rw-r--r--src/shared/battle-map/BattleMap/Struct/TileInstance.elm27
7 files changed, 146 insertions, 27 deletions
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/shared/battle-map/BattleMap/Comm/AddDataSetItem.elm b/src/shared/battle-map/BattleMap/Comm/AddDataSetItem.elm
new file mode 100644
index 0000000..bdc4238
--- /dev/null
+++ b/src/shared/battle-map/BattleMap/Comm/AddDataSetItem.elm
@@ -0,0 +1,38 @@
+module BattleMap.Comm.AddDataSetItem exposing (prefix, get_decoder_for)
+
+-- Elm -------------------------------------------------------------------------
+import Json.Decode
+
+-- Battle Map ------------------------------------------------------------------
+import BattleMap.Comm.AddTile
+
+-- Local Module ----------------------------------------------------------------
+import Struct.ServerReply
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+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/shared/battle-map/BattleMap/Struct/DataSetItem.elm b/src/shared/battle-map/BattleMap/Struct/DataSetItem.elm
new file mode 100644
index 0000000..c36906f
--- /dev/null
+++ b/src/shared/battle-map/BattleMap/Struct/DataSetItem.elm
@@ -0,0 +1,27 @@
+module BattleMap.Struct.DataSetItem exposing (Type(..), add_to)
+
+-- Battle Map ------------------------------------------------------------------
+import BattleMap.Struct.DataSet
+import BattleMap.Struct.Tile
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type Type =
+ Tile BattleMap.Struct.Tile.Type
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+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) ->