| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/query/qry_shim.erl | 16 | ||||
| -rw-r--r-- | src/roster/reply/rst_add_char.erl | 2 | ||||
| -rw-r--r-- | src/roster/struct/rst_character.erl | 31 | ||||
| -rw-r--r-- | src/shared/struct/shr_armor.erl.m4 | 6 | ||||
| -rw-r--r-- | src/shared/struct/shr_glyph_board.erl.m4 | 6 | ||||
| -rw-r--r-- | src/shared/struct/shr_portrait.erl.m4 | 8 | ||||
| -rw-r--r-- | src/shared/struct/shr_weapon.erl.m4 | 6 | ||||
| -rw-r--r-- | src/special/spe_battle.erl | 2 | 
8 files changed, 55 insertions, 22 deletions
diff --git a/src/query/qry_shim.erl b/src/query/qry_shim.erl index 666f7ec..1fba3f3 100644 --- a/src/query/qry_shim.erl +++ b/src/query/qry_shim.erl @@ -18,4 +18,20 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  -spec fill_db () -> 'ok'.  fill_db () -> +   P0 = +      spe_player:generate +      ( +         <<"Player1">>, +         <<"Kalimer0">>, +         <<"Player1@tacticians.online">> +      ), + +   P1 = +      spe_player:generate +      ( +         <<"Player2">>, +         <<"Kalimer1">>, +         <<"Player2@tacticians.online">> +      ), +     ok. diff --git a/src/roster/reply/rst_add_char.erl b/src/roster/reply/rst_add_char.erl index 1e0d1da..908ce3e 100644 --- a/src/roster/reply/rst_add_char.erl +++ b/src/roster/reply/rst_add_char.erl @@ -33,7 +33,7 @@ generate (IX, Character) ->           {<<"awp">>, ActiveWeapon},           {<<"swp">>, SecondaryWeapon},           {<<"ar">>, rst_character:get_armor_id(Character)}, -         {<<"gls">>, array:to_list(rst_character:get_glyph_ids(Character))}, +         {<<"gls">>, rst_character:get_glyph_ids(Character)},           {<<"gb">>, rst_character:get_glyph_board_id(Character)}        ]     }. diff --git a/src/roster/struct/rst_character.erl b/src/roster/struct/rst_character.erl index afe370d..2a159e4 100644 --- a/src/roster/struct/rst_character.erl +++ b/src/roster/struct/rst_character.erl @@ -11,7 +11,7 @@        portrait_id :: shr_portrait:id(),        weapon_ids :: {shr_weapon:id(), shr_weapon:id()},        armor_id :: shr_armor:id(), -      glyph_ids :: array:array(shr_glyph:id()), +      glyph_ids :: list(shr_glyph:id()),        glyph_board_id :: shr_glyph_board:id()     }  ). @@ -53,7 +53,7 @@  (     [        decode/1, -      random/0 +      new/0     ]  ). @@ -92,7 +92,7 @@ validate_armor (_Inventory, _Armor) ->     % TODO [SECURITY][LOW]: unimplemented     ok. --spec validate_glyphs (shr_inventory:type(), array:array(shr_glyph:id())) -> ok. +-spec validate_glyphs (shr_inventory:type(), list(shr_glyph:id())) -> ok.  validate_glyphs (_Inventory, _Glyphs) ->     % TODO [SECURITY][LOW]: unimplemented     ok. @@ -104,7 +104,7 @@ validate_glyph_board (_Inventory, _GlyphBoard) ->  -spec validate_glyphs_on_board     ( -      array:array(shr_glyph:id()), +      list(shr_glyph:id()),        shr_glyph_board:id()     )     -> ok. @@ -128,7 +128,7 @@ get_weapon_ids (Char) -> Char#character.weapon_ids.  -spec get_armor_id (type()) -> shr_armor:id().  get_armor_id (Char) -> Char#character.armor_id. --spec get_glyph_ids (type()) -> array:array(shr_glyph:id()). +-spec get_glyph_ids (type()) -> list(shr_glyph:id()).  get_glyph_ids (Char) -> Char#character.glyph_ids.  -spec get_glyph_board_id (type()) -> shr_glyph_board:id(). @@ -163,7 +163,7 @@ set_weapon_ids (WeaponIDs, Char) ->        weapon_ids = WeaponIDs     }. --spec set_glyph_ids (array:array(shr_glyph:id()), type()) -> type(). +-spec set_glyph_ids (list(shr_glyph:id()), type()) -> type().  set_glyph_ids (GlyphIDs, Char) ->     Char#character     { @@ -177,16 +177,17 @@ set_glyph_board_id (GlyphBoardID, Char) ->        glyph_board_id = GlyphBoardID     }. --spec random () -> type(). -random () -> +-spec new () -> type(). +new () -> +   UnarmedID = shr_weapon:get_id(shr_weapon:none()),     #character     { -      name = <<"">>, -      portrait_id = <<"0">>, -      weapon_ids = {0, 0}, -      armor_id = 0, -      glyph_ids = array:new(), -      glyph_board_id = <<"0">> +      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(). @@ -218,7 +219,7 @@ decode (JSONReqMap) ->        portrait_id = Portrait,        weapon_ids = {ActiveWeapon, SecondaryWeapon},        armor_id = Armor, -      glyph_ids = array:from_list(GlyphsList), +      glyph_ids = GlyphsList,        glyph_board_id = GlyphBoard     }. diff --git a/src/shared/struct/shr_armor.erl.m4 b/src/shared/struct/shr_armor.erl.m4 index 01d810a..a72331a 100644 --- a/src/shared/struct/shr_armor.erl.m4 +++ b/src/shared/struct/shr_armor.erl.m4 @@ -36,6 +36,7 @@  (     [        random_id/0, +      none/0,        from_id/1     ]  ). @@ -62,7 +63,10 @@ get_omnimods (Ar) -> Ar#armor.omnimods.  m4_include(__MAKEFILE_DATA_DIR/armor/global.m4.conf)m4_dnl  m4_include(__MAKEFILE_DATA_DIR/armor/basic.m4d)m4_dnl  from_id(_) -> -   from_id(0). +   none(). + +-spec none () -> type(). +none () -> from_id(0).  -spec random_id () -> id().  random_id () -> shr_roll:between(0, 4). diff --git a/src/shared/struct/shr_glyph_board.erl.m4 b/src/shared/struct/shr_glyph_board.erl.m4 index 1631441..7fe77b1 100644 --- a/src/shared/struct/shr_glyph_board.erl.m4 +++ b/src/shared/struct/shr_glyph_board.erl.m4 @@ -43,6 +43,7 @@  -export  (     [ +      none/0,        get_omnimods_with_glyphs/2     ]  ). @@ -90,7 +91,10 @@ get_slots (GlyphBoard) -> GlyphBoard#glyph_board.slots.  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">>). +   none(). + +-spec none () -> type(). +none () -> from_id(<<"0">>).  -spec get_omnimods_with_glyphs     ( diff --git a/src/shared/struct/shr_portrait.erl.m4 b/src/shared/struct/shr_portrait.erl.m4 index e009527..fefc434 100644 --- a/src/shared/struct/shr_portrait.erl.m4 +++ b/src/shared/struct/shr_portrait.erl.m4 @@ -37,7 +37,8 @@  -export  (     [ -      from_id/1 +      from_id/1, +      default/0     ]  ). @@ -66,4 +67,7 @@ get_icon_id (Pt) -> Pt#portrait.icon_id.  m4_include(__MAKEFILE_DATA_DIR/portrait/global.m4.conf)m4_dnl  m4_include(__MAKEFILE_DATA_DIR/portrait/basic.m4d)m4_dnl  from_id(_) -> -   from_id(<<"cat">>). +   default(). + +-spec default () -> type(). +default () -> from_id(<<"cat">>). diff --git a/src/shared/struct/shr_weapon.erl.m4 b/src/shared/struct/shr_weapon.erl.m4 index 55c2815..ccda881 100644 --- a/src/shared/struct/shr_weapon.erl.m4 +++ b/src/shared/struct/shr_weapon.erl.m4 @@ -40,6 +40,7 @@  (     [        random_id/0, +      none/0,        from_id/1     ]  ). @@ -71,7 +72,10 @@ get_omnimods (Wp) -> Wp#weapon.omnimods.  m4_include(__MAKEFILE_DATA_DIR/weapon/global.m4.conf)m4_dnl  m4_include(__MAKEFILE_DATA_DIR/weapon/basic.m4d)m4_dnl  from_id (_) -> -   from_id(0). +   none(). + +-spec none () -> type(). +none () -> from_id(0).  -spec random_id () -> id().  random_id () -> shr_roll:between(0, 24). diff --git a/src/special/spe_battle.erl b/src/special/spe_battle.erl index c494f50..fe18da1 100644 --- a/src/special/spe_battle.erl +++ b/src/special/spe_battle.erl @@ -110,7 +110,7 @@ get_glyphs_omnimods (RosterChar) ->     GlyphBoardID = rst_character:get_glyph_board_id(RosterChar),     GlyphIDs = rst_character:get_glyph_ids(RosterChar),     GlyphBoard = shr_glyph_board:from_id(GlyphBoardID), -   Glyphs = lists:map(fun shr_glyph:from_id/1, array:sparse_to_list(GlyphIDs)), +   Glyphs = lists:map(fun shr_glyph:from_id/1, GlyphIDs),     case shr_glyph_board:get_omnimods_with_glyphs(Glyphs, GlyphBoard) of        {ok, Result} -> Result;        error -> shr_omnimods:new([], [], [], [])  | 


