summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2018-06-22 14:50:24 +0200 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2018-06-22 14:50:24 +0200 |
commit | 5667cce161bdf6d4cba1398be52fbadfb87d5fcb (patch) | |
tree | add2604151aafaf282388b155d462e4597dee9f8 | |
parent | cbfcab80b9faf43a2f75cda431dff53842cf93dd (diff) |
I likely forgot that file in my previous commit.
-rw-r--r-- | src/battlemap/src/Update/SelectCharacterOrTile.elm | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/battlemap/src/Update/SelectCharacterOrTile.elm b/src/battlemap/src/Update/SelectCharacterOrTile.elm new file mode 100644 index 0000000..997dfa8 --- /dev/null +++ b/src/battlemap/src/Update/SelectCharacterOrTile.elm @@ -0,0 +1,52 @@ +module Update.SelectCharacterOrTile exposing (apply_to) + +-- Elm ------------------------------------------------------------------------- + +-- Battlemap ------------------------------------------------------------------- +import Struct.Character +import Struct.Event +import Struct.Location +import Struct.Model + +import Update.SelectCharacter +import Update.SelectTile + +import Util.Array + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +apply_to : ( + Struct.Model.Type -> + Struct.Location.Ref -> + (Struct.Model.Type, (Cmd Struct.Event.Type)) + ) +apply_to model loc_ref = + case + (Util.Array.filter_first + (\c -> + ( + ( + (Struct.Character.get_location c) + == (Struct.Location.from_ref loc_ref) + ) + && + (Struct.Character.is_alive c) + ) + ) + model.characters + ) + of + (Just char) -> + (Update.SelectCharacter.apply_to + model + (Struct.Character.get_index char) + ) + + Nothing -> + (Update.SelectTile.apply_to model loc_ref) + |