summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-09-22 13:46:32 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-09-22 13:46:32 +0200
commit2d20dc042a386bc9f66bc5f535403227f9acf1b1 (patch)
tree49e529ff4e12841d160627d9853c088ba0dd637b /client/elm/battlemap/src/Battlemap.elm
parent0d5fba42a1597e5a43266c071776e7acf58071e2 (diff)
No more import ... exposing.
It got too confusing.
Diffstat (limited to 'client/elm/battlemap/src/Battlemap.elm')
-rw-r--r--client/elm/battlemap/src/Battlemap.elm55
1 files changed, 29 insertions, 26 deletions
diff --git a/client/elm/battlemap/src/Battlemap.elm b/client/elm/battlemap/src/Battlemap.elm
index ef24c80..309b538 100644
--- a/client/elm/battlemap/src/Battlemap.elm
+++ b/client/elm/battlemap/src/Battlemap.elm
@@ -1,39 +1,30 @@
module Battlemap exposing
(
- Battlemap,
- random,
+ Type,
apply_to_tile,
apply_to_tile_unsafe,
has_location,
apply_to_all_tiles
)
-import Array exposing (Array, set, get, map)
+import Array
-import Battlemap.Tile exposing (Tile, generate)
-import Battlemap.Direction exposing (Direction(..))
-import Battlemap.Location exposing (Location)
+import Battlemap.Tile
+import Battlemap.Direction
+import Battlemap.Location
-type alias Battlemap =
+type alias Type =
{
width : Int,
height : Int,
- content : (Array Tile)
+ content : (Array.Array Battlemap.Tile.Type)
}
-random : Battlemap
-random =
- {
- width = 6,
- height = 6,
- content = (generate 6 6)
- }
-
-location_to_index : Battlemap -> Location -> Int
+location_to_index : Type -> Battlemap.Location.Type -> Int
location_to_index bmap loc =
((loc.y * bmap.width) + loc.x)
-has_location : Battlemap -> Location -> Bool
+has_location : Type -> Battlemap.Location.Type -> Bool
has_location bmap loc =
(
(loc.x >= 0)
@@ -42,17 +33,24 @@ has_location bmap loc =
&& (loc.y < bmap.height)
)
-apply_to_all_tiles : Battlemap -> (Tile -> Tile) -> Battlemap
+apply_to_all_tiles : (
+ Type -> (Battlemap.Tile.Type -> Battlemap.Tile.Type) -> Type
+ )
apply_to_all_tiles bmap fun =
{bmap |
- content = (map fun bmap.content)
+ content = (Array.map fun bmap.content)
}
-apply_to_tile : Battlemap -> Location -> (Tile -> Tile) -> (Maybe Battlemap)
+apply_to_tile : (
+ Type ->
+ Battlemap.Location.Type ->
+ (Battlemap.Tile.Type -> Battlemap.Tile.Type) ->
+ (Maybe Type)
+ )
apply_to_tile bmap loc fun =
let
index = (location_to_index bmap loc)
- at_index = (get index bmap.content)
+ at_index = (Array.get index bmap.content)
in
case at_index of
Nothing ->
@@ -61,7 +59,7 @@ apply_to_tile bmap loc fun =
(Just
{bmap |
content =
- (set
+ (Array.set
index
(fun tile)
bmap.content
@@ -69,18 +67,23 @@ apply_to_tile bmap loc fun =
}
)
-apply_to_tile_unsafe : Battlemap -> Location -> (Tile -> Tile) -> Battlemap
+apply_to_tile_unsafe : (
+ Type ->
+ Battlemap.Location.Type ->
+ (Battlemap.Tile.Type -> Battlemap.Tile.Type) ->
+ Type
+ )
apply_to_tile_unsafe bmap loc fun =
let
index = (location_to_index bmap loc)
- at_index = (get index bmap.content)
+ at_index = (Array.get index bmap.content)
in
case at_index of
Nothing -> bmap
(Just tile) ->
{bmap |
content =
- (set
+ (Array.set
index
(fun tile)
bmap.content