| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-10-05 15:41:03 +0200 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-10-05 15:41:03 +0200 | 
| commit | 2e2bfd2d0d3bc52db4274ddc3dd1778c77ac5868 (patch) | |
| tree | ed2f4fc5c07bdcd53514c51910e0d8094ef67cf2 /src/shared | |
| parent | 0d8e11193bf166758c2d9c46190b07b9b76f2958 (diff) | |
(Broken) Working on the addition of glyphs & their boards.
Diffstat (limited to 'src/shared')
| -rw-r--r-- | src/shared/struct/shr_glyph.erl.m4 (renamed from src/shared/struct/shr_glyph.erl) | 43 | ||||
| -rw-r--r-- | src/shared/struct/shr_glyph_board.erl | 21 | ||||
| -rw-r--r-- | src/shared/struct/shr_glyph_board.erl.m4 | 105 | 
3 files changed, 147 insertions, 22 deletions
| diff --git a/src/shared/struct/shr_glyph.erl b/src/shared/struct/shr_glyph.erl.m4 index cb971d1..cd59a27 100644 --- a/src/shared/struct/shr_glyph.erl +++ b/src/shared/struct/shr_glyph.erl.m4 @@ -5,12 +5,40 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  -type id() :: binary(). --export_type([id/0]). +-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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -18,4 +46,17 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% 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/shr_glyph_board.erl b/src/shared/struct/shr_glyph_board.erl deleted file mode 100644 index ad1545f..0000000 --- a/src/shared/struct/shr_glyph_board.erl +++ /dev/null @@ -1,21 +0,0 @@ --module(shr_glyph_board). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type id() :: binary(). - --export_type([id/0]). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - 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). | 


