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,7 +116,7 @@ namespace Server.Engines.ConPVP
m_Challenged.CloseGump<AcceptDuelGump>();
m_Challenger.SendMessage("{0} seems unresponsive.", m_Challenged.Name);
m_Challenger.SendMessage($"{m_Challenged.Name} seems unresponsive.");
m_Challenged.SendMessage("You decline the challenge.");
}
@ -202,7 +202,7 @@ namespace Server.Engines.ConPVP
pm.SendMessage(0x22, "You have already been challenged in a duel.");
}
m_Challenger.SendMessage("{0} cannot fight because they are already assigned to another duel.", pm.Name);
m_Challenger.SendMessage($"{pm.Name} cannot fight because they are already assigned to another duel.");
}
else if (DuelContext.CheckCombat(pm))
{
@ -211,8 +211,7 @@ namespace Server.Engines.ConPVP
"You have recently been in combat with another player and must wait before starting a duel."
);
m_Challenger.SendMessage(
"{0} cannot fight because they have recently been in combat with another player.",
pm.Name
$"{pm.Name} cannot fight because they have recently been in combat with another player."
);
}
else if (TournamentController.IsActive)
@ -244,8 +243,8 @@ namespace Server.Engines.ConPVP
if (added)
{
m_Challenger.SendMessage("{0} has accepted the request.", m_Challenged.Name);
m_Challenged.SendMessage("You have accepted the request from {0}.", m_Challenger.Name);
m_Challenger.SendMessage($"{m_Challenged.Name} has accepted the request.");
m_Challenged.SendMessage($"You have accepted the request from {m_Challenger.Name}.");
var ns = m_Challenger.NetState;
@ -270,14 +269,17 @@ namespace Server.Engines.ConPVP
else
{
m_Challenger.SendMessage(
"The participant list was full and so {0} could not join.",
m_Challenged.Name
);
m_Challenged.SendMessage(
"The participant list was full and so you could not join the fight {1} {0}.",
m_Challenger.Name,
m_Participant.Contains(m_Challenger) ? "with" : "against"
$"The participant list was full and so {m_Challenged.Name} could not join."
);
if (m_Participant.Contains(m_Challenger))
{
m_Challenged.SendMessage($"The participant list was full and so you could not join the fight with {m_Challenger.Name}.");
}
else
{
m_Challenged.SendMessage($"The participant list was full and so you could not join the fight against {m_Challenger.Name}.");
}
}
}
}
@ -288,12 +290,16 @@ namespace Server.Engines.ConPVP
BeginIgnore(m_Challenged, m_Challenger);
}
m_Challenger.SendMessage("{0} does not wish to fight.", m_Challenged.Name);
m_Challenged.SendMessage(
"You chose not to fight {1} {0}.",
m_Challenger.Name,
m_Participant.Contains(m_Challenger) ? "with" : "against"
);
m_Challenger.SendMessage($"{m_Challenged.Name} does not wish to fight.");
if (m_Participant.Contains(m_Challenger))
{
m_Challenged.SendMessage($"You chose not to fight with {m_Challenger.Name}.");
}
else
{
m_Challenged.SendMessage($"You chose not to fight against {m_Challenger.Name}.");
}
}
}

View file

