| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src/shared')
| -rw-r--r-- | src/shared/reply/shr_add_weapon.erl | 1 | ||||
| -rw-r--r-- | src/shared/struct/inventory/shr_inventory.erl | 16 | ||||
| -rw-r--r-- | src/shared/struct/inventory/shr_weapon.erl.m4 | 4 | ||||
| -rw-r--r-- | src/shared/struct/shr_character.erl | 46 | ||||
| -rw-r--r-- | src/shared/struct/shr_omnimods.erl | 28 | 
5 files changed, 50 insertions, 45 deletions
| diff --git a/src/shared/reply/shr_add_weapon.erl b/src/shared/reply/shr_add_weapon.erl index 44a83dd..bd8dfb5 100644 --- a/src/shared/reply/shr_add_weapon.erl +++ b/src/shared/reply/shr_add_weapon.erl @@ -25,6 +25,7 @@ generate (Weapon) ->           {<<"nam">>, shr_weapon:get_name(Weapon)},           {<<"rmi">>, shr_weapon:get_minimum_range(Weapon)},           {<<"rma">>, shr_weapon:get_maximum_range(Weapon)}, +         {<<"pri">>, shr_weapon:get_is_primary(Weapon)},           {<<"omni">>, shr_omnimods:encode(shr_weapon:get_omnimods(Weapon))}        ]     }. diff --git a/src/shared/struct/inventory/shr_inventory.erl b/src/shared/struct/inventory/shr_inventory.erl index 884c213..0396b0a 100644 --- a/src/shared/struct/inventory/shr_inventory.erl +++ b/src/shared/struct/inventory/shr_inventory.erl @@ -273,12 +273,7 @@ default () ->        glyphs = EmptySet     }. --spec allows_equipment -   ( -      (shr_equipment:type()|shr_equipment:unresolved()), -      type() -   ) -   -> boolean(). +-spec allows_equipment (shr_equipment:either(), type()) -> boolean().  allows_equipment (Eq, Inv) ->     Weapons = Inv#inventory.weapons,     Glyphs = Inv#inventory.glyphs, @@ -312,12 +307,7 @@ allows_equipment (Eq, Inv) ->        )     ). --spec add_equipment -   ( -      (shr_equipment:type()|shr_equipment:unresolved()), -      type() -   ) -   -> type(). +-spec add_equipment (shr_equipment:either(), type()) -> type().  add_equipment (Eq, Inv) ->     Inv#inventory     { @@ -360,7 +350,7 @@ add_equipment (Eq, Inv) ->  -spec ataxia_add_equipment     ( -      (shr_equipment:type()|shr_equipment:unresolved()), +      shr_equipment:either(),        type()     )     -> {type(), ataxic:basic()}. diff --git a/src/shared/struct/inventory/shr_weapon.erl.m4 b/src/shared/struct/inventory/shr_weapon.erl.m4 index a18c48e..b2c6734 100644 --- a/src/shared/struct/inventory/shr_weapon.erl.m4 +++ b/src/shared/struct/inventory/shr_weapon.erl.m4 @@ -30,6 +30,7 @@  (     [        get_id/1, +      get_is_primary/1,        get_name/1,        get_minimum_range/1,        get_maximum_range/1, @@ -60,6 +61,9 @@ get_id (Wp) -> Wp#weapon.id.  -spec get_name (type()) -> binary().  get_name (Wp) -> Wp#weapon.name. +-spec get_is_primary (type()) -> boolean(). +get_is_primary (Wp) -> Wp#weapon.is_primary. +  -spec get_minimum_range (type()) -> non_neg_integer().  get_minimum_range (Wp) -> Wp#weapon.range_min. diff --git a/src/shared/struct/shr_character.erl b/src/shared/struct/shr_character.erl index ea8e857..68e6cb6 100644 --- a/src/shared/struct/shr_character.erl +++ b/src/shared/struct/shr_character.erl @@ -69,6 +69,7 @@  -export  (     [ +      new/0,        resolve/2,        to_unresolved/1,        encode/1, @@ -107,6 +108,15 @@ get_equipment_but_weapons_omnimods (Equipment) ->  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec new () -> unresolved(). +new () -> +   #shr_char_ref +   { +      name = <<"Unnamed Character">>, +      equipment = shr_equipment:default_unresolved(), +      is_using_secondary = false +   }. +  %%%% Accessors  -spec get_name (either()) -> binary().  get_name (#shr_char{ name = R }) -> R; @@ -346,18 +356,44 @@ set_extra_omnimods (O, Char) ->  -spec resolve (shr_omnimods:type(), unresolved()) -> type().  resolve (LocalOmnimods, CharRef) -> -   Attributes = shr_attributes:default(),     Eq = shr_equipment:resolve(CharRef#shr_char_ref.equipment), +   EquipmentButWeaponsOmnimods = get_equipment_but_weapons_omnimods(Eq), + +   NewOmnimods = +      shr_omnimods:merge +      ( +         shr_omnimods:merge +         ( +            EquipmentButWeaponsOmnimods, +            shr_weapon:get_omnimods(get_active_weapon(CharRef)) +         ), +         LocalOmnimods +      ), + +   NewAttributes = +      shr_omnimods:apply_to_attributes +      ( +         NewOmnimods, +         shr_attributes:default() +      ), + +   NewStatistics = +      shr_omnimods:apply_to_statistics +      ( +         NewOmnimods, +         shr_statistics:new_raw(NewAttributes) +      ), +     #shr_char     {        name = CharRef#shr_char_ref.name, -      equipment_but_weapons_omnimods = get_equipment_but_weapons_omnimods(Eq), +      equipment_but_weapons_omnimods = EquipmentButWeaponsOmnimods,        equipment = Eq,        is_using_secondary = CharRef#shr_char_ref.is_using_secondary, -      statistics = shr_statistics:new_raw(Attributes), -      attributes = Attributes, -      omnimods = shr_omnimods:default(), +      statistics = NewStatistics, +      attributes = NewAttributes, +      omnimods = NewOmnimods,        extra_omnimods = LocalOmnimods     }. diff --git a/src/shared/struct/shr_omnimods.erl b/src/shared/struct/shr_omnimods.erl index 8d82287..081477d 100644 --- a/src/shared/struct/shr_omnimods.erl +++ b/src/shared/struct/shr_omnimods.erl @@ -29,8 +29,7 @@  (     [        default/0, -      new/4, -      new_dirty/4 +      new/4     ]  ). @@ -64,14 +63,6 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec cleanup_entry_list (list(entry())) -> list(entry()). -cleanup_entry_list (ModList) -> -   [First|Rem] = ModList, -   case First of -      {none, _} -> Rem; -      _ -> ModList -   end. -  -spec apply_coefficient_to_mods (float(), mods()) -> mods().  apply_coefficient_to_mods (Coef, Mods) ->     dict:map(fun (_Name, Val) -> shr_math_util:ceil(Coef * Val) end, Mods). @@ -119,23 +110,6 @@ new (AttributeMods, StatisticMods, AttackMods, DefenseMods) ->  -spec default () -> type().  default () -> new([], [], [], []). --spec new_dirty -( -      list(entry()), -      list(entry()), -      list(entry()), -      list(entry()) -   ) -   -> type(). -new_dirty(AttributeMods, StatisticMods, AttackMods, DefenseMods) -> -   new -   ( -      cleanup_entry_list(AttributeMods), -      cleanup_entry_list(StatisticMods), -      cleanup_entry_list(AttackMods), -      cleanup_entry_list(DefenseMods) -   ). -  %%% Modification  -spec merge (type(), type()) -> type().  merge (OmniA, OmniB) -> | 


