aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-01-17 15:07:49 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-01-17 15:07:49 +0100
commit816de590ed5656d6fef0a82eae8eb09fedd10b32 (patch)
tree73cd945fd955176f28b71211d58604c9a4719168
parent53e381b707550119afaed7bc956f3241a8208e5b (diff)
downloadtacticians-client-816de590ed5656d6fef0a82eae8eb09fedd10b32.zip
tacticians-client-816de590ed5656d6fef0a82eae8eb09fedd10b32.tar.bz2
...
-rw-r--r--src/main-menu/src/Struct/BattleSummary.elm4
-rw-r--r--src/main-menu/src/View/BattleListing.elm48
-rw-r--r--src/main-menu/src/View/CurrentTab.elm7
-rw-r--r--src/main-menu/src/View/Invasions.elm109
-rw-r--r--src/main-menu/src/View/MapListing.elm8
5 files changed, 43 insertions, 133 deletions
diff --git a/src/main-menu/src/Struct/BattleSummary.elm b/src/main-menu/src/Struct/BattleSummary.elm
index c62bd6c..4ea02bc 100644
--- a/src/main-menu/src/Struct/BattleSummary.elm
+++ b/src/main-menu/src/Struct/BattleSummary.elm
@@ -4,6 +4,7 @@ module Struct.BattleSummary exposing
Category(..),
Mode(..),
get_id,
+ get_ix,
get_name,
get_mode,
get_category,
@@ -69,6 +70,9 @@ category_from_string str =
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
+get_ix : Type -> Int
+get_ix t = t.ix
+
get_id : Type -> String
get_id t = t.id
diff --git a/src/main-menu/src/View/BattleListing.elm b/src/main-menu/src/View/BattleListing.elm
index 4e9479f..4d4183c 100644
--- a/src/main-menu/src/View/BattleListing.elm
+++ b/src/main-menu/src/View/BattleListing.elm
@@ -3,22 +3,27 @@ module View.BattleListing exposing (get_html)
-- Elm -------------------------------------------------------------------------
import Html
import Html.Attributes
--- import Html.Events
+import Html.Events
--- Map -------------------------------------------------------------------
+
+-- Main Menu -------------------------------------------------------------------
import Struct.BattleSummary
import Struct.Event
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_item_html : Struct.BattleSummary.Type -> (Html.Html Struct.Event.Type)
-get_item_html item =
+get_link_html : Struct.BattleSummary.Type -> (Html.Html Struct.Event.Type)
+get_link_html item =
(Html.a
[
(Html.Attributes.href
(
- "/battle/?id="
+ (
+ if (Struct.BattleSummary.is_pending item)
+ then "/pending_battle/?id="
+ else "/battle/?id="
+ )
++ (Struct.BattleSummary.get_id item)
)
),
@@ -50,6 +55,31 @@ get_item_html item =
]
)
+get_create_button_html : Struct.BattleSummary.Type -> (Html.Html Struct.Event.Type)
+get_create_button_html item =
+ (Html.a
+ [
+ (Html.Events.onClick
+ (Struct.Event.NewBattle
+ (
+ (Struct.BattleSummary.get_ix item),
+ (Struct.BattleSummary.get_category item)
+ )
+ )
+ ),
+ (Html.Attributes.class "clickable")
+ ]
+ [
+ (Html.text "New Battle")
+ ]
+ )
+
+get_item_html : Struct.BattleSummary.Type -> (Html.Html Struct.Event.Type)
+get_item_html item =
+ if ((Struct.BattleSummary.get_id item) == "")
+ then (get_create_button_html item)
+ else (get_link_html item)
+
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -79,14 +109,6 @@ get_html name class battle_summaries =
(Html.Attributes.class "main-menu-battle-listing-body")
]
(List.map (get_item_html) battle_summaries)
- ),
- (Html.div
- [
- (Html.Attributes.class "main-menu-battle-listing-add-new")
- ]
- [
- (Html.text "New")
- ]
)
]
)
diff --git a/src/main-menu/src/View/CurrentTab.elm b/src/main-menu/src/View/CurrentTab.elm
index 054d764..0815513 100644
--- a/src/main-menu/src/View/CurrentTab.elm
+++ b/src/main-menu/src/View/CurrentTab.elm
@@ -13,7 +13,6 @@ import Struct.Player
import Struct.UI
import View.BattleListing
-import View.Invasions
import View.MapListing
import View.Roster
@@ -33,8 +32,10 @@ default_tab model =
"main-menu-campaigns"
(Array.toList (Struct.Player.get_campaigns model.player))
),
- (View.Invasions.get_html
- (Struct.Player.get_invasions model.player)
+ (View.BattleListing.get_html
+ "Invasions"
+ "main-menu-invasions"
+ (Array.toList (Struct.Player.get_invasions model.player))
),
(View.BattleListing.get_html
"Events"
diff --git a/src/main-menu/src/View/Invasions.elm b/src/main-menu/src/View/Invasions.elm
deleted file mode 100644
index 233c621..0000000
--- a/src/main-menu/src/View/Invasions.elm
+++ /dev/null
@@ -1,109 +0,0 @@
-module View.Invasions exposing (get_html)
-
--- Elm -------------------------------------------------------------------------
-import Array
-
-import Html
-import Html.Attributes
-import Html.Events
-
--- Main Menu -------------------------------------------------------------------
-import Struct.BattleSummary
-import Struct.Event
-
---------------------------------------------------------------------------------
--- LOCAL -----------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_invasion_html : (
- Int ->
- Struct.BattleSummary.Type ->
- (Html.Html Struct.Event.Type)
- )
-get_invasion_html ix invasion =
- let
- invasion_id = (Struct.BattleSummary.get_id invasion)
- activation_class =
- (
- if (Struct.BattleSummary.is_players_turn invasion)
- then (Html.Attributes.class "main-menu-battle-summary-is-active")
- else (Html.Attributes.class "main-menu-battle-summary-is-inactive")
- )
- invasion_type =
- (
- if (ix >= 3)
- then (Html.Attributes.class "main-menu-invasion-defense")
- else (Html.Attributes.class "main-menu-invasion-attack")
- )
- in
- if (invasion_id == "")
- then
- (Html.a
- [
- (Html.Events.onClick
- (Struct.Event.NewBattle (ix, Struct.BattleSummary.Invasion))
- ),
- (Html.Attributes.class "clickable"),
- invasion_type
- ]
- [
- (Html.text "New Invasion")
- ]
- )
- else
- (Html.a
- [
- (Html.Attributes.href ("/battle/?id=" ++ invasion_id)),
- invasion_type,
- activation_class
- ]
- [
- (Html.div
- [
- (Html.Attributes.class "main-menu-battle-summary-name")
- ]
- [
- (Html.text (Struct.BattleSummary.get_name invasion))
- ]
- ),
- (Html.div
- [
- (Html.Attributes.class "main-menu-battle-summary-date")
- ]
- [
- (Html.text (Struct.BattleSummary.get_deadline invasion))
- ]
- )
- ]
- )
-
-
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_html : (
- (Array.Array Struct.BattleSummary.Type) ->
- (Html.Html Struct.Event.Type)
- )
-get_html invasions =
- (Html.div
- [
- (Html.Attributes.class "main-menu-invasions"),
- (Html.Attributes.class "main-menu-battle-listing")
- ]
- [
- (Html.div
- [
- (Html.Attributes.class "main-menu-battle-listing-header")
- ]
- [
- (Html.text "Invasions")
- ]
- ),
- (Html.div
- [
- (Html.Attributes.class "main-menu-battle-listing-body")
- ]
- (Array.toList (Array.indexedMap (get_invasion_html) invasions))
- )
- ]
- )
diff --git a/src/main-menu/src/View/MapListing.elm b/src/main-menu/src/View/MapListing.elm
index 79c39b4..b7be22a 100644
--- a/src/main-menu/src/View/MapListing.elm
+++ b/src/main-menu/src/View/MapListing.elm
@@ -61,14 +61,6 @@ get_html map_summaries =
(Html.Attributes.class "main-menu-map-listing-body")
]
(List.map (get_item_html) map_summaries)
- ),
- (Html.div
- [
- (Html.Attributes.class "main-menu-map-listing-add-new")
- ]
- [
- (Html.text "New")
- ]
)
]
)