@ -893,11 +893,11 @@ namespace Server.Engines.ConPVP
if (newLevel > oldLevel)
{
us.SendMessage(0x59, "You have achieved level {0}!", newLevel);
us.SendMessage(0x59, $"You have achieved level {newLevel}!");
}
else if (newLevel < oldLevel)
{
us.SendMessage(0x22, "You have lost a level. You are now at {0}.", newLevel);
us.SendMessage(0x22, $"You have lost a level. You are now at {newLevel}.");
}
}
@ -1768,18 +1768,32 @@ namespace Server.Engines.ConPVP
{
if (mob != rejector)
{
mob.SendMessage(0x22, "{0} has yielded.", rejector.Name);
mob.SendMessage(0x22, $"{rejector.Name} has yielded.");
}
}
else
{
if (mob == rejector)
{
mob.SendMessage(0x22, "You have rejected the {0}.", Rematch ? "rematch" : page);
if (Rematch)
{
mob.SendMessage(0x22, $"You have rejected the rematch.");
}
else
{
mob.SendMessage(0x22, $"You have rejected the {page}.");
}
}
else
{
mob.SendMessage(0x22, "{0} has rejected the {1}.", rejector.Name, Rematch ? "rematch" : page);
if (Rematch)
{
mob.SendMessage(0x22, $"{rejector.Name} has rejected the rematch.");
}
else
{
mob.SendMessage(0x22, $"{rejector.Name} has rejected the {page}.");
}
}
}
@ -2086,7 +2100,7 @@ namespace Server.Engines.ConPVP
var ruleset = Ruleset;
var basedef = ruleset.Base;
mob.SendMessage("Ruleset: {0}", basedef.Title);
mob.SendMessage($"Ruleset: {basedef.Title}");
BitArray defs;
@ -2098,7 +2112,7 @@ namespace Server.Engines.ConPVP
{
defs.Or(ruleset.Flavors[i].Options);
mob.SendMessage(" + {0}", ruleset.Flavors[i].Title);
mob.SendMessage($" + {ruleset.Flavors[i].Title}");
}
}
else
@ -2125,7 +2139,14 @@ namespace Server.Engines.ConPVP
mob.SendMessage("Modifications:");
}
mob.SendMessage("{0}: {1}", name, opts[i] ? "enabled" : "disabled");
if (opts[i])
{
mob.SendMessage($"{name}: enabled");
}
else
{
mob.SendMessage($"{name}: disabled");
}
}
}
}
@ -2337,7 +2358,7 @@ namespace Server.Engines.ConPVP
{
var dp = p.Players[j];
dp?.Mobile.SendMessage("The duel could not be started because {0}.", error);
dp?.Mobile.SendMessage($"The duel could not be started because {error}.");
}
}

View file

@ -712,11 +712,11 @@ namespace Server.Engines.ConPVP
if (points > 3)
{
m_Game.Alert("Touchdown {0} ({1})!", team.Name, m.Name);
m_Game.Alert($"Touchdown {team.Name} ({m.Name})!");
}
else
{
m_Game.Alert("Field goal {0} ({1})!", team.Name, m.Name);
m_Game.Alert($"Field goal {team.Name} ({m.Name})!");
}
for (var i = m_Helpers.Count - 1; i >= 0; i--)
@ -761,7 +761,7 @@ namespace Server.Engines.ConPVP
m.RevealingAction();
m.LocalOverheadMessage(MessageType.Regular, 0x59, false, "You got the bomb!");
m_Game.Alert("{1} ({2}) {0} the bomb!", verb, m.Name, team.Name);
m_Game.Alert($"{verb} ({m.Name}) {team.Name} the bomb!");
m.Target = new BombTarget(this, m);
@ -1661,11 +1661,6 @@ namespace Server.Engines.ConPVP
}
}
public void Alert(string format, params object[] args)
{
Alert(string.Format(format, args));
}
public BRTeamInfo GetTeamInfo(Mobile mob)
{
var teamID = GetTeamID(mob);
@ -1954,17 +1949,14 @@ namespace Server.Engines.ConPVP
mob.BankBox.DropItem(item);
}
mob.SendMessage(
"You have been awarded a {0} trophy and {1:N0}gp for your participation in this tournament.",
rank.ToString().ToLower(),
cash
mob.SendMessage( //There is no formatting flag for Lowercase, we may need a custom interface to get rid of it
$"You have been awarded a {rank.ToString().ToLower()} trophy and {cash:N0}gp for your participation in this tournament."
);
}
else
{
mob.SendMessage(
"You have been awarded a {0} trophy for your participation in this tournament.",
rank.ToString().ToLower()
$"You have been awarded a {rank.ToString().ToLower()} trophy for your participation in this tournament."
);
}
}

View file

