diff --git a/Projects/UOContent/Engines/Virtues/Compassion.cs b/Projects/UOContent/Engines/Virtues/Compassion.cs index e16089cf6..b80351d33 100644 --- a/Projects/UOContent/Engines/Virtues/Compassion.cs +++ b/Projects/UOContent/Engines/Virtues/Compassion.cs @@ -20,7 +20,7 @@ namespace Server public static void CheckAtrophy(Mobile from) { - if (!(from is PlayerMobile pm)) + if (from is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Engines/Virtues/Honor.cs b/Projects/UOContent/Engines/Virtues/Honor.cs index 4518142ea..c22b46493 100644 --- a/Projects/UOContent/Engines/Virtues/Honor.cs +++ b/Projects/UOContent/Engines/Virtues/Honor.cs @@ -24,7 +24,7 @@ namespace Server } } - private static int GetHonorDuration(PlayerMobile from) + private static int GetHonorDuration(Mobile from) { return VirtueHelper.GetLevel(from, VirtueName.Honor) switch { @@ -56,9 +56,9 @@ namespace Server var remainingMinutes = (int)Math.Ceiling(remainingTime.TotalMinutes); pm.SendLocalizedMessage( - 1063240, + 1063240, // You must wait ~1_HONOR_WAIT~ minutes before embracing honor again remainingMinutes.ToString() - ); // You must wait ~1_HONOR_WAIT~ minutes before embracing honor again + ); return; } @@ -130,7 +130,7 @@ namespace Server return; } - if (target.Body.IsHuman && (!(target is BaseCreature cret) || !cret.AlwaysAttackable && !cret.AlwaysMurderer)) + if (target.Body.IsHuman && (target is not BaseCreature cret || !cret.AlwaysAttackable && !cret.AlwaysMurderer)) { if (reg?.IsDisabled() != true) { @@ -143,7 +143,7 @@ namespace Server else { source.SendLocalizedMessage(1001018); // You cannot perform negative acts - return; // cannot honor in trammel town on blue + return; // cannot honor in trammel town on blue } } @@ -155,7 +155,7 @@ namespace Server source.SentHonorContext?.Cancel(); - new HonorContext(source, target); + _ = new HonorContext(source, target); source.Direction = source.GetDirectionTo(target); @@ -171,7 +171,7 @@ namespace Server protected override void OnTarget(Mobile from, object targeted) { - if (!(from is PlayerMobile pm)) + if (from is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Engines/Virtues/Justice.cs b/Projects/UOContent/Engines/Virtues/Justice.cs index ab321802d..1b5c7f7a8 100644 --- a/Projects/UOContent/Engines/Virtues/Justice.cs +++ b/Projects/UOContent/Engines/Virtues/Justice.cs @@ -29,25 +29,10 @@ namespace Server return GetMapRegion(map, first.Location) == GetMapRegion(map, second.Location); } - public static int GetMapRegion(Map map, Point3D loc) - { - if (map == null || map.MapID >= 2) - { - return 0; - } - - if (loc.X < 5120) - { - return 0; - } - - if (loc.Y < 2304) - { - return 1; - } - - return 2; - } + public static int GetMapRegion(Map map, Point3D loc) => + map is not { MapID: < 2 } ? 0 : + loc.X < 5120 ? 0 : + loc.Y < 2304 ? 1 : 2; public static void OnVirtueUsed(Mobile from) { @@ -56,7 +41,7 @@ namespace Server return; } - if (!(from is PlayerMobile protector)) + if (from is not PlayerMobile protector) { return; } @@ -192,7 +177,7 @@ namespace Server public static void CheckAtrophy(Mobile from) { - if (!(from is PlayerMobile pm)) + if (from is not PlayerMobile pm) { return; } @@ -240,9 +225,9 @@ namespace Server 20, 360, 25, - 1049365, + 1049365, // Another player is offering you their protection: 0x7FFF - ); // Another player is offering you their protection: + ); AddLabel(90, 55, 1153, protector.Name); AddImage(50, 45, 9005); diff --git a/Projects/UOContent/Engines/Virtues/Sacrifice.cs b/Projects/UOContent/Engines/Virtues/Sacrifice.cs index 4f1255047..146fcdf83 100644 --- a/Projects/UOContent/Engines/Virtues/Sacrifice.cs +++ b/Projects/UOContent/Engines/Virtues/Sacrifice.cs @@ -38,7 +38,7 @@ namespace Server public static void CheckAtrophy(Mobile from) { - if (!(from is PlayerMobile pm)) + if (from is not PlayerMobile pm) { return; } @@ -71,7 +71,7 @@ namespace Server return; } - if (!(from is PlayerMobile pm)) + if (from is not PlayerMobile pm) { return; } @@ -106,12 +106,12 @@ namespace Server return; } - if (!(from is PlayerMobile pm)) + if (from is not PlayerMobile pm) { return; } - if (!(targeted is Mobile targ)) + if (targeted is not Mobile targ) { return; } @@ -142,20 +142,12 @@ namespace Server } else { - int toGain; - - if (from.Fame < 5000) + int toGain = from.Fame switch { - toGain = 500; - } - else if (from.Fame < 10000) - { - toGain = 1000; - } - else - { - toGain = 2000; - } + < 5000 => 500, + < 10000 => 1000, + _ => 2000 + }; from.Fame = 0; diff --git a/Projects/UOContent/Engines/Virtues/Valor.cs b/Projects/UOContent/Engines/Virtues/Valor.cs index beb3d9391..70699b242 100644 --- a/Projects/UOContent/Engines/Virtues/Valor.cs +++ b/Projects/UOContent/Engines/Virtues/Valor.cs @@ -26,7 +26,7 @@ namespace Server public static void CheckAtrophy(Mobile from) { - if (!(from is PlayerMobile pm)) + if (from is not PlayerMobile pm) { return; } @@ -51,7 +51,7 @@ namespace Server public static void Valor(Mobile from, object targ) { - if (!(targ is IdolOfTheChampion idol) || idol.Deleted || idol.Spawn?.Deleted != false) + if (targ is not IdolOfTheChampion idol || idol.Deleted || idol.Spawn?.Deleted != false) { from.SendLocalizedMessage(1054035); // You must target a Champion Idol to challenge the Champion's spawn! } @@ -103,17 +103,15 @@ namespace Server if (from.Virtues.GetValue((int)VirtueName.Valor) >= needed) { VirtueHelper.Atrophy(from, VirtueName.Valor, consumed); - from.SendLocalizedMessage( - 1054037 - ); // Your challenge is heard by the Champion of this region! Beware its wrath! + // Your challenge is heard by the Champion of this region! Beware its wrath! + from.SendLocalizedMessage(1054037); idol.Spawn.HasBeenAdvanced = true; idol.Spawn.AdvanceLevel(); } else { - from.SendLocalizedMessage( - 1054039 - ); // The Champion of this region ignores your challenge. You must further prove your valor. + // The Champion of this region ignores your challenge. You must further prove your valor. + from.SendLocalizedMessage(1054039); } } else @@ -121,17 +119,15 @@ namespace Server if (vl == VirtueLevel.Knight) { VirtueHelper.Atrophy(from, VirtueName.Valor, 11000); - from.SendLocalizedMessage( - 1054037 - ); // Your challenge is heard by the Champion of this region! Beware its wrath! + // Your challenge is heard by the Champion of this region! Beware its wrath! + from.SendLocalizedMessage(1054037); idol.Spawn.EndRestart(); idol.Spawn.HasBeenAdvanced = true; } else { - from.SendLocalizedMessage( - 1054036 - ); // You must be a Knight of Valor to summon the champion's spawn in this manner! + // You must be a Knight of Valor to summon the champion's spawn in this manner! + from.SendLocalizedMessage(1054036); } } } diff --git a/Projects/UOContent/Engines/Virtues/VirtueHelper.cs b/Projects/UOContent/Engines/Virtues/VirtueHelper.cs index 5b4948056..ca2c56b67 100644 --- a/Projects/UOContent/Engines/Virtues/VirtueHelper.cs +++ b/Projects/UOContent/Engines/Virtues/VirtueHelper.cs @@ -51,12 +51,60 @@ namespace Server return (VirtueLevel)vl; } + public static string GetName(this VirtueName virtue) => + virtue switch + { + VirtueName.Humility => "Humility", + VirtueName.Sacrifice => "Sacrifice", + VirtueName.Compassion => "Compassion", + VirtueName.Spirituality => "Spirituality", + VirtueName.Valor => "Valor", + VirtueName.Honor => "Honor", + VirtueName.Justice => "Justice", + VirtueName.Honesty => "Honesty", + _ => "" + }; + public static int GetMaxAmount(VirtueName virtue) => virtue switch { - VirtueName.Honor => 20000, + VirtueName.Honor => 20000, VirtueName.Sacrifice => 22000, - _ => 21000 + _ => 21000 + }; + + public static int GetGainedLocalizedMessage(VirtueName virtue) => + virtue switch + { + VirtueName.Sacrifice => 1054160, // You have gained in sacrifice. + VirtueName.Compassion => 1053002, // You have gained in compassion. + VirtueName.Spirituality => 1155832, // You have gained in Spirituality. + VirtueName.Valor => 1054030, // You have gained in Valor! + VirtueName.Honor => 1063225, // You have gained in Honor. + VirtueName.Justice => 1049363, // You have gained in Justice. + VirtueName.Humility => 1052070, // You have gained in Humility. + _ => 0 + }; + + public static int GetGainedAPathLocalizedMessage(VirtueName virtue) => + virtue switch + { + VirtueName.Sacrifice => 1052008, // You have gained a path in Sacrifice! + VirtueName.Spirituality => 1155833, // You have gained a path in Spirituality! + VirtueName.Valor => 1054032, // You have gained a path in Valor! + VirtueName.Honor => 1063226, // You have gained a path in Honor! + VirtueName.Justice => 1049367, // You have gained a path in Justice! + VirtueName.Humility => 1155811, // You have gained a path in Humility! + _ => 0 + }; + + public static int GetHightestPathLocalizedMessage(VirtueName virtue) => + virtue switch + { + VirtueName.Compassion => 1053003, // You have achieved the highest path of compassion and can no longer gain any further. + VirtueName.Valor => 1054031, // You have achieved the highest path in Valor and can no longer gain any further. + VirtueName.Honesty => 1153771, // You have achieved the highest path in Honesty and can no longer gain any further. + _ => 0 }; public static bool Award(Mobile from, VirtueName virtue, int amount, ref bool gainedPath) @@ -126,37 +174,58 @@ namespace Server } var gainedPath = false; - var virtueName = Enum.GetName(typeof(VirtueName), virtue); + var virtueName = virtue.GetName(); if (Award(pm, virtue, amount, ref gainedPath)) { - // TODO: Localize? if (gainedPath) { - pm.SendMessage("You have gained a path in {0}!", virtueName); + var gainedPathMessage = GetGainedAPathLocalizedMessage(virtue); + if (gainedPathMessage != 0) + { + pm.SendLocalizedMessage(gainedPathMessage); + } + else + { + pm.SendMessage("You have gained a path in {0}!", virtueName); + } } else { - pm.SendMessage("You have gained in {0}.", virtueName); + var gainMessage = GetGainedLocalizedMessage(virtue); + if (gainMessage != 0) + { + pm.SendLocalizedMessage(gainMessage); + } + else + { + pm.SendMessage("You have gained in {0}.", virtueName); + } } if (virtue == VirtueName.Compassion) { pm.NextCompassionDay = Core.Now + TimeSpan.FromDays(1.0); - ++pm.CompassionGains; - if (pm.CompassionGains >= 5) + if (++pm.CompassionGains >= 5) { - pm.SendLocalizedMessage( - 1053004 - ); // You must wait about a day before you can gain in compassion again. + // You must wait about a day before you can gain in compassion again. + pm.SendLocalizedMessage(1053004); } } } else { - // TODO: Localize? - pm.SendMessage("You have achieved the highest path of {0} and can no longer gain any further.", virtueName); + var highestPathMessage = GetHightestPathLocalizedMessage(virtue); + if (highestPathMessage != 0) + { + pm.SendLocalizedMessage(highestPathMessage); + } + else + { + pm.SendMessage("You have achieved the highest path in {0} and can no longer gain any further.", virtueName); + } + } } } diff --git a/Projects/UOContent/Items/Weapons/Maces/BaseBashing.cs b/Projects/UOContent/Items/Weapons/Maces/BaseBashing.cs index 734b145ab..627cd4062 100644 --- a/Projects/UOContent/Items/Weapons/Maces/BaseBashing.cs +++ b/Projects/UOContent/Items/Weapons/Maces/BaseBashing.cs @@ -51,7 +51,7 @@ namespace Server.Items { damage *= 1.5; - attacker.SendMessage("You deliver a crushing blow!"); // Is this not localized? + attacker.SendLocalizedMessage(1060090); // You have delivered a crushing blow! attacker.PlaySound(0x11C); } diff --git a/Projects/UOContent/Items/Weapons/SpearsAndForks/BaseSpear.cs b/Projects/UOContent/Items/Weapons/SpearsAndForks/BaseSpear.cs index 7b51cf741..65a82a026 100644 --- a/Projects/UOContent/Items/Weapons/SpearsAndForks/BaseSpear.cs +++ b/Projects/UOContent/Items/Weapons/SpearsAndForks/BaseSpear.cs @@ -42,10 +42,10 @@ namespace Server.Items attacker.Skills.Anatomy.Value / 400.0 >= Utility.RandomDouble() && DuelContext.AllowSpecialAbility(attacker, "Paralyzing Blow", false)) { - defender.SendMessage("You receive a paralyzing blow!"); // Is this not localized? + defender.SendLocalizedMessage(1072221); // You have been hit by a paralyzing blow! defender.Freeze(TimeSpan.FromSeconds(2.0)); - attacker.SendMessage("You deliver a paralyzing blow!"); // Is this not localized? + attacker.SendLocalizedMessage(1060163); // You deliver a paralyzing blow! attacker.PlaySound(0x11C); } diff --git a/Projects/UOContent/Spells/Second/MagicTrap.cs b/Projects/UOContent/Spells/Second/MagicTrap.cs index 58abfbd5f..5dfbc66ac 100644 --- a/Projects/UOContent/Spells/Second/MagicTrap.cs +++ b/Projects/UOContent/Spells/Second/MagicTrap.cs @@ -23,9 +23,9 @@ namespace Server.Spells.Second public void Target(Item item) { - if (!(item is TrappableContainer cont)) + if (item is not TrappableContainer cont) { - Caster.SendMessage("You can't trap that"); // TODO: Localization for this? + Caster.SendLocalizedMessage(502942); // You can't trap this! } else if (!Caster.CanSee(item)) {