summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-06-16 00:26:23 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-06-16 00:26:23 +0200
commitcb496ae0c7e163721e103d9b6a6f801013d82066 (patch)
treeef60d4342912fdfc41437e0839d55bb003209425
parent748650edc79e8dc24e7cc7a9a2402390de0b5ba1 (diff)
characters as array, took a shot at optimization.
-rw-r--r--src/battlemap/src/Comm/CharacterTurn.elm4
-rw-r--r--src/battlemap/src/ElmModule/View.elm7
-rw-r--r--src/battlemap/src/Struct/Attack.elm60
-rw-r--r--src/battlemap/src/Struct/Character.elm13
-rw-r--r--src/battlemap/src/Struct/CharacterTurn.elm6
-rw-r--r--src/battlemap/src/Struct/Event.elm7
-rw-r--r--src/battlemap/src/Struct/Model.elm19
-rw-r--r--src/battlemap/src/Struct/TurnResult.elm80
-rw-r--r--src/battlemap/src/Struct/UI.elm4
-rw-r--r--src/battlemap/src/Update/DisplayCharacterInfo.elm14
-rw-r--r--src/battlemap/src/Update/EndTurn.elm26
-rw-r--r--src/battlemap/src/Update/LookForCharacter.elm16
-rw-r--r--src/battlemap/src/Update/SelectCharacter.elm18
-rw-r--r--src/battlemap/src/Update/SelectTile.elm2
-rw-r--r--src/battlemap/src/Update/SwitchTeam.elm10
-rw-r--r--src/battlemap/src/Update/SwitchWeapon.elm4
-rw-r--r--src/battlemap/src/View/Battlemap.elm92
-rw-r--r--src/battlemap/src/View/Battlemap/Character.elm18
-rw-r--r--src/battlemap/src/View/Character.elm8
-rw-r--r--src/battlemap/src/View/Controlled.elm24
-rw-r--r--src/battlemap/src/View/Controlled/CharacterCard.elm37
-rw-r--r--src/battlemap/src/View/SubMenu.elm13
-rw-r--r--src/battlemap/src/View/SubMenu/Characters.elm22
-rw-r--r--src/battlemap/src/View/SubMenu/Status.elm10
-rw-r--r--src/battlemap/src/View/SubMenu/Status/CharacterInfo.elm11
-rw-r--r--src/battlemap/src/View/SubMenu/Timeline.elm41
-rw-r--r--src/battlemap/src/View/SubMenu/Timeline/Attack.elm15
-rw-r--r--src/battlemap/src/View/SubMenu/Timeline/Movement.elm11
-rw-r--r--src/battlemap/src/View/SubMenu/Timeline/WeaponSwitch.elm11
29 files changed, 335 insertions, 268 deletions
diff --git a/src/battlemap/src/Comm/CharacterTurn.elm b/src/battlemap/src/Comm/CharacterTurn.elm
index 68f6c37..9287c45 100644
--- a/src/battlemap/src/Comm/CharacterTurn.elm
+++ b/src/battlemap/src/Comm/CharacterTurn.elm
@@ -71,7 +71,7 @@ encode_attack model =
(Json.Encode.object
[
("t", (Json.Encode.string "atk")),
- ("tix", (Json.Encode.string ix))
+ ("tix", (Json.Encode.int ix))
]
)
)
@@ -104,7 +104,7 @@ try_encoding model =
("bid", (Json.Encode.string "0")),
(
"cix",
- (Json.Encode.string (Struct.Character.get_ref char))
+ (Json.Encode.int (Struct.Character.get_index char))
),
(
"act",
diff --git a/src/battlemap/src/ElmModule/View.elm b/src/battlemap/src/ElmModule/View.elm
index 05fbc1c..b2c4d66 100644
--- a/src/battlemap/src/ElmModule/View.elm
+++ b/src/battlemap/src/ElmModule/View.elm
@@ -2,6 +2,7 @@ module ElmModule.View exposing (view)
-- Elm -------------------------------------------------------------------------
import Html
+import Html.Lazy
import Html.Attributes
-- Battlemap -------------------------------------------------------------------
@@ -31,7 +32,11 @@ view model =
]
[
(View.MainMenu.get_html model),
- (View.Controlled.get_html model),
+ (Html.Lazy.lazy2
+ (View.Controlled.get_html)
+ model.char_turn
+ model.player_id
+ ),
(Html.div
[
(Html.Attributes.class "battlemap-container"),
diff --git a/src/battlemap/src/Struct/Attack.elm b/src/battlemap/src/Struct/Attack.elm
index 4eab68e..e3199cd 100644
--- a/src/battlemap/src/Struct/Attack.elm
+++ b/src/battlemap/src/Struct/Attack.elm
@@ -8,7 +8,7 @@ module Struct.Attack exposing
)
-- Elm -------------------------------------------------------------------------
-import Dict
+import Array
import Json.Decode
@@ -74,42 +74,44 @@ decoder =
apply_damage_to_character : (
Int ->
- (Maybe Struct.Character.Type) ->
- (Maybe Struct.Character.Type)
+ Struct.Character.Type ->
+ Struct.Character.Type
+ )
+apply_damage_to_character damage char =
+ (Struct.Character.set_current_health
+ ((Struct.Character.get_current_health char) - damage)
+ char
)
-apply_damage_to_character damage maybe_character =
- case maybe_character of
- Nothing -> Nothing
-
- (Just char) ->
- (Just
- (Struct.Character.set_current_health
- ((Struct.Character.get_current_health char) - damage)
- char
- )
- )
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
apply_to_characters : (
- Struct.Character.Ref ->
- Struct.Character.Ref ->
+ Int ->
+ Int ->
Type ->
- (Dict.Dict Struct.Character.Ref Struct.Character.Type) ->
- (Dict.Dict Struct.Character.Ref Struct.Character.Type)
+ (Array.Array Struct.Character.Type) ->
+ (Array.Array Struct.Character.Type)
)
-apply_to_characters attacker_ref defender_ref attack characters =
+apply_to_characters attacker_ix defender_ix attack characters =
if ((attack.order == Counter) == attack.parried)
then
- (Dict.update
- defender_ref
- (apply_damage_to_character attack.damage)
- characters
- )
+ case (Array.get defender_ix characters) of
+ (Just char) ->
+ (Array.set
+ defender_ix
+ (apply_damage_to_character attack.damage char)
+ characters
+ )
+
+ Nothing -> characters
else
- (Dict.update
- attacker_ref
- (apply_damage_to_character attack.damage)
- characters
- )
+ case (Array.get attacker_ix characters) of
+ (Just char) ->
+ (Array.set
+ attacker_ix
+ (apply_damage_to_character attack.damage char)
+ characters
+ )
+
+ Nothing -> characters
diff --git a/src/battlemap/src/Struct/Character.elm b/src/battlemap/src/Struct/Character.elm
index 74642b1..2ae0273 100644
--- a/src/battlemap/src/Struct/Character.elm
+++ b/src/battlemap/src/Struct/Character.elm
@@ -1,8 +1,7 @@
module Struct.Character exposing
(
Type,
- Ref,
- get_ref,
+ get_index,
get_player_id,
get_name,
get_icon_id,
@@ -57,7 +56,7 @@ type alias PartiallyDecoded =
type alias Type =
{
- id : String,
+ ix : Int,
name : String,
icon : String,
portrait : String,
@@ -71,8 +70,6 @@ type alias Type =
armor : Struct.Armor.Type
}
-type alias Ref = String
-
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -83,7 +80,7 @@ finish_decoding add_char =
armor = Struct.Armor.none
almost_char =
{
- id = (toString add_char.ix),
+ ix = add_char.ix,
name = add_char.nam,
icon = add_char.ico,
portrait = add_char.prt,
@@ -102,8 +99,8 @@ finish_decoding add_char =
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_ref : Type -> Ref
-get_ref c = c.id
+get_index : Type -> Int
+get_index c = c.ix
get_name : Type -> String
get_name c = c.name
diff --git a/src/battlemap/src/Struct/CharacterTurn.elm b/src/battlemap/src/Struct/CharacterTurn.elm
index 26b906d..3b4c35d 100644
--- a/src/battlemap/src/Struct/CharacterTurn.elm
+++ b/src/battlemap/src/Struct/CharacterTurn.elm
@@ -38,7 +38,7 @@ type alias Type =
state : State,
active_character : (Maybe Struct.Character.Type),
path : (List Struct.Direction.Type),
- target : (Maybe Struct.Character.Ref),
+ target : (Maybe Int),
navigator : (Maybe Struct.Navigator.Type),
has_switched_weapons : Bool
}
@@ -123,12 +123,12 @@ set_has_switched_weapons v ct =
has_switched_weapons : Type -> Bool
has_switched_weapons ct = ct.has_switched_weapons
-set_target : (Maybe Struct.Character.Ref) -> Type -> Type
+set_target : (Maybe Int) -> Type -> Type
set_target target ct =
{ct |
state = ChoseTarget,
target = target
}
-try_getting_target : Type -> (Maybe Struct.Character.Ref)
+try_getting_target : Type -> (Maybe Int)
try_getting_target ct = ct.target
diff --git a/src/battlemap/src/Struct/Event.elm b/src/battlemap/src/Struct/Event.elm
index 13d42fe..a57bc2f 100644
--- a/src/battlemap/src/Struct/Event.elm
+++ b/src/battlemap/src/Struct/Event.elm
@@ -4,7 +4,6 @@ module Struct.Event exposing (Type(..), attempted)
import Http
-- Battlemap -------------------------------------------------------------------
-import Struct.Character
import Struct.Direction
import Struct.Error
import Struct.Location
@@ -17,13 +16,13 @@ import Struct.UI
type Type =
AbortTurnRequest
| AttackWithoutMovingRequest
- | CharacterInfoRequested Struct.Character.Ref
- | CharacterSelected Struct.Character.Ref
+ | CharacterInfoRequested Int
+ | CharacterSelected Int
| DebugLoadBattlemapRequest
| DebugTeamSwitchRequest
| DirectionRequested Struct.Direction.Type
| Failed Struct.Error.Type
- | LookingForCharacter Struct.Character.Ref
+ | LookingForCharacter Int
| None
| ScaleChangeRequested Float
| ServerReplied (Result Http.Error (List Struct.ServerReply.Type))
diff --git a/src/battlemap/src/Struct/Model.elm b/src/battlemap/src/Struct/Model.elm
index b954c68..6cf5368 100644
--- a/src/battlemap/src/Struct/Model.elm
+++ b/src/battlemap/src/Struct/Model.elm
@@ -3,6 +3,7 @@ module Struct.Model exposing
Type,
new,
add_character,
+ update_character,
add_weapon,
add_armor,
invalidate,
@@ -30,7 +31,7 @@ import Struct.Weapon
type alias Type =
{
battlemap: Struct.Battlemap.Type,
- characters: (Dict.Dict Struct.Character.Ref Struct.Character.Type),
+ characters: (Array.Array Struct.Character.Type),
weapons: (Dict.Dict Struct.Weapon.Ref Struct.Weapon.Type),
armors: (Dict.Dict Struct.Armor.Ref Struct.Armor.Type),
error: (Maybe Struct.Error.Type),
@@ -51,7 +52,7 @@ new : Type
new =
{
battlemap = (Struct.Battlemap.empty),
- characters = (Dict.empty),
+ characters = (Array.empty),
weapons = (Dict.empty),
armors = (Dict.empty),
error = Nothing,
@@ -65,8 +66,7 @@ add_character : Struct.Character.Type -> Type -> Type
add_character char model =
{model |
characters =
- (Dict.insert
- (Struct.Character.get_ref char)
+ (Array.push
char
model.characters
)
@@ -94,10 +94,9 @@ add_armor ar model =
)
}
-reset : (Dict.Dict Struct.Character.Ref Struct.Character.Type) -> Type -> Type
-reset characters model =
+reset : Type -> Type
+reset model =
{model |
- characters = characters,
error = Nothing,
ui =
(Struct.UI.reset_displayed_nav
@@ -106,6 +105,12 @@ reset characters model =
char_turn = (Struct.CharacterTurn.new)
}
+update_character : Int -> Struct.Character.Type -> Type -> Type
+update_character ix new_val model =
+ {model |
+ characters = (Array.set ix new_val model.characters)
+ }
+
invalidate : Struct.Error.Type -> Type -> Type
invalidate err model =
{model |
diff --git a/src/battlemap/src/Struct/TurnResult.elm b/src/battlemap/src/Struct/TurnResult.elm
index 18a8dbd..23fdf1d 100644
--- a/src/battlemap/src/Struct/TurnResult.elm
+++ b/src/battlemap/src/Struct/TurnResult.elm
@@ -9,7 +9,7 @@ module Struct.TurnResult exposing
)
-- Elm -------------------------------------------------------------------------
-import Dict
+import Array
import Json.Decode
@@ -52,44 +52,34 @@ type Type =
--------------------------------------------------------------------------------
apply_movement_to_character : (
Movement ->
- (Maybe Struct.Character.Type) ->
- (Maybe Struct.Character.Type)
+ Struct.Character.Type ->
+ Struct.Character.Type
)
-apply_movement_to_character movement maybe_char =
- case maybe_char of
- Nothing -> Nothing
-
- (Just char) ->
- (Just (Struct.Character.set_location movement.destination char))
+apply_movement_to_character movement char =
+ (Struct.Character.set_location movement.destination char)
apply_weapon_switch_to_character : (
- (Maybe Struct.Character.Type) ->
- (Maybe Struct.Character.Type)
+ Struct.Character.Type ->
+ Struct.Character.Type
+ )
+apply_weapon_switch_to_character char =
+ (Struct.Character.set_weapons
+ (Struct.WeaponSet.switch_weapons
+ (Struct.Character.get_weapons char)
+ )
+ char
)
-apply_weapon_switch_to_character maybe_char =
- case maybe_char of
- Nothing -> Nothing
-
- (Just char) ->
- (Just
- (Struct.Character.set_weapons
- (Struct.WeaponSet.switch_weapons
- (Struct.Character.get_weapons char)
- )
- char
- )
- )
apply_attack_to_characters : (
Attack ->
- (Dict.Dict Struct.Character.Ref Struct.Character.Type) ->
- (Dict.Dict Struct.Character.Ref Struct.Character.Type)
+ (Array.Array Struct.Character.Type) ->
+ (Array.Array Struct.Character.Type)
)
apply_attack_to_characters attack characters =
(List.foldl
(Struct.Attack.apply_to_characters
- (toString attack.attacker_index)
- (toString attack.defender_index)
+ attack.attacker_index
+ attack.defender_index
)
characters
attack.sequence
@@ -165,24 +155,34 @@ internal_decoder kind =
--------------------------------------------------------------------------------
apply_to_characters : (
Type ->
- (Dict.Dict Struct.Character.Ref Struct.Character.Type) ->
- (Dict.Dict Struct.Character.Ref Struct.Character.Type)
+ (Array.Array Struct.Character.Type) ->
+ (Array.Array Struct.Character.Type)
)
apply_to_characters turn_result characters =
case turn_result of
(Moved movement) ->
- (Dict.update
- (toString movement.character_index)
- (apply_movement_to_character movement)
- characters
- )
+ case (Array.get movement.character_index characters) of
+ (Just char) ->
+ (Array.set
+ movement.character_index
+ (apply_movement_to_character movement char)
+ characters
+ )
+
+ Nothing ->
+ characters
(SwitchedWeapon weapon_switch) ->
- (Dict.update
- (toString weapon_switch.character_index)
- (apply_weapon_switch_to_character)
- characters
- )
+ case (Array.get weapon_switch.character_index characters) of
+ (Just char) ->
+ (Array.set
+ weapon_switch.character_index
+ (apply_weapon_switch_to_character char)
+ characters
+ )
+
+ Nothing ->
+ characters
(Attacked attack) ->
(apply_attack_to_characters attack characters)
diff --git a/src/battlemap/src/Struct/UI.elm b/src/battlemap/src/Struct/UI.elm
index eb6b98a..fe1cfe1 100644
--- a/src/battlemap/src/Struct/UI.elm
+++ b/src/battlemap/src/Struct/UI.elm
@@ -43,8 +43,8 @@ type Tab =
type Action =
UsedManualControls
| SelectedLocation Struct.Location.Ref
- | SelectedCharacter Struct.Character.Ref
- | AttackedCharacter Struct.Character.Ref
+ | SelectedCharacter Int
+ | AttackedCharacter Int
type alias Type =
{
diff --git a/src/battlemap/src/Update/DisplayCharacterInfo.elm b/src/battlemap/src/Update/DisplayCharacterInfo.elm
index 37fe88e..1e2d9b8 100644
--- a/src/battlemap/src/Update/DisplayCharacterInfo.elm
+++ b/src/battlemap/src/Update/DisplayCharacterInfo.elm
@@ -1,6 +1,6 @@
module Update.DisplayCharacterInfo exposing (apply_to)
-- Elm -------------------------------------------------------------------------
-import Dict
+import Array
import Task
-- Battlemap -------------------------------------------------------------------
@@ -14,13 +14,9 @@ import Struct.UI
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-scroll_to_char : (
- Struct.Model.Type ->
- Struct.Character.Ref ->
- (Cmd Struct.Event.Type)
- )
-scroll_to_char model char_ref =
- case (Dict.get char_ref model.characters) of
+scroll_to_char : Struct.Model.Type -> Int -> (Cmd Struct.Event.Type)
+scroll_to_char model char_ix =
+ case (Array.get char_ix model.characters) of
(Just char) ->
(Task.attempt
(Struct.Event.attempted)
@@ -38,7 +34,7 @@ scroll_to_char model char_ref =
--------------------------------------------------------------------------------
apply_to : (
Struct.Model.Type ->
- Struct.Character.Ref ->
+ Int ->
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
apply_to model target_ref =
diff --git a/src/battlemap/src/Update/EndTurn.elm b/src/battlemap/src/Update/EndTurn.elm
index 173a713..4acbc94 100644
--- a/src/battlemap/src/Update/EndTurn.elm
+++ b/src/battlemap/src/Update/EndTurn.elm
@@ -27,25 +27,17 @@ make_it_so model char nav =
(Just cmd) ->
(
(Struct.Model.reset
- (Dict.update
- (Struct.Character.get_ref char)
- (\maybe_char ->
- case maybe_char of
- (Just char) ->
- (Just
- (Struct.Character.set_enabled
- False
- (Struct.Character.set_location
- (Struct.Navigator.get_current_location nav)
- char
- )
- )
- )
- Nothing -> Nothing
+ (Struct.Model.update_character
+ (Struct.Character.get_index char)
+ (Struct.Character.set_enabled
+ False
+ (Struct.Character.set_location
+ (Struct.Navigator.get_current_location nav)
+ char
+ )
)
- model.characters
+ model
)
- model
),
cmd
)
diff --git a/src/battlemap/src/Update/LookForCharacter.elm b/src/battlemap/src/Update/LookForCharacter.elm
index 4618a13..469b0f8 100644
--- a/src/battlemap/src/Update/LookForCharacter.elm
+++ b/src/battlemap/src/Update/LookForCharacter.elm
@@ -1,6 +1,6 @@
module Update.LookForCharacter exposing (apply_to)
-- Elm -------------------------------------------------------------------------
-import Dict
+import Array
import Task
-- Battlemap -------------------------------------------------------------------
@@ -16,11 +16,11 @@ import Struct.UI
--------------------------------------------------------------------------------
scroll_to_char : (
Struct.Model.Type ->
- Struct.Character.Ref ->
+ Int ->
(Cmd Struct.Event.Type)
)
-scroll_to_char model char_ref =
- case (Dict.get char_ref model.characters) of
+scroll_to_char model char_ix =
+ case (Array.get char_ix model.characters) of
(Just char) ->
(Task.attempt
(Struct.Event.attempted)
@@ -38,17 +38,17 @@ scroll_to_char model char_ref =
--------------------------------------------------------------------------------
apply_to : (
Struct.Model.Type ->
- Struct.Character.Ref ->
+ Int ->
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
-apply_to model target_ref =
+apply_to model target_ix =
(
{model |
ui =
(Struct.UI.set_previous_action
- (Just (Struct.UI.SelectedCharacter target_ref))
+ (Just (Struct.UI.SelectedCharacter target_ix))
model.ui
)
},
- (scroll_to_char model target_ref)
+ (scroll_to_char model target_ix)
)
diff --git a/src/battlemap/src/Update/SelectCharacter.elm b/src/battlemap/src/Update/SelectCharacter.elm
index 1263e67..bbd4527 100644
--- a/src/battlemap/src/Update/SelectCharacter.elm
+++ b/src/battlemap/src/Update/SelectCharacter.elm
@@ -1,7 +1,7 @@
module Update.SelectCharacter exposing (apply_to)
-- Elm -------------------------------------------------------------------------
-import Dict
+import Array
import Task
@@ -46,13 +46,13 @@ get_character_navigator model char =
(Struct.Battlemap.get_movement_cost_function
model.battlemap
(Struct.Character.get_location char)
- (Dict.values model.characters)
+ (Array.toList model.characters)
)
)
attack_character : (
Struct.Model.Type ->
- Struct.Character.Ref ->
+ Int ->
Struct.Character.Type ->
Struct.Model.Type
)
@@ -73,7 +73,7 @@ attack_character model target_char_id target_char =
ctrl_or_focus_character : (
Struct.Model.Type ->
- Struct.Character.Ref ->
+ Int ->
Struct.Character.Type ->
Struct.Model.Type
)
@@ -151,11 +151,11 @@ can_target_character model target =
second_click_on : (
Struct.Model.Type ->
- Struct.Character.Ref ->
+ Int ->
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
second_click_on model target_char_id =
- case (Dict.get target_char_id model.characters) of
+ case (Array.get target_char_id model.characters) of
(Just target_char) ->
case
(
@@ -233,7 +233,7 @@ second_click_on model target_char_id =
first_click_on : (
Struct.Model.Type ->
- Struct.Character.Ref ->
+ Int ->
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
first_click_on model target_char_id =
@@ -246,7 +246,7 @@ first_click_on model target_char_id =
then
(model, Cmd.none)
else
- case (Dict.get target_char_id model.characters) of
+ case (Array.get target_char_id model.characters) of
(Just target_char) ->
(
{model |
@@ -282,7 +282,7 @@ first_click_on model target_char_id =
--------------------------------------------------------------------------------
apply_to : (
Struct.Model.Type ->
- Struct.Character.Ref ->
+ Int ->
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
apply_to model target_char_id =
diff --git a/src/battlemap/src/Update/SelectTile.elm b/src/battlemap/src/Update/SelectTile.elm
index 8e0c52d..6d05476 100644
--- a/src/battlemap/src/Update/SelectTile.elm
+++ b/src/battlemap/src/Update/SelectTile.elm
@@ -125,7 +125,7 @@ go_to_tile model navigator loc_ref =
)
Nothing -> -- Clicked outside of the range indicator
- ((Struct.Model.reset model.characters model), Cmd.none)
+ ((Struct.Model.reset model), Cmd.none)
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
diff --git a/src/battlemap/src/Update/SwitchTeam.elm b/src/battlemap/src/Update/SwitchTeam.elm
index dec3348..355ff3c 100644
--- a/src/battlemap/src/Update/SwitchTeam.elm
+++ b/src/battlemap/src/Update/SwitchTeam.elm
@@ -20,17 +20,11 @@ apply_to model =
if (model.player_id == "0")
then
(
- (Struct.Model.reset
- model.characters
- {model | player_id = "1"}
- ),
+ (Struct.Model.reset {model | player_id = "1"}),
Cmd.none
)
else
(
- (Struct.Model.reset
- model.characters
- {model | player_id = "0"}
- ),
+ (Struct.Model.reset {model | player_id = "0"}),
Cmd.none
)
diff --git a/src/battlemap/src/Update/SwitchWeapon.elm b/src/battlemap/src/Update/SwitchWeapon.elm
index 8af4fe3..df45f50 100644
--- a/src/battlemap/src/Update/SwitchWeapon.elm
+++ b/src/battlemap/src/Update/SwitchWeapon.elm
@@ -1,6 +1,6 @@
module Update.SwitchWeapon exposing (apply_to)
-- Elm -------------------------------------------------------------------------
-import Dict
+import Array
-- Battlemap -------------------------------------------------------------------
import Struct.Battlemap
@@ -48,7 +48,7 @@ make_it_so model =
(Struct.Battlemap.get_movement_cost_function
model.battlemap
(Struct.Character.get_location new_char)
- (Dict.values model.characters)
+ (Array.toList model.characters)
)
)
(Struct.CharacterTurn.set_active_character
diff --git a/src/battlemap/src/View/Battlemap.elm b/src/battlemap/src/View/Battlemap.elm
index 829ed45..abf0744 100644
--- a/src/battlemap/src/View/Battlemap.elm
+++ b/src/battlemap/src/View/Battlemap.elm
@@ -3,8 +3,6 @@ module View.Battlemap exposing (get_html)
-- Elm -------------------------------------------------------------------------
import Array
-import Dict
-
import Html
import Html.Attributes
import Html.Lazy
@@ -15,6 +13,7 @@ import List
import Constants.UI
import Struct.Battlemap
+import Struct.Character
import Struct.CharacterTurn
import Struct.Event
import Struct.Model
@@ -70,6 +69,51 @@ get_tiles_html battlemap =
)
)
+maybe_print_navigator : (
+ Bool ->
+ (Maybe Struct.Navigator.Type) ->
+ (Html.Html Struct.Event.Type)
+ )
+maybe_print_navigator interactive maybe_nav =
+ let
+ name_suffix =
+ if (interactive)
+ then
+ "interactive"
+ else
+ "non-interactive"
+ in
+ case maybe_nav of
+ (Just nav) ->
+ (Html.div
+ [
+ (Html.Attributes.class ("battlemap-navigator" ++ name_suffix))
+ ]
+ (View.Battlemap.Navigator.get_html
+ (Struct.Navigator.get_summary nav)
+ interactive
+ )
+ )
+
+ Nothing ->
+ (Util.Html.nothing)
+
+get_characters_html : (
+ Struct.Model.Type ->
+ (Array.Array Struct.Character.Type) ->
+ (Html.Html Struct.Event.Type)
+ )
+get_characters_html model characters =
+ (Html.div
+ [
+ (Html.Attributes.class "battlemap-characters")
+ ]
+ (List.map
+ (View.Battlemap.Character.get_html model)
+ (Array.toList model.characters)
+ )
+ )
+
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -100,34 +144,20 @@ get_html model =
)
)
]
- (
- (Html.Lazy.lazy (get_tiles_html) model.battlemap)
- ::
- (List.map
- (View.Battlemap.Character.get_html model)
- (Dict.values model.characters)
- )
- ++
- (
- case (Struct.CharacterTurn.try_getting_navigator model.char_turn) of
- (Just navigator) ->
- (View.Battlemap.Navigator.get_html
- (Struct.Navigator.get_summary navigator)
- True
- )
-
- Nothing ->
- [(Util.Html.nothing)]
+ [
+ (Html.Lazy.lazy (get_tiles_html) model.battlemap),
+ -- Not in lazy mode, because I can't easily get rid of that 'model'
+ -- parameter.
+ (get_characters_html model model.characters),
+ (Html.Lazy.lazy2
+ (maybe_print_navigator)
+ True
+ model.char_turn.navigator
+ ),
+ (Html.Lazy.lazy2
+ (maybe_print_navigator)
+ False
+ (Struct.UI.try_getting_displayed_nav model.ui)
)
- ++
- case (Struct.UI.try_getting_displayed_nav model.ui) of
- (Just navigator) ->
- (View.Battlemap.Navigator.get_html
- (Struct.Navigator.get_summary navigator)
- False
- )
-
- Nothing ->
- [(Util.Html.nothing)]
- )
+ ]
)
diff --git a/src/battlemap/src/View/Battlemap/Character.elm b/src/battlemap/src/View/Battlemap/Character.elm
index 156a638..98ec757 100644
--- a/src/battlemap/src/View/Battlemap/Character.elm
+++ b/src/battlemap/src/View/Battlemap/Character.elm
@@ -1,9 +1,12 @@
module View.Battlemap.Character exposing (get_html)
-- Elm -------------------------------------------------------------------------
+import Debug
+
import Html
import Html.Attributes
import Html.Events
+import Html.Lazy
-- Battlemap ------------------------------------------------------------------
import Constants.UI
@@ -65,7 +68,7 @@ get_focus_class model char =
(
(Struct.UI.get_previous_action model.ui)
==
- (Just (Struct.UI.SelectedCharacter (Struct.Character.get_ref char)))
+ (Just (Struct.UI.SelectedCharacter (Struct.Character.get_index char)))
)
then
(Html.Attributes.class "battlemap-character-selected")
@@ -74,7 +77,7 @@ get_focus_class model char =
(
(Struct.CharacterTurn.try_getting_target model.char_turn)
==
- (Just (Struct.Character.get_ref char))
+ (Just (Struct.Character.get_index char))
)
then
(Html.Attributes.class "battlemap-character-targeted")
@@ -118,7 +121,10 @@ get_actual_html : (
get_actual_html model char =
(Html.div
[
- (Html.Attributes.class "battlemap-tiled"),
+ (Debug.log
+ ("Drawing char" ++ toString (Struct.Character.get_index char))
+ (Html.Attributes.class "battlemap-tiled")
+ ),
(Html.Attributes.class "battlemap-character-icon"),
(get_activation_level_class char),
(get_alliance_class model char),
@@ -126,7 +132,9 @@ get_actual_html model char =
(get_focus_class model char),
(Html.Attributes.class "clickable"),
(Html.Events.onClick
- (Struct.Event.CharacterSelected (Struct.Character.get_ref char))
+ (Struct.Event.CharacterSelected
+ (Struct.Character.get_index char)
+ )
)
]
[
@@ -146,6 +154,6 @@ get_html : (
get_html model char =
if (Struct.Character.is_alive char)
then
- (get_actual_html model char)
+ (Html.Lazy.lazy (get_actual_html model) char)
else
(Util.Html.nothing)
diff --git a/src/battlemap/src/View/Character.elm b/src/battlemap/src/View/Character.elm
index ec9d661..d7bcfef 100644
--- a/src/battlemap/src/View/Character.elm
+++ b/src/battlemap/src/View/Character.elm
@@ -70,7 +70,7 @@ get_focus_class model char =
(
(Struct.UI.get_previous_action model.ui)
==
- (Just (Struct.UI.SelectedCharacter (Struct.Character.get_ref char)))
+ (Just (Struct.UI.SelectedCharacter (Struct.Character.get_index char)))
)
then
(Html.Attributes.class "battlemap-character-selected")
@@ -79,7 +79,7 @@ get_focus_class model char =
(
(Struct.CharacterTurn.try_getting_target model.char_turn)
==
- (Just (Struct.Character.get_ref char))
+ (Just (Struct.Character.get_index char))
)
then
(Html.Attributes.class "battlemap-character-targeted")
@@ -131,7 +131,7 @@ get_icon_actual_html model char =
(get_focus_class model char),
(Html.Attributes.class "clickable"),
(Html.Events.onClick
- (Struct.Event.CharacterSelected (Struct.Character.get_ref char))
+ (Struct.Event.CharacterSelected (Struct.Character.get_index char))
)
]
[
@@ -208,7 +208,7 @@ get_portrait_html viewer_id char =
)
),
(Html.Events.onClick
- (Struct.Event.LookingForCharacter (Struct.Character.get_ref char))
+ (Struct.Event.LookingForCharacter (Struct.Character.get_index char))
)
]
[
diff --git a/src/battlemap/src/View/Controlled.elm b/src/battlemap/src/View/Controlled.elm
index fed78e2..2ad4876 100644
--- a/src/battlemap/src/View/Controlled.elm
+++ b/src/battlemap/src/View/Controlled.elm
@@ -63,14 +63,14 @@ inventory_button =
)
get_available_actions : (
- Struct.Model.Type ->
+ Struct.CharacterTurn.Type ->
(List (Html.Html Struct.Event.Type))
)
-get_available_actions model =
- case (Struct.CharacterTurn.get_state model.char_turn) of
+get_available_actions char_turn =
+ case (Struct.CharacterTurn.get_state char_turn) of
Struct.CharacterTurn.SelectedCharacter ->
[
- (attack_button model.char_turn),
+ (attack_button char_turn),
(inventory_button),
(end_turn_button " Doing Nothing"),
(abort_button)
@@ -95,20 +95,24 @@ get_available_actions model =
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
-get_html model =
+get_html : Struct.CharacterTurn.Type -> String -> (Html.Html Struct.Event.Type)
+get_html char_turn player_id =
case
- (Struct.CharacterTurn.try_getting_active_character model.char_turn)
+ (Struct.CharacterTurn.try_getting_active_character char_turn)
of
(Just char) ->
(Html.div
[(Html.Attributes.class "battlemap-controlled")]
[
- (View.Controlled.CharacterCard.get_summary_html model char),
+ (View.Controlled.CharacterCard.get_summary_html
+ char_turn
+ player_id
+ char
+ ),
(
if
(
- (Struct.CharacterTurn.get_state model.char_turn)
+ (Struct.CharacterTurn.get_state char_turn)
==
Struct.CharacterTurn.SelectedCharacter
)
@@ -119,7 +123,7 @@ get_html model =
),
(Html.div
[(Html.Attributes.class "battlemap-controlled-actions")]
- (get_available_actions model)
+ (get_available_actions char_turn)
)
]
)
diff --git a/src/battlemap/src/View/Controlled/CharacterCard.elm b/src/battlemap/src/View/Controlled/CharacterCard.elm
index 0d1d3d1..36b8546 100644
--- a/src/battlemap/src/View/Controlled/CharacterCard.elm
+++ b/src/battlemap/src/View/Controlled/CharacterCard.elm
@@ -116,22 +116,22 @@ get_inactive_movement_bar char =
)
get_movement_bar : (
- Struct.Model.Type ->
+ Struct.CharacterTurn.Type ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_movement_bar model char =
- case (Struct.CharacterTurn.try_getting_active_character model.char_turn) of
+get_movement_bar char_turn char =
+ case (Struct.CharacterTurn.try_getting_active_character char_turn) of
(Just active_char) ->
if
(
- (Struct.Character.get_ref active_char)
+ (Struct.Character.get_index active_char)
==
- (Struct.Character.get_ref char)
+ (Struct.Character.get_index char)
)
then
(get_active_movement_bar
- (Struct.CharacterTurn.try_getting_navigator model.char_turn)
+ (Struct.CharacterTurn.try_getting_navigator char_turn)
active_char
)
else
@@ -430,11 +430,11 @@ get_attributes char weapon armor =
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_minimal_html : (
- Struct.Model.Type ->
+ String ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_minimal_html model char =
+get_minimal_html player_id char =
(Html.div
[
(Html.Attributes.class "battlemap-character-card"),
@@ -447,20 +447,21 @@ get_minimal_html model char =
(Html.Attributes.class "battlemap-character-card-top")
]
[
- (View.Character.get_portrait_html model.player_id char),
+ (View.Character.get_portrait_html player_id char),
(get_health_bar char),
- (get_movement_bar model char)
+ (get_inactive_movement_bar char)
]
)
]
)
get_summary_html : (
- Struct.Model.Type ->
+ Struct.CharacterTurn.Type ->
+ String ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_summary_html model char =
+get_summary_html char_turn player_id char =
let
weapon_set = (Struct.Character.get_weapons char)
main_weapon = (Struct.WeaponSet.get_active_weapon weapon_set)
@@ -478,9 +479,9 @@ get_summary_html model char =
(Html.Attributes.class "battlemap-character-card-top")
]
[
- (View.Character.get_portrait_html model.player_id char),
+ (View.Character.get_portrait_html player_id char),
(get_health_bar char),
- (get_movement_bar model char)
+ (get_movement_bar char_turn char)
]
),
(get_weapon_details char_statistics main_weapon),
@@ -491,11 +492,11 @@ get_summary_html model char =
)
get_full_html : (
- Struct.Model.Type ->
+ String ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_full_html model char =
+get_full_html player_id char =
let
weapon_set = (Struct.Character.get_weapons char)
main_weapon = (Struct.WeaponSet.get_active_weapon weapon_set)
@@ -514,9 +515,9 @@ get_full_html model char =
(Html.Attributes.class "battlemap-character-card-top")
]
[
- (View.Character.get_portrait_html model.player_id char),
+ (View.Character.get_portrait_html player_id char),
(get_health_bar char),
- (get_movement_bar model char)
+ (get_inactive_movement_bar char)
]
),
(get_weapon_details char_statistics main_weapon),
diff --git a/src/battlemap/src/View/SubMenu.elm b/src/battlemap/src/View/SubMenu.elm
index ed3ebb9..db7f44f 100644
--- a/src/battlemap/src/View/SubMenu.elm
+++ b/src/battlemap/src/View/SubMenu.elm
@@ -1,10 +1,11 @@
module View.SubMenu exposing (get_html)
-- Elm -------------------------------------------------------------------------
-import Dict
+import Array
import Html
import Html.Attributes
+import Html.Lazy
-- Battlemap -------------------------------------------------------------------
import Struct.CharacterTurn
@@ -35,7 +36,7 @@ get_inner_html model tab =
(View.SubMenu.Status.get_html model)
Struct.UI.CharactersTab ->
- (View.SubMenu.Characters.get_html model)
+ (View.SubMenu.Characters.get_html model.characters model.player_id)
Struct.UI.SettingsTab ->
(View.SubMenu.Settings.get_html model)
@@ -58,14 +59,16 @@ get_html model =
Nothing ->
case (Struct.CharacterTurn.try_getting_target model.char_turn) of
(Just char_ref) ->
- case (Dict.get char_ref model.characters) of
+ case (Array.get char_ref model.characters) of
(Just char) ->
(Html.div
[(Html.Attributes.class "battlemap-sub-menu")]
[
(Html.text "Targeting:"),
- (View.Controlled.CharacterCard.get_summary_html
- model
+ (Html.Lazy.lazy3
+ (View.Controlled.CharacterCard.get_summary_html)
+ model.char_turn
+ model.player_id
char
)
]
diff --git a/src/battlemap/src/View/SubMenu/Characters.elm b/src/battlemap/src/View/SubMenu/Characters.elm
index 92cf52e..2f24b82 100644
--- a/src/battlemap/src/View/SubMenu/Characters.elm
+++ b/src/battlemap/src/View/SubMenu/Characters.elm
@@ -1,7 +1,7 @@
module View.SubMenu.Characters exposing (get_html)
-- Elm -------------------------------------------------------------------------
-import Dict
+import Array
import Html
import Html.Attributes
@@ -18,11 +18,11 @@ import View.Controlled.CharacterCard
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
get_character_element_html : (
- Struct.Model.Type ->
+ String ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_character_element_html model char =
+get_character_element_html player_id char =
(Html.div
[
(Html.Attributes.class "battlemap-characters-element"),
@@ -34,7 +34,7 @@ get_character_element_html model char =
(Html.Attributes.class "")
),
(Html.Events.onClick
- (Struct.Event.LookingForCharacter (Struct.Character.get_ref char))
+ (Struct.Event.LookingForCharacter (Struct.Character.get_index char))
),
(
if (Struct.Character.is_enabled char)
@@ -45,22 +45,26 @@ get_character_element_html model char =
)
]
[
- (View.Controlled.CharacterCard.get_minimal_html model char)
+ (View.Controlled.CharacterCard.get_minimal_html player_id char)
]
)
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
-get_html model =
+get_html : (
+ (Array.Array Struct.Character.Type) ->
+ String ->
+ (Html.Html Struct.Event.Type)
+ )
+get_html characters player_id =
(Html.div
[
(Html.Attributes.class "battlemap-tabmenu-content"),
(Html.Attributes.class "battlemap-tabmenu-characters-tab")
]
(List.map
- (get_character_element_html model)
- (Dict.values model.characters)
+ (get_character_element_html player_id)
+ (Array.toList characters)
)
)
diff --git a/src/battlemap/src/View/SubMenu/Status.elm b/src/battlemap/src/View/SubMenu/Status.elm
index 70a7e3c..c64bc2d 100644
--- a/src/battlemap/src/View/SubMenu/Status.elm
+++ b/src/battlemap/src/View/SubMenu/Status.elm
@@ -1,10 +1,11 @@
module View.SubMenu.Status exposing (get_html)
-- Elm -------------------------------------------------------------------------
-import Dict
+import Array
import Html
import Html.Attributes
+import Html.Lazy
-- Struct.Battlemap -------------------------------------------------------------------
import Struct.Event
@@ -37,10 +38,11 @@ get_html model =
)
(Just (Struct.UI.SelectedCharacter target_char)) ->
- case (Dict.get target_char model.characters) of
+ case (Array.get target_char model.characters) of
(Just char) ->
- (View.SubMenu.Status.CharacterInfo.get_html
- model
+ (Html.Lazy.lazy2
+ (View.SubMenu.Status.CharacterInfo.get_html)
+ model.player_id
char
)
diff --git a/src/battlemap/src/View/SubMenu/Status/CharacterInfo.elm b/src/battlemap/src/View/SubMenu/Status/CharacterInfo.elm
index 1713fdd..de27c79 100644
--- a/src/battlemap/src/View/SubMenu/Status/CharacterInfo.elm
+++ b/src/battlemap/src/View/SubMenu/Status/CharacterInfo.elm
@@ -1,13 +1,14 @@
module View.SubMenu.Status.CharacterInfo exposing (get_html)
-- Elm -------------------------------------------------------------------------
+import Debug
+
import Html
import Html.Attributes
-- Struct.Battlemap -------------------------------------------------------------------
import Struct.Character
import Struct.Event
-import Struct.Model
import View.Controlled.CharacterCard
@@ -19,17 +20,17 @@ import View.Controlled.CharacterCard
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html: (
- Struct.Model.Type ->
+ String ->
Struct.Character.Type ->
(Html.Html Struct.Event.Type)
)
-get_html model char =
+get_html player_id char =
(Html.div
[
- (Html.Attributes.class "battlemap-tabmenu-character-info")
+ (Debug.log "Drawing char info" (Html.Attributes.class "battlemap-tabmenu-character-info"))
]
[
(Html.text ("Focusing:")),
- (View.Controlled.CharacterCard.get_full_html model char)
+ (View.Controlled.CharacterCard.get_full_html player_id char)
]
)
diff --git a/src/battlemap/src/View/SubMenu/Timeline.elm b/src/battlemap/src/View/SubMenu/Timeline.elm
index eb67085..70b22bc 100644
--- a/src/battlemap/src/View/SubMenu/Timeline.elm
+++ b/src/battlemap/src/View/SubMenu/Timeline.elm
@@ -1,6 +1,7 @@
module View.SubMenu.Timeline exposing (get_html)
-- Elm -------------------------------------------------------------------------
+import Debug
import Array
import Html
@@ -9,6 +10,7 @@ import Html.Attributes
import Html.Lazy
-- Battlemap -------------------------------------------------------------------
+import Struct.Character
import Struct.Event
import Struct.TurnResult
import Struct.Model
@@ -21,38 +23,52 @@ import View.SubMenu.Timeline.WeaponSwitch
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
get_turn_result_html : (
- Struct.Model.Type ->
+ (Array.Array Struct.Character.Type) ->
+ String ->
Struct.TurnResult.Type ->
(Html.Html Struct.Event.Type)
)
-get_turn_result_html model turn_result =
+get_turn_result_html characters player_id turn_result =
case turn_result of
(Struct.TurnResult.Moved movement) ->
- (View.SubMenu.Timeline.Movement.get_html model movement)
+ (View.SubMenu.Timeline.Movement.get_html
+ characters
+ player_id
+ movement
+ )
(Struct.TurnResult.Attacked attack) ->
- (View.SubMenu.Timeline.Attack.get_html model attack)
+ (View.SubMenu.Timeline.Attack.get_html
+ characters
+ player_id
+ attack
+ )
(Struct.TurnResult.SwitchedWeapon weapon_switch) ->
(View.SubMenu.Timeline.WeaponSwitch.get_html
- model
+ characters
+ player_id
weapon_switch
)
true_get_html : (
- Struct.Model.Type ->
+ (Array.Array Struct.Character.Type) ->
+ String ->
(Array.Array Struct.TurnResult.Type) ->
(Html.Html Struct.Event.Type)
)
-true_get_html model turn_results =
+true_get_html characters player_id turn_results =
(Html.div
[
- (Html.Attributes.class "battlemap-tabmenu-content"),
+ (Debug.log
+ "Drawing timeline"
+ (Html.Attributes.class "battlemap-tabmenu-content")
+ ),
(Html.Attributes.class "battlemap-tabmenu-timeline-tab")
]
(Array.toList
(Array.map
- (get_turn_result_html model)
+ (get_turn_result_html characters player_id)
turn_results
)
)
@@ -63,4 +79,9 @@ true_get_html model turn_results =
--------------------------------------------------------------------------------
get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
get_html model =
- (Html.Lazy.lazy (true_get_html model) model.timeline)
+ (Html.Lazy.lazy3
+ (true_get_html)
+ model.characters
+ model.player_id
+ model.timeline
+ )
diff --git a/src/battlemap/src/View/SubMenu/Timeline/Attack.elm b/src/battlemap/src/View/SubMenu/Timeline/Attack.elm
index 3330007..974867e 100644
--- a/src/battlemap/src/View/SubMenu/Timeline/Attack.elm
+++ b/src/battlemap/src/View/SubMenu/Timeline/Attack.elm
@@ -1,7 +1,7 @@
module View.SubMenu.Timeline.Attack exposing (get_html)
-- Elm -------------------------------------------------------------------------
-import Dict
+import Array
import Html
import Html.Attributes
@@ -121,15 +121,16 @@ get_attack_html attacker defender attack =
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html : (
- Struct.Model.Type ->
+ (Array.Array Struct.Character.Type) ->
+ String ->
Struct.TurnResult.Attack ->
(Html.Html Struct.Event.Type)
)
-get_html model attack =
+get_html characters player_id attack =
case
(
- (Dict.get (toString attack.attacker_index) model.characters),
- (Dict.get (toString attack.defender_index) model.characters)
+ (Array.get attack.attacker_index characters),
+ (Array.get attack.defender_index characters)
)
of
((Just atkchar), (Just defchar)) ->
@@ -140,8 +141,8 @@ get_html model attack =
]
(
[
- (View.Character.get_portrait_html model.player_id atkchar),
- (View.Character.get_portrait_html model.player_id defchar),
+ (View.Character.get_portrait_html player_id atkchar),
+ (View.Character.get_portrait_html player_id defchar),
(get_title_html atkchar defchar)
]
++
diff --git a/src/battlemap/src/View/SubMenu/Timeline/Movement.elm b/src/battlemap/src/View/SubMenu/Timeline/Movement.elm
index bba9bc1..afc4055 100644
--- a/src/battlemap/src/View/SubMenu/Timeline/Movement.elm
+++ b/src/battlemap/src/View/SubMenu/Timeline/Movement.elm
@@ -1,7 +1,7 @@
module View.SubMenu.Timeline.Movement exposing (get_html)
-- Elm -------------------------------------------------------------------------
-import Dict
+import Array
import Html
import Html.Attributes
@@ -23,12 +23,13 @@ import View.Character
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html : (
- Struct.Model.Type ->
+ (Array.Array Struct.Character.Type) ->
+ String ->
Struct.TurnResult.Movement ->
(Html.Html Struct.Event.Type)
)
-get_html model movement =
- case (Dict.get (toString movement.character_index) model.characters) of
+get_html characters player_id movement =
+ case (Array.get movement.character_index characters) of
(Just char) ->
(Html.div
[
@@ -36,7 +37,7 @@ get_html model movement =
(Html.Attributes.class "battlemap-timeline-movement")
]
[
- (View.Character.get_portrait_html model.player_id char),
+ (View.Character.get_portrait_html player_id char),
(Html.text
(
(Struct.Character.get_name char)
diff --git a/src/battlemap/src/View/SubMenu/Timeline/WeaponSwitch.elm b/src/battlemap/src/View/SubMenu/Timeline/WeaponSwitch.elm
index 53122ad..21d07e6 100644
--- a/src/battlemap/src/View/SubMenu/Timeline/WeaponSwitch.elm
+++ b/src/battlemap/src/View/SubMenu/Timeline/WeaponSwitch.elm
@@ -1,7 +1,7 @@
module View.SubMenu.Timeline.WeaponSwitch exposing (get_html)
-- Elm -------------------------------------------------------------------------
-import Dict
+import Array
import Html
import Html.Attributes
@@ -23,12 +23,13 @@ import View.Character
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html : (
- Struct.Model.Type ->
+ (Array.Array Struct.Character.Type) ->
+ String ->
Struct.TurnResult.WeaponSwitch ->
(Html.Html Struct.Event.Type)
)
-get_html model weapon_switch =
- case (Dict.get (toString weapon_switch.character_index) model.characters) of
+get_html characters player_id weapon_switch =
+ case (Array.get weapon_switch.character_index characters) of
(Just char) ->
(Html.div
[
@@ -36,7 +37,7 @@ get_html model weapon_switch =
(Html.Attributes.class "battlemap-timeline-weapon-switch")
]
[
- (View.Character.get_portrait_html model.player_id char),
+ (View.Character.get_portrait_html player_id char),
(Html.text
(
(Struct.Character.get_name char)