summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/battle/src/Comm')
-rw-r--r-- | src/battle/src/Comm/CharacterTurn.elm | 76 | ||||
-rw-r--r-- | src/battle/src/Comm/Send.elm | 17 |
2 files changed, 11 insertions, 82 deletions
diff --git a/src/battle/src/Comm/CharacterTurn.elm b/src/battle/src/Comm/CharacterTurn.elm index b59dd4c..7809b00 100644 --- a/src/battle/src/Comm/CharacterTurn.elm +++ b/src/battle/src/Comm/CharacterTurn.elm @@ -21,77 +21,6 @@ import Struct.Model -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -encode_move : Struct.Model.Type -> (Maybe Json.Encode.Value) -encode_move model = - case (Struct.CharacterTurn.get_path model.char_turn) of - [] -> Nothing - path -> - (Just - (Json.Encode.object - [ - ("t", (Json.Encode.string "mov")), - ( - "p", - (Json.Encode.list - (List.map - ( - (Json.Encode.string) - << - (Struct.Direction.to_string) - ) - (List.reverse path) - ) - ) - ) - ] - ) - ) - -encode_weapon_switch : Struct.Model.Type -> (Maybe Json.Encode.Value) -encode_weapon_switch model = - if (Struct.CharacterTurn.has_switched_weapons model.char_turn) - then - (Just - (Json.Encode.object - [ - ("t", (Json.Encode.string "swp")) - ] - ) - ) - else - Nothing - -encode_attack : Struct.Model.Type -> (Maybe Json.Encode.Value) -encode_attack model = - case (Struct.CharacterTurn.try_getting_target model.char_turn) of - Nothing -> Nothing - - (Just ix) -> - (Just - (Json.Encode.object - [ - ("t", (Json.Encode.string "atk")), - ("tix", (Json.Encode.int ix)) - ] - ) - ) - -encode_actions : Struct.Model.Type -> (List Json.Encode.Value) -encode_actions model = - case - ( - (encode_move model), - (encode_weapon_switch model), - (encode_attack model) - ) - of - ((Just move), Nothing, Nothing) -> [move] - ((Just move), Nothing, (Just attack)) -> [move, attack] - ((Just move), (Just switch_weapon), Nothing) -> [move, switch_weapon] - (Nothing, (Just switch_weapon), Nothing) -> [switch_weapon] - (Nothing, Nothing, (Just attack)) -> [attack] - _ -> [] - try_encoding : Struct.Model.Type -> (Maybe Json.Encode.Value) try_encoding model = case (Struct.CharacterTurn.try_getting_active_character model.char_turn) of @@ -106,10 +35,7 @@ try_encoding model = "cix", (Json.Encode.int (Struct.Character.get_index char)) ), - ( - "act", - (Json.Encode.list (encode_actions model)) - ) + ("act", (Struct.CharacterTurn.encode model.char_turn)) ] ) ) diff --git a/src/battle/src/Comm/Send.elm b/src/battle/src/Comm/Send.elm index f501b19..d577e58 100644 --- a/src/battle/src/Comm/Send.elm +++ b/src/battle/src/Comm/Send.elm @@ -66,13 +66,16 @@ try_sending model recipient try_encoding_fun = case (try_encoding_fun model) of (Just serial) -> (Just - (Http.send - Struct.Event.ServerReplied - (Http.post - recipient - (Http.jsonBody serial) - (Json.Decode.list (decode)) - ) + (Http.post + { + url = recipient, + body = (Http.jsonBody serial), + expect = + (Http.expectJson + Struct.Event.ServerReplied + (Json.Decode.list (decode)) + ) + } ) ) |