refactor(armor): fold lower-requirements into AosArmorAttributes.GetProperties
LowerStatReq (1060435) now emitted inside AosArmorAttributes.GetProperties in cliloc order (ahead of MageArmor/SelfRepair), via a passed-in value: armor passes the computed GetLowerStatReq() (raw + resource ArmorLowerRequirements), clothing passes its raw ClothingAttributes.LowerStatReq. Removes the inline line from both item bases.
This commit is contained in:
parent
12cbf7eea9
commit
27d00ba63a
4 changed files with 29 additions and 18 deletions
|
|
@ -36,23 +36,36 @@ public class AosArmorAttributesPropertiesTests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void EmitsMageArmorAndSelfRepairOnly()
|
||||
public void EmitsMageArmorAndSelfRepair_DoesNotReadLowerStatReqOrDurabilityFromContainer()
|
||||
{
|
||||
var attrs = new AosArmorAttributes(null)
|
||||
{
|
||||
MageArmor = 1,
|
||||
SelfRepair = 4,
|
||||
LowerStatReq = 50, // must NOT be emitted here
|
||||
DurabilityBonus = 10 // must NOT be emitted here
|
||||
LowerStatReq = 50, // container value must NOT be auto-emitted (it's passed in by the consumer)
|
||||
DurabilityBonus = 10 // never emitted by this method
|
||||
};
|
||||
|
||||
var opl = new ObjectPropertyList(null);
|
||||
attrs.GetProperties(opl);
|
||||
attrs.GetProperties(opl); // no lowerStatReq arg
|
||||
var map = Decode(opl);
|
||||
|
||||
Assert.Equal("", map[1060437]); // MageArmor (no-arg)
|
||||
Assert.Equal("4", map[1060450]); // SelfRepair
|
||||
Assert.False(map.ContainsKey(1060435)); // LowerStatReq excluded
|
||||
Assert.False(map.ContainsKey(1060435)); // LowerStatReq NOT read from container
|
||||
Assert.False(map.ContainsKey(1060410)); // DurabilityBonus excluded
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmitsLowerStatReqWhenPassed()
|
||||
{
|
||||
var attrs = new AosArmorAttributes(null) { MageArmor = 1, LowerStatReq = 50 };
|
||||
|
||||
var opl = new ObjectPropertyList(null);
|
||||
attrs.GetProperties(opl, lowerStatReq: 77); // computed value passed by the consumer, not the raw 50
|
||||
var map = Decode(opl);
|
||||
|
||||
Assert.Equal("77", map[1060435]); // emitted from the param, not the container's 50
|
||||
Assert.Equal("", map[1060437]); // MageArmor still emitted
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1323,12 +1323,7 @@ namespace Server.Items
|
|||
list.Add(1061078, prop); // artifact rarity ~1_val~
|
||||
}
|
||||
|
||||
ArmorAttributes.GetProperties(list);
|
||||
|
||||
if ((prop = GetLowerStatReq()) != 0)
|
||||
{
|
||||
list.Add(1060435, prop); // lower requirements ~1_val~%
|
||||
}
|
||||
ArmorAttributes.GetProperties(list, lowerStatReq: GetLowerStatReq());
|
||||
|
||||
Attributes.GetProperties(list, luckBonus: GetLuckBonus());
|
||||
|
||||
|
|
|
|||
|
|
@ -754,12 +754,7 @@ namespace Server.Items
|
|||
list.Add(1061078, prop); // artifact rarity ~1_val~
|
||||
}
|
||||
|
||||
ClothingAttributes.GetProperties(list);
|
||||
|
||||
if ((prop = ClothingAttributes.LowerStatReq) != 0)
|
||||
{
|
||||
list.Add(1060435, prop); // lower requirements ~1_val~%
|
||||
}
|
||||
ClothingAttributes.GetProperties(list, lowerStatReq: ClothingAttributes.LowerStatReq);
|
||||
|
||||
Attributes.GetProperties(list);
|
||||
|
||||
|
|
|
|||
|
|
@ -1198,10 +1198,18 @@ namespace Server
|
|||
return value;
|
||||
}
|
||||
|
||||
public void GetProperties(IPropertyList list)
|
||||
// lowerStatReq is passed in because consumers compute it differently: armor folds in the
|
||||
// resource's ArmorLowerRequirements via GetLowerStatReq(), clothing reads it raw. Emitted in
|
||||
// cliloc order (1060435) ahead of MageArmor/SelfRepair.
|
||||
public void GetProperties(IPropertyList list, int lowerStatReq = 0)
|
||||
{
|
||||
int prop;
|
||||
|
||||
if (lowerStatReq != 0)
|
||||
{
|
||||
list.Add(1060435, lowerStatReq); // lower requirements ~1_val~%
|
||||
}
|
||||
|
||||
if (MageArmor != 0)
|
||||
{
|
||||
list.Add(1060437); // mage armor
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue