| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-07-11 17:54:14 +0200 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-07-11 17:54:14 +0200 | 
| commit | fde827cba1ff3d889135c74ee1978098465fd200 (patch) | |
| tree | d6022f800aa8226bf79a26a19189965c8cbfb2fe /src/battle/game-logic/btl_movement.erl | |
| parent | df59024199c387903e3d4a901171939a358489d3 (diff) | |
"Battlemap" -> "Battle".
Diffstat (limited to 'src/battle/game-logic/btl_movement.erl')
| -rw-r--r-- | src/battle/game-logic/btl_movement.erl | 60 | 
1 files changed, 60 insertions, 0 deletions
diff --git a/src/battle/game-logic/btl_movement.erl b/src/battle/game-logic/btl_movement.erl new file mode 100644 index 0000000..87b1806 --- /dev/null +++ b/src/battle/game-logic/btl_movement.erl @@ -0,0 +1,60 @@ +-module(btl_movement). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export([cross/4]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec cross +   ( +      btl_battlemap:type(), +      list(btl_location:type()), +      list(btl_direction:enum()), +      non_neg_integer(), +      btl_location:type() +   ) +   -> {btl_location:type(), non_neg_integer()}. +cross (_Battlemap, _ForbiddenLocations, [], Cost, Location) -> +   {Location, Cost}; +cross (Battlemap, ForbiddenLocations, [Step|NextSteps], Cost, Location) -> +   NextLocation = btl_location:apply_direction(Step, Location), +   NextTileClassID = btl_battlemap:get_tile_class_id(NextLocation, Battlemap), +   NextTileID = btl_tile:class_id_to_type_id(NextTileClassID), +   NextTile = btl_tile:from_id(NextTileID), +   NextCost = (Cost + btl_tile:get_cost(NextTile)), +   IsForbidden = +      lists:foldl +      ( +         fun (ForbiddenLocation, Prev) -> +            (Prev or (NextLocation == ForbiddenLocation)) +         end, +         false, +         ForbiddenLocations +      ), + +   IsForbidden = false, + +   cross(Battlemap, ForbiddenLocations, NextSteps, NextCost, NextLocation). + +-spec cross +   ( +      btl_battlemap:type(), +      list(btl_location:type()), +      list(btl_direction:enum()), +      btl_location:type() +   ) +   -> {btl_location:type(), non_neg_integer()}. +cross (Battlemap, ForbiddenLocations, Path, Location) -> +   cross(Battlemap, ForbiddenLocations, Path, 0, Location).  | 


