From 2d54254e59289c452777fccb1f4d00b56eb7e451 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Wed, 27 Sep 2017 11:31:17 +0200 Subject: Improves error msgs & UI controls. --- elm/battlemap/src/Model.elm | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'elm/battlemap/src/Model.elm') diff --git a/elm/battlemap/src/Model.elm b/elm/battlemap/src/Model.elm index 4303b6f..437d118 100644 --- a/elm/battlemap/src/Model.elm +++ b/elm/battlemap/src/Model.elm @@ -1,10 +1,20 @@ -module Model exposing (Type, CharacterSelection, State(..)) +module Model exposing + ( + Type, + CharacterSelection, + State(..), + get_state, + invalidate, + reset, + clear_error + ) import Dict import Battlemap import Battlemap.Navigator import Battlemap.Location +import Battlemap.Tile import Battlemap.RangeIndicator import Error @@ -24,7 +34,6 @@ type alias CharacterSelection = type State = Default - | Error Error.Type | MovingCharacterWithButtons | MovingCharacterWithClick | FocusingTile @@ -34,5 +43,28 @@ type alias Type = state: State, battlemap: Battlemap.Type, characters: (Dict.Dict Character.Ref Character.Type), + error: (Maybe Error.Type), selection: (Maybe CharacterSelection) } + +get_state : Type -> State +get_state model = model.state + +reset : Type -> Type +reset model = + {model | + state = Default, + selection = Nothing, + error = Nothing, + battlemap = + (Battlemap.apply_to_all_tiles + model.battlemap + (Battlemap.Tile.reset) + ) + } + +invalidate : Type -> Error.Type -> Type +invalidate model err = {model | error = (Just err)} + +clear_error : Type -> Type +clear_error model = {model | error = Nothing} -- cgit v1.2.3-70-g09d2