summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2019-12-12 18:24:00 +0100
committernsensfel <SpamShield0@noot-noot.org>2019-12-12 18:24:00 +0100
commit65104411c1dbb3f9da1a10ee1aef76dbf2886b2c (patch)
treef2bbd995210fbe56bcc2ffe9659442a1736a62f5 /src
parent0f32d059365e037405a71ecbd0f01b82b59cf7da (diff)
...
Diffstat (limited to 'src')
-rw-r--r--src/battle/src/Struct/Battle.elm87
-rw-r--r--src/battle/src/Struct/Character.elm24
-rw-r--r--src/shared/battle-map/BattleMap/Struct/Map.elm10
-rw-r--r--src/shared/battle-map/BattleMap/Struct/Marker.elm27
-rw-r--r--src/shared/battle-map/BattleMap/Struct/TileInstance.elm43
-rw-r--r--src/shared/battle-map/BattleMap/View/Tile.elm6
6 files changed, 100 insertions, 97 deletions
diff --git a/src/battle/src/Struct/Battle.elm b/src/battle/src/Struct/Battle.elm
index ae6e3fe..c7f5c0a 100644
--- a/src/battle/src/Struct/Battle.elm
+++ b/src/battle/src/Struct/Battle.elm
@@ -6,6 +6,7 @@ module Struct.Battle exposing
add_character,
get_character,
set_character,
+ refresh_character,
update_character,
get_characters,
set_characters,
@@ -74,54 +75,42 @@ type alias Type =
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
--- TODO: move this elsewhere, this is too complicated a function for a module
--- that's not solely focused on attacks of opportunity.
-regenerate_attack_of_opportunity_markers_of_char : (
+regenerate_attack_of_opportunity_tags_for_char : (
Int ->
Struct.Character.Type ->
Type ->
Type
)
-regenerate_attack_of_opportunity_markers_of_char char_ix char battle =
- if ((Struct.Character.get_player_index char) == battle.own_player_ix)
- then battle
- else
- let
- marker_name = ("matk_c" ++ (String.fromInt char_ix))
- map_without_this_marker =
- (BattleMap.Struct.Map.remove_marker marker_name battle.map)
- in
- case (Struct.Character.get_melee_attack_range char) of
- 0 -> {battle | map = map_without_this_marker}
- attack_range ->
- {battle |
- map =
- (BattleMap.Struct.Map.add_marker
- marker_name
- (BattleMap.Struct.Marker.new_melee_attack
- char_ix
- (BattleMap.Struct.Location.add_neighborhood_to_set
- (BattleMap.Struct.Map.get_width
- map_without_this_marker
- )
- (BattleMap.Struct.Map.get_height
- map_without_this_marker
- )
- attack_range
- (Struct.Character.get_location char)
- (Set.empty)
+regenerate_attack_of_opportunity_tags_for_char char_ix char battle =
+ let
+ tag_name = ("matk_c" ++ (String.fromInt char_ix))
+ map_without_this_tag =
+ (BattleMap.Struct.Map.remove_tag tag_name battle.map)
+ in
+ case (Struct.Character.get_melee_attack_range char) of
+ 0 -> {battle | map = map_without_this_tag}
+ attack_range ->
+ {battle |
+ map =
+ (BattleMap.Struct.Map.add_tag
+ tag_name
+ (BattleMap.Struct.Marker.new_melee_attack
+ char_ix
+ (BattleMap.Struct.Location.add_neighborhood_to_set
+ (BattleMap.Struct.Map.get_width
+ map_without_this_tag
)
+ (BattleMap.Struct.Map.get_height
+ map_without_this_tag
+ )
+ attack_range
+ (Struct.Character.get_location char)
+ (Set.empty)
)
- map_without_this_marker
)
- }
-
-regenerate_attack_of_opportunity_markers : Int -> Type -> Type
-regenerate_attack_of_opportunity_markers char_ix battle =
- case (Array.get char_ix battle.characters) of
- Nothing -> battle
- (Just char) ->
- (regenerate_attack_of_opportunity_markers_of_char char_ix char battle)
+ map_without_this_tag
+ )
+ }
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
@@ -172,6 +161,24 @@ get_characters battle = battle.characters
set_characters : (Array.Array Struct.Character.Type) -> Type -> Type
set_characters chars battle = {battle | characters = chars}
+refresh_character : BattleMap.Struct.DataSet.Type -> Int -> Type -> Type
+refresh_character map_dataset ix battle =
+ let
+ character = (get_character ix battle)
+ refreshed_character =
+ (Struct.Character.refresh_omnimods
+ (\loc ->
+ (BattleMap.Struct.Map.get_omnimods_at loc map_dataset battle.map)
+ )
+ character
+ )
+ in
+ (regenerate_attack_of_opportunity_tags_for_char
+ ix
+ refreshed_character
+ (set_character ix refreshed_character battle)
+ )
+
-----------------
---- Players ----
-----------------
diff --git a/src/battle/src/Struct/Character.elm b/src/battle/src/Struct/Character.elm
index 327d23c..54a3a8c 100644
--- a/src/battle/src/Struct/Character.elm
+++ b/src/battle/src/Struct/Character.elm
@@ -20,6 +20,7 @@ module Struct.Character exposing
get_base_character,
set_base_character,
get_melee_attack_range,
+ refresh_omnimods,
decoder,
resolve
)
@@ -181,6 +182,29 @@ set_location location omnimods char =
dirty_set_location : BattleMap.Struct.Location.Type -> Type -> Type
dirty_set_location location char = { char | location = location }
+refresh_omnimods : (
+ (BattleMap.Struct.Location.Type -> Battle.Struct.Omnimods.Type) ->
+ Type ->
+ Type
+ )
+refresh_omnimods omnimods_fun character =
+ let
+ previous_max_health =
+ (Battle.Struct.Attributes.get_max_health
+ (BattleCharacters.Struct.Character.get_attributes char.base)
+ )
+ in
+ (fix_health
+ previous_max_health
+ {char |
+ base =
+ (BattleCharacters.Struct.Character.set_extra_omnimods
+ (omnimods_fun char.location)
+ char.base
+ )
+ }
+ )
+
get_base_character : Type -> BattleCharacters.Struct.Character.Type
get_base_character char = char.base
diff --git a/src/shared/battle-map/BattleMap/Struct/Map.elm b/src/shared/battle-map/BattleMap/Struct/Map.elm
index 1f254ac..cb0143e 100644
--- a/src/shared/battle-map/BattleMap/Struct/Map.elm
+++ b/src/shared/battle-map/BattleMap/Struct/Map.elm
@@ -103,7 +103,7 @@ remove_marker marker_name map =
(BattleMap.Struct.Location.from_ref loc)
map
)
- (BattleMap.Struct.TileInstance.remove_trigger
+ (BattleMap.Struct.TileInstance.remove_tag
marker_name
)
array
@@ -126,7 +126,7 @@ add_marker marker_name marker map =
(BattleMap.Struct.Location.from_ref loc)
map
)
- (BattleMap.Struct.TileInstance.add_trigger marker_name)
+ (BattleMap.Struct.TileInstance.add_tag marker_name)
array
)
)
@@ -247,8 +247,8 @@ get_tile_data_function bmap occupied_tiles start_loc loc =
else (BattleMap.Struct.TileInstance.get_cost tile)
),
(Set.foldl
- (\trigger dangers_count ->
- case (Dict.get trigger bmap.markers) of
+ (\tag dangers_count ->
+ case (Dict.get tag bmap.markers) of
Nothing -> dangers_count
(Just marker) ->
if (BattleMap.Struct.Marker.is_dangerous marker)
@@ -256,7 +256,7 @@ get_tile_data_function bmap occupied_tiles start_loc loc =
else dangers_count
)
0
- (BattleMap.Struct.TileInstance.get_triggers tile)
+ (BattleMap.Struct.TileInstance.get_tags tile)
)
)
diff --git a/src/shared/battle-map/BattleMap/Struct/Marker.elm b/src/shared/battle-map/BattleMap/Struct/Marker.elm
index 7012e4b..45a3986 100644
--- a/src/shared/battle-map/BattleMap/Struct/Marker.elm
+++ b/src/shared/battle-map/BattleMap/Struct/Marker.elm
@@ -38,6 +38,7 @@ type alias SpawnZoneStruct =
type DataType =
MeleeAttackZone MeleeAttackZoneStruct
| SpawnZone SpawnZoneStruct
+ | Tag
| None
type alias Type =
@@ -52,15 +53,6 @@ type alias Type =
decoder_internals : String -> (Json.Decode.Decoder DataType)
decoder_internals t =
case t of
- "matk" ->
- (Json.Decode.map
- (\e -> (MeleeAttackZone e))
- (Json.Decode.map
- MeleeAttackZoneStruct
- (Json.Decode.field "cix" (Json.Decode.int))
- )
- )
-
"spawn" ->
(Json.Decode.map
(\e -> (SpawnZone e))
@@ -150,20 +142,9 @@ encode marker =
]
)
- MeleeAttackZone zone ->
- (Json.Encode.object
- [
- ("t", (Json.Encode.string "matk")),
- ("cix", (Json.Encode.int zone.character_ix))
- ]
- )
-
- None ->
- (Json.Encode.object
- [
- ("t", (Json.Encode.string "none"))
- ]
- )
+ -- TODO/FIXME: Do not encode those, since they should not be
+ -- sent to the server.
+ _ -> (Json.Encode.null)
)
)
]
diff --git a/src/shared/battle-map/BattleMap/Struct/TileInstance.elm b/src/shared/battle-map/BattleMap/Struct/TileInstance.elm
index aca7f49..91e3bf5 100644
--- a/src/shared/battle-map/BattleMap/Struct/TileInstance.elm
+++ b/src/shared/battle-map/BattleMap/Struct/TileInstance.elm
@@ -15,9 +15,12 @@ module BattleMap.Struct.TileInstance exposing
get_border_variant_id,
get_border_class_id,
get_local_variant_ix,
- remove_trigger,
- add_trigger,
- get_triggers,
+-- remove_status_indicator,
+-- add_status_indicator,
+-- get_status_indicators,
+ remove_tag,
+ add_tag,
+ get_tags,
error,
solve,
set_location_from_index,
@@ -44,7 +47,6 @@ import BattleMap.Struct.Location
import Constants.UI
import Constants.Movement
-
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -55,7 +57,7 @@ type alias Type =
family : BattleMap.Struct.Tile.FamilyID,
class_id : BattleMap.Struct.Tile.Ref,
variant_id : BattleMap.Struct.Tile.VariantID,
- triggers : (Set.Set String),
+ tags : (Set.Set String),
borders : (List Border)
}
@@ -97,7 +99,7 @@ default tile =
variant_id = "0",
crossing_cost = (BattleMap.Struct.Tile.get_cost tile),
family = (BattleMap.Struct.Tile.get_family tile),
- triggers = (Set.empty),
+ tags = (Set.empty),
borders = []
}
@@ -109,7 +111,7 @@ error x y =
variant_id = "0",
family = "0",
crossing_cost = Constants.Movement.cost_when_out_of_bounds,
- triggers = (Set.empty),
+ tags = (Set.empty),
borders = []
}
@@ -183,14 +185,7 @@ decoder =
|> (Json.Decode.Pipeline.hardcoded "") -- Family
|> (Json.Decode.Pipeline.hardcoded tile_id)
|> (Json.Decode.Pipeline.hardcoded variant_id)
- |>
- (Json.Decode.Pipeline.required
- "t"
- (Json.Decode.map
- (Set.fromList)
- (Json.Decode.list (Json.Decode.string))
- )
- )
+ |> (Json.Decode.Pipeline.hardcoded (Set.empty)) -- tags
|>
(Json.Decode.Pipeline.hardcoded
(list_to_borders borders [])
@@ -245,23 +240,23 @@ encode tile_inst =
"t",
(Json.Encode.list
(Json.Encode.string)
- (Set.toList tile_inst.triggers)
+ (Set.toList tile_inst.tags)
)
)
]
)
-get_triggers : Type -> (Set.Set String)
-get_triggers tile_inst = tile_inst.triggers
+get_tags : Type -> (Set.Set String)
+get_tags tile_inst = tile_inst.tags
-add_trigger : String -> Type -> Type
-add_trigger trigger tile_inst =
+add_tag : String -> Type -> Type
+add_tag tag tile_inst =
{tile_inst |
- triggers = (Set.insert trigger tile_inst.triggers)
+ tags = (Set.insert tag tile_inst.tags)
}
-remove_trigger : String -> Type -> Type
-remove_trigger trigger tile_inst =
+remove_tag : String -> Type -> Type
+remove_tag tag tile_inst =
{tile_inst |
- triggers = (Set.remove trigger tile_inst.triggers)
+ tags = (Set.remove tag tile_inst.tags)
}
diff --git a/src/shared/battle-map/BattleMap/View/Tile.elm b/src/shared/battle-map/BattleMap/View/Tile.elm
index 1d92493..ffe34b0 100644
--- a/src/shared/battle-map/BattleMap/View/Tile.elm
+++ b/src/shared/battle-map/BattleMap/View/Tile.elm
@@ -63,11 +63,7 @@ get_content_html tile =
(Html.Attributes.class "tile-icon-dg")
]
(
- case
- (Set.size
- (BattleMap.Struct.TileInstance.get_triggers tile)
- )
- of
+ case (Set.size (BattleMap.Struct.TileInstance.get_tags tile)) of
0 -> []
other -> [(Html.text (String.fromInt other))]
)