summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2019-02-15 18:18:54 +0100
committernsensfel <SpamShield0@noot-noot.org>2019-02-15 18:18:54 +0100
commit85b1e04a22e7564b702aa27c5f6467ad4d5f4416 (patch)
treed0a408eb97412feccdbcfe20b951669b6f6e6588 /src/shared/struct/inventory
parent9b91ff37a1e39f48631b5bee338c31318d1e2336 (diff)
Re-organizing shr_ structs.
Diffstat (limited to 'src/shared/struct/inventory')
-rw-r--r--src/shared/struct/inventory/shr_armor.erl.m468
-rw-r--r--src/shared/struct/inventory/shr_glyph.erl.m462
-rw-r--r--src/shared/struct/inventory/shr_glyph_board.erl.m4109
-rw-r--r--src/shared/struct/inventory/shr_portrait.erl.m473
-rw-r--r--src/shared/struct/inventory/shr_weapon.erl.m479
5 files changed, 391 insertions, 0 deletions
diff --git a/src/shared/struct/inventory/shr_armor.erl.m4 b/src/shared/struct/inventory/shr_armor.erl.m4
new file mode 100644
index 0000000..18d203a
--- /dev/null
+++ b/src/shared/struct/inventory/shr_armor.erl.m4
@@ -0,0 +1,68 @@
+-module(shr_armor).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-type id() :: binary().
+
+-record
+(
+ armor,
+ {
+ id :: id(),
+ name :: binary(),
+ omnimods :: shr_omnimods:type()
+ }
+).
+
+-opaque type() :: #armor{}.
+
+-export_type([type/0, id/0]).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% Accessors
+-export
+(
+ [
+ get_id/1,
+ get_name/1,
+ get_omnimods/1
+ ]
+).
+
+-export
+(
+ [
+ none/0,
+ from_id/1
+ ]
+).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% Accessors
+-spec get_id (type()) -> id().
+get_id (Ar) -> Ar#armor.id.
+
+-spec get_name (type()) -> binary().
+get_name (Ar) -> Ar#armor.name.
+
+-spec get_omnimods (type()) -> shr_omnimods:type().
+get_omnimods (Ar) -> Ar#armor.omnimods.
+
+-spec from_id (id()) -> type().
+m4_include(__MAKEFILE_DATA_DIR/armor/global.m4.conf)m4_dnl
+m4_include(__MAKEFILE_DATA_DIR/armor/basic.m4d)m4_dnl
+from_id(_) ->
+ none().
+
+-spec none () -> type().
+none () -> from_id(<<"0">>).
diff --git a/src/shared/struct/inventory/shr_glyph.erl.m4 b/src/shared/struct/inventory/shr_glyph.erl.m4
new file mode 100644
index 0000000..cd59a27
--- /dev/null
+++ b/src/shared/struct/inventory/shr_glyph.erl.m4
@@ -0,0 +1,62 @@
+-module(shr_glyph).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-type id() :: binary().
+
+-record
+(
+ glyph,
+ {
+ id :: id(),
+ name :: binary(),
+ omnimods :: shr_omnimods:type()
+ }
+).
+
+-type type() :: #glyph{}.
+
+-export_type([type/0, id/0]).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+-export
+(
+ [
+ from_id/1
+ ]
+).
+
+-export
+(
+ [
+ get_id/1,
+ get_name/1,
+ get_omnimods/1
+ ]
+).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-spec get_id (type()) -> id().
+get_id (Glyph) -> Glyph#glyph.id.
+
+-spec get_name (type()) -> binary().
+get_name (Glyph) -> Glyph#glyph.name.
+
+-spec get_omnimods (type()) -> shr_omnimods:type().
+get_omnimods (Glyph) -> Glyph#glyph.omnimods.
+
+-spec from_id (id()) -> type().
+m4_include(__MAKEFILE_DATA_DIR/glyph/global.m4.conf)m4_dnl
+m4_include(__MAKEFILE_DATA_DIR/glyph/basic.m4d)m4_dnl
+from_id(_) ->
+ from_id(<<"0">>).
diff --git a/src/shared/struct/inventory/shr_glyph_board.erl.m4 b/src/shared/struct/inventory/shr_glyph_board.erl.m4
new file mode 100644
index 0000000..7fe77b1
--- /dev/null
+++ b/src/shared/struct/inventory/shr_glyph_board.erl.m4
@@ -0,0 +1,109 @@
+-module(shr_glyph_board).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-type id() :: binary().
+
+-record
+(
+ glyph_board,
+ {
+ id :: id(),
+ name :: binary(),
+ omnimods :: shr_omnimods:type(),
+ slots :: list(integer())
+ }
+).
+
+-type type() :: #glyph_board{}.
+
+-export_type([type/0, id/0]).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-export
+(
+ [
+ from_id/1
+ ]
+).
+
+-export
+(
+ [
+ get_id/1,
+ get_name/1,
+ get_omnimods/1,
+ get_slots/1
+ ]
+).
+
+-export
+(
+ [
+ none/0,
+ get_omnimods_with_glyphs/2
+ ]
+).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-spec get_omnimods_with_glyphs_internals
+ (
+ shr_omnimods:type(),
+ list(shr_glyph:type()),
+ list(integer())
+ )
+ -> ({'ok', shr_omnimods:type()} | 'error').
+get_omnimods_with_glyphs_internals (Omnimods, [], []) ->
+ {ok, Omnimods};
+get_omnimods_with_glyphs_internals (_Omnimods, [], _) ->
+ error;
+get_omnimods_with_glyphs_internals (_Omnimods, _, []) ->
+ error;
+get_omnimods_with_glyphs_internals (Omnimods, [Glyph|NextGlyphs], [M|NextMs]) ->
+ Multiplier = (M / 100),
+ GlyphOmnimods = shr_glyph:get_omnimods(Glyph),
+ ModGlyphOmnimods = shr_omnimods:apply_coefficient(Multiplier, GlyphOmnimods),
+ NextOmnimods = shr_omnimods:merge(Omnimods, ModGlyphOmnimods),
+
+ get_omnimods_with_glyphs_internals(NextOmnimods, NextGlyphs, NextMs).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-spec get_id (type()) -> id().
+get_id (GlyphBoard) -> GlyphBoard#glyph_board.id.
+
+-spec get_name (type()) -> binary().
+get_name (GlyphBoard) -> GlyphBoard#glyph_board.name.
+
+-spec get_omnimods (type()) -> shr_omnimods:type().
+get_omnimods (GlyphBoard) -> GlyphBoard#glyph_board.omnimods.
+
+-spec get_slots (type()) -> list(non_neg_integer()).
+get_slots (GlyphBoard) -> GlyphBoard#glyph_board.slots.
+
+-spec from_id (id()) -> type().
+m4_include(__MAKEFILE_DATA_DIR/glyph_board/global.m4.conf)m4_dnl
+m4_include(__MAKEFILE_DATA_DIR/glyph_board/basic.m4d)m4_dnl
+from_id(_) ->
+ none().
+
+-spec none () -> type().
+none () -> from_id(<<"0">>).
+
+-spec get_omnimods_with_glyphs
+ (
+ list(shr_glyph:type()),
+ type()
+ )
+ -> ({'ok', shr_omnimods:type()} | 'error').
+get_omnimods_with_glyphs (Glyphs, GlyphBoard) ->
+ BoardOmnimods = GlyphBoard#glyph_board.omnimods,
+ BoardSlots = GlyphBoard#glyph_board.slots,
+
+ get_omnimods_with_glyphs_internals(BoardOmnimods, Glyphs, BoardSlots).
diff --git a/src/shared/struct/inventory/shr_portrait.erl.m4 b/src/shared/struct/inventory/shr_portrait.erl.m4
new file mode 100644
index 0000000..fefc434
--- /dev/null
+++ b/src/shared/struct/inventory/shr_portrait.erl.m4
@@ -0,0 +1,73 @@
+-module(shr_portrait).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-type id() :: binary().
+
+-record
+(
+ portrait,
+ {
+ id :: id(),
+ name :: binary(),
+ body_id :: binary(),
+ icon_id :: binary()
+ }
+).
+
+-opaque type() :: #portrait{}.
+
+-export_type([type/0, id/0]).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% Accessors
+-export
+(
+ [
+ get_id/1,
+ get_name/1,
+ get_body_id/1,
+ get_icon_id/1
+ ]
+).
+
+-export
+(
+ [
+ from_id/1,
+ default/0
+ ]
+).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% Accessors
+-spec get_id (type()) -> id().
+get_id (Pt) -> Pt#portrait.id.
+
+-spec get_name (type()) -> binary().
+get_name (Pt) -> Pt#portrait.name.
+
+-spec get_body_id (type()) -> binary().
+get_body_id (Pt) -> Pt#portrait.body_id.
+
+-spec get_icon_id (type()) -> binary().
+get_icon_id (Pt) -> Pt#portrait.icon_id.
+
+-spec from_id (id()) -> type().
+m4_include(__MAKEFILE_DATA_DIR/portrait/global.m4.conf)m4_dnl
+m4_include(__MAKEFILE_DATA_DIR/portrait/basic.m4d)m4_dnl
+from_id(_) ->
+ default().
+
+-spec default () -> type().
+default () -> from_id(<<"cat">>).
diff --git a/src/shared/struct/inventory/shr_weapon.erl.m4 b/src/shared/struct/inventory/shr_weapon.erl.m4
new file mode 100644
index 0000000..1a2dcf5
--- /dev/null
+++ b/src/shared/struct/inventory/shr_weapon.erl.m4
@@ -0,0 +1,79 @@
+-module(shr_weapon).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-type id() :: binary().
+
+-record
+(
+ weapon,
+ {
+ id :: id(),
+ name :: binary(),
+ is_primary :: boolean(),
+ range_min:: non_neg_integer(),
+ range_max :: non_neg_integer(),
+ omnimods :: shr_omnimods:type()
+ }
+).
+
+-opaque type() :: #weapon{}.
+
+-export_type([type/0, id/0]).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% Accessors
+-export
+(
+ [
+ get_id/1,
+ get_name/1,
+ get_minimum_range/1,
+ get_maximum_range/1,
+ get_omnimods/1
+ ]
+).
+
+-export
+(
+ [
+ none/0,
+ from_id/1
+ ]
+).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% Accessors
+-spec get_id (type()) -> id().
+get_id (Wp) -> Wp#weapon.id.
+
+-spec get_name (type()) -> binary().
+get_name (Wp) -> Wp#weapon.name.
+
+-spec get_minimum_range (type()) -> non_neg_integer().
+get_minimum_range (Wp) -> Wp#weapon.range_min.
+
+-spec get_maximum_range (type()) -> non_neg_integer().
+get_maximum_range (Wp) -> Wp#weapon.range_max.
+
+-spec get_omnimods (type()) -> shr_omnimods:type().
+get_omnimods (Wp) -> Wp#weapon.omnimods.
+
+-spec from_id (id()) -> type().
+m4_include(__MAKEFILE_DATA_DIR/weapon/global.m4.conf)m4_dnl
+m4_include(__MAKEFILE_DATA_DIR/weapon/basic.m4d)m4_dnl
+m4_include(__MAKEFILE_DATA_DIR/weapon/secondary.m4d)m4_dnl
+from_id (_) ->
+ none().
+
+-spec none () -> type().
+none () -> from_id(<<"0">>).