summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/battle-map/BattleMap')
-rw-r--r--src/shared/battle-map/BattleMap/Struct/Map.elm27
-rw-r--r--src/shared/battle-map/BattleMap/Struct/TileInstance.elm42
2 files changed, 68 insertions, 1 deletions
diff --git a/src/shared/battle-map/BattleMap/Struct/Map.elm b/src/shared/battle-map/BattleMap/Struct/Map.elm
index ed6c587..7b31947 100644
--- a/src/shared/battle-map/BattleMap/Struct/Map.elm
+++ b/src/shared/battle-map/BattleMap/Struct/Map.elm
@@ -15,6 +15,7 @@ module BattleMap.Struct.Map exposing
get_width,
new,
set_tile_to,
+ update_tile_at,
solve_tiles,
maybe_get_tile_at
)
@@ -136,12 +137,36 @@ add_marker marker_name marker map =
)
}
-set_tile_to : BattleMap.Struct.Location.Type -> BattleMap.Struct.TileInstance.Type -> Type -> Type
+set_tile_to : (
+ BattleMap.Struct.Location.Type ->
+ BattleMap.Struct.TileInstance.Type ->
+ Type ->
+ Type
+ )
set_tile_to loc tile_inst map =
{map |
content = (Array.set (location_to_index loc map) tile_inst map.content)
}
+update_tile_at : (
+ BattleMap.Struct.Location.Type ->
+ (
+ BattleMap.Struct.TileInstance.Type ->
+ BattleMap.Struct.TileInstance.Type
+ ) ->
+ Type ->
+ Type
+ )
+update_tile_at loc fun map =
+ {map |
+ content =
+ (Shared.Util.Array.update
+ (location_to_index loc map)
+ (fun)
+ map.content
+ )
+ }
+
empty : Type
empty =
{
diff --git a/src/shared/battle-map/BattleMap/Struct/TileInstance.elm b/src/shared/battle-map/BattleMap/Struct/TileInstance.elm
index 91e3bf5..8ffeafc 100644
--- a/src/shared/battle-map/BattleMap/Struct/TileInstance.elm
+++ b/src/shared/battle-map/BattleMap/Struct/TileInstance.elm
@@ -24,6 +24,11 @@ module BattleMap.Struct.TileInstance exposing
error,
solve,
set_location_from_index,
+ add_extra_display_effect,
+ remove_extra_display_effect,
+ get_extra_display_effects,
+ get_extra_display_effects_list,
+ reset_extra_display_effects,
decoder,
encode
)
@@ -38,6 +43,9 @@ import Json.Encode
import Json.Decode
import Json.Decode.Pipeline
+-- Shared ----------------------------------------------------------------------
+import Shared.Util.Set
+
-- Battle Map ------------------------------------------------------------------
import BattleMap.Struct.DataSet
import BattleMap.Struct.Tile
@@ -58,6 +66,7 @@ type alias Type =
class_id : BattleMap.Struct.Tile.Ref,
variant_id : BattleMap.Struct.Tile.VariantID,
tags : (Set.Set String),
+ extra_display_effects : (Set.Set String),
borders : (List Border)
}
@@ -100,6 +109,7 @@ default tile =
crossing_cost = (BattleMap.Struct.Tile.get_cost tile),
family = (BattleMap.Struct.Tile.get_family tile),
tags = (Set.empty),
+ extra_display_effects = (Set.empty),
borders = []
}
@@ -112,6 +122,7 @@ error x y =
family = "0",
crossing_cost = Constants.Movement.cost_when_out_of_bounds,
tags = (Set.empty),
+ extra_display_effects = (Set.empty),
borders = []
}
@@ -186,6 +197,7 @@ decoder =
|> (Json.Decode.Pipeline.hardcoded tile_id)
|> (Json.Decode.Pipeline.hardcoded variant_id)
|> (Json.Decode.Pipeline.hardcoded (Set.empty)) -- tags
+ |> (Json.Decode.Pipeline.hardcoded (Set.empty)) -- display_effects
|>
(Json.Decode.Pipeline.hardcoded
(list_to_borders borders [])
@@ -260,3 +272,33 @@ remove_tag tag tile_inst =
{tile_inst |
tags = (Set.remove tag tile_inst.tags)
}
+
+add_extra_display_effect : String -> Type -> Type
+add_extra_display_effect effect_name tile =
+ {tile |
+ extra_display_effects =
+ (Set.insert effect_name tile.extra_display_effects)
+ }
+
+toggle_extra_display_effect : String -> Type -> Type
+toggle_extra_display_effect effect_name tile =
+ {tile |
+ extra_display_effects =
+ (Shared.Util.Set.toggle effect_name tile.extra_display_effects)
+ }
+
+remove_extra_display_effect : String -> Type -> Type
+remove_extra_display_effect effect_name tile =
+ {tile |
+ extra_display_effects =
+ (Set.remove effect_name tile.extra_display_effects)
+ }
+
+get_extra_display_effects : Type -> (Set.Set String)
+get_extra_display_effects tile = tile.extra_display_effects
+
+get_extra_display_effects_list : Type -> (List String)
+get_extra_display_effects_list tile = (Set.toList tile.extra_display_effects)
+
+reset_extra_display_effects : Type -> Type
+reset_extra_display_effects tile = {tile | extra_display_effects = (Set.empty)}