| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-02-23 11:35:45 +0100 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-02-23 11:35:45 +0100 | 
| commit | acf9e9f1eb880ffb8ab918c40724eda566aefcc7 (patch) | |
| tree | efa3dd6c88d7970632fbe44f322d03b983b02768 /src/shim/battlemap_shim.erl | |
| parent | 43e38e5fc54fd58e8230b2b5198b6d8cb625803c (diff) | |
Starting a big refactoring...
Diffstat (limited to 'src/shim/battlemap_shim.erl')
| -rw-r--r-- | src/shim/battlemap_shim.erl | 64 | 
1 files changed, 64 insertions, 0 deletions
| diff --git a/src/shim/battlemap_shim.erl b/src/shim/battlemap_shim.erl new file mode 100644 index 0000000..b19a653 --- /dev/null +++ b/src/shim/battlemap_shim.erl @@ -0,0 +1,64 @@ +-module(battlemap_shim). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-record +( +   battlemap, +   { +      id, +      width, +      height, +      content, +      instances +   } +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export +( +   [ +      generate_random/0 +   ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +generate(_Prev, Result, _X, 0, _BaseWidth) -> +   Result; +generate(Prev, Result, 0, Y, BaseWidth) -> +   generate(Prev, Result, BaseWidth, (Y - 1), BaseWidth); +generate(Prev, Result, X, Y, BaseWidth) -> +   case rand:uniform(100) of +      N when (N >= 10) -> +         generate(Prev, [Prev|Result], (X - 1), Y, BaseWidth); + +      N -> +         NewTileType = (N - 1), +         generate +         ( +            NewTileType, +            [NewTileType|Result], +            (X - 1), +            Y, +            BaseWidth +         ) +   end. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +generate_random () -> +   Width = (rand:uniform(48) + 16), +   Height = (rand:uniform(48) + 16), +   #battlemap +   { +      id = <<"0">>, +      width = Width, +      height = Height, +      content = array:from_list(generate(0, [], Width, Height, Width)) +   }. | 


