summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/battle')
-rw-r--r--src/battle/btl_shim.erl28
-rw-r--r--src/battle/game-logic/btl_movement.erl12
-rw-r--r--src/battle/game-logic/btl_turn_actions.erl4
-rw-r--r--src/battle/reply/btl_set_map.erl8
-rw-r--r--src/battle/struct/btl_battle.erl8
-rw-r--r--src/battle/struct/btl_character.erl14
-rw-r--r--src/battle/struct/btl_map.erl14
7 files changed, 44 insertions, 44 deletions
diff --git a/src/battle/btl_shim.erl b/src/battle/btl_shim.erl
index 2964a76..07ec687 100644
--- a/src/battle/btl_shim.erl
+++ b/src/battle/btl_shim.erl
@@ -30,7 +30,7 @@ generate_random_characters
0,
_CharactersPerPlayer,
_TotalCharacterCount,
- _Battlemap,
+ _Map,
_ForbiddenLocations,
Result
) ->
@@ -41,7 +41,7 @@ generate_random_characters
0,
CharactersPerPlayer,
TotalCharacterCount,
- Battlemap,
+ Map,
ForbiddenLocations,
Result
) ->
@@ -51,7 +51,7 @@ generate_random_characters
CharactersPerPlayer,
CharactersPerPlayer,
TotalCharacterCount,
- Battlemap,
+ Map,
ForbiddenLocations,
Result
);
@@ -61,7 +61,7 @@ generate_random_characters
PlayerCharacterCount,
CharactersPerPlayer,
TotalCharacterCount,
- Battlemap,
+ Map,
ForbiddenLocations,
Result
) ->
@@ -70,8 +70,8 @@ generate_random_characters
(
TotalCharacterCount,
MaxPlayerIX,
- btl_map:get_width(Battlemap),
- btl_map:get_height(Battlemap),
+ btl_map:get_width(Map),
+ btl_map:get_height(Map),
ForbiddenLocations
),
Character =
@@ -86,7 +86,7 @@ generate_random_characters
(PlayerCharacterCount - 1),
CharactersPerPlayer,
(TotalCharacterCount + 1),
- Battlemap,
+ Map,
[btl_character:get_location(Character)|ForbiddenLocations],
[Character|Result]
).
@@ -132,11 +132,11 @@ demo_map () ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec generate_random_battle () -> btl_battle:type().
generate_random_battle () ->
- %BattlemapWidth = 32, % shr_roll:between(16, 32),
- %BattlemapHeight = 32, %shr_roll:between(16, 32),
- %Battlemap = btl_map:random(0, BattlemapWidth, BattlemapHeight),
- Battlemap = btl_map:from_list(0, 32, 32, demo_map()),
- Characters = generate_random_characters(1, 8, 8, 0, Battlemap, [], []),
+ %MapWidth = 32, % shr_roll:between(16, 32),
+ %MapHeight = 32, %shr_roll:between(16, 32),
+ %Map = btl_map:random(0, MapWidth, MapHeight),
+ Map = btl_map:from_list(0, 32, 32, demo_map()),
+ Characters = generate_random_characters(1, 8, 8, 0, Map, [], []),
PlayersAsList = [btl_player:new(0, 8, <<"0">>), btl_player:new(1, 0, <<"1">>)],
{UsedWeaponIDs, UsedArmorIDs} =
@@ -165,7 +165,7 @@ generate_random_battle () ->
)
end,
sets:new(),
- btl_map:get_tile_class_ids(Battlemap)
+ btl_map:get_tile_class_ids(Map)
),
Battle =
@@ -173,7 +173,7 @@ generate_random_battle () ->
(
<<"0">>,
PlayersAsList,
- Battlemap,
+ Map,
Characters,
sets:to_list(UsedWeaponIDs),
sets:to_list(UsedArmorIDs),
diff --git a/src/battle/game-logic/btl_movement.erl b/src/battle/game-logic/btl_movement.erl
index f78eca1..9acce73 100644
--- a/src/battle/game-logic/btl_movement.erl
+++ b/src/battle/game-logic/btl_movement.erl
@@ -26,11 +26,11 @@
btl_location:type()
)
-> {btl_location:type(), non_neg_integer()}.
-cross (_Battlemap, _ForbiddenLocations, [], Cost, Location) ->
+cross (_Map, _ForbiddenLocations, [], Cost, Location) ->
{Location, Cost};
-cross (Battlemap, ForbiddenLocations, [Step|NextSteps], Cost, Location) ->
+cross (Map, ForbiddenLocations, [Step|NextSteps], Cost, Location) ->
NextLocation = btl_location:apply_direction(Step, Location),
- NextTileClassID = btl_map:get_tile_class_id(NextLocation, Battlemap),
+ NextTileClassID = btl_map:get_tile_class_id(NextLocation, Map),
NextTileID = btl_tile:class_id_to_type_id(NextTileClassID),
NextTile = btl_tile:from_id(NextTileID),
NextCost = (Cost + btl_tile:get_cost(NextTile)),
@@ -46,7 +46,7 @@ cross (Battlemap, ForbiddenLocations, [Step|NextSteps], Cost, Location) ->
IsForbidden = false,
- cross(Battlemap, ForbiddenLocations, NextSteps, NextCost, NextLocation).
+ cross(Map, ForbiddenLocations, NextSteps, NextCost, NextLocation).
-spec cross
(
@@ -56,5 +56,5 @@ cross (Battlemap, ForbiddenLocations, [Step|NextSteps], Cost, Location) ->
btl_location:type()
)
-> {btl_location:type(), non_neg_integer()}.
-cross (Battlemap, ForbiddenLocations, Path, Location) ->
- cross(Battlemap, ForbiddenLocations, Path, 0, Location).
+cross (Map, ForbiddenLocations, Path, Location) ->
+ cross(Map, ForbiddenLocations, Path, 0, Location).
diff --git a/src/battle/game-logic/btl_turn_actions.erl b/src/battle/game-logic/btl_turn_actions.erl
index d46818f..caf2e26 100644
--- a/src/battle/game-logic/btl_turn_actions.erl
+++ b/src/battle/game-logic/btl_turn_actions.erl
@@ -79,7 +79,7 @@ get_path_cost_and_destination (Data, Path) ->
Character = btl_character_turn_data:get_character(Data),
CharacterIX = btl_character_turn_data:get_character_ix(Data),
Battle = btl_character_turn_data:get_battle(Data),
- Battlemap = btl_battle:get_map(Battle),
+ Map = btl_battle:get_map(Battle),
ForbiddenLocations =
array:foldl
@@ -99,7 +99,7 @@ get_path_cost_and_destination (Data, Path) ->
{NewLocation, Cost} =
btl_movement:cross
(
- Battlemap,
+ Map,
ForbiddenLocations,
Path,
btl_character:get_location(Character)
diff --git a/src/battle/reply/btl_set_map.erl b/src/battle/reply/btl_set_map.erl
index c520930..b4025b1 100644
--- a/src/battle/reply/btl_set_map.erl
+++ b/src/battle/reply/btl_set_map.erl
@@ -17,15 +17,15 @@
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec generate (btl_map:type()) -> {list(any())}.
-generate (Battlemap) ->
+generate (Map) ->
{
[
{<<"msg">>, <<"set_map">>},
- {<<"w">>, btl_map:get_width(Battlemap)},
- {<<"h">>, btl_map:get_height(Battlemap)},
+ {<<"w">>, btl_map:get_width(Map)},
+ {<<"h">>, btl_map:get_height(Map)},
{
<<"t">>,
- array:sparse_to_list(btl_map:get_tile_class_ids(Battlemap))
+ array:sparse_to_list(btl_map:get_tile_class_ids(Map))
}
]
}.
diff --git a/src/battle/struct/btl_battle.erl b/src/battle/struct/btl_battle.erl
index 97742aa..22c96f6 100644
--- a/src/battle/struct/btl_battle.erl
+++ b/src/battle/struct/btl_battle.erl
@@ -128,10 +128,10 @@ get_encoded_last_turns_effects (Battle) ->
get_all_timelines([], StartingPoint, CurrentPlayerIX, PlayersCount, Players).
-spec set_map (btl_map:type(), type()) -> type().
-set_map (Battlemap, Battle) ->
+set_map (Map, Battle) ->
Battle#battle
{
- map = Battlemap
+ map = Map
}.
-spec set_characters (array:array(btl_character:type()), type()) -> type().
@@ -192,14 +192,14 @@ set_current_player_turn (PlayerTurn, Battle) ->
list(btl_tile:id())
)
-> type().
-new (ID, PlayersAsList, Battlemap, CharactersAsList, UWIDs, UAIDs, UTIDs) ->
+new (ID, PlayersAsList, Map, CharactersAsList, UWIDs, UAIDs, UTIDs) ->
#battle
{
id = ID,
used_weapon_ids = UWIDs,
used_armor_ids = UAIDs,
used_tile_ids = UTIDs,
- map = Battlemap,
+ map = Map,
characters = array:from_list(CharactersAsList),
players = array:from_list(PlayersAsList),
current_player_turn = btl_player_turn:new(0, 0)
diff --git a/src/battle/struct/btl_character.erl b/src/battle/struct/btl_character.erl
index d9362ea..3f5c360 100644
--- a/src/battle/struct/btl_character.erl
+++ b/src/battle/struct/btl_character.erl
@@ -89,9 +89,9 @@
list({non_neg_integer(), non_neg_integer()})
)
-> {non_neg_integer(), non_neg_integer()}.
-find_random_location (BattlemapWidth, BattlemapHeight, ForbiddenLocations) ->
- X = shr_roll:between(0, (BattlemapWidth - 1)),
- Y = shr_roll:between(0, (BattlemapHeight - 1)),
+find_random_location (MapWidth, MapHeight, ForbiddenLocations) ->
+ X = shr_roll:between(0, (MapWidth - 1)),
+ Y = shr_roll:between(0, (MapHeight - 1)),
IsForbidden = lists:member({X, Y}, ForbiddenLocations),
@@ -99,8 +99,8 @@ find_random_location (BattlemapWidth, BattlemapHeight, ForbiddenLocations) ->
true ->
find_random_location
(
- BattlemapWidth,
- BattlemapHeight,
+ MapWidth,
+ MapHeight,
ForbiddenLocations
);
@@ -241,9 +241,9 @@ set_statistics (Stats, Char) ->
list({non_neg_integer(), non_neg_integer()})
)
-> type().
-random (ID, PlayerIX, BattlemapWidth, BattlemapHeight, ForbiddenLocations) ->
+random (ID, PlayerIX, MapWidth, MapHeight, ForbiddenLocations) ->
Location =
- find_random_location(BattlemapWidth, BattlemapHeight, ForbiddenLocations),
+ find_random_location(MapWidth, MapHeight, ForbiddenLocations),
WeaponIDs = {shr_weapon:random_id(), shr_weapon:random_id()},
ArmorID = shr_armor:random_id(),
Attributes = shr_attributes:random(),
diff --git a/src/battle/struct/btl_map.erl b/src/battle/struct/btl_map.erl
index ef34833..83cf455 100644
--- a/src/battle/struct/btl_map.erl
+++ b/src/battle/struct/btl_map.erl
@@ -64,21 +64,21 @@ location_to_array_index (ArrayWidth, {X, Y}) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Accessors
-spec get_id (type()) -> id().
-get_id (Battlemap) -> Battlemap#map.id.
+get_id (Map) -> Map#map.id.
-spec get_width (type()) -> integer().
-get_width (Battlemap) -> Battlemap#map.width.
+get_width (Map) -> Map#map.width.
-spec get_height (type()) -> integer().
-get_height (Battlemap) -> Battlemap#map.height.
+get_height (Map) -> Map#map.height.
-spec get_tile_class_ids (type()) -> array:array(btl_tile:class_id()).
-get_tile_class_ids (Battlemap) -> Battlemap#map.tile_class_ids.
+get_tile_class_ids (Map) -> Map#map.tile_class_ids.
-spec get_tile_class_id (btl_location:type(), type()) -> btl_tile:class_id().
-get_tile_class_id (Location, Battlemap) ->
- TileIX = location_to_array_index(Battlemap#map.width, Location),
- array:get(TileIX, Battlemap#map.tile_class_ids).
+get_tile_class_id (Location, Map) ->
+ TileIX = location_to_array_index(Map#map.width, Location),
+ array:get(TileIX, Map#map.tile_class_ids).
-spec from_list
(