@ -317,7 +317,7 @@ namespace Server.Engines.ConPVP
SendHome();
from.LocalOverheadMessage(MessageType.Regular, 0x59, false, "You returned the cookies!");
m_TeamInfo.Game.Alert("The {1} cookies have been returned by {0}.", from.Name, ourTeam.Name);
m_TeamInfo.Game.Alert($"The {from.Name} cookies have been returned by {ourTeam.Name}.");
}
}
else if (!from.PlaceInBackpack(this))
@ -329,12 +329,7 @@ namespace Server.Engines.ConPVP
from.RevealingAction();
from.LocalOverheadMessage(MessageType.Regular, 0x59, false, "You stole the cookies!");
m_TeamInfo.Game.Alert(
"The {1} cookies have been stolen by {0} ({2}).",
from.Name,
ourTeam.Name,
useTeam.Name
);
m_TeamInfo.Game.Alert($"The {ourTeam.Name} cookies have been stolen by {from.Name} ({useTeam.Name}).");
BeginCountdown(120);
}
@ -393,12 +388,14 @@ namespace Server.Engines.ConPVP
case 2:
case 1:
{
owner?.SendMessage(
0x26,
"You have {0} {1} to capture the cookies!",
m_ReturnCount,
m_ReturnCount == 1 ? "second" : "seconds"
);
if (m_ReturnCount == 1)
{
owner?.SendMessage(0x26, $"You have {m_ReturnCount} second to capture the cookies!");
}
else
{
owner?.SendMessage(0x26, $"You have {m_ReturnCount} seconds to capture the cookies!");
}
break;
}
@ -413,7 +410,7 @@ namespace Server.Engines.ConPVP
SendHome();
m_TeamInfo?.Game?.Alert("The {0} cookies have been returned.", m_TeamInfo.Name);
m_TeamInfo?.Game?.Alert($"The {m_TeamInfo.Name} cookies have been returned.");
return;
}
@ -442,7 +439,7 @@ namespace Server.Engines.ConPVP
if (obj == useTeam.Flag)
{
from.LocalOverheadMessage(MessageType.Regular, 0x59, false, "You captured the cookies!");
m_TeamInfo.Game.Alert("{0} captured the {1} cookies!", from.Name, ourTeam.Name);
m_TeamInfo.Game.Alert($"{from.Name} captured the {ourTeam.Name} cookies!");
SendHome();
@ -934,11 +931,6 @@ namespace Server.Engines.ConPVP
}
}
public void Alert(string format, params object[] args)
{
Alert(string.Format(format, args));
}
public CTFTeamInfo GetTeamInfo(Mobile mob)
{
var teamID = GetTeamID(mob);
@ -1280,16 +1272,13 @@ namespace Server.Engines.ConPVP
}
mob.SendMessage(
"You have been awarded a {0} trophy and {1:N0}gp for your participation in this tournament.",
rank.ToString().ToLower(),
cash
$"You have been awarded a {rank.ToString().ToLower()} trophy and {cash:N0}gp for your participation in this tournament."
);
}
else
{
mob.SendMessage(
"You have been awarded a {0} trophy for your participation in this tournament.",
rank.ToString().ToLower()
$"You have been awarded a {rank.ToString().ToLower()} trophy for your participation in this tournament."
);
}
}

View file

@ -503,18 +503,7 @@ namespace Server.Engines.ConPVP
public DDController Controller { get; }
public Map Facet
{
get
{
if (m_Context.Arena != null)
{
return m_Context.Arena.Facet;
}
return Controller.Map;
}
}
public Map Facet => m_Context.Arena?.Facet ?? Controller.Map;
public void Alert(string text)
{
@ -534,11 +523,6 @@ namespace Server.Engines.ConPVP
}
}
public void Alert(string format, params object[] args)
{
Alert(string.Format(format, args));
}
public DDTeamInfo GetTeamInfo(Mobile mob)
{
var teamID = GetTeamID(mob);
@ -847,16 +831,13 @@ namespace Server.Engines.ConPVP
}
mob.SendMessage(
"You have been awarded a {0} trophy and {1:N0}gp for your participation in this tournament.",
rank.ToString().ToLower(),
cash
$"You have been awarded a {rank.ToString().ToLower()} trophy and {cash:N0}gp for your participation in this tournament."
);
}
else
{
mob.SendMessage(
"You have been awarded a {0} trophy for your participation in this tournament.",
rank.ToString().ToLower()
$"You have been awarded a {rank.ToString().ToLower()} trophy for your participation in this tournament."
);
}
}
@ -945,7 +926,7 @@ namespace Server.Engines.ConPVP
Controller.PointA?.TeamOwner != null;
point.TeamOwner = team;
Alert("{0} has captured {1}!", team.Name, point.Name);
Alert($"{team.Name} has captured {point.Name}!");
var isDom = Controller.PointA?.TeamOwner == Controller.PointB?.TeamOwner && Controller.PointA?.TeamOwner != null;
@ -978,14 +959,14 @@ namespace Server.Engines.ConPVP
if (++m_CapStage < 10)
{
Alert("{0} is dominating... {1}", team.Name, 10 - m_CapStage);
Alert($"{team.Name} is dominating... {10 - m_CapStage}");
Controller.PointA?.SetCaptureHue(m_CapStage);
Controller.PointB?.SetCaptureHue(m_CapStage);
}
else
{
Alert("{0} has scored!", team.Name);
Alert($"{team.Name} has scored!");
team.Score += 100;
team.Captures += 1;

View file

@ -149,7 +149,7 @@ namespace Server.Engines.ConPVP
var kingName = king.Name ?? "";
var killerName = killer.Name ?? "";
m_Game.Alert("{0} ({1}) was dethroned by {2} ({3})!", kingName, kingTeam.Name, killerName, killerTeam.Name);
m_Game.Alert($"{kingName} ({kingTeam.Name}) was dethroned by {killerName} ({killerTeam.Name})!");
}
DeKingify();
@ -251,7 +251,7 @@ namespace Server.Engines.ConPVP
var hill = m_Hill.Name.DefaultIfNullOrEmpty("the hill");
var king = m_Hill.King.Name ?? "";
m_Hill.Game.Alert("{0} ({1}) is king of {2}!", king, ti.Name, hill);
m_Hill.Game.Alert($"{king} ({ti.Name}) is king of {hill}!");
m_Hill.PublicOverheadMessage(MessageType.Regular, 0x0481, false, "Capture!");
@ -905,11 +905,6 @@ namespace Server.Engines.ConPVP
}
}
public void Alert(string format, params object[] args)
{
Alert(string.Format(format, args));
}
public KHTeamInfo GetTeamInfo(Mobile mob)
{
var teamID = GetTeamID(mob);
@ -1212,16 +1207,13 @@ namespace Server.Engines.ConPVP
}
mob.SendMessage(
"You have been awarded a {0} trophy and {1:N0}gp for your participation in this game.",
rank.ToString().ToLower(),
cash
$"You have been awarded a {rank.ToString().ToLower()} trophy and {cash:N0}gp for your participation in this game."
);
}
else
{
mob.SendMessage(
"You have been awarded a {0} trophy for your participation in this game.",
rank.ToString().ToLower()
$"You have been awarded a {rank.ToString().ToLower()} trophy for your participation in this game."
);
}
}

