aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2019-05-09 17:46:07 +0200
committernsensfel <SpamShield0@noot-noot.org>2019-05-09 17:46:07 +0200
commitc61ecd8b3c9a5e9354a4cd9c3a66650b9057332b (patch)
tree454339bd775b3c4ab201143755bfe9cc1a7bdd0e
parentaf452e14397afb04d207628f568238a09989478d (diff)
downloadtacticians-client-c61ecd8b3c9a5e9354a4cd9c3a66650b9057332b.zip
tacticians-client-c61ecd8b3c9a5e9354a4cd9c3a66650b9057332b.tar.bz2
(Untested) Should set player_ix, keep track of player chars.
-rw-r--r--src/battle/src/Struct/Model.elm20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/battle/src/Struct/Model.elm b/src/battle/src/Struct/Model.elm
index 86055b2..01cf4fe 100644
--- a/src/battle/src/Struct/Model.elm
+++ b/src/battle/src/Struct/Model.elm
@@ -27,6 +27,8 @@ import Array
import Dict
+import Set
+
-- Shared ----------------------------------------------------------------------
import Struct.Flags
@@ -99,6 +101,7 @@ type alias Type =
battle_id : String,
session_token : String,
player_ix : Int,
+ player_characters_ix : (Set.Set Int),
ui : Struct.UI.Type,
char_turn : Struct.CharacterTurn.Type,
timeline : (Array.Array Struct.TurnResult.Type)
@@ -146,6 +149,7 @@ new flags =
),
session_token = flags.token,
player_ix = 0,
+ player_characters_ix = (Set.empty),
ui = (Struct.UI.default),
char_turn = (Struct.CharacterTurn.new),
timeline = (Array.empty)
@@ -170,7 +174,15 @@ add_character char model =
(Array.push
char
model.characters
- )
+ ),
+ player_characters_ix =
+ if ((Struct.Character.get_player_ix char) == model.player_ix)
+ then
+ (Set.insert
+ (Struct.Character.get_index char)
+ model.player_characters_ix
+ )
+ else model.player_characters_ix
}
add_weapon : BattleCharacters.Struct.Weapon.Type -> Type -> Type
@@ -235,7 +247,11 @@ add_player pl model =
(Array.push
pl
model.players
- )
+ ),
+ player_ix =
+ if ((Struct.Player.get_id pl) == model.player_id)
+ then (Struct.Player.get_index pl)
+ else model.player_ix
}
add_tile : BattleMap.Struct.Tile.Type -> Type -> Type