| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src/battlemap/src/Model/HandleServerReply.elm')
| -rw-r--r-- | src/battlemap/src/Model/HandleServerReply.elm | 41 | 
1 files changed, 26 insertions, 15 deletions
| diff --git a/src/battlemap/src/Model/HandleServerReply.elm b/src/battlemap/src/Model/HandleServerReply.elm index 7245cc4..59b614c 100644 --- a/src/battlemap/src/Model/HandleServerReply.elm +++ b/src/battlemap/src/Model/HandleServerReply.elm @@ -1,36 +1,47 @@  module Model.HandleServerReply exposing (apply_to)  -- Elm ------------------------------------------------------------------------- -import Dict +import Json.Decode  -- Battlemap -------------------------------------------------------------------  import Model  import Error  import Event +import Model.SetMap +  --------------------------------------------------------------------------------  -- LOCAL -----------------------------------------------------------------------  -------------------------------------------------------------------------------- +apply_command: (List String) -> Model.Type -> Model.Type +apply_command cmd model = +   case +      cmd +   of +      ["set_map", data] -> +         (Model.SetMap.apply_to model data) + +      ["add_char", data] -> model + +      _ -> +         (Model.invalidate +            model +            (Error.new +               Error.Programming +               ( +                  "Received invalid command from server:" +                  ++ (toString cmd) +               ) +            ) +         )  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  --------------------------------------------------------------------------------  apply_to : (        Model.Type -> -      (Dict.Dict String (List String)) -> +      (List (List String)) ->        (Model.Type, (Cmd Event.Type))     )  apply_to model serialized_commands = -   ( -      (Model.invalidate -         model -         (Error.new -            Error.Unimplemented -            ( -               "Received reply from server:" -               ++ (toString serialized_commands) -            ) -         ) -      ), -      Cmd.none -   ) +   ((List.foldr (apply_command) model serialized_commands), Cmd.none) | 


