summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2019-04-26 17:45:48 +0200 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2019-04-26 17:45:48 +0200 |
commit | a7c6455285cfd3a671078be4e58df0afae07bf0c (patch) | |
tree | b06531c2423e0fa6a1f60ace83b5e03a40067262 /src/roster/struct/rst_character.erl | |
parent | ec6eec260d6383ae948505c3d42b3055ae3dd94c (diff) |
...
Diffstat (limited to 'src/roster/struct/rst_character.erl')
-rw-r--r-- | src/roster/struct/rst_character.erl | 239 |
1 files changed, 0 insertions, 239 deletions
diff --git a/src/roster/struct/rst_character.erl b/src/roster/struct/rst_character.erl deleted file mode 100644 index 61d7b7e..0000000 --- a/src/roster/struct/rst_character.erl +++ /dev/null @@ -1,239 +0,0 @@ --module(rst_character). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - rst_char, - { - name :: binary(), - portrait_id :: shr_portrait:id(), - weapon_ids :: {shr_weapon:id(), shr_weapon:id()}, - armor_id :: shr_armor:id(), - glyph_ids :: list(shr_glyph:id()), - glyph_board_id :: shr_glyph_board:id() - } -). - --opaque type() :: #rst_char{}. - --export_type([type/0]). -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_name/1, - get_portrait_id/1, - get_weapon_ids/1, - get_armor_id/1, - get_glyph_ids/1, - get_glyph_board_id/1, - - set_name/2, - set_portrait_id/2, - set_weapon_ids/2, - set_armor_id/2, - set_glyph_ids/2, - set_glyph_board_id/2, - - get_name_field/0, - get_portrait_id_field/0, - get_weapon_ids_field/0, - get_armor_id_field/0, - get_glyph_ids_field/0, - get_glyph_board_id_field/0 - ] -). - --export -( - [ - decode/1, - new/0 - ] -). - --export -( - [ - validate/2 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec validate_name (binary()) -> ok. -validate_name (_Name) -> - % TODO [SECURITY][LOW]: unimplemented - ok. - --spec validate_portrait_id (shr_inventory:type(), shr_portrait:id()) -> ok. -validate_portrait_id (_Inventory, _Portrait) -> - % TODO [SECURITY][LOW]: unimplemented - ok. - --spec validate_weapons - ( - shr_inventory:type(), - {shr_weapon:id(), shr_weapon:id()} - ) - -> ok. -validate_weapons (_Inventory, {_ActiveWeapon, _SecondaryWeapon}) -> - % TODO [SECURITY][LOW]: unimplemented - ok. - --spec validate_armor (shr_inventory:type(), shr_armor:id()) -> ok. -validate_armor (_Inventory, _Armor) -> - % TODO [SECURITY][LOW]: unimplemented - ok. - --spec validate_glyphs (shr_inventory:type(), list(shr_glyph:id())) -> ok. -validate_glyphs (_Inventory, _Glyphs) -> - % TODO [SECURITY][LOW]: unimplemented - ok. - --spec validate_glyph_board (shr_inventory:type(), shr_glyph_board:id()) -> ok. -validate_glyph_board (_Inventory, _GlyphBoard) -> - % TODO [SECURITY][LOW]: unimplemented - ok. - --spec validate_glyphs_on_board - ( - list(shr_glyph:id()), - shr_glyph_board:id() - ) - -> ok. -validate_glyphs_on_board (_Glyphs, _GlyphBoard) -> - % TODO [SECURITY][LOW]: unimplemented - ok. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --spec get_name (type()) -> binary(). -get_name (Char) -> Char#rst_char.name. - --spec get_portrait_id (type()) -> shr_portrait:id(). -get_portrait_id (Char) -> Char#rst_char.portrait_id. - --spec get_weapon_ids (type()) -> {shr_weapon:id(), shr_weapon:id()}. -get_weapon_ids (Char) -> Char#rst_char.weapon_ids. - --spec get_armor_id (type()) -> shr_armor:id(). -get_armor_id (Char) -> Char#rst_char.armor_id. - --spec get_glyph_ids (type()) -> list(shr_glyph:id()). -get_glyph_ids (Char) -> Char#rst_char.glyph_ids. - --spec get_glyph_board_id (type()) -> shr_glyph_board:id(). -get_glyph_board_id (Char) -> Char#rst_char.glyph_board_id. - - --spec set_name (binary(), type()) -> type(). -set_name (Name, Char) -> - Char#rst_char - { - name = Name - }. - --spec set_portrait_id (shr_portrait:id(), type()) -> type(). -set_portrait_id (PortraitID, Char) -> - Char#rst_char - { - portrait_id = PortraitID - }. - --spec set_armor_id (shr_armor:id(), type()) -> type(). -set_armor_id (ArmorID, Char) -> - Char#rst_char - { - armor_id = ArmorID - }. - --spec set_weapon_ids ({shr_weapon:id(), shr_weapon:id()}, type()) -> type(). -set_weapon_ids (WeaponIDs, Char) -> - Char#rst_char - { - weapon_ids = WeaponIDs - }. - --spec set_glyph_ids (list(shr_glyph:id()), type()) -> type(). -set_glyph_ids (GlyphIDs, Char) -> - Char#rst_char - { - glyph_ids = GlyphIDs - }. - --spec set_glyph_board_id (shr_glyph_board:id(), type()) -> type(). -set_glyph_board_id (GlyphBoardID, Char) -> - Char#rst_char - { - glyph_board_id = GlyphBoardID - }. - --spec new () -> type(). -new () -> - UnarmedID = shr_weapon:get_id(shr_weapon:none()), - #rst_char - { - name = <<"Nameless">>, - portrait_id = shr_portrait:get_id(shr_portrait:default()), - weapon_ids = {UnarmedID, UnarmedID}, - armor_id = shr_armor:get_id(shr_armor:none()), - glyph_ids = [], - glyph_board_id = shr_glyph_board:get_id(shr_glyph_board:none()) - }. - --spec get_name_field () -> non_neg_integer(). -get_name_field () -> #rst_char.name. --spec get_portrait_id_field () -> non_neg_integer(). -get_portrait_id_field () -> #rst_char.portrait_id. --spec get_armor_id_field () -> non_neg_integer(). -get_armor_id_field () -> #rst_char.armor_id. --spec get_weapon_ids_field () -> non_neg_integer(). -get_weapon_ids_field () -> #rst_char.weapon_ids. --spec get_glyph_ids_field () -> non_neg_integer(). -get_glyph_ids_field () -> #rst_char.glyph_ids. --spec get_glyph_board_id_field () -> non_neg_integer(). -get_glyph_board_id_field () -> #rst_char.glyph_board_id. - --spec decode (map()) -> type(). -decode (JSONReqMap) -> - Name = maps:get(<<"nam">>, JSONReqMap), - Portrait = maps:get(<<"prt">>, JSONReqMap), - ActiveWeapon = maps:get(<<"awp">>, JSONReqMap), - SecondaryWeapon = maps:get(<<"swp">>, JSONReqMap), - Armor = maps:get(<<"ar">>, JSONReqMap), - GlyphsList = maps:get(<<"gls">>, JSONReqMap), - GlyphBoard = maps:get(<<"gb">>, JSONReqMap), - - #rst_char - { - name = Name, - portrait_id = Portrait, - weapon_ids = {ActiveWeapon, SecondaryWeapon}, - armor_id = Armor, - glyph_ids = GlyphsList, - glyph_board_id = GlyphBoard - }. - --spec validate (shr_inventory:type(), type()) -> ok. -validate (Inventory, Character) -> - Glyphs = Character#rst_char.glyph_ids, - GlyphBoard = Character#rst_char.glyph_board_id, - - validate_name(Character#rst_char.name), - validate_portrait_id(Inventory, Character#rst_char.portrait_id), - validate_weapons(Inventory, Character#rst_char.weapon_ids), - validate_armor(Inventory, Character#rst_char.armor_id), - validate_glyphs(Inventory, Glyphs), - validate_glyph_board(Inventory, GlyphBoard), - validate_glyphs_on_board(Glyphs, GlyphBoard), - - ok. |