| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2019-04-26 15:05:44 +0200 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2019-04-26 15:05:44 +0200 | 
| commit | ec6eec260d6383ae948505c3d42b3055ae3dd94c (patch) | |
| tree | 1d9ab2b09ab0a534fc6c09b62b940d9f1c7e139f /src/shared/struct/inventory/shr_inventory.erl | |
| parent | 7d428bac2f9d62c5a0e704eb32be869c10fec72e (diff) | |
Makes Dialyzer validate shared & battle.
Diffstat (limited to 'src/shared/struct/inventory/shr_inventory.erl')
| -rw-r--r-- | src/shared/struct/inventory/shr_inventory.erl | 48 | 
1 files changed, 28 insertions, 20 deletions
| diff --git a/src/shared/struct/inventory/shr_inventory.erl b/src/shared/struct/inventory/shr_inventory.erl index 4ea3e7b..884c213 100644 --- a/src/shared/struct/inventory/shr_inventory.erl +++ b/src/shared/struct/inventory/shr_inventory.erl @@ -22,8 +22,9 @@  ).  -opaque type() :: #inventory{}. +-type id() :: ataxia_id:type(). --export_type([type/0]). +-export_type([type/0, id/0]).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -95,19 +96,27 @@ get_glyphs (Inv) -> Inv#inventory.glyphs.  -spec add_weapon (shr_weapon:id(), type()) -> type(). -add_weapon (V, Inv) -> Inv#inventory{ weapons = V }. +add_weapon (V, Inv) -> +   Inv#inventory{ weapons = ordsets:add_element(V, Inv#inventory.weapons) }.  -spec add_armor (shr_armor:id(), type()) -> type(). -add_armor (V, Inv) -> Inv#inventory{ armors = V }. +add_armor (V, Inv) -> +   Inv#inventory{ armors = ordsets:add_element(V, Inv#inventory.armors) }.  -spec add_portrait (shr_portrait:id(), type()) -> type(). -add_portrait (V, Inv) -> Inv#inventory{ portraits = V }. +add_portrait (V, Inv) -> +   Inv#inventory{ portraits = ordsets:add_element(V, Inv#inventory.portraits) }.  -spec add_glyph_board (shr_glyph_board:id(), type()) -> type(). -add_glyph_board (V, Inv) -> Inv#inventory{ glyph_boards = V }. +add_glyph_board (V, Inv) -> +   Inv#inventory +   { +      glyph_boards = ordsets:add_element(V, Inv#inventory.glyph_boards) +   }.  -spec add_glyph (shr_glyph:id(), type()) -> type(). -add_glyph (V, Inv) -> Inv#inventory{ glyphs = V }. +add_glyph (V, Inv) -> +   Inv#inventory{ glyphs = ordsets:add_element(V, Inv#inventory.glyphs) }.  -spec ataxia_add_weapon @@ -115,12 +124,12 @@ add_glyph (V, Inv) -> Inv#inventory{ glyphs = V }.        shr_weapon:id(),        type()     ) -   -> {type(), list(ataxic:basic())}. +   -> {type(), ataxic:basic()}.  ataxia_add_weapon (V, Inv) ->     CurrentWeapons = Inv#inventory.weapons,     case ordsets:is_element(V, CurrentWeapons) of -      true -> Inv; +      true -> {Inv, ataxic:current_value()};        false ->           {              Inv#inventory{ weapons = ordsets:add_element(V, CurrentWeapons) }, @@ -142,12 +151,12 @@ ataxia_add_weapon (V, Inv) ->        shr_armor:id(),        type()     ) -   -> {type(), list(ataxic:basic())}. +   -> {type(), ataxic:basic()}.  ataxia_add_armor (V, Inv) ->     CurrentArmors = Inv#inventory.armors,     case ordsets:is_element(V, CurrentArmors) of -      true -> Inv; +      true -> {Inv, ataxic:current_value()};        false ->           {              Inv#inventory{ armors = ordsets:add_element(V, CurrentArmors) }, @@ -169,12 +178,12 @@ ataxia_add_armor (V, Inv) ->        shr_portrait:id(),        type()     ) -   -> {type(), list(ataxic:basic())}. +   -> {type(), ataxic:basic()}.  ataxia_add_portrait (V, Inv) ->     CurrentPortraits = Inv#inventory.portraits,     case ordsets:is_element(V, CurrentPortraits) of -      true -> Inv; +      true -> {Inv, ataxic:current_value()};        false ->           {              Inv#inventory @@ -199,12 +208,12 @@ ataxia_add_portrait (V, Inv) ->        shr_glyph_board:id(),        type()     ) -   -> {type(), list(ataxic:basic())}. +   -> {type(), ataxic:basic()}.  ataxia_add_glyph_board (V, Inv) ->     CurrentGlyphBoards = Inv#inventory.glyph_boards,     case ordsets:is_element(V, CurrentGlyphBoards) of -      true -> Inv; +      true -> {Inv, ataxic:current_value()};        false ->           {              Inv#inventory @@ -229,12 +238,12 @@ ataxia_add_glyph_board (V, Inv) ->        shr_glyph:id(),        type()     ) -   -> {type(), list(ataxic:basic())}. +   -> {type(), ataxic:basic()}.  ataxia_add_glyph (V, Inv) ->     CurrentGlyphs = Inv#inventory.glyphs,     case ordsets:is_element(V, CurrentGlyphs) of -      true -> Inv; +      true -> {Inv, ataxic:current_value()};        false ->           {              Inv#inventory{ glyphs = ordsets:add_element(V, CurrentGlyphs) }, @@ -354,7 +363,7 @@ add_equipment (Eq, Inv) ->        (shr_equipment:type()|shr_equipment:unresolved()),        type()     ) -   -> {type(), list(ataxic:basic())}. +   -> {type(), ataxic:basic()}.  ataxia_add_equipment (Eq, Inv) ->     {S0Inv, Ataxic0} =        ataxia_add_weapon(shr_equipment:get_primary_weapon_id(Eq), Inv), @@ -380,10 +389,9 @@ ataxia_add_equipment (Eq, Inv) ->     {        S4Inv, -      lists:flatten +      ataxic:optimize        ( -         [Ataxic0, Ataxic1, Ataxic2, Ataxic3], -         lists:flatten(Ataxic4s) +         ataxic:sequence([Ataxic0, Ataxic1, Ataxic2, Ataxic3|Ataxic4s])        )     }. | 


