fix(content): Localizes some messages and cleans up virtues (#657)

This commit is contained in:
Kamron Batman 2021-07-11 23:10:54 -07:00 • committed by GitHub
parent fb915992dd
commit f8820e581a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 122 additions and 80 deletions

View file

@ -20,7 +20,7 @@ namespace Server
public static void CheckAtrophy(Mobile from) public static void CheckAtrophy(Mobile from)
{ {
if (!(from is PlayerMobile pm)) if (from is not PlayerMobile pm)
{ {
return; return;
} }

View file

@ -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 return VirtueHelper.GetLevel(from, VirtueName.Honor) switch
{ {
@ -56,9 +56,9 @@ namespace Server
var remainingMinutes = (int)Math.Ceiling(remainingTime.TotalMinutes); var remainingMinutes = (int)Math.Ceiling(remainingTime.TotalMinutes);
pm.SendLocalizedMessage( pm.SendLocalizedMessage(
1063240, 1063240, // You must wait ~1_HONOR_WAIT~ minutes before embracing honor again
remainingMinutes.ToString() remainingMinutes.ToString()
); // You must wait ~1_HONOR_WAIT~ minutes before embracing honor again );
return; return;
} }
@ -130,7 +130,7 @@ namespace Server
return; 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) if (reg?.IsDisabled() != true)
{ {
@ -143,7 +143,7 @@ namespace Server
else else
{ {
source.SendLocalizedMessage(1001018); // You cannot perform negative acts 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(); source.SentHonorContext?.Cancel();
new HonorContext(source, target); _ = new HonorContext(source, target);
source.Direction = source.GetDirectionTo(target); source.Direction = source.GetDirectionTo(target);
@ -171,7 +171,7 @@ namespace Server
protected override void OnTarget(Mobile from, object targeted) protected override void OnTarget(Mobile from, object targeted)
{ {
if (!(from is PlayerMobile pm)) if (from is not PlayerMobile pm)
{ {
return; return;
} }

View file

@ -29,25 +29,10 @@ namespace Server
return GetMapRegion(map, first.Location) == GetMapRegion(map, second.Location); return GetMapRegion(map, first.Location) == GetMapRegion(map, second.Location);
} }
public static int GetMapRegion(Map map, Point3D loc) public static int GetMapRegion(Map map, Point3D loc) =>
{ map is not { MapID: < 2 } ? 0 :
if (map == null || map.MapID >= 2) loc.X < 5120 ? 0 :
{ loc.Y < 2304 ? 1 : 2;
return 0;
}
if (loc.X < 5120)
{
return 0;
}
if (loc.Y < 2304)
{
return 1;
}
return 2;
}
public static void OnVirtueUsed(Mobile from) public static void OnVirtueUsed(Mobile from)
{ {
@ -56,7 +41,7 @@ namespace Server
return; return;
} }
if (!(from is PlayerMobile protector)) if (from is not PlayerMobile protector)
{ {
return; return;
} }
@ -192,7 +177,7 @@ namespace Server
public static void CheckAtrophy(Mobile from) public static void CheckAtrophy(Mobile from)
{ {
if (!(from is PlayerMobile pm)) if (from is not PlayerMobile pm)
{ {
return; return;
} }
@ -240,9 +225,9 @@ namespace Server
20, 20,
360, 360,
25, 25,
1049365, 1049365, // Another player is offering you their <a href="?ForceTopic88">protection</a>:
0x7FFF 0x7FFF
); // Another player is offering you their <a href="?ForceTopic88">protection</a>: );
AddLabel(90, 55, 1153, protector.Name); AddLabel(90, 55, 1153, protector.Name);
AddImage(50, 45, 9005); AddImage(50, 45, 9005);

View file

@ -38,7 +38,7 @@ namespace Server
public static void CheckAtrophy(Mobile from) public static void CheckAtrophy(Mobile from)
{ {
if (!(from is PlayerMobile pm)) if (from is not PlayerMobile pm)
{ {
return; return;
} }
@ -71,7 +71,7 @@ namespace Server
return; return;
} }
if (!(from is PlayerMobile pm)) if (from is not PlayerMobile pm)
{ {
return; return;
} }
@ -106,12 +106,12 @@ namespace Server
return; return;
} }
if (!(from is PlayerMobile pm)) if (from is not PlayerMobile pm)
{ {
return; return;
} }
if (!(targeted is Mobile targ)) if (targeted is not Mobile targ)
{ {
return; return;
} }
@ -142,20 +142,12 @@ namespace Server
} }
else else
{ {
int toGain; int toGain = from.Fame switch
if (from.Fame < 5000)
{ {
toGain = 500; < 5000 => 500,
} < 10000 => 1000,
else if (from.Fame < 10000) _ => 2000
{ };
toGain = 1000;
}
else
{
toGain = 2000;
}
from.Fame = 0; from.Fame = 0;

View file

@ -26,7 +26,7 @@ namespace Server
public static void CheckAtrophy(Mobile from) public static void CheckAtrophy(Mobile from)
{ {
if (!(from is PlayerMobile pm)) if (from is not PlayerMobile pm)
{ {
return; return;
} }
@ -51,7 +51,7 @@ namespace Server
public static void Valor(Mobile from, object targ) 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! 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) if (from.Virtues.GetValue((int)VirtueName.Valor) >= needed)
{ {
VirtueHelper.Atrophy(from, VirtueName.Valor, consumed); VirtueHelper.Atrophy(from, VirtueName.Valor, consumed);
from.SendLocalizedMessage( // Your challenge is heard by the Champion of this region! Beware its wrath!
1054037 from.SendLocalizedMessage(1054037);
); // Your challenge is heard by the Champion of this region! Beware its wrath!
idol.Spawn.HasBeenAdvanced = true; idol.Spawn.HasBeenAdvanced = true;
idol.Spawn.AdvanceLevel(); idol.Spawn.AdvanceLevel();
} }
else else
{ {
from.SendLocalizedMessage( // The Champion of this region ignores your challenge. You must further prove your valor.
1054039 from.SendLocalizedMessage(1054039);
); // The Champion of this region ignores your challenge. You must further prove your valor.
} }
} }
else else
@ -121,17 +119,15 @@ namespace Server
if (vl == VirtueLevel.Knight) if (vl == VirtueLevel.Knight)
{ {
VirtueHelper.Atrophy(from, VirtueName.Valor, 11000); VirtueHelper.Atrophy(from, VirtueName.Valor, 11000);
from.SendLocalizedMessage( // Your challenge is heard by the Champion of this region! Beware its wrath!
1054037 from.SendLocalizedMessage(1054037);
); // Your challenge is heard by the Champion of this region! Beware its wrath!
idol.Spawn.EndRestart(); idol.Spawn.EndRestart();
idol.Spawn.HasBeenAdvanced = true; idol.Spawn.HasBeenAdvanced = true;
} }
else else
{ {
from.SendLocalizedMessage( // You must be a Knight of Valor to summon the champion's spawn in this manner!
1054036 from.SendLocalizedMessage(1054036);
); // You must be a Knight of Valor to summon the champion's spawn in this manner!
} }
} }
} }

View file

@ -51,12 +51,60 @@ namespace Server
return (VirtueLevel)vl; 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) => public static int GetMaxAmount(VirtueName virtue) =>
virtue switch virtue switch
{ {
VirtueName.Honor => 20000, VirtueName.Honor => 20000,
VirtueName.Sacrifice => 22000, 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) public static bool Award(Mobile from, VirtueName virtue, int amount, ref bool gainedPath)
@ -126,37 +174,58 @@ namespace Server
} }
var gainedPath = false; var gainedPath = false;
var virtueName = Enum.GetName(typeof(VirtueName), virtue); var virtueName = virtue.GetName();
if (Award(pm, virtue, amount, ref gainedPath)) if (Award(pm, virtue, amount, ref gainedPath))
{ {
// TODO: Localize?
if (gainedPath) 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 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) if (virtue == VirtueName.Compassion)
{ {
pm.NextCompassionDay = Core.Now + TimeSpan.FromDays(1.0); pm.NextCompassionDay = Core.Now + TimeSpan.FromDays(1.0);
++pm.CompassionGains;
if (pm.CompassionGains >= 5) if (++pm.CompassionGains >= 5)
{ {
pm.SendLocalizedMessage( // You must wait about a day before you can gain in compassion again.
1053004 pm.SendLocalizedMessage(1053004);
); // You must wait about a day before you can gain in compassion again.
} }
} }
} }
else else
{ {
// TODO: Localize? var highestPathMessage = GetHightestPathLocalizedMessage(virtue);
pm.SendMessage("You have achieved the highest path of {0} and can no longer gain any further.", virtueName); 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);
}
} }
} }
} }

View file

@ -51,7 +51,7 @@ namespace Server.Items
{ {
damage *= 1.5; 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); attacker.PlaySound(0x11C);
} }

View file

@ -42,10 +42,10 @@ namespace Server.Items
attacker.Skills.Anatomy.Value / 400.0 >= Utility.RandomDouble() && attacker.Skills.Anatomy.Value / 400.0 >= Utility.RandomDouble() &&
DuelContext.AllowSpecialAbility(attacker, "Paralyzing Blow", false)) 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)); 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); attacker.PlaySound(0x11C);
} }

View file

@ -23,9 +23,9 @@ namespace Server.Spells.Second
public void Target(Item item) 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)) else if (!Caster.CanSee(item))
{ {