summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2017-10-19 13:30:40 +0200
committernsensfel <SpamShield0@noot-noot.org>2017-10-19 13:30:40 +0200
commite008855086d124f0de14eacc858ecb57d23e371c (patch)
treee3fe94dcf2966d17ac970b4b9cbbf6998c1f34a6 /elm/battlemap/src/Battlemap.elm
parentab299e08cee6ee9b2b122ce87b9bdab3b0dd637c (diff)
Starting a more modular approach for the website.
Diffstat (limited to 'elm/battlemap/src/Battlemap.elm')
-rw-r--r--elm/battlemap/src/Battlemap.elm142
1 files changed, 0 insertions, 142 deletions
diff --git a/elm/battlemap/src/Battlemap.elm b/elm/battlemap/src/Battlemap.elm
deleted file mode 100644
index d2e4523..0000000
--- a/elm/battlemap/src/Battlemap.elm
+++ /dev/null
@@ -1,142 +0,0 @@
-module Battlemap exposing
- (
- Type,
- reset,
- get_navigator_remaining_points,
- get_tiles,
- set_navigator,
- try_getting_navigator_location,
- try_getting_navigator_path_to,
- try_getting_navigator_summary,
- try_adding_step_to_navigator
- )
-
-import Array
-
-import Battlemap.Navigator
-import Battlemap.Tile
-import Battlemap.Direction
-import Battlemap.Location
-
---------------------------------------------------------------------------------
--- TYPES -----------------------------------------------------------------------
---------------------------------------------------------------------------------
-type alias Type =
- {
- width: Int,
- height: Int,
- content: (Array.Array Battlemap.Tile.Type),
- navigator: (Maybe Battlemap.Navigator.Type)
- }
-
---------------------------------------------------------------------------------
--- LOCAL -----------------------------------------------------------------------
---------------------------------------------------------------------------------
-location_to_index : Type -> Battlemap.Location.Type -> Int
-location_to_index bmap loc =
- ((loc.y * bmap.width) + loc.x)
-
-has_location : Type -> Battlemap.Location.Type -> Bool
-has_location bmap loc =
- (
- (loc.x >= 0)
- && (loc.y >= 0)
- && (loc.x < bmap.width)
- && (loc.y < bmap.height)
- )
-
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
-get_tiles : Type -> (Array.Array Battlemap.Tile.Type)
-get_tiles bmap = bmap.content
-
-reset : Type -> Type
-reset bmap =
- {bmap |
- navigator = Nothing
- }
-
-try_getting_navigator_location : Type -> (Maybe Battlemap.Location.Type)
-try_getting_navigator_location bmap =
- case bmap.navigator of
- (Just navigator) ->
- (Just (Battlemap.Navigator.get_current_location navigator))
-
- Nothing -> Nothing
-
-get_navigator_remaining_points : Type -> Int
-get_navigator_remaining_points bmap =
- case bmap.navigator of
- (Just navigator) -> (Battlemap.Navigator.get_remaining_points navigator)
- Nothing -> -1
-
-set_navigator : (
- Battlemap.Location.Type ->
- Int ->
- Int ->
- (Battlemap.Location.Type -> Bool) ->
- Type ->
- Type
- )
-set_navigator start_loc movement_points attack_range can_cross bmap =
- {bmap |
- navigator =
- (Just
- (Battlemap.Navigator.new
- start_loc
- movement_points
- attack_range
- (\loc -> ((can_cross loc) && (has_location bmap loc)))
- )
- )
- }
-
-try_adding_step_to_navigator : (
- Type ->
- (Battlemap.Location.Type -> Bool) ->
- Battlemap.Direction.Type ->
- (Maybe Type)
- )
-try_adding_step_to_navigator bmap can_cross dir =
- case bmap.navigator of
- (Just navigator) ->
- let
- new_navigator =
- (Battlemap.Navigator.try_adding_step
- navigator
- dir
- (\loc -> ((can_cross loc) && (has_location bmap loc)))
- (\loc ->
- case
- (Array.get (location_to_index bmap loc) bmap.content)
- of
- (Just tile) -> (Battlemap.Tile.get_cost tile)
- Nothing -> 0
- )
- )
- in
- case new_navigator of
- (Just _) -> (Just {bmap | navigator = new_navigator})
- Nothing -> Nothing
-
- _ -> Nothing
-
-try_getting_navigator_summary : Type -> (Maybe Battlemap.Navigator.Summary)
-try_getting_navigator_summary bmap =
- case bmap.navigator of
- (Just navigator) -> (Just (Battlemap.Navigator.get_summary navigator))
- Nothing -> Nothing
-
-try_getting_navigator_path_to : (
- Type ->
- Battlemap.Location.Ref ->
- (Maybe (List Battlemap.Direction.Type))
- )
-try_getting_navigator_path_to bmap loc_ref =
- case bmap.navigator of
- (Just navigator) ->
- (Battlemap.Navigator.try_getting_path_to navigator loc_ref)
-
- Nothing -> Nothing
-