summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/battlemap/struct')
-rw-r--r--src/battlemap/struct/bm_battle.erl26
-rw-r--r--src/battlemap/struct/bm_character.erl24
2 files changed, 36 insertions, 14 deletions
diff --git a/src/battlemap/struct/bm_battle.erl b/src/battlemap/struct/bm_battle.erl
index 08c4943..c4207e8 100644
--- a/src/battlemap/struct/bm_battle.erl
+++ b/src/battlemap/struct/bm_battle.erl
@@ -10,6 +10,8 @@
battle,
{
id :: id(),
+ used_armor_ids:: list(sh_armor:id()),
+ used_weapon_ids :: list(sh_weapon:id()),
battlemap :: bm_battlemap:type(),
characters :: array:array(bm_character:type()),
players :: array:array(bm_player:type()),
@@ -29,6 +31,8 @@
(
[
get_id/1,
+ get_used_weapon_ids/1,
+ get_used_armor_ids/1,
get_battlemap/1,
get_characters/1,
get_character/2,
@@ -53,7 +57,7 @@
-export
(
[
- new/4
+ new/6
]
).
@@ -80,13 +84,17 @@ get_all_timelines (Result, CurrentIndex, EndPoint, ArraySize, Players) ->
-spec get_id (type()) -> id().
get_id (Battle) -> Battle#battle.id.
+-spec get_used_weapon_ids (type()) -> list(sh_weapon:id()).
+get_used_weapon_ids (Battle) -> Battle#battle.used_weapon_ids.
+
+-spec get_used_armor_ids (type()) -> list(sh_armor:id()).
+get_used_armor_ids (Battle) -> Battle#battle.used_armor_ids.
+
-spec get_battlemap (type()) -> bm_battlemap:type().
-get_battlemap (Battle) ->
- Battle#battle.battlemap.
+get_battlemap (Battle) -> Battle#battle.battlemap.
-spec get_characters (type()) -> array:array(bm_character:type()).
-get_characters (Battle) ->
- Battle#battle.characters.
+get_characters (Battle) -> Battle#battle.characters.
-spec get_character (non_neg_integer(), type()) -> bm_character:type().
get_character (IX, Battle) ->
@@ -173,13 +181,17 @@ set_current_player_turn (PlayerTurn, Battle) ->
id(),
list(bm_player:type()),
bm_battlemap:type(),
- list(bm_character:type())
+ list(bm_character:type()),
+ list(sh_weapon:id()),
+ list(sh_armor:id())
)
-> type().
-new (ID, PlayersAsList, Battlemap, CharactersAsList) ->
+new (ID, PlayersAsList, Battlemap, CharactersAsList, UWIDs, UAIDs) ->
#battle
{
id = ID,
+ used_weapon_ids = UWIDs,
+ used_armor_ids = UAIDs,
battlemap = Battlemap,
characters = array:from_list(CharactersAsList),
players = array:from_list(PlayersAsList),
diff --git a/src/battlemap/struct/bm_character.erl b/src/battlemap/struct/bm_character.erl
index 5552a02..594f9cd 100644
--- a/src/battlemap/struct/bm_character.erl
+++ b/src/battlemap/struct/bm_character.erl
@@ -17,6 +17,7 @@
attributes :: sh_attributes:type(),
statistics :: sh_statistics:type(),
weapon_ids :: {sh_weapon:id(), sh_weapon:id()},
+ armor_id :: sh_armor:id(),
location :: {non_neg_integer(), non_neg_integer()},
current_health :: non_neg_integer(),
active :: boolean()
@@ -41,12 +42,14 @@
get_attributes/1,
get_statistics/1,
get_weapon_ids/1,
+ get_armor_id/1,
get_location/1,
get_current_health/1,
get_is_alive/1,
get_is_active/1,
set_weapon_ids/2,
+ set_armor_id/2,
set_statistics/2,
set_location/2,
set_current_health/2,
@@ -117,6 +120,9 @@ get_portrait (Char) -> Char#character.portrait.
-spec get_attributes (type()) -> sh_attributes:type().
get_attributes (Char) -> Char#character.attributes.
+-spec get_armor_id (type()) -> sh_armor:id().
+get_armor_id (Char) -> Char#character.armor_id.
+
-spec get_weapon_ids (type()) -> {sh_weapon:id(), sh_weapon:id()}.
get_weapon_ids (Char) -> Char#character.weapon_ids.
@@ -169,12 +175,14 @@ set_is_active (Active, Char) ->
active = Active
}.
--spec set_weapon_ids
- (
- {sh_weapon:id(), sh_weapon:id()},
- type()
- )
- -> type().
+-spec set_armor_id (sh_armor:id(), type()) -> type().
+set_armor_id (ArmorID, Char) ->
+ Char#character
+ {
+ armor_id = ArmorID
+ }.
+
+-spec set_weapon_ids ({sh_weapon:id(), sh_weapon:id()}, type()) -> type().
set_weapon_ids (WeaponIDs, Char) ->
Char#character
{
@@ -207,8 +215,9 @@ random (ID, OwnerID, BattlemapWidth, BattlemapHeight, ForbiddenLocations) ->
Location =
find_random_location(BattlemapWidth, BattlemapHeight, ForbiddenLocations),
WeaponIDs = {sh_weapon:random_id(), sh_weapon:random_id()},
+ ArmorID = sh_armor:random_id(),
Attributes = sh_attributes:random(),
- Statistics = sh_statistics:new(Attributes, WeaponIDs),
+ Statistics = sh_statistics:new(Attributes, WeaponIDs, ArmorID),
IDAsListString = integer_to_list(ID),
IDAsBinaryString = list_to_binary(IDAsListString),
@@ -221,6 +230,7 @@ random (ID, OwnerID, BattlemapWidth, BattlemapHeight, ForbiddenLocations) ->
portrait = IDAsBinaryString,
attributes = Attributes,
weapon_ids = WeaponIDs,
+ armor_id = ArmorID,
statistics = Statistics,
location = Location,
current_health = sh_statistics:get_health(Statistics),