summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2017-10-27 13:34:40 +0200 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2017-10-27 13:34:40 +0200 |
commit | 5f318a009042d92acaddc426811db9d608f1dcac (patch) | |
tree | 566f32b4656f465852aea559d7fdaecaf63b0666 | |
parent | 7223eae774a00ba7093a387e184abf274ab13891 (diff) |
Starting to add communications w/ the server.
-rw-r--r-- | src/battlemap/src/Constants/IO.elm | 7 | ||||
-rw-r--r-- | src/battlemap/src/Send/CharacterActions.elm | 48 |
2 files changed, 55 insertions, 0 deletions
diff --git a/src/battlemap/src/Constants/IO.elm b/src/battlemap/src/Constants/IO.elm new file mode 100644 index 0000000..c6f3e48 --- /dev/null +++ b/src/battlemap/src/Constants/IO.elm @@ -0,0 +1,7 @@ +module Constants.IO exposing (..) + +base_url : String +base_url = "https://tacticians.online" + +battlemap_handler_url : String +battlemap_handler_url = (base_url ++ "/handler/battlemap/") diff --git a/src/battlemap/src/Send/CharacterActions.elm b/src/battlemap/src/Send/CharacterActions.elm new file mode 100644 index 0000000..7d2f380 --- /dev/null +++ b/src/battlemap/src/Send/CharacterActions.elm @@ -0,0 +1,48 @@ +module IO.CharacterTurn exposing (send) + +-- Elm ------------------------------------------------------------------------- +import Http + +import Json.Encode +import Json.Decode + +-- Battlemap ------------------------------------------------------------------- +import Constants.IO + +import Event +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +encode : Model -> Json.Encode.Value +encode model = + (Json.Encode.encode + 0 + (Json.Encode.object + [ + ("user_token", Json.Encode.string model.user_token), + ("char_id", Json.Encode.string ...), + ("path", Jsong.Encode.string ...), + ("target_id", Jsong.Encode.string ...) + ] + ) + ) + +decode : (Json.Decode.Decoder a) +decode = + +receive : (Http.Result (Http.Error a)) -> Event +receive reply = + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +send : Model -> (Http.Request String) +send model = + (Http.send + (receive) + (Http.post + Constants.IO.battlemap_handler_url + (Http.jsonBody (encode model)) + (decode) + ) + ) |