fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283)

This commit is contained in:
Fabrizio 2022-11-29 04:58:12 +01:00 • committed by GitHub
parent 0facd73842
commit 537526a328
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
94 changed files with 514 additions and 769 deletions

View file

@ -116,16 +116,6 @@ namespace Server.Factions
}
}
public void Broadcast(string format, params object[] args)
{
Broadcast(string.Format(format, args));
}
public void Broadcast(int hue, string format, params object[] args)
{
Broadcast(hue, string.Format(format, args));
}
public void BeginBroadcast(Mobile from)
{
from.SendLocalizedMessage(1010265); // Enter Faction Message
@ -139,7 +129,7 @@ namespace Server.Factions
State.RegisterBroadcast();
}
Broadcast(Definition.HueBroadcast, "{0} [Commander] {1} : {2}", from.Name, Definition.FriendlyName, text);
Broadcast(Definition.HueBroadcast, $"{from.Name} [Commander] {Definition.FriendlyName} : {text}");
}
public static void HandleAtrophy()
@ -816,7 +806,7 @@ namespace Server.Factions
}
}
e.Mobile.SendMessage("{0} items reset", count);
e.Mobile.SendMessage($"{count} items reset");
}
public static void FactionCommander_OnCommand(CommandEventArgs e)

View file

@ -183,7 +183,7 @@ namespace Server.Factions
type = "guard";
}
from.SendMessage("Target the {0} you wish to dismiss.", type);
from.SendMessage($"Target the {type} you wish to dismiss.");
from.BeginTarget(12, false, TargetFlags.None, EndOrderFiring);
}
@ -216,7 +216,7 @@ namespace Server.Factions
}
else
{
from.SendMessage("That is not a {0}!", type);
from.SendMessage($"That is not a {type}!");
}
}
@ -557,9 +557,7 @@ namespace Server.Factions
{
town.Silver += e.GetInt32(0);
e.Mobile.SendMessage(
"You have granted {0:N0} silver to the town. It now has {1:N0} silver.",
e.GetInt32(0),
town.Silver
$"You have granted {e.GetInt32(0):N0} silver to the town. It now has {town.Silver:N0} silver."
);
}
}

View file

@ -65,8 +65,7 @@ namespace Server.Factions
else
{
m_From.SendMessage(
"You will be removed from the faction in {0} days.",
Faction.LeavePeriod.TotalDays
$"You will be removed from the faction in {Faction.LeavePeriod.TotalDays} days."
);
}
}
@ -97,8 +96,7 @@ namespace Server.Factions
else
{
mob.SendMessage(
"Your guild will quit the faction in {0} days.",
Faction.LeavePeriod.TotalDays
$"Your guild will quit the faction in {Faction.LeavePeriod.TotalDays} days."
);
}
}

View file

@ -83,9 +83,7 @@ namespace Server.Factions
if (from.Alive)
{
Placer.SendMessage(
"You have earned {0} silver pieces because {1} fell for your trap.",
silverGiven,
from.Name
$"You have earned {silverGiven} silver pieces because {from.Name} fell for your trap."
);
}
else

View file

@ -140,29 +140,19 @@ namespace Server.Factions
var warning = Utility.Random(6) switch
{
0 => "I warn you, {0}, you would do well to leave this area before someone shows you the world of gray.",
1 => "It would be wise to leave this area, {0}, lest your head become my commanders' trophy.",
2 => "You are bold, {0}, for one of the meager {1}. Leave now, lest you be taught the taste of dirt.",
3 => "Your presence here is an insult, {0}. Be gone now, knave.",
4 => "Dost thou wish to be hung by your toes, {0}? Nay? Then come no closer.",
_ => "Hey, {0}. Yeah, you. Get out of here before I beat you with a stick." // 5
0 => $"I warn you, {m.Name}, you would do well to leave this area before someone shows you the world of gray.",
1 => $"It would be wise to leave this area, {m.Name}, lest your head become my commanders' trophy.",
2 => $"You are bold, {m.Name}, for one of the meager {Faction.Find(m)?.Definition.FriendlyName ?? "civilians"}. Leave now, lest you be taught the taste of dirt.",
3 => $"Your presence here is an insult, {m.Name}. Be gone now, knave.",
4 => $"Dost thou wish to be hung by your toes, {m.Name}? Nay? Then come no closer.",
_ => $"Hey, {m.Name}. Yeah, you. Get out of here before I beat you with a stick." // 5
};
var faction = Faction.Find(m);
Say(warning, m.Name, faction == null ? "civilians" : faction.Definition.FriendlyName);
Say(warning);
}
}
public override bool HandlesOnSpeech(Mobile from)
{
if (InRange(from, ListenRange))
{
return true;
}
return base.HandlesOnSpeech(from);
}
public override bool HandlesOnSpeech(Mobile from) => InRange(from, ListenRange) || base.HandlesOnSpeech(from);
private void ChangeReaction(Faction faction, ReactionType type)
{
@ -171,12 +161,19 @@ namespace Server.Factions
switch (type)
{
case ReactionType.Ignore:
Say(1005179);
break; // Civilians will now be ignored.
{
Say(1005179);
break; // Civilians will now be ignored.
}
case ReactionType.Warn:
Say(1005180);
break; // Civilians will now be warned of their impending deaths.
case ReactionType.Attack: return;
{
Say(1005180);
break; // Civilians will now be warned of their impending deaths.
}
case ReactionType.Attack:
{
return;
}
}
}
else