summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-10-05 15:41:03 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-10-05 15:41:03 +0200
commit2e2bfd2d0d3bc52db4274ddc3dd1778c77ac5868 (patch)
treeed2f4fc5c07bdcd53514c51910e0d8094ef67cf2 /src/shared/struct/shr_glyph_board.erl.m4
parent0d8e11193bf166758c2d9c46190b07b9b76f2958 (diff)
(Broken) Working on the addition of glyphs & their boards.
Diffstat (limited to 'src/shared/struct/shr_glyph_board.erl.m4')
-rw-r--r--src/shared/struct/shr_glyph_board.erl.m4105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/shared/struct/shr_glyph_board.erl.m4 b/src/shared/struct/shr_glyph_board.erl.m4
new file mode 100644
index 0000000..1631441
--- /dev/null
+++ b/src/shared/struct/shr_glyph_board.erl.m4
@@ -0,0 +1,105 @@
+-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
+(
+ [
+ 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(_) ->
+ 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).