fix: Various code cleanup (#756)

This commit is contained in:
Kamron Batman 2021-09-03 19:41:12 -07:00 • committed by GitHub
parent f4378acd05
commit dbd4d6f13f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 117 additions and 280 deletions

View file

@ -339,42 +339,21 @@ namespace Server.Items
ar += 10 + 5 * (int)_protection;
}
switch (_resource)
ar += _resource switch
{
case CraftResource.DullCopper:
ar += 2;
break;
case CraftResource.ShadowIron:
ar += 4;
break;
case CraftResource.Copper:
ar += 6;
break;
case CraftResource.Bronze:
ar += 8;
break;
case CraftResource.Gold:
ar += 10;
break;
case CraftResource.Agapite:
ar += 12;
break;
case CraftResource.Verite:
ar += 14;
break;
case CraftResource.Valorite:
ar += 16;
break;
case CraftResource.SpinedLeather:
ar += 10;
break;
case CraftResource.HornedLeather:
ar += 13;
break;
case CraftResource.BarbedLeather:
ar += 16;
break;
}
CraftResource.DullCopper => 2,
CraftResource.ShadowIron => 4,
CraftResource.Copper => 6,
CraftResource.Bronze => 8,
CraftResource.Gold => 10,
CraftResource.Agapite => 12,
CraftResource.Verite => 14,
CraftResource.Valorite => 16,
CraftResource.SpinedLeather => 10,
CraftResource.HornedLeather => 13,
CraftResource.BarbedLeather => 16,
_ => 0
};
ar += -8 + 8 * (int)_quality;
return ScaleArmorByDurability(ar);
@ -557,27 +536,22 @@ namespace Server.Items
BaseEnergyResistance + GetProtOffset() + GetResourceAttrs().ArmorEnergyResist + _energyBonus;
[CommandProperty(AccessLevel.GameMaster)]
public ArmorBodyType BodyPosition
{
get
public ArmorBodyType BodyPosition =>
Layer switch
{
return Layer switch
{
Layer.Neck => ArmorBodyType.Gorget,
Layer.TwoHanded => ArmorBodyType.Shield,
Layer.Gloves => ArmorBodyType.Gloves,
Layer.Helm => ArmorBodyType.Helmet,
Layer.Arms => ArmorBodyType.Arms,
Layer.InnerLegs => ArmorBodyType.Legs,
Layer.OuterLegs => ArmorBodyType.Legs,
Layer.Pants => ArmorBodyType.Legs,
Layer.InnerTorso => ArmorBodyType.Chest,
Layer.OuterTorso => ArmorBodyType.Chest,
Layer.Shirt => ArmorBodyType.Chest,
_ => ArmorBodyType.Gorget
};
}
}
Layer.Neck => ArmorBodyType.Gorget,
Layer.TwoHanded => ArmorBodyType.Shield,
Layer.Gloves => ArmorBodyType.Gloves,
Layer.Helm => ArmorBodyType.Helmet,
Layer.Arms => ArmorBodyType.Arms,
Layer.InnerLegs => ArmorBodyType.Legs,
Layer.OuterLegs => ArmorBodyType.Legs,
Layer.Pants => ArmorBodyType.Legs,
Layer.InnerTorso => ArmorBodyType.Chest,
Layer.OuterTorso => ArmorBodyType.Chest,
Layer.Shirt => ArmorBodyType.Chest,
_ => ArmorBodyType.Gorget
};
public static double[] ArmorScalars { get; set; } = { 0.07, 0.07, 0.14, 0.15, 0.22, 0.35 };
@ -865,20 +839,12 @@ namespace Server.Items
public int ComputeStatReq(StatType type)
{
int v;
if (type == StatType.Str)
int v = type switch
{
v = StrRequirement;
}
else if (type == StatType.Dex)
{
v = DexRequirement;
}
else
{
v = IntRequirement;
}
StatType.Str => StrRequirement,
StatType.Dex => DexRequirement,
_ => IntRequirement
};
return AOS.Scale(v, 100 - GetLowerStatReq());
}
@ -920,17 +886,8 @@ namespace Server.Items
InvalidateProperties();
}
public CraftAttributeInfo GetResourceAttrs()
{
var info = CraftResources.GetInfo(_resource);
if (info == null)
{
return CraftAttributeInfo.Blank;
}
return info.AttributeInfo;
}
public CraftAttributeInfo GetResourceAttrs() =>
CraftResources.GetInfo(_resource)?.AttributeInfo ?? CraftAttributeInfo.Blank;
public int GetProtOffset()
{
@ -946,31 +903,17 @@ namespace Server.Items
public int GetDurabilityBonus()
{
var bonus = 0;
var bonus = _quality == ArmorQuality.Exceptional ? 20 : 0;
if (_quality == ArmorQuality.Exceptional)
bonus += _durability switch
{
bonus += 20;
}
switch (_durability)
{
case ArmorDurabilityLevel.Durable:
bonus += 20;
break;
case ArmorDurabilityLevel.Substantial:
bonus += 50;
break;
case ArmorDurabilityLevel.Massive:
bonus += 70;
break;
case ArmorDurabilityLevel.Fortified:
bonus += 100;
break;
case ArmorDurabilityLevel.Indestructible:
bonus += 120;
break;
}
ArmorDurabilityLevel.Durable => 20,
ArmorDurabilityLevel.Substantial => 50,
ArmorDurabilityLevel.Massive => 70,
ArmorDurabilityLevel.Fortified => 100,
ArmorDurabilityLevel.Indestructible => 120,
_ => 0
};
if (Core.AOS)
{