From 4b81d2114f0677da56157e14d9174afb61139067 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Sat, 22 Dec 2018 09:26:35 +0100 Subject: Converts the main-menu module. --- README.md | 3 ++- src/main-menu/Makefile | 2 +- src/main-menu/elm-package.json | 19 ------------------ src/main-menu/elm.json | 27 ++++++++++++++++++++++++++ src/main-menu/src/Main.elm | 6 +++--- src/main-menu/src/Struct/BattleSummary.elm | 2 +- src/main-menu/src/Struct/Event.elm | 8 +++++++- src/main-menu/src/Struct/InvasionRequest.elm | 2 +- src/main-menu/src/Struct/MapSummary.elm | 2 +- src/main-menu/src/Struct/Player.elm | 2 +- src/main-menu/src/Update/HandleServerReply.elm | 9 +++++++-- 11 files changed, 51 insertions(+), 31 deletions(-) delete mode 100644 src/main-menu/elm-package.json create mode 100644 src/main-menu/elm.json diff --git a/README.md b/README.md index 6947046..af701c0 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,9 @@ multiplayer turn-based strategy game. ## Getting Started ### Prerequisites -* Elm +* Elm 0.19 * GNU make +* Sass * Tacticians Online - Data * m4 diff --git a/src/main-menu/Makefile b/src/main-menu/Makefile index 3b58a08..737be75 100644 --- a/src/main-menu/Makefile +++ b/src/main-menu/Makefile @@ -5,7 +5,7 @@ SRC_DIR ?= src WWW_DIR ?= www WWW_SCRIPT_DIR ?= $(WWW_DIR)/script -ELM_CC ?= elm-make --warn +ELM_CC ?= elm make --optimize MAIN_MODULE ?= $(SRC_DIR)/Main.elm diff --git a/src/main-menu/elm-package.json b/src/main-menu/elm-package.json deleted file mode 100644 index d62239e..0000000 --- a/src/main-menu/elm-package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": "1.0.0", - "summary": "helpful summary of your project, less than 80 characters", - "repository": "https://github.com/nsensfel/tacticians-client.git", - "license": "Apache 2.0", - "source-directories": [ - "src", - "../shared/elm" - ], - "exposed-modules": [], - "dependencies": { - "NoRedInk/elm-decode-pipeline": "3.0.0 <= v < 4.0.0", - "elm-lang/core": "5.1.1 <= v < 6.0.0", - "elm-lang/dom": "1.1.1 <= v < 2.0.0", - "elm-lang/html": "2.0.0 <= v < 3.0.0", - "elm-lang/http": "1.0.0 <= v < 2.0.0" - }, - "elm-version": "0.18.0 <= v < 0.19.0" -} diff --git a/src/main-menu/elm.json b/src/main-menu/elm.json new file mode 100644 index 0000000..20622be --- /dev/null +++ b/src/main-menu/elm.json @@ -0,0 +1,27 @@ +{ + "type": "application", + "source-directories": [ + "src", + "../shared/elm" + ], + "elm-version": "0.19.0", + "dependencies": { + "direct": { + "NoRedInk/elm-json-decode-pipeline": "1.0.0", + "elm/browser": "1.0.1", + "elm/core": "1.0.0", + "elm/html": "1.0.0", + "elm/http": "1.0.0", + "elm/json": "1.1.2", + "elm/url": "1.0.0" + }, + "indirect": { + "elm/time": "1.0.0", + "elm/virtual-dom": "1.0.2" + } + }, + "test-dependencies": { + "direct": {}, + "indirect": {} + } +} diff --git a/src/main-menu/src/Main.elm b/src/main-menu/src/Main.elm index 8140041..0ee235f 100644 --- a/src/main-menu/src/Main.elm +++ b/src/main-menu/src/Main.elm @@ -1,7 +1,7 @@ -- Elm ------------------------------------------------------------------------ -import Html +import Browser --- Map ------------------------------------------------------------------- +-- Main Menu ------------------------------------------------------------------- import Struct.Model import Struct.Event import Struct.Flags @@ -13,7 +13,7 @@ import ElmModule.Update main : (Program Struct.Flags.Type Struct.Model.Type Struct.Event.Type) main = - (Html.programWithFlags + (Browser.element { init = ElmModule.Init.init, view = ElmModule.View.view, diff --git a/src/main-menu/src/Struct/BattleSummary.elm b/src/main-menu/src/Struct/BattleSummary.elm index c67ef04..8eb8d6f 100644 --- a/src/main-menu/src/Struct/BattleSummary.elm +++ b/src/main-menu/src/Struct/BattleSummary.elm @@ -66,7 +66,7 @@ get_invasion_category ix = decoder : (Json.Decode.Decoder Type) decoder = - (Json.Decode.Pipeline.decode + (Json.Decode.succeed Type |> (Json.Decode.Pipeline.required "id" Json.Decode.string) |> (Json.Decode.Pipeline.required "nme" Json.Decode.string) diff --git a/src/main-menu/src/Struct/Event.elm b/src/main-menu/src/Struct/Event.elm index 24e5ea5..decf171 100644 --- a/src/main-menu/src/Struct/Event.elm +++ b/src/main-menu/src/Struct/Event.elm @@ -29,4 +29,10 @@ attempted act = case act of (Result.Ok _) -> None (Result.Err msg) -> - (Failed (Struct.Error.new Struct.Error.Failure (toString msg))) + (Failed + (Struct.Error.new + Struct.Error.Failure + -- TODO: find a way to get some relevant text here. + "(text representation not implemented)" + ) + ) diff --git a/src/main-menu/src/Struct/InvasionRequest.elm b/src/main-menu/src/Struct/InvasionRequest.elm index f1e25b2..3681b27 100644 --- a/src/main-menu/src/Struct/InvasionRequest.elm +++ b/src/main-menu/src/Struct/InvasionRequest.elm @@ -75,7 +75,7 @@ get_url_params : Type -> String get_url_params ir = ( "?ix=" - ++ (toString ir.ix) + ++ (String.fromInt ir.ix) ++ ( case ir.category of diff --git a/src/main-menu/src/Struct/MapSummary.elm b/src/main-menu/src/Struct/MapSummary.elm index 7ad0e53..e6e8120 100644 --- a/src/main-menu/src/Struct/MapSummary.elm +++ b/src/main-menu/src/Struct/MapSummary.elm @@ -37,7 +37,7 @@ get_name t = t.name decoder : (Json.Decode.Decoder Type) decoder = - (Json.Decode.Pipeline.decode + (Json.Decode.succeed Type |> (Json.Decode.Pipeline.required "id" Json.Decode.string) |> (Json.Decode.Pipeline.required "nme" Json.Decode.string) diff --git a/src/main-menu/src/Struct/Player.elm b/src/main-menu/src/Struct/Player.elm index 81b4ed8..44d335a 100644 --- a/src/main-menu/src/Struct/Player.elm +++ b/src/main-menu/src/Struct/Player.elm @@ -71,7 +71,7 @@ get_inventory_id t = t.inventory_id decoder : (Json.Decode.Decoder Type) decoder = - (Json.Decode.Pipeline.decode + (Json.Decode.succeed Type |> (Json.Decode.Pipeline.required "id" Json.Decode.string) |> (Json.Decode.Pipeline.required "nme" Json.Decode.string) diff --git a/src/main-menu/src/Update/HandleServerReply.elm b/src/main-menu/src/Update/HandleServerReply.elm index d68496c..d633bf3 100644 --- a/src/main-menu/src/Update/HandleServerReply.elm +++ b/src/main-menu/src/Update/HandleServerReply.elm @@ -2,12 +2,15 @@ module Update.HandleServerReply exposing (apply_to) -- Elm ------------------------------------------------------------------------- import Http +import Url -- Shared ---------------------------------------------------------------------- import Action.Ports import Struct.Flags +import Util.Http + -- Main Menu ------------------------------------------------------------------- import Constants.IO @@ -38,7 +41,7 @@ disconnected current_state = Constants.IO.base_url ++ "/login/?action=disconnect&goto=" ++ - (Http.encodeUri + (Url.percentEncode ( "/main-menu/?" ++ (Struct.Flags.get_params_as_url model.flags) @@ -82,7 +85,9 @@ apply_to model query_result = (Result.Err error) -> ( (Struct.Model.invalidate - (Struct.Error.new Struct.Error.Networking (toString error)) + (Struct.Error.new Struct.Error.Networking + (Util.Http.error_to_string error) + ) model ), Cmd.none -- cgit v1.2.3-70-g09d2