summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-10-18 20:59:41 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-10-18 20:59:41 +0200
commit96d7905f7faef941f5454fd2c8b0b50a294fd26c (patch)
tree77377c56ed005fc56dcaad506f0f12bb598fef66 /elm/battlemap/src/Battlemap
parent2805c647010cbcca126ebf162fcbdd691fc72488 (diff)
Borked mouse controls for the navigator, it seems.
Diffstat (limited to 'elm/battlemap/src/Battlemap')
-rw-r--r--elm/battlemap/src/Battlemap/Html.elm112
-rw-r--r--elm/battlemap/src/Battlemap/Navigator.elm31
-rw-r--r--elm/battlemap/src/Battlemap/Navigator/Path.elm3
-rw-r--r--elm/battlemap/src/Battlemap/Tile.elm14
4 files changed, 43 insertions, 117 deletions
diff --git a/elm/battlemap/src/Battlemap/Html.elm b/elm/battlemap/src/Battlemap/Html.elm
deleted file mode 100644
index 2fa6472..0000000
--- a/elm/battlemap/src/Battlemap/Html.elm
+++ /dev/null
@@ -1,112 +0,0 @@
-module Battlemap.Html exposing (view)
-
-import Array
-
-import Html
-import Html.Events
-
-import Battlemap
-import Battlemap.Tile
-import Battlemap.Direction
-
-import Event
-
-type alias GridBuilder =
- {
- row : (List (Html.Html Event.Type)),
- columns : (List (Html.Html Event.Type)),
- row_size : Int,
- bmap : Battlemap.Type
- }
-
-view_battlemap_cell : Battlemap.Tile.Type -> (Html.Html Event.Type)
-view_battlemap_cell t =
- (Html.td
- [
- (Html.Events.onClick
- (Battlemap.Tile.get_location t)
- ),
- (Html.Attribute.class (Battlemap.Tile.get_css_class t))
- ]
- [
- case (Battlemap.Tile.get_character t) of
- (Just char_id) ->
- (Character.Html.get_icon
- (Character.get model char_id)
- )
-
- Nothing -> (Html.text "") -- Meaning no element.
- ]
- )
-
-
-foldr_to_html : Battlemap.Tile.Type -> GridBuilder -> GridBuilder
-foldr_to_html t gb =
- if (gb.row_size == gb.bmap.width)
- then
- {gb |
- row = [(view_battlemap_cell t)],
- row_size = 1,
- columns =
- (
- (Html.tr [] gb.row) :: gb.columns
- )
- }
- else
- {gb |
- row = ((view_battlemap_cell t) :: gb.row),
- row_size = (gb.row_size + 1)
- }
-
-grid_builder_to_html : GridBuilder -> (List (Html.Html Event.Type))
-grid_builder_to_html gb =
- if (gb.row_size == 0)
- then
- gb.columns
- else
- ((Html.tr [] gb.row) :: gb.columns)
-
-tiles_grid battlemap =
- (Html.table
- [
- (Html.Attribute.class "battlemap-tiles-grid")
- ]
- (grid_builder_to_html
- (Array.foldr
- (foldr_to_html)
- {
- row = [],
- columns = [],
- row_size = 0,
- bmap = battlemap
- }
- battlemap.content
- )
- )
- )
-
-view : Battlemap.Type -> (Html.Html Event.Type)
-view battlemap =
- (Html.div
- [
- (Html.Attribute.class "battlemap-container")
- ]
- [
- (Html.div
- [
- (Html.Attribute.class "battlemap-tiles-container")
- ]
- [ (tiles_grid battlemap) ]
- ),
- case battlemap.navigator of
- (Just navigator) ->
- (Html.div
- [
- (Html.Attribute.class "battlemap-navigator-container")
- ]
- [ (Battlemap.Navigator.Html.view battlemap.navigator) ]
- )
-
- Nothing -> (Html.text "") -- Meaning no element.
- ]
- )
diff --git a/elm/battlemap/src/Battlemap/Navigator.elm b/elm/battlemap/src/Battlemap/Navigator.elm
index ac394b5..6687b18 100644
--- a/elm/battlemap/src/Battlemap/Navigator.elm
+++ b/elm/battlemap/src/Battlemap/Navigator.elm
@@ -1,10 +1,12 @@
module Battlemap.Navigator exposing
(
Type,
+ Summary,
new,
get_current_location,
get_remaining_points,
get_range_markers,
+ get_summary,
try_adding_step,
try_getting_path_to
)
@@ -13,6 +15,7 @@ import Dict
import Battlemap.Location
import Battlemap.Direction
+import Battlemap.Marker
import Battlemap.Navigator.Path
import Battlemap.Navigator.RangeIndicator
@@ -33,6 +36,12 @@ type alias Type =
)
}
+type alias Summary =
+ {
+ starting_location: Battlemap.Location.Type,
+ path: (List Battlemap.Direction.Type),
+ markers: (List (Battlemap.Location.Ref, Battlemap.Marker.Type))
+ }
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -79,6 +88,27 @@ get_range_markers : (
)
get_range_markers navigator = (Dict.toList navigator.range_indicators)
+get_summary : Type -> Summary
+get_summary navigator =
+ {
+ starting_location = navigator.starting_location,
+ path = (Battlemap.Navigator.Path.get_summary navigator.path),
+ markers =
+ (List.map
+ (\(loc, range_indicator) ->
+ (
+ loc,
+ (Battlemap.Navigator.RangeIndicator.get_marker
+ range_indicator
+ )
+ )
+ )
+ (Dict.toList
+ navigator.range_indicators
+ )
+ )
+ }
+
try_adding_step : (
Type ->
Battlemap.Direction.Type ->
@@ -108,3 +138,4 @@ try_getting_path_to navigator loc_ref =
(Just target) ->
(Just (Battlemap.Navigator.RangeIndicator.get_path target))
Nothing -> Nothing
+
diff --git a/elm/battlemap/src/Battlemap/Navigator/Path.elm b/elm/battlemap/src/Battlemap/Navigator/Path.elm
index a20c0b7..53e12c0 100644
--- a/elm/battlemap/src/Battlemap/Navigator/Path.elm
+++ b/elm/battlemap/src/Battlemap/Navigator/Path.elm
@@ -4,6 +4,7 @@ module Battlemap.Navigator.Path exposing
new,
get_current_location,
get_remaining_points,
+ get_summary,
try_following_direction
)
@@ -131,6 +132,8 @@ get_current_location path = path.current_location
get_remaining_points : Type -> Int
get_remaining_points path = path.remaining_points
+get_summary : Type -> (List Battlemap.Direction.Type)
+get_summary path = path.previous_directions
try_following_direction : (
(Battlemap.Location.Type -> Bool) ->
(Battlemap.Location.Type -> Int) ->
diff --git a/elm/battlemap/src/Battlemap/Tile.elm b/elm/battlemap/src/Battlemap/Tile.elm
index 828fb67..255310a 100644
--- a/elm/battlemap/src/Battlemap/Tile.elm
+++ b/elm/battlemap/src/Battlemap/Tile.elm
@@ -1,7 +1,8 @@
module Battlemap.Tile exposing
(
Type,
- get_class,
+ get_location,
+ get_icon_id,
get_cost
)
@@ -9,13 +10,16 @@ import Battlemap.Location
type alias Type =
{
- location : Battlemap.Location.Ref,
- class : Int,
+ location : Battlemap.Location.Type,
+ icon_id : String,
crossing_cost : Int
}
-get_class : Type -> Int
-get_class tile = tile.class
+get_location : Type -> Battlemap.Location.Type
+get_location tile = tile.location
+
+get_icon_id : Type -> String
+get_icon_id tile = tile.icon_id
get_cost : Type -> Int
get_cost tile = tile.crossing_cost