| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-02-26 13:52:29 +0100 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-02-26 13:52:29 +0100 | 
| commit | fd4d031ab5b31763d376c663cc049f62ee389243 (patch) | |
| tree | cd09a29bb888acf772fa1aee59fe95e8bd75fe4e /src/struct/battlemap_instance.erl | |
| parent | 66ec11ce5d2e227846d6e6b2899cda851a70fc04 (diff) | |
Got it to run, at last.
Diffstat (limited to 'src/struct/battlemap_instance.erl')
| -rw-r--r-- | src/struct/battlemap_instance.erl | 42 | 
1 files changed, 42 insertions, 0 deletions
diff --git a/src/struct/battlemap_instance.erl b/src/struct/battlemap_instance.erl index 9a57d09..d031ccd 100644 --- a/src/struct/battlemap_instance.erl +++ b/src/struct/battlemap_instance.erl @@ -38,6 +38,13 @@     ]  ). +-export +( +   [ +      random/4 +   ] +). +  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -92,3 +99,38 @@ set_last_turns_effects (Effects, BattlemapInstance) ->     {        last_turns_effects = Effects     }. + +random (ID, PlayersAsList, Battlemap, Characters) -> +   BattlemapWidth = battlemap:get_width(Battlemap), +   BattlemapHeight = battlemap:get_height(Battlemap), +   CharacterInstancesAsList = +      lists:mapfoldl +      ( +         fun (Character, ForbiddenLocations) -> +            NewCharacterInstance = +               character_instance:random +               ( +                  Character, +                  BattlemapWidth, +                  BattlemapHeight, +                  ForbiddenLocations +               ), +            NewCharacterInstanceLocation = +               character_instance:get_location(NewCharacterInstance), +            { +               NewCharacterInstance, +               [NewCharacterInstanceLocation|ForbiddenLocations] +            } +         end, +         Characters +      ), + +   #battlemap_instance +   { +      id = ID, +      battlemap = Battlemap, +      character_instances = array:from_list(CharacterInstancesAsList), +      players = array:from_list(PlayersAsList), +      current_player_turn = player_turn:new(0, 0), +      last_turns_effects = [] +   }.  | 


