summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/roster-editor/src/Update')
-rw-r--r-- | src/roster-editor/src/Update/JoinBattle.elm | 28 | ||||
-rw-r--r-- | src/roster-editor/src/Update/ToggleBattleIndex.elm | 10 |
2 files changed, 33 insertions, 5 deletions
diff --git a/src/roster-editor/src/Update/JoinBattle.elm b/src/roster-editor/src/Update/JoinBattle.elm new file mode 100644 index 0000000..eb164bc --- /dev/null +++ b/src/roster-editor/src/Update/JoinBattle.elm @@ -0,0 +1,28 @@ +module Update.JoinBattle exposing (apply_to) + +-- Elm ------------------------------------------------------------------------- +--import Array + +-- Roster Editor --------------------------------------------------------------- +import Comm.JoinBattle + +import Struct.Event +import Struct.Model + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +apply_to : Struct.Model.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type)) +apply_to model = + ( + model, + (case (Comm.JoinBattle.try model) of + (Just cmd) -> cmd + Nothing -> Cmd.none + ) + ) + diff --git a/src/roster-editor/src/Update/ToggleBattleIndex.elm b/src/roster-editor/src/Update/ToggleBattleIndex.elm index 42d8374..584c314 100644 --- a/src/roster-editor/src/Update/ToggleBattleIndex.elm +++ b/src/roster-editor/src/Update/ToggleBattleIndex.elm @@ -22,11 +22,11 @@ remove_battle_index : ( remove_battle_index model char index = {model | edited_char = Nothing, - used_indices = + battle_order = (Array.set (Struct.Character.get_battle_index char) - False - model.used_indices + -1 + model.battle_order ), characters = (Array.set @@ -43,12 +43,12 @@ give_battle_index : ( Struct.Model.Type ) give_battle_index model char index = - case (Util.Array.indexed_search (\e -> (not e)) model.used_indices) of + case (Util.Array.indexed_search (\e -> (e == -1)) model.battle_order) of Nothing -> model (Just (battle_index, _)) -> {model | edited_char = Nothing, - used_indices = (Array.set battle_index True model.used_indices), + battle_order = (Array.set battle_index index model.battle_order), characters = (Array.set index |