summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/shared/battle-map/BattleMap/Comm')
-rw-r--r-- | src/shared/battle-map/BattleMap/Comm/AddDataSetItem.elm | 38 | ||||
-rw-r--r-- | src/shared/battle-map/BattleMap/Comm/AddTile.elm | 4 |
2 files changed, 41 insertions, 1 deletions
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 -------------------------------------------------------------------- |