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

@ -183,9 +183,7 @@ namespace Server.Items
World.Broadcast(
0x35,
true,
"{0} solen hives teleporters have been created. The entire process took {1:0.#} seconds.",
count,
(endTime - startTime).TotalSeconds
$"{count} solen hives teleporters have been created. The entire process took {(endTime - startTime).TotalSeconds:0.#} seconds."
);
}

View file

@ -202,8 +202,8 @@ namespace Server.Items
public override void OnSingleClick(Mobile from)
{
LabelTo(from, "{0} by {1}", _title, _author);
LabelTo(from, "[{0} pages]", _pages.Length);
LabelTo(from, $"{_title} by {_author}");
LabelTo(from, $"[{_pages.Length} pages]");
}
public override void OnDoubleClick(Mobile from)

View file

@ -441,7 +441,7 @@ namespace Server.Items
}
else
{
from.SendMessage("Only {0} may use this.", RequiredRace.PluralName);
from.SendMessage($"Only {RequiredRace.PluralName} may use this.");
}
return false;
@ -553,7 +553,7 @@ namespace Server.Items
}
else
{
m.SendMessage("Only {0} may use this.", clothing.RequiredRace.PluralName);
m.SendMessage($"Only {clothing.RequiredRace.PluralName} may use this.");
}
m.AddToBackpack(clothing);

View file

@ -83,7 +83,7 @@ public partial class StrongBox : BaseContainer, IChoppable
if (CheckContentDisplay(from))
{
LabelTo(from, "({0} items, {1} stones)", TotalItems, TotalWeight);
LabelTo(from, $"({TotalItems} items, {TotalWeight} stones)");
}
}

View file

@ -658,7 +658,7 @@ public partial class TreasureMap : MapItem
_ => "northwest"
};
from.SendAsciiMessage(0x44, "Try looking for the treasure chest more to the {0}.", sDir);
from.SendAsciiMessage(0x44, $"Try looking for the treasure chest more to the {sDir}.");
}
}
}

View file

@ -111,7 +111,7 @@ public partial class PublicMoongate : Item
count += MoonGen(PMList.Malas);
count += MoonGen(PMList.Tokuno);
World.Broadcast(0x35, true, "{0} moongates generated.", count);
World.Broadcast(0x35, true, $"{count} moongates generated.");
}
private static void DeleteAll()
@ -133,7 +133,7 @@ public partial class PublicMoongate : Item
if (list.Count > 0)
{
World.Broadcast(0x35, true, "{0} moongates removed.", list.Count);
World.Broadcast(0x35, true, $"{list.Count} moongates removed.");
}
}

View file

@ -162,11 +162,11 @@ public partial class Teleporter : Item
{
if (_mapDest != null && _pointDest != Point3D.Zero)
{
LabelTo(from, "{0} [{1}]", _pointDest, _mapDest);
LabelTo(from, $"{_pointDest} [{_mapDest}]");
}
else if (_mapDest != null)
{
LabelTo(from, "[{0}]", _mapDest);
LabelTo(from, $"[{_mapDest}]");
}
else if (_pointDest != Point3D.Zero)
{

View file

@ -57,7 +57,7 @@ public partial class WayPoint : Item
}
else
{
LabelTo(from, "(Linked: {0})", _nextPoint.Location);
LabelTo(from, $"(Linked: {_nextPoint.Location})");
}
}
}

View file

@ -7,7 +7,6 @@ namespace Server.Items
[Flippable(0x1f14, 0x1f15, 0x1f16, 0x1f17)]
public class RecallRune : Item
{
private const string RuneFormat = "a recall rune for {0}";
private string m_Description;
private BaseHouse m_House;
private bool m_Marked;
@ -268,7 +267,7 @@ namespace Server.Items
LabelTo(
from,
House != null ? 1063260 : 1063259, // ~1_val~ (Tokuno Islands)[(House)]
string.Format(RuneFormat, desc)
$"a recall rune for {desc}"
);
}
else if (m_TargetMap == Map.Malas)
@ -276,7 +275,7 @@ namespace Server.Items
LabelTo(
from,
House != null ? 1062454 : 1060804, // ~1_val~ (Malas)[(House)]
string.Format(RuneFormat, desc)
$"a recall rune for {desc}"
);
}
else if (m_TargetMap == Map.Felucca)
@ -284,7 +283,7 @@ namespace Server.Items
LabelTo(
from,
House != null ? 1062452 : 1060805, // ~1_val~ (Felucca)[(House)]
string.Format(RuneFormat, desc)
$"a recall rune for {desc}"
);
}
else if (m_TargetMap == Map.Trammel)
@ -292,17 +291,19 @@ namespace Server.Items
LabelTo(
from,
House != null ? 1062453 : 1060806, // ~1_val~ (Trammel)[(House)]
string.Format(RuneFormat, desc)
$"a recall rune for {desc}"
);
}
else
{
LabelTo(
from,
House != null ? "{0} ({1})(House)" : "{0} ({1})",
string.Format(RuneFormat, desc),
m_TargetMap
);
if (House != null)
{
LabelTo(from, $"a recall rune for {desc} ({m_TargetMap})(House)");
}
else
{
LabelTo(from, $"a recall rune for {desc} ({m_TargetMap})");
}
}
}
else

View file

@ -283,10 +283,7 @@ namespace Server.Items
CommandLogging.WriteLine(
from,
"{0} {1} filling spellbook {2}",
from.AccessLevel,
CommandLogging.Format(from),
CommandLogging.Format(book)
$"{from.AccessLevel} {CommandLogging.Format(from)} filling spellbook {CommandLogging.Format(book)}"
);
}
else

View file

@ -527,7 +527,7 @@ namespace Server.Items
}
else
{
from.SendMessage(MessageHue, "You do not have the {0} required to enter the raffle.", FormatPrice());
from.SendMessage(MessageHue, $"You do not have the {FormatPrice()} required to enter the raffle.");
}
}
else
@ -555,9 +555,7 @@ namespace Server.Items
m_Winner.SendMessage(
MessageHue,
"Congratulations, {0}! You have won the raffle for the plot located at {1}.",
m_Winner.Name,
FormatLocation()
$"Congratulations, {m_Winner.Name}! You have won the raffle for the plot located at {FormatLocation()}."
);
if (m_Winner.AddToBackpack(Deed))