aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'elm/battlemap/src/Update')
-rw-r--r--elm/battlemap/src/Update/DirectionRequest.elm51
-rw-r--r--elm/battlemap/src/Update/EndTurn.elm81
-rw-r--r--elm/battlemap/src/Update/SelectCharacter.elm95
-rw-r--r--elm/battlemap/src/Update/SelectTile.elm95
4 files changed, 0 insertions, 322 deletions
diff --git a/elm/battlemap/src/Update/DirectionRequest.elm b/elm/battlemap/src/Update/DirectionRequest.elm
deleted file mode 100644
index e069439..0000000
--- a/elm/battlemap/src/Update/DirectionRequest.elm
+++ /dev/null
@@ -1,51 +0,0 @@
-module Update.DirectionRequest exposing (apply_to)
-
-import Dict
-
-import Battlemap.Direction
-import Battlemap.Navigator.Move
-
-import Model
-import Error
-
-make_it_so : Model.Type -> Battlemap.Direction.Type -> Model.Type
-make_it_so model dir =
- case model.selection of
- Nothing ->
- (Model.invalidate
- model
- (Error.new
- Error.Programming
- "DirectionRequest: model moving char, no selection."
- )
- )
- (Just selection) ->
- let
- (new_bmap, new_nav) =
- (Battlemap.Navigator.Move.to
- model.battlemap
- selection.navigator
- dir
- (Dict.values model.characters)
- )
- in
- {model |
- state = Model.MovingCharacterWithButtons,
- battlemap = new_bmap,
- selection = (Just {selection | navigator = new_nav})
- }
-
-
-apply_to : Model.Type -> Battlemap.Direction.Type -> Model.Type
-apply_to model dir =
- case (Model.get_state model) of
- Model.MovingCharacterWithButtons -> (make_it_so model dir)
- Model.MovingCharacterWithClick -> (make_it_so model dir)
- _ ->
- (Model.invalidate
- model
- (Error.new
- Error.IllegalAction
- "This can only be done while moving a character."
- )
- )
diff --git a/elm/battlemap/src/Update/EndTurn.elm b/elm/battlemap/src/Update/EndTurn.elm
deleted file mode 100644
index ce9da28..0000000
--- a/elm/battlemap/src/Update/EndTurn.elm
+++ /dev/null
@@ -1,81 +0,0 @@
-module Update.EndTurn exposing (apply_to)
-
-import Dict
-
-import Battlemap
-import Battlemap.Direction
-import Battlemap.Navigator
-import Battlemap.Tile
-
-import Model
-
-import Error
-
-make_it_so : Model.Type -> Model.Type
-make_it_so model =
- case model.selection of
- Nothing ->
- (Model.invalidate
- model
- (Error.new
- Error.Programming
- "EndTurn: model moving char, no selection."
- )
- )
- (Just selection) ->
- case (Dict.get selection.character model.characters) of
- Nothing ->
- (Model.invalidate
- model
- (Error.new
- Error.Programming
- "EndTurn: model moving char, unknown char selected."
- )
- )
- (Just char) ->
- {model |
- state = Model.Default,
- selection = Nothing,
- battlemap =
- (Battlemap.apply_to_all_tiles
- (Battlemap.apply_to_tile_unsafe
- (Battlemap.apply_to_tile_unsafe
- model.battlemap
- char.location
- (\t -> {t | char_level = Nothing})
- )
- selection.navigator.current_location
- (\t -> {t | char_level = (Just selection.character)})
- )
- (Battlemap.Tile.reset)
- ),
- characters =
- (Dict.update
- selection.character
- (\mc ->
- case mc of
- Nothing -> Nothing
- (Just c) ->
- (Just
- {c |
- location = selection.navigator.current_location
- }
- )
- )
- model.characters
- )
- }
-
-apply_to : Model.Type -> Model.Type
-apply_to model =
- case (Model.get_state model) of
- Model.MovingCharacterWithButtons -> (make_it_so model)
- Model.MovingCharacterWithClick -> (make_it_so model)
- _ ->
- (Model.invalidate
- model
- (Error.new
- Error.IllegalAction
- "This can only be done while moving a character."
- )
- )
diff --git a/elm/battlemap/src/Update/SelectCharacter.elm b/elm/battlemap/src/Update/SelectCharacter.elm
deleted file mode 100644
index 570f82c..0000000
--- a/elm/battlemap/src/Update/SelectCharacter.elm
+++ /dev/null
@@ -1,95 +0,0 @@
-module Update.SelectCharacter exposing (apply_to)
-
-import Dict
-
-import Character
-
-import Battlemap
-import Battlemap.Direction
-import Battlemap.Location
-import Battlemap.Navigator
-import Battlemap.Tile
-import Battlemap.RangeIndicator
-
-import Model
-import Event
-import Error
-
-display_range : (
- Int ->
- Battlemap.Location.Ref ->
- Battlemap.RangeIndicator.Type ->
- Battlemap.Type ->
- Battlemap.Type
- )
-display_range dist loc_ref indicator bmap =
- (Battlemap.apply_to_tile_unsafe
- bmap
- (Battlemap.Location.from_ref loc_ref)
- (\e ->
- {e |
- mod_level =
- (
- if (indicator.distance <= dist)
- then
- (Just Battlemap.Tile.CanBeReached)
- else
- (Just Battlemap.Tile.CanBeAttacked)
- )
- }
- )
- )
-
-
-make_it_so : Model.Type -> Character.Ref -> Model.Type
-make_it_so model char_id =
- case (Dict.get char_id model.characters) of
- Nothing ->
- (Model.invalidate
- model
- (Error.new
- Error.Programming
- "SelectCharacter: Unknown char selected."
- )
- )
- (Just char) ->
- let
- new_range_indicator =
- (Battlemap.RangeIndicator.generate
- model.battlemap
- char.location
- char.movement_points
- (char.movement_points + char.atk_dist)
- )
- in
- {model |
- state = Model.MovingCharacterWithClick,
- battlemap =
- (
- (Dict.foldl
- (display_range char.movement_points)
- (Battlemap.apply_to_all_tiles
- model.battlemap
- (Battlemap.Tile.reset)
- )
- new_range_indicator
- )
- ),
- selection =
- (Just
- {
- character = char_id,
- navigator =
- (Battlemap.Navigator.new
- char.location
- char.movement_points
- ),
- range_indicator = new_range_indicator
- }
- )
- }
-
-apply_to : Model.Type -> Character.Ref -> Model.Type
-apply_to model char_id =
- case (Model.get_state model) of
- _ -> (make_it_so model char_id)
diff --git a/elm/battlemap/src/Update/SelectTile.elm b/elm/battlemap/src/Update/SelectTile.elm
deleted file mode 100644
index cc2af35..0000000
--- a/elm/battlemap/src/Update/SelectTile.elm
+++ /dev/null
@@ -1,95 +0,0 @@
-module Update.SelectTile exposing (apply_to)
-
-import Dict
-
-import Character
-
-import Battlemap
-import Battlemap.Direction
-import Battlemap.Location
-import Battlemap.Navigator
-import Battlemap.Tile
-import Battlemap.RangeIndicator
-
-import Update.DirectionRequest
-import Update.EndTurn
-
-import Model
-import Error
-
-autopilot : Battlemap.Direction.Type -> Model.Type -> Model.Type
-autopilot dir model =
- (Update.DirectionRequest.apply_to model dir)
-
-go_to_tile : Model.Type -> Battlemap.Location.Ref -> Model.Type
-go_to_tile model loc_ref =
- case model.selection of
- Nothing ->
- (Model.invalidate
- model
- (Error.new
- Error.Programming
- "SelectTile: model moving char, no selection."
- )
- )
- (Just selection) ->
- case (Dict.get loc_ref selection.range_indicator) of
- Nothing -> -- Clicked outside of the range indicator
- (Model.reset model)
- (Just indicator) ->
- let
- new_model =
- (List.foldr
- (autopilot)
- {model |
- battlemap =
- (Battlemap.apply_to_all_tiles
- model.battlemap
- (Battlemap.Tile.set_direction
- Battlemap.Direction.None
- )
- ),
- selection =
- (Just
- {
- selection |
- navigator =
- (Battlemap.Navigator.reset
- selection.navigator
- )
- }
- )
- }
- indicator.path
- )
- in
- if
- (
- (model.state == Model.MovingCharacterWithClick)
- &&
- (
- (Battlemap.Location.get_ref
- selection.navigator.current_location
- )
- == loc_ref
- )
- )
- then
- (Update.EndTurn.apply_to new_model)
- else
- {new_model | state = Model.MovingCharacterWithClick}
-
-
-apply_to : Model.Type -> Battlemap.Location.Ref -> Model.Type
-apply_to model loc_ref =
- case (Model.get_state model) of
- Model.MovingCharacterWithButtons -> (go_to_tile model loc_ref)
- Model.MovingCharacterWithClick -> (go_to_tile model loc_ref)
- _ ->
- (Model.invalidate
- model
- (Error.new
- Error.IllegalAction
- "This can only be done while moving a character."
- )
- )