summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-09-18 18:15:59 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-09-18 18:15:59 +0200
commit0b9096ed0c66db403c244a4720bac60326a40394 (patch)
tree233d01b0b04463c3c8db7e20f3c3152f73427a34 /client/elm/battlemap/src/Update.elm
parentc9786fd27954c79faf901963003a8b7b3131ca4c (diff)
Character-focused navigators.
Diffstat (limited to 'client/elm/battlemap/src/Update.elm')
-rw-r--r--client/elm/battlemap/src/Update.elm65
1 files changed, 46 insertions, 19 deletions
diff --git a/client/elm/battlemap/src/Update.elm b/client/elm/battlemap/src/Update.elm
index 86b9c6e..719d259 100644
--- a/client/elm/battlemap/src/Update.elm
+++ b/client/elm/battlemap/src/Update.elm
@@ -2,30 +2,57 @@ module Update exposing (..)
import Model exposing (Model, model)
-import Battlemap.Direction exposing (..)
+import Battlemap exposing (apply_to_all_tiles)
+import Battlemap.Direction exposing (Direction)
-import Battlemap.Navigator as Nr exposing (go)
+import Battlemap.Navigator as Nr exposing (go, reset_navigation)
-type Msg = DirectionRequest Direction | None
+import Dict as Dt exposing (get)
+
+import Character exposing (CharacterRef)
+
+type Msg =
+ DirectionRequest Direction
+ | SelectCharacter CharacterRef
update : Msg -> Model -> Model
update msg model =
case msg of
(DirectionRequest d) ->
- (case model.navigator of
- Nothing -> model
- (Just nav) ->
- let
- (new_bmap, new_nav) =
- (Nr.go
- model.battlemap
- nav
- d
- )
- in
- {model |
- battlemap = new_bmap,
- navigator = (Just new_nav)
- }
+ (case model.selection of
+ Nothing ->
+ model
+ (Just char_id) ->
+ (case model.navigator of
+ Nothing -> model
+ (Just nav) ->
+ let
+ (new_bmap, new_nav) =
+ (Nr.go
+ model.battlemap
+ nav
+ d
+ )
+ in
+ {model |
+ battlemap = new_bmap,
+ navigator = (Just new_nav)
+ }
+ )
)
- _ -> model
+ (SelectCharacter char_id) ->
+ {model |
+ selection = (Just char_id),
+ battlemap =
+ (apply_to_all_tiles
+ model.battlemap
+ (reset_navigation)
+ ),
+ navigator =
+ (case (Dt.get char_id model.characters) of
+ Nothing -> Nothing
+ (Just char) ->
+ (Just (Nr.new_navigator {x = char.x, y = char.y}))
+ )
+ }
+ --_ -> model