View file

@ -245,26 +245,29 @@ namespace Server.Engines.ConPVP
if (pm.DuelContext != null)
{
from.SendMessage("{0} cannot fight because they are already assigned to another duel.", pm.Name);
from.SendMessage($"{pm.Name} cannot fight because they are already assigned to another duel.");
}
else if (DuelContext.CheckCombat(pm))
{
from.SendMessage(
"{0} cannot fight because they have recently been in combat with another player.",
pm.Name
$"{pm.Name} cannot fight because they have recently been in combat with another player."
);
}
else if (mob.HasGump<AcceptDuelGump>())
{
from.SendMessage("{0} has already been offered a duel.");
from.SendMessage($"{mob.Name} has already been offered a duel.");
}
else
{
from.SendMessage(
"You send {0} to {1}.",
m_Participant.Find(from) == null ? "a challenge" : "an invitation",
mob.Name
);
if (m_Participant.Find(from) == null)
{
from.SendMessage($"You send a challenge to {mob.Name}.");
}
else
{
from.SendMessage($"You send an invitation to {mob.Name}.");
}
mob.SendGump(new AcceptDuelGump(from, mob, m_Context, m_Participant, m_Index));
}
}

View file

@ -662,16 +662,13 @@ namespace Server.Engines.ConPVP
}
mob.SendMessage(
"You have been awarded a {0} trophy and {1:N0}gp for your participation in this tournament.",
rank.ToString().ToLower(),
cash
$"You have been awarded a {rank.ToString().ToLower()} trophy and {cash:N0}gp for your participation in this tournament."
);
}
else
{
mob.SendMessage(
"You have been awarded a {0} trophy for your participation in this tournament.",
rank.ToString().ToLower()
$"You have been awarded a {rank.ToString().ToLower()} trophy for your participation in this tournament."
);
}
}

View file

@ -92,15 +92,7 @@ namespace Server.Engines.ConPVP
public int CompareTo(TourneyParticipant p) => p.TotalLadderXP - TotalLadderXP;
public void AddLog(string text)
{
Log.Add(text);
}
public void AddLog(string format, params object[] args)
{
AddLog(string.Format(format, args));
}
public void AddLog(string text) => Log.Add(text);
public void WonMatch(TourneyMatch match)
{

View file

@ -92,7 +92,7 @@ namespace Server.Items
if (Owner != null)
{
LabelTo(from, "{0} -- {1}", Title, Owner.RawName);
LabelTo(from, $"{Title} -- {Owner.RawName}");
}
else if (Title != null)
{