summaryrefslogtreecommitdiff
path: root/src/shim
diff options
context:
space:
mode:
Diffstat (limited to 'src/shim')
-rw-r--r--src/shim/attributes_shim.erl47
-rw-r--r--src/shim/battlemap_instance_shim.erl55
-rw-r--r--src/shim/battlemap_shim.erl64
-rw-r--r--src/shim/character_shim.erl57
-rw-r--r--src/shim/weapon_shim.erl24
5 files changed, 247 insertions, 0 deletions
diff --git a/src/shim/attributes_shim.erl b/src/shim/attributes_shim.erl
new file mode 100644
index 0000000..b80ee6d
--- /dev/null
+++ b/src/shim/attributes_shim.erl
@@ -0,0 +1,47 @@
+-module(attributes_shim).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-record
+(
+ attributes,
+ {
+ constitution,
+ dexterity,
+ intelligence,
+ mind,
+ speed,
+ strength
+ }
+).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% Accessors
+-export
+(
+ [
+ rand/0
+ ]
+).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+random_attribute (Min, Max) -> (rand:uniform(Max - Min) - 1) + Min.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+rand () ->
+ #attributes
+ {
+ constitution = random_attribute(10, 100),
+ dexterity = random_attribute(10, 100),
+ intelligence = random_attribute(10, 100),
+ mind = random_attribute(10, 100),
+ speed = random_attribute(10, 100),
+ strength = random_attribute(10, 100)
+ }.
diff --git a/src/shim/battlemap_instance_shim.erl b/src/shim/battlemap_instance_shim.erl
new file mode 100644
index 0000000..94ae7ce
--- /dev/null
+++ b/src/shim/battlemap_instance_shim.erl
@@ -0,0 +1,55 @@
+-module(battlemap_instance_shim).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-record
+(
+ battlemap_instance,
+ {
+ id,
+ chars,
+ curr_player,
+ players,
+ rem_chars,
+ last_turn
+ }
+).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-export
+(
+ [
+ generate_random/2
+ ]
+).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+generate_random (CharInsts, Players) ->
+ #battlemap_instance
+ {
+ id = <<"0">>,
+ chars = dict:from_list(CharInsts),
+ curr_player = 0,
+ players = array:from_list(Players),
+ rem_chars =
+ lists:filtermap
+ (
+ fun ({K, V}) ->
+ case character_instance:get_owner(V) of
+ 0 -> {true, K};
+ _ -> false
+ end
+ end,
+ CharInsts
+ ),
+ last_turn = []
+ }.
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))
+ }.
diff --git a/src/shim/character_shim.erl b/src/shim/character_shim.erl
new file mode 100644
index 0000000..35a0753
--- /dev/null
+++ b/src/shim/character_shim.erl
@@ -0,0 +1,57 @@
+-module(character_shim).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-record
+(
+ character,
+ {
+ id,
+ name,
+ icon,
+ portrait,
+ attributes,
+ weapons,
+ glyphs,
+ armors
+ }
+).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-export
+(
+ [
+ generate_random/1
+ ]
+).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+generate_char (N) ->
+ IDAsString = list_to_binary(integer_to_list(N)),
+ #character
+ {
+ id = IDAsString, % ID
+ name = IDAsString, % Name
+ icon = IDAsString, % Icon
+ portrait = IDAsString, % Portrait
+ attributes = attributes_shim:rand(),
+ weapons = {weapon_shim:rand(), weapon_shim:rand()},
+ glyphs = [],
+ armors = []
+ }.
+
+generate (0, Result) ->
+ Result;
+generate (N, Prev) ->
+ generate((N - 1), [generate_char(N - 1)|Prev]).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+generate_random (N) ->
+ generate(N, []).
diff --git a/src/shim/weapon_shim.erl b/src/shim/weapon_shim.erl
new file mode 100644
index 0000000..e0364f0
--- /dev/null
+++ b/src/shim/weapon_shim.erl
@@ -0,0 +1,24 @@
+-module(weapon_shim).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%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