From 33e57128d48a012533c42635f52037fcdedd4c56 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Tue, 26 Sep 2017 19:13:04 +0200 Subject: Range indicators are now clickable. --- .../elm/battlemap/src/Update/DirectionRequest.elm | 25 +++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'client/elm/battlemap/src/Update/DirectionRequest.elm') diff --git a/client/elm/battlemap/src/Update/DirectionRequest.elm b/client/elm/battlemap/src/Update/DirectionRequest.elm index 477ba71..da32240 100644 --- a/client/elm/battlemap/src/Update/DirectionRequest.elm +++ b/client/elm/battlemap/src/Update/DirectionRequest.elm @@ -6,23 +6,32 @@ import Battlemap.Direction import Battlemap.Navigator.Move import Model +import Error -apply_to : Model.Type -> Battlemap.Direction.Type -> Model.Type -apply_to model dir = - case (model.state, model.navigator) of - (_ , Nothing) -> model - ((Model.MovingCharacter _), (Just nav)) -> +make_it_so : Model.Type -> Battlemap.Direction.Type -> Model.Type +make_it_so model dir = + case model.selection of + Nothing -> {model | state = (Model.Error Error.Programming)} + (Just selection) -> let (new_bmap, new_nav) = (Battlemap.Navigator.Move.to model.battlemap - nav + selection.navigator dir (Dict.values model.characters) ) in {model | + state = Model.MovingCharacterWithButtons, battlemap = new_bmap, - navigator = (Just new_nav) + selection = (Just {selection | navigator = new_nav}) } - (_, _) -> model + + +apply_to : Model.Type -> Battlemap.Direction.Type -> Model.Type +apply_to model dir = + case model.state of + Model.MovingCharacterWithButtons -> (make_it_so model dir) + Model.MovingCharacterWithClick -> (make_it_so model dir) + _ -> {model | state = (Model.Error Error.IllegalAction)} -- cgit v1.2.3-70-g09d2