aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/battlemap/src/Comm/CharacterTurn.elm3
-rw-r--r--src/battlemap/src/ElmModule/Update.elm4
-rw-r--r--src/battlemap/src/Struct/CharacterTurn.elm6
-rw-r--r--src/battlemap/src/Struct/Event.elm1
-rw-r--r--src/battlemap/src/Update/AbortTurn.elm24
-rw-r--r--src/battlemap/src/Update/EndTurn.elm7
-rw-r--r--src/battlemap/src/Update/SelectCharacter.elm12
-rw-r--r--src/battlemap/src/Update/SelectTile.elm27
-rw-r--r--src/battlemap/src/View/Battlemap.elm1
-rw-r--r--src/battlemap/src/View/Controlled.elm47
-rw-r--r--src/battlemap/src/View/Controlled/CharacterCard.elm2
-rw-r--r--src/battlemap/src/View/Help.elm3
-rw-r--r--src/battlemap/src/View/MainMenu.elm1
-rw-r--r--src/battlemap/src/View/SubMenu.elm31
-rw-r--r--src/battlemap/src/View/SubMenu/Status.elm2
15 files changed, 129 insertions, 42 deletions
diff --git a/src/battlemap/src/Comm/CharacterTurn.elm b/src/battlemap/src/Comm/CharacterTurn.elm
index a7e137d..050d24f 100644
--- a/src/battlemap/src/Comm/CharacterTurn.elm
+++ b/src/battlemap/src/Comm/CharacterTurn.elm
@@ -63,8 +63,9 @@ encode_weapon_switch model =
encode_attack : Struct.Model.Type -> (Maybe Json.Encode.Value)
encode_attack model =
- case (Struct.CharacterTurn.get_target model.char_turn) of
+ case (Struct.CharacterTurn.try_getting_target model.char_turn) of
Nothing -> Nothing
+
(Just ix) ->
(Just
(Json.Encode.object
diff --git a/src/battlemap/src/ElmModule/Update.elm b/src/battlemap/src/ElmModule/Update.elm
index 36270a4..43b6476 100644
--- a/src/battlemap/src/ElmModule/Update.elm
+++ b/src/battlemap/src/ElmModule/Update.elm
@@ -6,6 +6,7 @@ module ElmModule.Update exposing (update)
import Struct.Event
import Struct.Model
+import Update.AbortTurn
import Update.AttackWithoutMoving
import Update.ChangeScale
import Update.DisplayCharacterInfo
@@ -64,3 +65,6 @@ update event model =
Struct.Event.WeaponSwitchRequest ->
(Update.SwitchWeapon.apply_to new_model)
+
+ Struct.Event.AbortTurnRequest ->
+ (Update.AbortTurn.apply_to new_model)
diff --git a/src/battlemap/src/Struct/CharacterTurn.elm b/src/battlemap/src/Struct/CharacterTurn.elm
index 6188913..26b906d 100644
--- a/src/battlemap/src/Struct/CharacterTurn.elm
+++ b/src/battlemap/src/Struct/CharacterTurn.elm
@@ -8,7 +8,7 @@ module Struct.CharacterTurn exposing
has_switched_weapons,
get_path,
get_state,
- get_target,
+ try_getting_target,
lock_path,
new,
set_active_character,
@@ -130,5 +130,5 @@ set_target target ct =
target = target
}
-get_target : Type -> (Maybe Struct.Character.Ref)
-get_target ct = ct.target
+try_getting_target : Type -> (Maybe Struct.Character.Ref)
+try_getting_target ct = ct.target
diff --git a/src/battlemap/src/Struct/Event.elm b/src/battlemap/src/Struct/Event.elm
index c2696eb..bc4de17 100644
--- a/src/battlemap/src/Struct/Event.elm
+++ b/src/battlemap/src/Struct/Event.elm
@@ -26,3 +26,4 @@ type Type =
| DebugLoadBattlemapRequest
| WeaponSwitchRequest
| AttackWithoutMovingRequest
+ | AbortTurnRequest
diff --git a/src/battlemap/src/Update/AbortTurn.elm b/src/battlemap/src/Update/AbortTurn.elm
new file mode 100644
index 0000000..4fc1b04
--- /dev/null
+++ b/src/battlemap/src/Update/AbortTurn.elm
@@ -0,0 +1,24 @@
+module Update.AbortTurn exposing (apply_to)
+
+-- Elm -------------------------------------------------------------------------
+
+-- Struct.Battlemap -------------------------------------------------------------------
+import Struct.CharacterTurn
+import Struct.Event
+import Struct.Model
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+apply_to : Struct.Model.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type))
+apply_to model =
+ (
+ {model |
+ char_turn = (Struct.CharacterTurn.new)
+ },
+ Cmd.none
+ )
diff --git a/src/battlemap/src/Update/EndTurn.elm b/src/battlemap/src/Update/EndTurn.elm
index 142f8ff..c583b16 100644
--- a/src/battlemap/src/Update/EndTurn.elm
+++ b/src/battlemap/src/Update/EndTurn.elm
@@ -81,13 +81,16 @@ apply_to model =
) ->
(make_it_so model char nav)
+ (Struct.CharacterTurn.SelectedCharacter, (Just char), (Just nav)) ->
+ (make_it_so model char nav)
+
(_, _, _) ->
(
(Struct.Model.invalidate
model
(Struct.Error.new
- Struct.Error.IllegalAction
- "This can only be done while moving a character."
+ Struct.Error.Programming
+ "Character turn appears to be in an illegal state."
)
),
Cmd.none
diff --git a/src/battlemap/src/Update/SelectCharacter.elm b/src/battlemap/src/Update/SelectCharacter.elm
index 152aa9c..cc83f6b 100644
--- a/src/battlemap/src/Update/SelectCharacter.elm
+++ b/src/battlemap/src/Update/SelectCharacter.elm
@@ -34,7 +34,9 @@ attack_character model target_char_id target_char =
model.char_turn
),
ui =
- (Struct.UI.set_previous_action model.ui Nothing)
+ (Struct.UI.reset_displayed_tab
+ (Struct.UI.set_previous_action model.ui Nothing)
+ )
}
ctrl_or_focus_character : (
@@ -146,13 +148,7 @@ double_clicked_character model target_char_id =
)
else
(
- (Struct.Model.invalidate
- model
- (Struct.Error.new
- Struct.Error.IllegalAction
- "Has not yet moved, target is out of range, or dead."
- )
- ),
+ (ctrl_or_focus_character model target_char_id target_char),
Cmd.none
)
diff --git a/src/battlemap/src/Update/SelectTile.elm b/src/battlemap/src/Update/SelectTile.elm
index 9c0b136..3219873 100644
--- a/src/battlemap/src/Update/SelectTile.elm
+++ b/src/battlemap/src/Update/SelectTile.elm
@@ -64,9 +64,12 @@ go_to_tile model navigator loc_ref =
(
{model |
ui =
- (Struct.UI.set_previous_action
- model.ui
- (Just (Struct.UI.SelectedLocation loc_ref))
+ (Struct.UI.set_displayed_tab
+ (Struct.UI.set_previous_action
+ model.ui
+ (Just (Struct.UI.SelectedLocation loc_ref))
+ )
+ Struct.UI.StatusTab
)
},
Cmd.none
@@ -96,9 +99,12 @@ go_to_tile model navigator loc_ref =
model.char_turn
),
ui =
- (Struct.UI.set_previous_action
- model.ui
- (Just (Struct.UI.SelectedLocation loc_ref))
+ (Struct.UI.set_displayed_tab
+ (Struct.UI.set_previous_action
+ model.ui
+ (Just (Struct.UI.SelectedLocation loc_ref))
+ )
+ Struct.UI.StatusTab
)
},
Cmd.none
@@ -136,9 +142,12 @@ apply_to model loc_ref =
(
{model |
ui =
- (Struct.UI.set_previous_action
- model.ui
- (Just (Struct.UI.SelectedLocation loc_ref))
+ (Struct.UI.set_displayed_tab
+ (Struct.UI.set_previous_action
+ model.ui
+ (Just (Struct.UI.SelectedLocation loc_ref))
+ )
+ Struct.UI.StatusTab
)
},
Cmd.none
diff --git a/src/battlemap/src/View/Battlemap.elm b/src/battlemap/src/View/Battlemap.elm
index 14243aa..6bac42e 100644
--- a/src/battlemap/src/View/Battlemap.elm
+++ b/src/battlemap/src/View/Battlemap.elm
@@ -19,7 +19,6 @@ import Struct.CharacterTurn
import Struct.Event
import Struct.Model
import Struct.Navigator
-import Struct.Tile
import Struct.UI
import Util.Html
diff --git a/src/battlemap/src/View/Controlled.elm b/src/battlemap/src/View/Controlled.elm
index 0afd481..4b467b5 100644
--- a/src/battlemap/src/View/Controlled.elm
+++ b/src/battlemap/src/View/Controlled.elm
@@ -10,6 +10,7 @@ import Struct.Character
import Struct.CharacterTurn
import Struct.Event
import Struct.Model
+import Struct.Navigator
import Struct.WeaponSet
import Util.Html
@@ -19,18 +20,40 @@ import View.Controlled.CharacterCard
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-attack_button : (Html.Html Struct.Event.Type)
-attack_button =
+has_a_path : Struct.CharacterTurn.Type -> Bool
+has_a_path char_turn =
+ case (Struct.CharacterTurn.try_getting_navigator char_turn) of
+ (Just nav) -> ((Struct.Navigator.get_path nav) /= [])
+ Nothing -> False
+
+
+attack_button : Struct.CharacterTurn.Type -> (Html.Html Struct.Event.Type)
+attack_button char_turn =
(Html.button
[ (Html.Events.onClick Struct.Event.AttackWithoutMovingRequest) ]
- [ (Html.text "Select Target") ]
+ [
+ (Html.text
+ (
+ if (has_a_path char_turn)
+ then ("Go & Select Target")
+ else ("Select Target")
+ )
+ )
+ ]
+ )
+
+abort_button : (Html.Html Struct.Event.Type)
+abort_button =
+ (Html.button
+ [ (Html.Events.onClick Struct.Event.AbortTurnRequest) ]
+ [ (Html.text "Abort") ]
)
-end_turn_button : (Html.Html Struct.Event.Type)
-end_turn_button =
+end_turn_button : String -> (Html.Html Struct.Event.Type)
+end_turn_button suffix =
(Html.button
[ (Html.Events.onClick Struct.Event.TurnEnded) ]
- [ (Html.text "End Turn") ]
+ [ (Html.text ("End Turn" ++ suffix)) ]
)
inventory_button : (Html.Html Struct.Event.Type)
@@ -48,18 +71,22 @@ get_available_actions model =
case (Struct.CharacterTurn.get_state model.char_turn) of
Struct.CharacterTurn.SelectedCharacter ->
[
- (attack_button),
- (inventory_button)
+ (attack_button model.char_turn),
+ (inventory_button),
+ (end_turn_button " Doing Nothing"),
+ (abort_button)
]
Struct.CharacterTurn.MovedCharacter ->
[
- (end_turn_button)
+ (end_turn_button " Without Attacking"),
+ (abort_button)
]
Struct.CharacterTurn.ChoseTarget ->
[
- (end_turn_button)
+ (end_turn_button " By Attacking"),
+ (abort_button)
]
_ ->
diff --git a/src/battlemap/src/View/Controlled/CharacterCard.elm b/src/battlemap/src/View/Controlled/CharacterCard.elm
index 9c88b75..b93c0c8 100644
--- a/src/battlemap/src/View/Controlled/CharacterCard.elm
+++ b/src/battlemap/src/View/Controlled/CharacterCard.elm
@@ -1,8 +1,6 @@
module View.Controlled.CharacterCard exposing (get_html)
-- Elm -------------------------------------------------------------------------
-import Dict
-
import Html
import Html.Attributes
diff --git a/src/battlemap/src/View/Help.elm b/src/battlemap/src/View/Help.elm
index 7b89008..293a53d 100644
--- a/src/battlemap/src/View/Help.elm
+++ b/src/battlemap/src/View/Help.elm
@@ -3,7 +3,6 @@ module View.Help exposing (get_html)
-- Elm -------------------------------------------------------------------------
import Html
import Html.Attributes
-import Html.Events
-- Struct.Battlemap -------------------------------------------------------------------
import Struct.CharacterTurn
@@ -11,8 +10,6 @@ import Struct.Error
import Struct.Event
import Struct.Model
-import Util.Html
-
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
diff --git a/src/battlemap/src/View/MainMenu.elm b/src/battlemap/src/View/MainMenu.elm
index b666195..e7a3606 100644
--- a/src/battlemap/src/View/MainMenu.elm
+++ b/src/battlemap/src/View/MainMenu.elm
@@ -10,7 +10,6 @@ import Struct.Event
import Struct.Model
import Struct.UI
-import Util.Html
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
diff --git a/src/battlemap/src/View/SubMenu.elm b/src/battlemap/src/View/SubMenu.elm
index 1690024..f582329 100644
--- a/src/battlemap/src/View/SubMenu.elm
+++ b/src/battlemap/src/View/SubMenu.elm
@@ -1,16 +1,23 @@
module View.SubMenu exposing (get_html)
-- Elm -------------------------------------------------------------------------
+import Dict
+
import Html
import Html.Attributes
-- Battlemap -------------------------------------------------------------------
+import Struct.Character
+import Struct.CharacterTurn
import Struct.Event
import Struct.Model
import Struct.UI
+import Struct.WeaponSet
import Util.Html
+import View.Controlled.CharacterCard
+
import View.SubMenu.Characters
import View.SubMenu.Settings
import View.SubMenu.Status
@@ -51,4 +58,26 @@ get_html model =
)
Nothing ->
- (Util.Html.nothing)
+ case (Struct.CharacterTurn.try_getting_target model.char_turn) of
+ (Just char_ref) ->
+ case (Dict.get char_ref model.characters) of
+ (Just char) ->
+ (Html.div
+ [(Html.Attributes.class "battlemap-sub-menu")]
+ [
+ (Html.text "Targeting:"),
+ (View.Controlled.CharacterCard.get_html
+ model
+ char
+ (Struct.WeaponSet.get_active_weapon
+ (Struct.Character.get_weapons char)
+ )
+ )
+ ]
+ )
+
+ Nothing ->
+ (Util.Html.nothing)
+
+ Nothing ->
+ (Util.Html.nothing)
diff --git a/src/battlemap/src/View/SubMenu/Status.elm b/src/battlemap/src/View/SubMenu/Status.elm
index 2ff5bf4..031f795 100644
--- a/src/battlemap/src/View/SubMenu/Status.elm
+++ b/src/battlemap/src/View/SubMenu/Status.elm
@@ -151,7 +151,7 @@ get_html model =
_ -> (Html.text "Error: Unknown character selected.")
_ ->
- (Html.text "Double-click on a character to control it.")
+ (Html.text "Nothing is being focused.")
)
]
)