aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-01-17 12:11:47 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-01-17 12:11:47 +0100
commit4e1381121b442b8861c9fca7ae98cccf7cde62fd (patch)
treeee429ae906e60a9ec0f9fd515ac124ef8efd1b57
parent378b6db51669d9d3b02680ac09378df72ca95ac9 (diff)
downloadtacticians-client-4e1381121b442b8861c9fca7ae98cccf7cde62fd.zip
tacticians-client-4e1381121b442b8861c9fca7ae98cccf7cde62fd.tar.bz2
...
-rw-r--r--src/main-menu/src/ElmModule/Update.elm18
-rw-r--r--src/main-menu/src/Struct/BattleRequest.elm12
-rw-r--r--src/main-menu/src/Struct/Event.elm2
-rw-r--r--src/main-menu/src/Update/HandleNewBattle.elm (renamed from src/main-menu/src/Update/HandleNewInvasion.elm)31
-rw-r--r--src/main-menu/src/View/BattleListing.elm2
-rw-r--r--src/main-menu/src/View/CurrentTab.elm4
-rw-r--r--src/main-menu/src/View/Invasions.elm6
-rw-r--r--src/main-menu/src/View/Tab/NewBattle.elm224
-rw-r--r--src/main-menu/src/View/Tab/NewInvasion.elm176
9 files changed, 280 insertions, 195 deletions
diff --git a/src/main-menu/src/ElmModule/Update.elm b/src/main-menu/src/ElmModule/Update.elm
index 5eb3e19..095d7da 100644
--- a/src/main-menu/src/ElmModule/Update.elm
+++ b/src/main-menu/src/ElmModule/Update.elm
@@ -6,7 +6,7 @@ module ElmModule.Update exposing (update)
import Struct.Event
import Struct.Model
-import Update.HandleNewInvasion
+import Update.HandleNewBattle
import Update.HandleServerReply
--------------------------------------------------------------------------------
@@ -37,16 +37,16 @@ update event model =
(Struct.Event.ServerReplied result) ->
(Update.HandleServerReply.apply_to model result)
- (Struct.Event.NewInvasion ix) ->
- (Update.HandleNewInvasion.apply_to new_model ix)
+ (Struct.Event.NewBattle (ix, category)) ->
+ (Update.HandleNewBattle.apply_to new_model ix category)
- (Struct.Event.InvasionSetSize size) ->
- (Update.HandleNewInvasion.set_size new_model size)
+ (Struct.Event.BattleSetSize size) ->
+ (Update.HandleNewBattle.set_size new_model size)
- (Struct.Event.InvasionSetCategory cat) ->
- (Update.HandleNewInvasion.set_category new_model cat)
+ (Struct.Event.BattleSetMode mode) ->
+ (Update.HandleNewBattle.set_mode new_model mode)
- (Struct.Event.InvasionSetMap map_summary) ->
- (Update.HandleNewInvasion.set_map new_model map_summary)
+ (Struct.Event.BattleSetMap map_summary) ->
+ (Update.HandleNewBattle.set_map new_model map_summary)
(Struct.Event.TabSelected tab) -> (model, Cmd.none)
diff --git a/src/main-menu/src/Struct/BattleRequest.elm b/src/main-menu/src/Struct/BattleRequest.elm
index a02a1bf..b6864e1 100644
--- a/src/main-menu/src/Struct/BattleRequest.elm
+++ b/src/main-menu/src/Struct/BattleRequest.elm
@@ -5,9 +5,11 @@ module Struct.BattleRequest exposing
new,
get_ix,
get_mode,
+ get_category,
get_size,
get_map_id,
set_mode,
+ set_category,
set_size,
set_map_id,
get_url_params
@@ -58,9 +60,15 @@ get_ix ir = ir.ix
get_mode : Type -> Struct.BattleSummary.Mode
get_mode ir = ir.mode
+get_category : Type -> Struct.BattleSummary.Category
+get_category ir = ir.category
+
set_mode : Struct.BattleSummary.Mode -> Type -> Type
set_mode mode ir = {ir | mode = mode}
+set_category : Struct.BattleSummary.Category -> Type -> Type
+set_category category ir = {ir | category = category}
+
get_size : Type -> (Maybe Size)
get_size ir = ir.size
@@ -87,6 +95,7 @@ get_url_params ir =
Struct.BattleSummary.Campaign -> "c"
)
++ "&mod="
+ ++
(
case ir.mode of
Struct.BattleSummary.Either -> "e"
@@ -94,6 +103,7 @@ get_url_params ir =
Struct.BattleSummary.Defend -> "d"
)
++ "&s="
+ ++
(
case ir.size of
(Just Medium) -> "m"
@@ -101,5 +111,5 @@ get_url_params ir =
_ -> "s"
)
++ "&map_id="
- ir.map_id
+ ++ ir.map_id
)
diff --git a/src/main-menu/src/Struct/Event.elm b/src/main-menu/src/Struct/Event.elm
index 8699ddb..d552d2d 100644
--- a/src/main-menu/src/Struct/Event.elm
+++ b/src/main-menu/src/Struct/Event.elm
@@ -18,7 +18,7 @@ type Type =
None
| Failed Struct.Error.Type
| ServerReplied (Result Http.Error (List Struct.ServerReply.Type))
- | NewBattle (Int, Struct.BattleRequest.Category)
+ | NewBattle (Int, Struct.BattleSummary.Category)
| BattleSetSize Struct.BattleRequest.Size
| BattleSetMap Struct.MapSummary.Type
| BattleSetMode Struct.BattleSummary.Mode
diff --git a/src/main-menu/src/Update/HandleNewInvasion.elm b/src/main-menu/src/Update/HandleNewBattle.elm
index 0dd53c9..396635e 100644
--- a/src/main-menu/src/Update/HandleNewInvasion.elm
+++ b/src/main-menu/src/Update/HandleNewBattle.elm
@@ -3,6 +3,7 @@ module Update.HandleNewBattle exposing
apply_to,
set_size,
set_category,
+ set_mode,
set_map
)
-- Elm -------------------------------------------------------------------------
@@ -48,7 +49,7 @@ set_size model size =
set_category : (
Struct.Model.Type ->
- Struct.BattleSummary.BattleCategory ->
+ Struct.BattleSummary.Category ->
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
set_category model category =
@@ -56,13 +57,37 @@ set_category model category =
Struct.UI.None -> -- TODO: err
(model, Cmd.none)
- (Struct.UI.NewBattle invasion) ->
+ (Struct.UI.NewBattle battle) ->
+ (
+ {model |
+ ui =
+ (Struct.UI.set_action
+ (Struct.UI.NewBattle
+ (Struct.BattleRequest.set_category category battle)
+ )
+ model.ui
+ )
+ },
+ Cmd.none
+ )
+
+set_mode : (
+ Struct.Model.Type ->
+ Struct.BattleSummary.Mode ->
+ (Struct.Model.Type, (Cmd Struct.Event.Type))
+ )
+set_mode model mode =
+ case (Struct.UI.get_action model.ui) of
+ Struct.UI.None -> -- TODO: err
+ (model, Cmd.none)
+
+ (Struct.UI.NewBattle battle) ->
(
{model |
ui =
(Struct.UI.set_action
(Struct.UI.NewBattle
- (Struct.BattleRequest.set_category category invasion)
+ (Struct.BattleRequest.set_mode mode battle)
)
model.ui
)
diff --git a/src/main-menu/src/View/BattleListing.elm b/src/main-menu/src/View/BattleListing.elm
index 9b667ac..4e9479f 100644
--- a/src/main-menu/src/View/BattleListing.elm
+++ b/src/main-menu/src/View/BattleListing.elm
@@ -44,7 +44,7 @@ get_item_html item =
(Html.Attributes.class "main-menu-battle-summary-date")
]
[
- (Html.text (Struct.BattleSummary.get_last_edit item))
+ (Html.text (Struct.BattleSummary.get_deadline item))
]
)
]
diff --git a/src/main-menu/src/View/CurrentTab.elm b/src/main-menu/src/View/CurrentTab.elm
index 3a5f711..054d764 100644
--- a/src/main-menu/src/View/CurrentTab.elm
+++ b/src/main-menu/src/View/CurrentTab.elm
@@ -17,7 +17,7 @@ import View.Invasions
import View.MapListing
import View.Roster
-import View.Tab.NewInvasion
+import View.Tab.NewBattle
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
@@ -54,4 +54,4 @@ get_html : (Struct.Model.Type -> (Html.Html Struct.Event.Type))
get_html model =
case (Struct.UI.get_current_tab model.ui) of
Struct.UI.DefaultTab -> (default_tab model)
- Struct.UI.NewInvasionTab -> (View.Tab.NewInvasion.get_html model)
+ Struct.UI.NewBattleTab -> (View.Tab.NewBattle.get_html model)
diff --git a/src/main-menu/src/View/Invasions.elm b/src/main-menu/src/View/Invasions.elm
index b4ce14c..233c621 100644
--- a/src/main-menu/src/View/Invasions.elm
+++ b/src/main-menu/src/View/Invasions.elm
@@ -39,7 +39,9 @@ get_invasion_html ix invasion =
then
(Html.a
[
- (Html.Events.onClick (Struct.Event.NewInvasion ix)),
+ (Html.Events.onClick
+ (Struct.Event.NewBattle (ix, Struct.BattleSummary.Invasion))
+ ),
(Html.Attributes.class "clickable"),
invasion_type
]
@@ -68,7 +70,7 @@ get_invasion_html ix invasion =
(Html.Attributes.class "main-menu-battle-summary-date")
]
[
- (Html.text (Struct.BattleSummary.get_last_edit invasion))
+ (Html.text (Struct.BattleSummary.get_deadline invasion))
]
)
]
diff --git a/src/main-menu/src/View/Tab/NewBattle.elm b/src/main-menu/src/View/Tab/NewBattle.elm
new file mode 100644
index 0000000..c5d22fa
--- /dev/null
+++ b/src/main-menu/src/View/Tab/NewBattle.elm
@@ -0,0 +1,224 @@
+module View.Tab.NewBattle exposing (get_html)
+
+-- Elm -------------------------------------------------------------------------
+import Array
+import List
+
+import Html
+import Html.Attributes
+import Html.Events
+
+-- Main Menu -------------------------------------------------------------------
+import Struct.BattleRequest
+import Struct.BattleSummary
+import Struct.Event
+import Struct.MapSummary
+import Struct.Model
+import Struct.Player
+import Struct.UI
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+select_mode_html : (Html.Html Struct.Event.Type)
+select_mode_html =
+ (Html.div
+ [
+ ]
+ [
+ (Html.button
+ [
+ (Html.Events.onClick
+ (Struct.Event.BattleSetMode
+ Struct.BattleSummary.Attack
+ )
+ )
+ ]
+ [
+ (Html.text "New Offensive")
+ ]
+ ),
+ (Html.button
+ [
+ (Html.Events.onClick
+ (Struct.Event.BattleSetMode
+ Struct.BattleSummary.Defend
+ )
+ )
+ ]
+ [
+ (Html.text "New Defense")
+ ]
+ )
+ ]
+ )
+
+select_size_html : Struct.BattleRequest.Size -> (Html.Html Struct.Event.Type)
+select_size_html max_size =
+ (Html.div
+ [
+ ]
+ [
+ (Html.button
+ [
+ (Html.Events.onClick
+ (Struct.Event.BattleSetSize
+ Struct.BattleRequest.Small
+ )
+ )
+ ]
+ [
+ (Html.text "Small")
+ ]
+ ),
+ (Html.button
+ [
+ (Html.Events.onClick
+ (Struct.Event.BattleSetSize
+ Struct.BattleRequest.Medium
+ )
+ )
+ ]
+ [
+ (Html.text "Medium")
+ ]
+ ),
+ (Html.button
+ [
+ (Html.Events.onClick
+ (Struct.Event.BattleSetSize
+ Struct.BattleRequest.Large
+ )
+ )
+ ]
+ [
+ (Html.text "Large")
+ ]
+ )
+ ]
+ )
+
+map_button_html : Struct.MapSummary.Type -> (Html.Html Struct.Event.Type)
+map_button_html map_summary =
+ (Html.button
+ [
+ (Html.Events.onClick (Struct.Event.BattleSetMap map_summary))
+ ]
+ [
+ (Html.text (Struct.MapSummary.get_name map_summary))
+ ]
+ )
+
+select_map_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
+select_map_html model =
+ (Html.div
+ [
+ ]
+ (
+ (Html.text "Map Selection:")
+ ::
+ (List.map
+ (map_button_html)
+ (Array.toList (Struct.Player.get_maps model.player))
+ )
+ )
+ )
+
+select_characters_html : (
+ Struct.BattleRequest.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+select_characters_html battle_req =
+ (Html.a
+ [
+ (Html.Attributes.href
+ (
+ "/roster-editor/"
+ ++
+ (Struct.BattleRequest.get_url_params battle_req)
+ )
+ )
+ ]
+ [
+ (Html.text "Select Characters")
+ ]
+ )
+
+new_invasion_html : (
+ Struct.BattleRequest.Type ->
+ Struct.Model.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+new_invasion_html battle_req model =
+ case
+ (
+ (Struct.BattleRequest.get_mode battle_req),
+ (Struct.BattleRequest.get_size battle_req)
+ )
+ of
+ (Struct.BattleSummary.Attack, Nothing) ->
+ (select_size_html Struct.BattleRequest.Large)
+
+ (Struct.BattleSummary.Attack, _) ->
+ (select_characters_html battle_req)
+
+ (Struct.BattleSummary.Defend, Nothing) ->
+ (select_map_html model)
+
+ (Struct.BattleSummary.Defend, _) ->
+ (select_characters_html battle_req)
+
+ (_, _) ->
+ (select_mode_html)
+
+new_event_html : (
+ Struct.BattleRequest.Type ->
+ Struct.Model.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+new_event_html battle_req model =
+ (Html.div
+ [
+ ]
+ [
+ (Html.text "Not available yet.")
+ ]
+ )
+
+new_campaign_html : (
+ Struct.BattleRequest.Type ->
+ Struct.Model.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+new_campaign_html battle_req model =
+ (Html.div
+ [
+ ]
+ [
+ (Html.text "Not available yet.")
+ ]
+ )
+
+get_actual_html : (
+ Struct.BattleRequest.Type ->
+ Struct.Model.Type ->
+ (Html.Html Struct.Event.Type)
+ )
+get_actual_html battle_req model =
+ case (Struct.BattleRequest.get_category battle_req) of
+ Struct.BattleSummary.Invasion -> (new_invasion_html battle_req model)
+ Struct.BattleSummary.Event -> (new_event_html battle_req model)
+ Struct.BattleSummary.Campaign -> (new_campaign_html battle_req model)
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
+get_html model =
+ case (Struct.UI.get_action model.ui) of
+ Struct.UI.None ->
+ -- TODO: explain & let the user go back to the main menu.
+ (Html.text "Error.")
+
+ (Struct.UI.NewBattle battle_req) ->
+ (get_actual_html battle_req model)
diff --git a/src/main-menu/src/View/Tab/NewInvasion.elm b/src/main-menu/src/View/Tab/NewInvasion.elm
deleted file mode 100644
index 8cba188..0000000
--- a/src/main-menu/src/View/Tab/NewInvasion.elm
+++ /dev/null
@@ -1,176 +0,0 @@
-module View.Tab.NewBattle exposing (get_html)
-
--- Elm -------------------------------------------------------------------------
-import Html
-import Html.Attributes
-import Html.Events
-
--- Main Menu -------------------------------------------------------------------
-import Struct.Event
-import Struct.Model
-import Struct.UI
-import Struct.BattleRequest
-import Struct.BattleSummary
-
---------------------------------------------------------------------------------
--- LOCAL -----------------------------------------------------------------------
---------------------------------------------------------------------------------
-select_category_html : (Html.Html Struct.Event.Type)
-select_category_html =
- (Html.div
- [
- ]
- [
- (Html.button
- [
- (Html.Events.onClick
- (Struct.Event.BattleSetCategory
- Struct.BattleSummary.BattleAttack
- )
- )
- ]
- [
- (Html.text "New Offensive")
- ]
- ),
- (Html.button
- [
- (Html.Events.onClick
- (Struct.Event.BattleSetCategory
- Struct.BattleSummary.BattleDefend
- )
- )
- ]
- [
- (Html.text "New Defense")
- ]
- )
- ]
- )
-
-select_size_html : Struct.BattleRequest.Size -> (Html.Html Struct.Event.Type)
-select_size_html max_size =
- (Html.div
- [
- ]
- [
- (Html.button
- [
- (Html.Events.onClick
- (Struct.Event.BattleSetSize
- Struct.BattleRequest.Small
- )
- )
- ]
- [
- (Html.text "Small")
- ]
- ),
- (Html.button
- [
- (Html.Events.onClick
- (Struct.Event.BattleSetSize
- Struct.BattleRequest.Medium
- )
- )
- ]
- [
- (Html.text "Medium")
- ]
- ),
- (Html.button
- [
- (Html.Events.onClick
- (Struct.Event.BattleSetSize
- Struct.BattleRequest.Large
- )
- )
- ]
- [
- (Html.text "Large")
- ]
- )
- ]
- )
-
-select_map_html : (Html.Html Struct.Event.Type)
-select_map_html =
- (Html.div
- [
- ]
- [
- (Html.text "Map Selection")
- ]
- )
-
-
-get_actual_html : Struct.BattleRequest.Type -> (Html.Html Struct.Event.Type)
-get_actual_html battle_req =
- case (Struct.BattleRequest.get_category battle_req) of
- Struct.BattleSummary.Invasion ->
-
- _ ->
- case
- Struct.BattleSummary.Either -> (select_category_html)
- Struct.BattleSummary.Attack ->
- (
- case (Struct.BattleRequest.get_size battle_req) of
- -- TODO: use roster size as upper limit.
- Nothing -> (select_size_html Struct.BattleRequest.Large)
- _ ->
- (Html.a
- [
- (Html.Attributes.href
- (
- "/roster-editor/"
- ++
- (Struct.BattleRequest.get_url_params battle_req)
- )
- )
- ]
- [
- (Html.text "Select Characters")
- ]
- )
- )
- Struct.BattleSummary.Defend ->
- (
- case (Struct.BattleRequest.get_map_id battle_req) of
- -- FIXME: Requires model.
- "" -> (select_map_html)
- _ ->
- case (Struct.BattleRequest.get_size battle_req) of
- Nothing ->
- -- TODO: use min(RosterSize, MapSize) as upper limit.
- (select_size_html Struct.BattleRequest.Large)
- _ ->
- (Html.a
- [
- (Html.Attributes.href
- (
- "/roster-editor/"
- ++
- (Struct.BattleRequest.get_url_params
- battle_req
- )
- )
- )
- ]
- [
- (Html.text "Select Characters")
- ]
- )
- )
-
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
-get_html model =
- case (Struct.UI.get_action model.ui) of
- Struct.UI.None ->
- -- TODO: explain & let the user go back to the main menu.
- (Html.text "Error.")
-
- (Struct.UI.NewBattle battle_req) ->
- (get_actual_html battle_req)