Skip to content

Commit

Permalink
fix: Various code cleanup (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Sep 4, 2021
1 parent f4378ac commit dbd4d6f
Show file tree
Hide file tree
Showing 40 changed files with 118 additions and 281 deletions.
1 change: 0 additions & 1 deletion Projects/Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Running;

namespace Benchmarks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/

using System.Collections.Immutable;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis;
using SerializableMigration;
Expand Down
1 change: 0 additions & 1 deletion Projects/UOContent/Engines/ConPVP/Games/CTF.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Server.Gumps;
using Server.Items;
Expand Down
6 changes: 3 additions & 3 deletions Projects/UOContent/Engines/Ethics/Evil/Powers/UnholySense.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using System.Text;
using Server.Buffers;
using Server.Network;

namespace Server.Ethics.Evil
Expand Down Expand Up @@ -46,15 +46,15 @@ public override void BeginInvoke(Player from)
++enemyCount;
}

var sb = new StringBuilder();
using var sb = new ValueStringBuilder();

sb.Append("You sense ");
sb.Append(enemyCount == 0 ? "no" : enemyCount.ToString());
sb.Append(enemyCount == 1 ? " enemy" : " enemies");

if (primary != null)
{
sb.Append(", and a strong presense");
sb.Append(", and a strong presence");

switch (from.Mobile.GetDirectionTo(primary.Mobile))
{
Expand Down
6 changes: 3 additions & 3 deletions Projects/UOContent/Engines/Ethics/Hero/Powers/HolySense.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using System.Text;
using Server.Buffers;
using Server.Network;

namespace Server.Ethics.Hero
Expand Down Expand Up @@ -46,15 +46,15 @@ public override void BeginInvoke(Player from)
++enemyCount;
}

var sb = new StringBuilder();
using var sb = new ValueStringBuilder();

sb.Append("You sense ");
sb.Append(enemyCount == 0 ? "no" : enemyCount.ToString());
sb.Append(enemyCount == 1 ? " enemy" : " enemies");

if (primary != null)
{
sb.Append(", and a strong presense");
sb.Append(", and a strong presence");

switch (from.Mobile.GetDirectionTo(primary.Mobile))
{
Expand Down
1 change: 0 additions & 1 deletion Projects/UOContent/Engines/Khaldun/RaiseSwitch.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using Server.Network;

namespace Server.Items
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
1 change: 0 additions & 1 deletion Projects/UOContent/Engines/ML Quests/Definitions/Bedlam.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
4 changes: 1 addition & 3 deletions Projects/UOContent/Engines/ML Quests/Definitions/Ilshenar.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
1 change: 0 additions & 1 deletion Projects/UOContent/Engines/ML Quests/Definitions/Malas.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Server.Engines.MLQuests.Items;
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Items;
using Server.Mobiles;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Linq;
using Server.Gumps;
using Server.Multis;
using Server.Network;
Expand Down
149 changes: 46 additions & 103 deletions Projects/UOContent/Items/Armor/BaseArmor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,42 +339,21 @@ public virtual double ArmorRating
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);
Expand Down Expand Up @@ -557,27 +536,22 @@ public virtual double ArmorScalar
BaseEnergyResistance + GetProtOffset() + GetResourceAttrs().ArmorEnergyResist + _energyBonus;

[CommandProperty(AccessLevel.GameMaster)]
public ArmorBodyType BodyPosition
{
get
{
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
};
}
}
public ArmorBodyType BodyPosition =>
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
};

public static double[] ArmorScalars { get; set; } = { 0.07, 0.07, 0.14, 0.15, 0.22, 0.35 };

Expand Down Expand Up @@ -865,20 +839,12 @@ public override void OnAfterDuped(Item newItem)

public int ComputeStatReq(StatType type)
{
int v;

if (type == StatType.Str)
{
v = StrRequirement;
}
else if (type == StatType.Dex)
{
v = DexRequirement;
}
else
int v = type switch
{
v = IntRequirement;
}
StatType.Str => StrRequirement,
StatType.Dex => DexRequirement,
_ => IntRequirement
};

return AOS.Scale(v, 100 - GetLowerStatReq());
}
Expand Down Expand Up @@ -920,17 +886,8 @@ public void DistributeBonuses(int amount)
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()
{
Expand All @@ -946,31 +903,17 @@ public int GetProtOffset()

public int GetDurabilityBonus()
{
var bonus = 0;

if (_quality == ArmorQuality.Exceptional)
{
bonus += 20;
}
var bonus = _quality == ArmorQuality.Exceptional ? 20 : 0;

switch (_durability)
bonus += _durability switch
{
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)
{
Expand Down
1 change: 0 additions & 1 deletion Projects/UOContent/Items/Containers/MarkContainer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;

namespace Server.Items
{
Expand Down
Loading

0 comments on commit dbd4d6f

Please sign in to comment.