{count}");
}
int y = 25 + 20;
diff --git a/Projects/Scripts/Engines/ConPVP/Gumps/TournamentBracketGump.cs b/Projects/Scripts/Engines/ConPVP/Gumps/TournamentBracketGump.cs
index 838404aeb..b78222b09 100644
--- a/Projects/Scripts/Engines/ConPVP/Gumps/TournamentBracketGump.cs
+++ b/Projects/Scripts/Engines/ConPVP/Gumps/TournamentBracketGump.cs
@@ -162,44 +162,26 @@ namespace Server.Engines.ConPVP
int y = 53;
- string groupText = null;
-
- switch (tourney.GroupType)
+ var groupText = tourney.GroupType switch
{
- case GroupingType.HighVsLow:
- groupText = "High vs Low";
- break;
- case GroupingType.Nearest:
- groupText = "Closest opponent";
- break;
- case GroupingType.Random:
- groupText = "Random";
- break;
- }
+ GroupingType.HighVsLow => "High vs Low",
+ GroupingType.Nearest => "Closest opponent",
+ GroupingType.Random => "Random",
+ _ => null
+ };
AddHtml(35, y, 190, 20, $"Grouping: {groupText}");
y += 20;
- string tieText = null;
-
- switch (tourney.TieType)
+ var tieText = tourney.TieType switch
{
- case TieType.Random:
- tieText = "Random";
- break;
- case TieType.Highest:
- tieText = "Highest advances";
- break;
- case TieType.Lowest:
- tieText = "Lowest advances";
- break;
- case TieType.FullAdvancement:
- tieText = tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances";
- break;
- case TieType.FullElimination:
- tieText = tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated";
- break;
- }
+ TieType.Random => "Random",
+ TieType.Highest => "Highest advances",
+ TieType.Lowest => "Lowest advances",
+ TieType.FullAdvancement => (tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances"),
+ TieType.FullElimination => (tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated"),
+ _ => null
+ };
AddHtml(35, y, 190, 20, $"Tiebreaker: {tieText}");
y += 20;
@@ -352,7 +334,7 @@ namespace Server.Engines.ConPVP
AddHtml(25, 53, 250, 20, $"Name: {mob.Name}");
AddHtml(25, 73, 250, 20,
- $"Guild: {(mob.Guild == null ? "None" : mob.Guild.Name + " [" + mob.Guild.Abbreviation + "]")}");
+ $"Guild: {(mob.Guild == null ? "None" : $"{mob.Guild.Name} [{mob.Guild.Abbreviation}]")}");
AddHtml(25, 93, 250, 20, $"Rank: {(entry == null ? "N/A" : LadderGump.Rank(entry.Index + 1))}");
AddHtml(25, 113, 250, 20, $"Level: {(entry == null ? 0 : Ladder.GetLevel(entry.Experience))}");
AddHtml(25, 133, 250, 20, $"Wins: {entry?.Wins ?? 0:N0}");
@@ -375,7 +357,7 @@ namespace Server.Engines.ConPVP
StartPage(out int index, out int count, out int y, 12);
for (int i = 0; i < count; ++i, y += 18)
- AddRightArrow(25, y, ToButtonID(3, index + i), "Round #" + (index + i + 1));
+ AddRightArrow(25, y, ToButtonID(3, index + i), $"Round #{index + i + 1}");
break;
}
diff --git a/Projects/Scripts/Engines/ConPVP/Ladder.cs b/Projects/Scripts/Engines/ConPVP/Ladder.cs
index b2171f0a8..fbcf29c48 100644
--- a/Projects/Scripts/Engines/ConPVP/Ladder.cs
+++ b/Projects/Scripts/Engines/ConPVP/Ladder.cs
@@ -256,10 +256,10 @@ namespace Server.Engines.ConPVP
if (index >= 0 && index < Entries.Count)
{
- while (index - 1 >= 0 && (entry.CompareTo(Entries[index - 1])) < 0)
+ while (index - 1 >= 0 && entry.CompareTo(Entries[index - 1]) < 0)
index = Swap(index, index - 1);
- while (index + 1 < Entries.Count && (entry.CompareTo(Entries[index + 1])) > 0)
+ while (index + 1 < Entries.Count && entry.CompareTo(Entries[index + 1]) > 0)
index = Swap(index, index + 1);
}
}
diff --git a/Projects/Scripts/Engines/ConPVP/RulesetLayout.cs b/Projects/Scripts/Engines/ConPVP/RulesetLayout.cs
index 4b9f3a6ab..b25555877 100644
--- a/Projects/Scripts/Engines/ConPVP/RulesetLayout.cs
+++ b/Projects/Scripts/Engines/ConPVP/RulesetLayout.cs
@@ -700,7 +700,7 @@ namespace Server.Engines.ConPVP
public string FindByIndex(int index)
{
if (index >= Offset && index < Offset + Options.Length)
- return Description + ": " + Options[index - Offset];
+ return $"{Description}: {Options[index - Offset]}";
for (int i = 0; i < Children.Length; ++i)
{
diff --git a/Projects/Scripts/Engines/ConPVP/SafeZone.cs b/Projects/Scripts/Engines/ConPVP/SafeZone.cs
index e6016ad9f..212324942 100644
--- a/Projects/Scripts/Engines/ConPVP/SafeZone.cs
+++ b/Projects/Scripts/Engines/ConPVP/SafeZone.cs
@@ -31,7 +31,7 @@ namespace Server.Engines.ConPVP
PlayerMobile pm = m as PlayerMobile ??
(m is BaseCreature bc && bc.Summoned ?
- bc.SummonMaster as PlayerMobile : null);
+ bc.SummonMaster as PlayerMobile : null);
if (pm?.DuelContext?.StartedBeginCountdown == true)
return true;
diff --git a/Projects/Scripts/Engines/ConPVP/Tournament.cs b/Projects/Scripts/Engines/ConPVP/Tournament.cs
index f841ccb9c..bd2e9c569 100644
--- a/Projects/Scripts/Engines/ConPVP/Tournament.cs
+++ b/Projects/Scripts/Engines/ConPVP/Tournament.cs
@@ -203,10 +203,8 @@ namespace Server.Engines.ConPVP
public bool HasParticipant(Mobile mob)
{
for (int i = 0; i < Participants.Count; ++i)
- {
if (Participants[i].Players.Contains(mob))
return true;
- }
return false;
}
@@ -369,10 +367,8 @@ namespace Server.Engines.ConPVP
int rem = 0;
for (int i = 0; i < part.Context.Participants.Count; ++i)
- {
if (part.Context.Participants[i]?.Eliminated == false)
++rem;
- }
TourneyParticipant tp = part.TourneyPart;
@@ -791,92 +787,92 @@ namespace Server.Engines.ConPVP
continue;
for (int j = 0; j < part.Players.Count; ++j)
- part.Players[j].SendMessage("You have been disqualified from the tournament.");
+ part.Players[j].SendMessage("You have been disqualified from the tournament.");
- Undefeated.RemoveAt(i);
+ Undefeated.RemoveAt(i);
- if (Undefeated.Count == 1)
+ if (Undefeated.Count == 1)
+ {
+ TourneyParticipant winner = Undefeated[0];
+
+ try
{
- TourneyParticipant winner = Undefeated[0];
-
- try
+ if (EventController != null)
{
- if (EventController != null)
+ Alert("The tournament has completed!",
+ $"Team {EventController.GetTeamName(Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner))} has won");
+ }
+ else if (TourneyType == TourneyType.RandomTeam)
+ {
+ Alert("The tournament has completed!",
+ $"Team {Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) + 1} has won!");
+ }
+ else if (TourneyType == TourneyType.Faction)
+ {
+ if (m_ParticipantsPerMatch == 4)
{
- Alert("The tournament has completed!",
- $"Team {EventController.GetTeamName(Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner))} has won");
- }
- else if (TourneyType == TourneyType.RandomTeam)
- {
- Alert("The tournament has completed!",
- $"Team {Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) + 1} has won!");
- }
- else if (TourneyType == TourneyType.Faction)
- {
- if (m_ParticipantsPerMatch == 4)
- {
- string name = "(null)";
+ string name = "(null)";
- switch (Pyramid.Levels[0].Matches[0]
- .Participants.IndexOf(winner))
+ switch (Pyramid.Levels[0].Matches[0]
+ .Participants.IndexOf(winner))
+ {
+ case 0:
{
- case 0:
- {
- name = "Minax";
- break;
- }
- case 1:
- {
- name = "Council of Mages";
- break;
- }
- case 2:
- {
- name = "True Britannians";
- break;
- }
- case 3:
- {
- name = "Shadowlords";
- break;
- }
+ name = "Minax";
+ break;
}
+ case 1:
+ {
+ name = "Council of Mages";
+ break;
+ }
+ case 2:
+ {
+ name = "True Britannians";
+ break;
+ }
+ case 3:
+ {
+ name = "Shadowlords";
+ break;
+ }
+ }
- Alert("The tournament has completed!", $"The {name} team has won!");
- }
- else if (m_ParticipantsPerMatch == 2)
- {
- Alert("The tournament has completed!",
- $"The {(Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) == 0 ? "Evil" : "Hero")} team has won!");
- }
- else
- {
- Alert("The tournament has completed!",
- $"Team {Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) + 1} has won!");
- }
+ Alert("The tournament has completed!", $"The {name} team has won!");
}
- else if (TourneyType == TourneyType.RedVsBlue)
+ else if (m_ParticipantsPerMatch == 2)
{
Alert("The tournament has completed!",
- $"Team {(Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) == 0 ? "Red" : "Blue")} has won!");
+ $"The {(Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) == 0 ? "Evil" : "Hero")} team has won!");
}
else
{
Alert("The tournament has completed!",
- $"{winner.NameList} {(winner.Players.Count > 1 ? "are" : "is")} the champion{(winner.Players.Count == 1 ? "" : "s")}.");
+ $"Team {Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) + 1} has won!");
}
}
- catch
+ else if (TourneyType == TourneyType.RedVsBlue)
{
- // ignored
+ Alert("The tournament has completed!",
+ $"Team {(Pyramid.Levels[0].Matches[0].Participants.IndexOf(winner) == 0 ? "Red" : "Blue")} has won!");
+ }
+ else
+ {
+ Alert("The tournament has completed!",
+ $"{winner.NameList} {(winner.Players.Count > 1 ? "are" : "is")} the champion{(winner.Players.Count == 1 ? "" : "s")}.");
}
-
- GiveAwards();
-
- CurrentStage = TournamentStage.Inactive;
- Undefeated.Clear();
- break;
}
+ catch
+ {
+ // ignored
+ }
+
+ GiveAwards();
+
+ CurrentStage = TournamentStage.Inactive;
+ Undefeated.Clear();
+ break;
+ }
}
diff --git a/Projects/Scripts/Engines/ConPVP/TournamentPyramid.cs b/Projects/Scripts/Engines/ConPVP/TournamentPyramid.cs
index 983947d9e..a3b4d2da0 100644
--- a/Projects/Scripts/Engines/ConPVP/TournamentPyramid.cs
+++ b/Projects/Scripts/Engines/ConPVP/TournamentPyramid.cs
@@ -146,20 +146,13 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < partsPerMatch; ++i)
{
- int idx = 0;
-
- switch (groupType)
+ var idx = groupType switch
{
- case GroupingType.HighVsLow:
- idx = i * (copy.Count - 1) / (partsPerMatch - 1);
- break;
- case GroupingType.Nearest:
- idx = 0;
- break;
- case GroupingType.Random:
- idx = Utility.Random(copy.Count);
- break;
- }
+ GroupingType.HighVsLow => (i * (copy.Count - 1) / (partsPerMatch - 1)),
+ GroupingType.Nearest => 0,
+ GroupingType.Random => Utility.Random(copy.Count),
+ _ => 0
+ };
thisMatch.Add(copy[idx]);
copy.RemoveAt(idx);
diff --git a/Projects/Scripts/Engines/ConPVP/TournamentRegistrar.cs b/Projects/Scripts/Engines/ConPVP/TournamentRegistrar.cs
index 562d7cccf..bd34dbcaa 100644
--- a/Projects/Scripts/Engines/ConPVP/TournamentRegistrar.cs
+++ b/Projects/Scripts/Engines/ConPVP/TournamentRegistrar.cs
@@ -1,93 +1,93 @@
-using System;
-using Server.Factions;
-using Server.Mobiles;
-using Server.Network;
-
-namespace Server.Engines.ConPVP
-{
-public class TournamentRegistrar : Banker
- {
- [Constructible]
- public TournamentRegistrar()
- {
- Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);
- }
-
- public TournamentRegistrar(Serial serial) : base(serial)
- {
- }
-
- [CommandProperty(AccessLevel.GameMaster)]
- public TournamentController Tournament{ get; set; }
-
- private void Announce_Callback()
- {
- Tournament tourney = Tournament?.Tournament;
-
- if (tourney?.Stage == TournamentStage.Signup)
- PublicOverheadMessage(MessageType.Regular, 0x35, false,
- "Come one, come all! Do you aspire to be a fighter of great renown? Join this tournament and show the world your abilities.");
- }
-
- public override void OnMovement(Mobile m, Point3D oldLocation)
- {
- base.OnMovement(m, oldLocation);
-
- Tournament tourney = Tournament?.Tournament;
-
- if (InRange(m, 4) && !InRange(oldLocation, 4) && tourney != null && tourney.Stage == TournamentStage.Signup &&
- m.CanBeginAction(this))
- {
- Ladder ladder = Ladder.Instance;
-
- LadderEntry entry = ladder?.Find(m);
-
- if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
- return;
-
- if (tourney.IsFactionRestricted && Faction.Find(m) == null) return;
-
- if (tourney.HasParticipant(m))
- return;
-
- PrivateOverheadMessage(MessageType.Regular, 0x35, false,
- $"Hello m'{(m.Female ? "Lady" : "Lord")}. Dost thou wish to enter this tournament? You need only to write your name in this book.",
- m.NetState);
- m.BeginAction(this);
- Timer.DelayCall(TimeSpan.FromSeconds(10.0), ReleaseLock_Callback, m);
- }
- }
-
- public void ReleaseLock_Callback(Mobile m)
- {
- m.EndAction(this);
- }
-
- public override void Serialize(GenericWriter writer)
- {
- base.Serialize(writer);
-
- writer.Write(0);
-
- writer.Write(Tournament);
- }
-
- public override void Deserialize(GenericReader reader)
- {
- base.Deserialize(reader);
-
- int version = reader.ReadInt();
-
- switch (version)
- {
- case 0:
- {
- Tournament = reader.ReadItem() as TournamentController;
- break;
- }
- }
-
- Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);
- }
- }
-}
\ No newline at end of file
+using System;
+using Server.Factions;
+using Server.Mobiles;
+using Server.Network;
+
+namespace Server.Engines.ConPVP
+{
+ public class TournamentRegistrar : Banker
+ {
+ [Constructible]
+ public TournamentRegistrar()
+ {
+ Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);
+ }
+
+ public TournamentRegistrar(Serial serial) : base(serial)
+ {
+ }
+
+ [CommandProperty(AccessLevel.GameMaster)]
+ public TournamentController Tournament{ get; set; }
+
+ private void Announce_Callback()
+ {
+ Tournament tourney = Tournament?.Tournament;
+
+ if (tourney?.Stage == TournamentStage.Signup)
+ PublicOverheadMessage(MessageType.Regular, 0x35, false,
+ "Come one, come all! Do you aspire to be a fighter of great renown? Join this tournament and show the world your abilities.");
+ }
+
+ public override void OnMovement(Mobile m, Point3D oldLocation)
+ {
+ base.OnMovement(m, oldLocation);
+
+ Tournament tourney = Tournament?.Tournament;
+
+ if (InRange(m, 4) && !InRange(oldLocation, 4) && tourney != null && tourney.Stage == TournamentStage.Signup &&
+ m.CanBeginAction(this))
+ {
+ Ladder ladder = Ladder.Instance;
+
+ LadderEntry entry = ladder?.Find(m);
+
+ if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
+ return;
+
+ if (tourney.IsFactionRestricted && Faction.Find(m) == null) return;
+
+ if (tourney.HasParticipant(m))
+ return;
+
+ PrivateOverheadMessage(MessageType.Regular, 0x35, false,
+ $"Hello m'{(m.Female ? "Lady" : "Lord")}. Dost thou wish to enter this tournament? You need only to write your name in this book.",
+ m.NetState);
+ m.BeginAction(this);
+ Timer.DelayCall(TimeSpan.FromSeconds(10.0), ReleaseLock_Callback, m);
+ }
+ }
+
+ public void ReleaseLock_Callback(Mobile m)
+ {
+ m.EndAction(this);
+ }
+
+ public override void Serialize(GenericWriter writer)
+ {
+ base.Serialize(writer);
+
+ writer.Write(0);
+
+ writer.Write(Tournament);
+ }
+
+ public override void Deserialize(GenericReader reader)
+ {
+ base.Deserialize(reader);
+
+ int version = reader.ReadInt();
+
+ switch (version)
+ {
+ case 0:
+ {
+ Tournament = reader.ReadItem() as TournamentController;
+ break;
+ }
+ }
+
+ Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);
+ }
+ }
+}
diff --git a/Projects/Scripts/Engines/ConPVP/TournamentSignupItem.cs b/Projects/Scripts/Engines/ConPVP/TournamentSignupItem.cs
index d7631da5a..fcb2ca420 100644
--- a/Projects/Scripts/Engines/ConPVP/TournamentSignupItem.cs
+++ b/Projects/Scripts/Engines/ConPVP/TournamentSignupItem.cs
@@ -5,7 +5,7 @@ using Server.Network;
namespace Server.Engines.ConPVP
{
-public class TournamentSignupItem : Item
+ public class TournamentSignupItem : Item
{
[Constructible]
public TournamentSignupItem() : base(4029) => Movable = false;
@@ -34,85 +34,85 @@ public class TournamentSignupItem : Item
if (tourney == null)
return;
-
+
if (Registrar != null)
- Registrar.Direction = Registrar.GetDirectionTo(this);
+ Registrar.Direction = Registrar.GetDirectionTo(this);
- switch (tourney.Stage)
+ switch (tourney.Stage)
+ {
+ case TournamentStage.Fighting:
{
- case TournamentStage.Fighting:
+ if (Registrar != null)
{
- if (Registrar != null)
- {
- if (tourney.HasParticipant(from))
- Registrar.PrivateOverheadMessage(MessageType.Regular,
- 0x35, false, "Excuse me? You are already signed up.", from.NetState);
- else
- Registrar.PrivateOverheadMessage(MessageType.Regular,
- 0x22, false, "The tournament has already begun. You are too late to signup now.",
- from.NetState);
- }
-
- break;
+ if (tourney.HasParticipant(from))
+ Registrar.PrivateOverheadMessage(MessageType.Regular,
+ 0x35, false, "Excuse me? You are already signed up.", from.NetState);
+ else
+ Registrar.PrivateOverheadMessage(MessageType.Regular,
+ 0x22, false, "The tournament has already begun. You are too late to signup now.",
+ from.NetState);
}
- case TournamentStage.Inactive:
+
+ break;
+ }
+ case TournamentStage.Inactive:
+ {
+ Registrar?.PrivateOverheadMessage(MessageType.Regular,
+ 0x35, false, "The tournament is closed.", from.NetState);
+
+ break;
+ }
+ case TournamentStage.Signup:
+ {
+ Ladder ladder = Ladder.Instance;
+ LadderEntry entry = ladder?.Find(from);
+
+ if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
{
Registrar?.PrivateOverheadMessage(MessageType.Regular,
- 0x35, false, "The tournament is closed.", from.NetState);
+ 0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
break;
}
- case TournamentStage.Signup:
+
+ if (tourney.IsFactionRestricted && Faction.Find(from) == null)
{
- Ladder ladder = Ladder.Instance;
- LadderEntry entry = ladder?.Find(from);
-
- if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
- {
- Registrar?.PrivateOverheadMessage(MessageType.Regular,
- 0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
-
- break;
- }
-
- if (tourney.IsFactionRestricted && Faction.Find(from) == null)
- {
- Registrar?.PrivateOverheadMessage(MessageType.Regular,
- 0x35, false, "Only those who have declared their faction allegiance may participate.",
- from.NetState);
-
- break;
- }
-
- if (from.HasGump
())
- {
- Registrar?.PrivateOverheadMessage(MessageType.Regular,
- 0x22, false, "You must first respond to the offer I've given you.", from.NetState);
- }
- else if (from.HasGump())
- {
- Registrar?.PrivateOverheadMessage(MessageType.Regular,
- 0x22, false, "You must first cancel your duel offer.", from.NetState);
- }
- else if (from is PlayerMobile mobile && mobile.DuelContext != null)
- {
- Registrar?.PrivateOverheadMessage(MessageType.Regular,
- 0x22, false, "You are already participating in a duel.", mobile.NetState);
- }
- else if (!tourney.HasParticipant(from))
- {
- from.CloseGump();
- from.SendGump(new ConfirmSignupGump(from, Registrar, tourney, new List { from }));
- }
- else
- {
- Registrar?.PrivateOverheadMessage(MessageType.Regular,
- 0x35, false, "You have already entered this tournament.", from.NetState);
- }
+ Registrar?.PrivateOverheadMessage(MessageType.Regular,
+ 0x35, false, "Only those who have declared their faction allegiance may participate.",
+ from.NetState);
break;
}
+
+ if (from.HasGump())
+ {
+ Registrar?.PrivateOverheadMessage(MessageType.Regular,
+ 0x22, false, "You must first respond to the offer I've given you.", from.NetState);
+ }
+ else if (from.HasGump())
+ {
+ Registrar?.PrivateOverheadMessage(MessageType.Regular,
+ 0x22, false, "You must first cancel your duel offer.", from.NetState);
+ }
+ else if (from is PlayerMobile mobile && mobile.DuelContext != null)
+ {
+ Registrar?.PrivateOverheadMessage(MessageType.Regular,
+ 0x22, false, "You are already participating in a duel.", mobile.NetState);
+ }
+ else if (!tourney.HasParticipant(from))
+ {
+ from.CloseGump();
+ from.SendGump(new ConfirmSignupGump(from, Registrar, tourney, new List { from }));
+ }
+ else
+ {
+ Registrar?.PrivateOverheadMessage(MessageType.Regular,
+ 0x35, false, "You have already entered this tournament.", from.NetState);
+ }
+
+ break;
}
+ }
}
}
@@ -143,4 +143,4 @@ public class TournamentSignupItem : Item
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Engines/ConPVP/Trophy.cs b/Projects/Scripts/Engines/ConPVP/Trophy.cs
index 3a97c3155..79ad641ce 100644
--- a/Projects/Scripts/Engines/ConPVP/Trophy.cs
+++ b/Projects/Scripts/Engines/ConPVP/Trophy.cs
@@ -102,18 +102,13 @@ namespace Server.Items
{
Name = $"{m_Rank.ToString().ToLower()} trophy";
- switch (m_Rank)
+ Hue = m_Rank switch
{
- case TrophyRank.Gold:
- Hue = 2213;
- break;
- case TrophyRank.Silver:
- Hue = 0;
- break;
- case TrophyRank.Bronze:
- Hue = 2206;
- break;
- }
+ TrophyRank.Gold => 2213,
+ TrophyRank.Silver => 0,
+ TrophyRank.Bronze => 2206,
+ _ => Hue
+ };
}
}
}
\ No newline at end of file
diff --git a/Projects/Scripts/Engines/Craft/Core/CraftGump.cs b/Projects/Scripts/Engines/Craft/Core/CraftGump.cs
index 2a0b866dd..e7f5447ce 100644
--- a/Projects/Scripts/Engines/Craft/Core/CraftGump.cs
+++ b/Projects/Scripts/Engines/Craft/Core/CraftGump.cs
@@ -201,7 +201,7 @@ namespace Server.Engines.Craft
CraftContext context = m_CraftSystem.GetContext(m_From);
AddButton(220, 260, 4005, 4007, GetButtonID(6, 4));
- AddHtmlLocalized(255, 263, 200, 18, context == null || !context.DoNotColor ? 1061591 : 1061590,
+ AddHtmlLocalized(255, 263, 200, 18, context?.DoNotColor != true ? 1061591 : 1061590,
LabelColor);
}
@@ -557,18 +557,13 @@ namespace Server.Engines.Craft
if (context == null || !system.MarkOption)
break;
- switch (context.MarkOption)
+ context.MarkOption = context.MarkOption switch
{
- case CraftMarkOption.MarkItem:
- context.MarkOption = CraftMarkOption.DoNotMark;
- break;
- case CraftMarkOption.DoNotMark:
- context.MarkOption = CraftMarkOption.PromptForMark;
- break;
- case CraftMarkOption.PromptForMark:
- context.MarkOption = CraftMarkOption.MarkItem;
- break;
- }
+ CraftMarkOption.MarkItem => CraftMarkOption.DoNotMark,
+ CraftMarkOption.DoNotMark => CraftMarkOption.PromptForMark,
+ CraftMarkOption.PromptForMark => CraftMarkOption.MarkItem,
+ _ => context.MarkOption
+ };
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));
diff --git a/Projects/Scripts/Engines/Craft/Core/CraftGumpItem.cs b/Projects/Scripts/Engines/Craft/Core/CraftGumpItem.cs
index 406f0a19c..02badb300 100644
--- a/Projects/Scripts/Engines/Craft/Core/CraftGumpItem.cs
+++ b/Projects/Scripts/Engines/Craft/Core/CraftGumpItem.cs
@@ -111,15 +111,12 @@ namespace Server.Engines.Craft
private TextDefinition RequiredExpansionMessage(Expansion expansion)
{
- switch (expansion)
+ return expansion switch
{
- case Expansion.SE:
- return 1063363; // * Requires the "Samurai Empire" expansion
- case Expansion.ML:
- return 1072651; // * Requires the "Mondain's Legacy" expansion
- default:
- return $"* Requires the \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion";
- }
+ Expansion.SE => (TextDefinition)1063363, // * Requires the "Samurai Empire" expansion
+ Expansion.ML => (TextDefinition)1072651, // * Requires the "Mondain's Legacy" expansion
+ _ => (TextDefinition)$"* Requires the \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion"
+ };
}
public void DrawItem()
diff --git a/Projects/Scripts/Engines/Craft/Core/CraftItem.cs b/Projects/Scripts/Engines/Craft/Core/CraftItem.cs
index 13644ba2c..23611a3ed 100644
--- a/Projects/Scripts/Engines/Craft/Core/CraftItem.cs
+++ b/Projects/Scripts/Engines/Craft/Core/CraftItem.cs
@@ -755,7 +755,7 @@ namespace Server.Engines.Craft
if (allRequiredSkills && chance >= 0.0)
{
- if (Recipe == null || !(from is PlayerMobile) || ((PlayerMobile)from).HasRecipe(Recipe))
+ if (Recipe == null || (from as PlayerMobile)?.HasRecipe(Recipe) != false)
{
int badCraft = craftSystem.CanCraft(from, tool, ItemType);
@@ -827,20 +827,15 @@ namespace Server.Engines.Craft
}
}
- private object
- RequiredExpansionMessage(
- Expansion expansion) //Eventually convert to TextDefinition, but that requires that we convert all the gumps to ues it too. Not that it wouldn't be a bad idea.
+ //Eventually convert to TextDefinition, but that requires that we convert all the gumps to ues it too. Not that it wouldn't be a bad idea.
+ private object RequiredExpansionMessage(Expansion expansion)
{
- switch (expansion)
+ return expansion switch
{
- case Expansion.SE:
- return 1063307; // The "Samurai Empire" expansion is required to attempt this item.
- case Expansion.ML:
- return 1072650; // The "Mondain's Legacy" expansion is required to attempt this item.
- default:
- return
- $"The \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion is required to attempt this item.";
- }
+ Expansion.SE => (object)1063307, // The "Samurai Empire" expansion is required to attempt this item.
+ Expansion.ML => 1072650, // The "Mondain's Legacy" expansion is required to attempt this item.
+ _ => $"The \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion is required to attempt this item."
+ };
}
public void CompleteCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes,
diff --git a/Projects/Scripts/Engines/Craft/Core/Enhance.cs b/Projects/Scripts/Engines/Craft/Core/Enhance.cs
index 95969b93d..e2fe21aa0 100644
--- a/Projects/Scripts/Engines/Craft/Core/Enhance.cs
+++ b/Projects/Scripts/Engines/Craft/Core/Enhance.cs
@@ -304,33 +304,18 @@ namespace Server.Engines.Craft
EnhanceResult res = Enhance.Invoke(from, m_CraftSystem, m_Tool, item, m_Resource, m_ResourceType,
ref message);
- switch (res)
+ message = res switch
{
- case EnhanceResult.NotInBackpack:
- message = 1061005;
- break; // The item must be in your backpack to enhance it.
- case EnhanceResult.AlreadyEnhanced:
- message = 1061012;
- break; // This item is already enhanced with the properties of a special material.
- case EnhanceResult.BadItem:
- message = 1061011;
- break; // You cannot enhance this type of item with the properties of the selected special material.
- case EnhanceResult.BadResource:
- message = 1061010;
- break; // You must select a special material in order to enhance an item with its properties.
- case EnhanceResult.Broken:
- message = 1061080;
- break; // You attempt to enhance the item, but fail catastrophically. The item is lost.
- case EnhanceResult.Failure:
- message = 1061082;
- break; // You attempt to enhance the item, but fail. Some material is lost in the process.
- case EnhanceResult.Success:
- message = 1061008;
- break; // You enhance the item with the properties of the special material.
- case EnhanceResult.NoSkill:
- message = 1044153;
- break; // You don't have the required skills to attempt this item.
- }
+ EnhanceResult.NotInBackpack => 1061005,
+ EnhanceResult.AlreadyEnhanced => 1061012,
+ EnhanceResult.BadItem => 1061011,
+ EnhanceResult.BadResource => 1061010,
+ EnhanceResult.Broken => 1061080,
+ EnhanceResult.Failure => 1061082,
+ EnhanceResult.Success => 1061008,
+ EnhanceResult.NoSkill => 1044153,
+ _ => message
+ };
from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, message));
}
diff --git a/Projects/Scripts/Engines/Craft/Core/Recipes.cs b/Projects/Scripts/Engines/Craft/Core/Recipes.cs
index 9f4b286a7..a2b3578c3 100644
--- a/Projects/Scripts/Engines/Craft/Core/Recipes.cs
+++ b/Projects/Scripts/Engines/Craft/Core/Recipes.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using Server.Commands;
using Server.Mobiles;
using Server.Targeting;
diff --git a/Projects/Scripts/Engines/Craft/Core/Resmelt.cs b/Projects/Scripts/Engines/Craft/Core/Resmelt.cs
index 12d392327..4e63f3d50 100644
--- a/Projects/Scripts/Engines/Craft/Core/Resmelt.cs
+++ b/Projects/Scripts/Engines/Craft/Core/Resmelt.cs
@@ -65,35 +65,18 @@ namespace Server.Engines.Craft
if (craftResource.Amount < 2)
return SmeltResult.Invalid; // Not enough metal to resmelt
- double difficulty = 0.0;
-
- switch (resource)
+ var difficulty = resource switch
{
- case CraftResource.DullCopper:
- difficulty = 65.0;
- break;
- case CraftResource.ShadowIron:
- difficulty = 70.0;
- break;
- case CraftResource.Copper:
- difficulty = 75.0;
- break;
- case CraftResource.Bronze:
- difficulty = 80.0;
- break;
- case CraftResource.Gold:
- difficulty = 85.0;
- break;
- case CraftResource.Agapite:
- difficulty = 90.0;
- break;
- case CraftResource.Verite:
- difficulty = 95.0;
- break;
- case CraftResource.Valorite:
- difficulty = 99.0;
- break;
- }
+ CraftResource.DullCopper => 65.0,
+ CraftResource.ShadowIron => 70.0,
+ CraftResource.Copper => 75.0,
+ CraftResource.Bronze => 80.0,
+ CraftResource.Gold => 85.0,
+ CraftResource.Agapite => 90.0,
+ CraftResource.Verite => 95.0,
+ CraftResource.Valorite => 99.0,
+ _ => 0.0
+ };
if (difficulty > from.Skills.Mining.Value)
return SmeltResult.NoSkill;
@@ -163,19 +146,13 @@ namespace Server.Engines.Craft
isStoreBought = false;
}
- switch (result)
+ message = result switch
{
- default:
- case SmeltResult.Invalid:
- message = 1044272;
- break; // You can't melt that down into ingots.
- case SmeltResult.NoSkill:
- message = 1044269;
- break; // You have no idea how to work this metal.
- case SmeltResult.Success:
- message = isStoreBought ? 500418 : 1044270;
- break; // You melt the item down into ingots.
- }
+ SmeltResult.Invalid => 1044272,
+ SmeltResult.NoSkill => 1044269,
+ SmeltResult.Success => (isStoreBought ? 500418 : 1044270),
+ _ => 1044272
+ };
from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, message));
}
diff --git a/Projects/Scripts/Engines/Doom/GauntletSpawner.cs b/Projects/Scripts/Engines/Doom/GauntletSpawner.cs
index 57c4225aa..2a10a2ddf 100644
--- a/Projects/Scripts/Engines/Doom/GauntletSpawner.cs
+++ b/Projects/Scripts/Engines/Doom/GauntletSpawner.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using Server.Commands;
using Server.Items;
using Server.Mobiles;
using Server.Regions;
@@ -90,18 +89,13 @@ namespace Server.Engines.Doom
int hue = 0;
bool lockDoors = m_State == GauntletSpawnerState.InProgress;
- switch (m_State)
+ hue = m_State switch
{
- case GauntletSpawnerState.InSequence:
- hue = InSequenceItemHue;
- break;
- case GauntletSpawnerState.InProgress:
- hue = InProgressItemHue;
- break;
- case GauntletSpawnerState.Completed:
- hue = CompletedItemHue;
- break;
- }
+ GauntletSpawnerState.InSequence => InSequenceItemHue,
+ GauntletSpawnerState.InProgress => InProgressItemHue,
+ GauntletSpawnerState.Completed => CompletedItemHue,
+ _ => hue
+ };
if (Door != null)
{
diff --git a/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs b/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs
index 058ad0a1e..4dbad8c90 100644
--- a/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs
+++ b/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Server.Commands;
using Server.Mobiles;
using Server.Network;
using Server.Spells;
@@ -239,7 +238,7 @@ namespace Server.Engines.Doom
{
LeverPuzzleRegion region = m_Tiles[index];
- if (region?.Occupant != null && region.Occupant.Alive) return (PlayerMobile)region.Occupant;
+ if (region?.Occupant?.Alive == true) return (PlayerMobile)region.Occupant;
return null;
}
@@ -338,7 +337,7 @@ namespace Server.Engines.Doom
else
{
for (int i = 0; i < 16; i++) /* Count matching SET bits, ie correct codes */
- if (((MyKey >> i) & 1) == 1 && ((TheirKey >> i) & 1) == 1)
+ if ((MyKey >> i & 1) == 1 && (TheirKey >> i & 1) == 1)
correct++;
PuzzleStatus(Statue_Msg[correct], correct > 0 ? correct.ToString() : null);
diff --git a/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs b/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs
index a1be099c1..967aaa563 100644
--- a/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs
+++ b/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs
@@ -28,7 +28,7 @@ namespace Server.Engines.Doom
if (m_Controller.Enabled)
return;
- if (m_Wanderer == null || !m_Wanderer.Alive)
+ if (m_Wanderer?.Alive != true)
{
m_Wanderer = new WandererOfTheVoid();
m_Wanderer.MoveToWorld(LeverPuzzleController.lr_Enter, Map.Malas);
diff --git a/Projects/Scripts/Engines/Ethics/Evil/Mobiles/UnholyFamiliar.cs b/Projects/Scripts/Engines/Ethics/Evil/Mobiles/UnholyFamiliar.cs
index b768f793b..360e8ea3a 100644
--- a/Projects/Scripts/Engines/Ethics/Evil/Mobiles/UnholyFamiliar.cs
+++ b/Projects/Scripts/Engines/Ethics/Evil/Mobiles/UnholyFamiliar.cs
@@ -61,7 +61,7 @@ namespace Server.Mobiles
if (suffix.Length == 0)
suffix = Ethic.Evil.Definition.Adjunct.String;
else
- suffix = string.Concat(suffix, " ", Ethic.Evil.Definition.Adjunct.String);
+ suffix = $"{suffix} {Ethic.Evil.Definition.Adjunct.String}";
return base.ApplyNameSuffix(suffix);
}
diff --git a/Projects/Scripts/Engines/Ethics/Evil/Mobiles/UnholySteed.cs b/Projects/Scripts/Engines/Ethics/Evil/Mobiles/UnholySteed.cs
index 837af47c0..d8d09a9b2 100644
--- a/Projects/Scripts/Engines/Ethics/Evil/Mobiles/UnholySteed.cs
+++ b/Projects/Scripts/Engines/Ethics/Evil/Mobiles/UnholySteed.cs
@@ -58,7 +58,7 @@ namespace Server.Mobiles
if (suffix.Length == 0)
suffix = Ethic.Evil.Definition.Adjunct.String;
else
- suffix = string.Concat(suffix, " ", Ethic.Evil.Definition.Adjunct.String);
+ suffix = $"{suffix} {Ethic.Evil.Definition.Adjunct.String}";
return base.ApplyNameSuffix(suffix);
}
diff --git a/Projects/Scripts/Engines/Ethics/Hero/Mobiles/HolyFamiliar.cs b/Projects/Scripts/Engines/Ethics/Hero/Mobiles/HolyFamiliar.cs
index cad69eb9c..803216dae 100644
--- a/Projects/Scripts/Engines/Ethics/Hero/Mobiles/HolyFamiliar.cs
+++ b/Projects/Scripts/Engines/Ethics/Hero/Mobiles/HolyFamiliar.cs
@@ -62,7 +62,7 @@ namespace Server.Mobiles
if (suffix.Length == 0)
suffix = Ethic.Hero.Definition.Adjunct.String;
else
- suffix = string.Concat(suffix, " ", Ethic.Hero.Definition.Adjunct.String);
+ suffix = $"{suffix} {Ethic.Hero.Definition.Adjunct.String}";
return base.ApplyNameSuffix(suffix);
}
diff --git a/Projects/Scripts/Engines/Ethics/Hero/Mobiles/HolySteed.cs b/Projects/Scripts/Engines/Ethics/Hero/Mobiles/HolySteed.cs
index d8ceb96aa..51d8216c0 100644
--- a/Projects/Scripts/Engines/Ethics/Hero/Mobiles/HolySteed.cs
+++ b/Projects/Scripts/Engines/Ethics/Hero/Mobiles/HolySteed.cs
@@ -58,7 +58,7 @@ namespace Server.Mobiles
if (suffix.Length == 0)
suffix = Ethic.Hero.Definition.Adjunct.String;
else
- suffix = string.Concat(suffix, " ", Ethic.Hero.Definition.Adjunct.String);
+ suffix = $"{suffix} {Ethic.Hero.Definition.Adjunct.String}";
return base.ApplyNameSuffix(suffix);
}
diff --git a/Projects/Scripts/Engines/Factions/Core/Election.cs b/Projects/Scripts/Engines/Factions/Core/Election.cs
index 690b59b09..af6b6f63a 100644
--- a/Projects/Scripts/Engines/Factions/Core/Election.cs
+++ b/Projects/Scripts/Engines/Factions/Core/Election.cs
@@ -79,21 +79,13 @@ namespace Server.Factions
{
get
{
- TimeSpan period;
-
- switch (CurrentState)
+ var period = CurrentState switch
{
- default:
- case ElectionState.Pending:
- period = PendingPeriod;
- break;
- case ElectionState.Election:
- period = VotingPeriod;
- break;
- case ElectionState.Campaign:
- period = CampaignPeriod;
- break;
- }
+ ElectionState.Pending => PendingPeriod,
+ ElectionState.Election => VotingPeriod,
+ ElectionState.Campaign => CampaignPeriod,
+ _ => PendingPeriod
+ };
TimeSpan until = LastStateTime + period - DateTime.UtcNow;
@@ -104,21 +96,13 @@ namespace Server.Factions
}
set
{
- TimeSpan period;
-
- switch (CurrentState)
+ var period = CurrentState switch
{
- default:
- case ElectionState.Pending:
- period = PendingPeriod;
- break;
- case ElectionState.Election:
- period = VotingPeriod;
- break;
- case ElectionState.Campaign:
- period = CampaignPeriod;
- break;
- }
+ ElectionState.Pending => PendingPeriod,
+ ElectionState.Election => VotingPeriod,
+ ElectionState.Campaign => CampaignPeriod,
+ _ => PendingPeriod
+ };
LastStateTime = DateTime.UtcNow - period + value;
}
diff --git a/Projects/Scripts/Engines/Factions/Core/Faction.cs b/Projects/Scripts/Engines/Factions/Core/Faction.cs
index fb2a30699..4f9e0c0a4 100644
--- a/Projects/Scripts/Engines/Factions/Core/Faction.cs
+++ b/Projects/Scripts/Engines/Factions/Core/Faction.cs
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Server.Accounting;
-using Server.Commands;
using Server.Commands.Generic;
using Server.Engines.ConPVP;
using Server.Ethics;
@@ -381,7 +380,7 @@ namespace Server.Factions
else
{
AddMember(mob);
- mob.SendLocalizedMessage(1042756, true, " " + m_Definition.FriendlyName); // You are now joining a faction:
+ mob.SendLocalizedMessage(1042756, true, $" {m_Definition.FriendlyName}"); // You are now joining a faction:
}
}
@@ -424,7 +423,7 @@ namespace Server.Factions
{
pm.SendLocalizedMessage(1010104); // You cannot join a faction as a young player
}
- else if (pl != null && pl.IsLeaving)
+ else if (pl?.IsLeaving == true)
{
pm.SendLocalizedMessage(
1005051); // You cannot use the faction stone until you have finished quitting your current faction
@@ -505,7 +504,7 @@ namespace Server.Factions
{
PlayerState pl = PlayerState.Find(mob);
- if (pl == null || !pl.IsLeaving)
+ if (pl?.IsLeaving != true)
return false;
if (pl.Leaving + LeavePeriod >= DateTime.UtcNow)
diff --git a/Projects/Scripts/Engines/Factions/Core/Generator.cs b/Projects/Scripts/Engines/Factions/Core/Generator.cs
index 945b13e25..1e5a6c60c 100644
--- a/Projects/Scripts/Engines/Factions/Core/Generator.cs
+++ b/Projects/Scripts/Engines/Factions/Core/Generator.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Server.Commands;
namespace Server.Factions
{
diff --git a/Projects/Scripts/Engines/Factions/Core/Keywords.cs b/Projects/Scripts/Engines/Factions/Core/Keywords.cs
index 07f635afd..ec2955400 100644
--- a/Projects/Scripts/Engines/Factions/Core/Keywords.cs
+++ b/Projects/Scripts/Engines/Factions/Core/Keywords.cs
@@ -29,7 +29,7 @@ namespace Server.Factions
{
Town town = Town.FromRegion(from.Region);
- if (town == null || !town.IsFinance(from) || !from.Alive)
+ if (town?.IsFinance(from) != true || !from.Alive)
break;
if (FactionGump.Exists(from))
@@ -43,7 +43,7 @@ namespace Server.Factions
{
Town town = Town.FromRegion(from.Region);
- if (town == null || !town.IsSheriff(from) || !from.Alive)
+ if (town?.IsSheriff(from) != true || !from.Alive)
break;
if (FactionGump.Exists(from))
@@ -123,7 +123,7 @@ namespace Server.Factions
{
Faction faction = Faction.Find(from);
- if (faction == null || !faction.IsCommander(from))
+ if (faction?.IsCommander(from) != true)
break;
if (from.AccessLevel == AccessLevel.Player && !faction.FactionMessageReady)
@@ -151,4 +151,4 @@ namespace Server.Factions
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Engines/Factions/Core/Town.cs b/Projects/Scripts/Engines/Factions/Core/Town.cs
index 635b6c67e..50be1761f 100644
--- a/Projects/Scripts/Engines/Factions/Core/Town.cs
+++ b/Projects/Scripts/Engines/Factions/Core/Town.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using Server.Commands;
using Server.Targeting;
namespace Server.Factions
diff --git a/Projects/Scripts/Engines/Factions/Gumps/ElectionManagementGump.cs b/Projects/Scripts/Engines/Factions/Gumps/ElectionManagementGump.cs
index 27b520e55..0740c3252 100644
--- a/Projects/Scripts/Engines/Factions/Gumps/ElectionManagementGump.cs
+++ b/Projects/Scripts/Engines/Factions/Gumps/ElectionManagementGump.cs
@@ -94,7 +94,7 @@ namespace Server.Factions
}
else if (obj is int i1)
{
- AddHtml(x, 140 + idx * 20, 60, 20, Color(Center(i1 + "%"), LabelColor));
+ AddHtml(x, 140 + idx * 20, 60, 20, Color(Center($"{i1}%"), LabelColor));
x += 60;
}
}
diff --git a/Projects/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs b/Projects/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs
index 8ef7087f4..ac307a999 100644
--- a/Projects/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs
+++ b/Projects/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs
@@ -33,7 +33,7 @@ namespace Server.Factions
if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0)
AddHtmlLocalized(125, 80, 350, 20, 1011480 + faction.Tithe / 10);
else
- AddHtml(125, 80, 350, 20, faction.Tithe + "%");
+ AddHtml(125, 80, 350, 20, $"{faction.Tithe}%");
AddHtmlLocalized(20, 100, 100, 20, 1011458); // Traps placed :
AddHtml(125, 100, 50, 20, faction.Traps.Count.ToString());
@@ -105,7 +105,7 @@ namespace Server.Factions
BaseMonolith monolith = town.Monolith;
- AddImage(20, 60 + i * 30, monolith?.Sigil != null && monolith.Sigil.IsPurifying ? 0x938 : 0x939);
+ AddImage(20, 60 + i * 30, monolith?.Sigil?.IsPurifying == true ? 0x938 : 0x939);
}
}
@@ -185,7 +185,7 @@ namespace Server.Factions
if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0)
AddHtmlLocalized(140, 70, 250, 20, 1011480 + faction.Tithe / 10);
else
- AddHtml(140, 70, 250, 20, faction.Tithe + "%");
+ AddHtml(140, 70, 250, 20, $"{faction.Tithe}%");
AddHtmlLocalized(20, 100, 120, 20, 1011474); // Silver available :
AddHtml(140, 100, 50, 20, faction.Silver.ToString("N0")); // NOTE: Added 'N0' formatting
@@ -335,7 +335,7 @@ namespace Server.Factions
town.Silver += 10000;
// 10k in silver has been received by:
- m_From.SendLocalizedMessage(1042726, true, " " + town.Definition.FriendlyName);
+ m_From.SendLocalizedMessage(1042726, true, $" {town.Definition.FriendlyName}");
}
}
diff --git a/Projects/Scripts/Engines/Factions/Gumps/FinanceGump.cs b/Projects/Scripts/Engines/Factions/Gumps/FinanceGump.cs
index a4ac3201f..35426e605 100644
--- a/Projects/Scripts/Engines/Factions/Gumps/FinanceGump.cs
+++ b/Projects/Scripts/Engines/Factions/Gumps/FinanceGump.cs
@@ -68,9 +68,9 @@ namespace Server.Factions
AddRadio(x, y, 208, 209, town.Tax == ofs, i + 1);
if (ofs < 0)
- AddLabel(x + 35, y, 0x26, string.Concat("- ", -ofs, "%"));
+ AddLabel(x + 35, y, 0x26, $"- {-ofs}%");
else
- AddLabel(x + 35, y, 0x12A, string.Concat("+ ", ofs, "%"));
+ AddLabel(x + 35, y, 0x12A, $"+ {ofs}%");
}
AddRadio(20, 270, 208, 209, town.Tax == 0, 0);
diff --git a/Projects/Scripts/Engines/Factions/Gumps/JoinStoneGump.cs b/Projects/Scripts/Engines/Factions/Gumps/JoinStoneGump.cs
index 96874dd37..f68d5d060 100644
--- a/Projects/Scripts/Engines/Factions/Gumps/JoinStoneGump.cs
+++ b/Projects/Scripts/Engines/Factions/Gumps/JoinStoneGump.cs
@@ -31,7 +31,7 @@ namespace Server.Factions
if (faction.Tithe >= 0 && faction.Tithe <= 100 && faction.Tithe % 10 == 0)
AddHtmlLocalized(125, 80, 350, 20, 1011480 + faction.Tithe / 10);
else
- AddHtml(125, 80, 350, 20, faction.Tithe + "%");
+ AddHtml(125, 80, 350, 20, $"{faction.Tithe}%");
AddButton(20, 400, 4005, 4007, 1);
diff --git a/Projects/Scripts/Engines/Factions/Items/FactionStone.cs b/Projects/Scripts/Engines/Factions/Items/FactionStone.cs
index 0881ba539..16cadd566 100644
--- a/Projects/Scripts/Engines/Factions/Items/FactionStone.cs
+++ b/Projects/Scripts/Engines/Factions/Items/FactionStone.cs
@@ -53,7 +53,7 @@ namespace Server.Factions
{
PlayerState pl = PlayerState.Find(mobile);
- if (pl != null && pl.IsLeaving)
+ if (pl?.IsLeaving == true)
mobile.SendLocalizedMessage(
1005051); // You cannot use the faction stone until you have finished quitting your current faction
else
diff --git a/Projects/Scripts/Engines/Factions/Items/Power Faction Items/UrnOfAscension.cs b/Projects/Scripts/Engines/Factions/Items/Power Faction Items/UrnOfAscension.cs
index 4033462ba..08b088de7 100644
--- a/Projects/Scripts/Engines/Factions/Items/Power Faction Items/UrnOfAscension.cs
+++ b/Projects/Scripts/Engines/Factions/Items/Power Faction Items/UrnOfAscension.cs
@@ -32,7 +32,7 @@ namespace Server
BaseHouse house = BaseHouse.FindHouseAt(mob);
- if (house == null || house.IsFriend(from) || house.IsFriend(mob))
+ if (house?.IsFriend(from) != false || house.IsFriend(mob))
{
Faction.ClearSkillLoss(mob);
@@ -66,4 +66,4 @@ namespace Server
int version = reader.ReadEncodedInt();
}
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs b/Projects/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs
index 4e2cdd4ff..a2a057fb5 100644
--- a/Projects/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs
+++ b/Projects/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs
@@ -131,31 +131,16 @@ namespace Server.Factions
{
Direction = GetDirectionTo(m);
- string warning = null;
-
- switch (Utility.Random(6))
+ var warning = Utility.Random(6) switch
{
- case 0:
- warning =
- "I warn you, {0}, you would do well to leave this area before someone shows you the world of gray.";
- break;
- case 1:
- warning = "It would be wise to leave this area, {0}, lest your head become my commanders' trophy.";
- break;
- case 2:
- warning =
- "You are bold, {0}, for one of the meager {1}. Leave now, lest you be taught the taste of dirt.";
- break;
- case 3:
- warning = "Your presence here is an insult, {0}. Be gone now, knave.";
- break;
- case 4:
- warning = "Dost thou wish to be hung by your toes, {0}? Nay? Then come no closer.";
- break;
- case 5:
- warning = "Hey, {0}. Yeah, you. Get out of here before I beat you with a stick.";
- break;
- }
+ 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.",
+ 5 => "Hey, {0}. Yeah, you. Get out of here before I beat you with a stick.",
+ _ => null
+ };
Faction faction = Faction.Find(m);
@@ -188,20 +173,13 @@ namespace Server.Factions
}
else
{
- TextDefinition def = null;
-
- switch (type)
+ var def = type switch
{
- case ReactionType.Ignore:
- def = faction.Definition.GuardIgnore;
- break;
- case ReactionType.Warn:
- def = faction.Definition.GuardWarn;
- break;
- case ReactionType.Attack:
- def = faction.Definition.GuardAttack;
- break;
- }
+ ReactionType.Ignore => faction.Definition.GuardIgnore,
+ ReactionType.Warn => faction.Definition.GuardWarn,
+ ReactionType.Attack => faction.Definition.GuardAttack,
+ _ => null
+ };
if (def != null && def.Number > 0)
Say(def.Number);
@@ -229,7 +207,7 @@ namespace Server.Factions
{
if (e.HasKeyword(0xE6) && (Insensitive.Equals(e.Speech, "orders") || WasNamed(e.Speech))) // *orders*
{
- if (m_Town == null || !m_Town.IsSheriff(from))
+ if (m_Town?.IsSheriff(from) != true)
{
Say(1042189); // I don't work for you!
}
@@ -319,7 +297,7 @@ namespace Server.Factions
{
if (m_Faction != null && Map == Faction.Facet)
{
- string text = string.Concat("(Guard, ", m_Faction.Definition.FriendlyName, ")");
+ string text = $"(Guard, {m_Faction.Definition.FriendlyName})";
int hue = Faction.Find(from) == m_Faction ? 98 : 38;
diff --git a/Projects/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs b/Projects/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs
index 556e318bb..e31baae4a 100644
--- a/Projects/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs
+++ b/Projects/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs
@@ -212,22 +212,22 @@ namespace Server.Factions
if (maxCircle < 1)
maxCircle = 1;
- switch (Utility.Random(maxCircle * 2))
+ return Utility.Random(maxCircle * 2) switch
{
- case 0:
- case 1: return new MagicArrowSpell(m_Guard);
- case 2:
- case 3: return new HarmSpell(m_Guard);
- case 4:
- case 5: return new FireballSpell(m_Guard);
- case 6:
- case 7: return new LightningSpell(m_Guard);
- case 8: return new MindBlastSpell(m_Guard);
- case 9: return new ParalyzeSpell(m_Guard);
- case 10: return new EnergyBoltSpell(m_Guard);
- case 11: return new ExplosionSpell(m_Guard);
- default: return new FlameStrikeSpell(m_Guard);
- }
+ 0 => (Spell)new MagicArrowSpell(m_Guard),
+ 1 => new MagicArrowSpell(m_Guard),
+ 2 => new HarmSpell(m_Guard),
+ 3 => new HarmSpell(m_Guard),
+ 4 => new FireballSpell(m_Guard),
+ 5 => new FireballSpell(m_Guard),
+ 6 => new LightningSpell(m_Guard),
+ 7 => new LightningSpell(m_Guard),
+ 8 => new MindBlastSpell(m_Guard),
+ 9 => new ParalyzeSpell(m_Guard),
+ 10 => new EnergyBoltSpell(m_Guard),
+ 11 => new ExplosionSpell(m_Guard),
+ _ => new FlameStrikeSpell(m_Guard)
+ };
}
public Mobile FindDispelTarget(bool activeOnly)
@@ -367,7 +367,7 @@ namespace Server.Factions
public void RunFrom(Mobile m)
{
- Run((m_Mobile.GetDirectionTo(m) - 4) & Direction.Mask);
+ Run(m_Mobile.GetDirectionTo(m) - 4 & Direction.Mask);
}
public void OnFailedMove()
@@ -398,7 +398,7 @@ namespace Server.Factions
public void Run(Direction d)
{
- if (m_Mobile.Spell != null && m_Mobile.Spell.IsCasting || m_Mobile.Paralyzed || m_Mobile.Frozen ||
+ if (m_Mobile.Spell?.IsCasting == true || m_Mobile.Paralyzed || m_Mobile.Frozen ||
m_Mobile.DisallowAllMoves)
return;
@@ -498,10 +498,7 @@ namespace Server.Factions
{
Mobile toFollow = null;
- if (m_Guard.Town != null && m_Guard.Orders.Movement == MovementType.Follow)
- {
- toFollow = m_Guard.Orders.Follow ?? m_Guard.Town.Sheriff;
- }
+ if (m_Guard.Town != null && m_Guard.Orders.Movement == MovementType.Follow) toFollow = m_Guard.Orders.Follow ?? m_Guard.Town.Sheriff;
if (toFollow != null && toFollow.Map == m_Guard.Map &&
toFollow.InRange(m_Guard, m_Guard.RangePerception * 3) &&
diff --git a/Projects/Scripts/Engines/Harvest/Core/HarvestSystem.cs b/Projects/Scripts/Engines/Harvest/Core/HarvestSystem.cs
index 5d2fb1981..3e02a6d1a 100644
--- a/Projects/Scripts/Engines/Harvest/Core/HarvestSystem.cs
+++ b/Projects/Scripts/Engines/Harvest/Core/HarvestSystem.cs
@@ -396,13 +396,13 @@ namespace Server.Engines.Harvest
{
if (toHarvest is Static staticObj && !staticObj.Movable)
{
- tileID = (staticObj.ItemID & 0x3FFF) | 0x4000;
+ tileID = staticObj.ItemID & 0x3FFF | 0x4000;
map = staticObj.Map;
loc = staticObj.GetWorldLocation();
}
else if (toHarvest is StaticTarget staticTarget)
{
- tileID = (staticTarget.ItemID & 0x3FFF) | 0x4000;
+ tileID = staticTarget.ItemID & 0x3FFF | 0x4000;
map = from.Map;
loc = staticTarget.Location;
}
diff --git a/Projects/Scripts/Engines/Harvest/Fishing.cs b/Projects/Scripts/Engines/Harvest/Fishing.cs
index 620003856..79064a01d 100644
--- a/Projects/Scripts/Engines/Harvest/Fishing.cs
+++ b/Projects/Scripts/Engines/Harvest/Fishing.cs
@@ -400,9 +400,9 @@ namespace Server.Engines.Harvest
number = 1043297;
if ((item.ItemData.Flags & TileFlag.ArticleA) != 0)
- name = "a " + item.ItemData.Name;
+ name = $"a {item.ItemData.Name}";
else if ((item.ItemData.Flags & TileFlag.ArticleAn) != 0)
- name = "an " + item.ItemData.Name;
+ name = $"an {item.ItemData.Name}";
else
name = item.ItemData.Name;
}
diff --git a/Projects/Scripts/Engines/Help/PagePromptGump.cs b/Projects/Scripts/Engines/Help/PagePromptGump.cs
index 40e5ab934..982991a35 100644
--- a/Projects/Scripts/Engines/Help/PagePromptGump.cs
+++ b/Projects/Scripts/Engines/Help/PagePromptGump.cs
@@ -38,7 +38,7 @@ namespace Server.Engines.Help
else
{
TextRelay entry = info.GetTextEntry(0);
- string text = entry == null ? "" : entry.Text.Trim();
+ string text = entry?.Text.Trim() ?? "";
if (text.Length == 0)
{
diff --git a/Projects/Scripts/Engines/Help/PageQueue.cs b/Projects/Scripts/Engines/Help/PageQueue.cs
index f6afaace9..f719ddea8 100644
--- a/Projects/Scripts/Engines/Help/PageQueue.cs
+++ b/Projects/Scripts/Engines/Help/PageQueue.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using System.Net.Mail;
using Server.Accounting;
-using Server.Commands;
using Server.Misc;
using Server.Mobiles;
using Server.Network;
@@ -108,7 +107,7 @@ namespace Server.Engines.Help
if (index != -1)
// m_Entry.AddResponse(m_Entry.Sender, "[Logout]");
- PageQueue.Remove(m_Entry);
+ PageQueue.Remove(m_Entry);
}
}
}
diff --git a/Projects/Scripts/Engines/Help/PageQueueGump.cs b/Projects/Scripts/Engines/Help/PageQueueGump.cs
index 38885ae14..a87f3d40e 100644
--- a/Projects/Scripts/Engines/Help/PageQueueGump.cs
+++ b/Projects/Scripts/Engines/Help/PageQueueGump.cs
@@ -61,10 +61,8 @@ namespace Server.Engines.Help
PageEntry e = list[i];
if (e.Sender.Deleted || e.Sender.NetState == null)
- {
// e.AddResponse(e.Sender, "[Logout]");
PageQueue.Remove(e);
- }
else
++i;
}
@@ -740,12 +738,10 @@ namespace Server.Engines.Help
TextRelay text = info.GetTextEntry(0);
if (text != null)
- {
// m_Entry.AddResponse(state.Mobile, "[Response] " + text.Text);
m_Entry.Sender.SendGump(new MessageSentGump(m_Entry.Sender, state.Mobile.Name, text.Text));
- //m_Entry.Sender.SendMessage( 0x482, "{0} tells you:", state.Mobile.Name );
- //m_Entry.Sender.SendMessage( 0x482, text.Text );
- }
+ //m_Entry.Sender.SendMessage( 0x482, "{0} tells you:", state.Mobile.Name );
+ //m_Entry.Sender.SendMessage( 0x482, text.Text );
Resend(state);
@@ -762,10 +758,7 @@ namespace Server.Engines.Help
{
Resend(state);
- if (m_Entry.SpeechLog != null)
- {
- state.Mobile.SendGump(new SpeechLogGump(m_Entry.Sender, m_Entry.SpeechLog));
- }
+ if (m_Entry.SpeechLog != null) state.Mobile.SendGump(new SpeechLogGump(m_Entry.Sender, m_Entry.SpeechLog));
break;
}
@@ -775,11 +768,9 @@ namespace Server.Engines.Help
List preresp = PredefinedResponse.List;
if (index >= 0 && index < preresp.Count)
- {
// m_Entry.AddResponse(state.Mobile, "[PreDef] " + preresp[index].Title);
m_Entry.Sender.SendGump(new MessageSentGump(m_Entry.Sender, state.Mobile.Name,
preresp[index].Message));
- }
Resend(state);
diff --git a/Projects/Scripts/Engines/Khaldun/PuzzleChest.cs b/Projects/Scripts/Engines/Khaldun/PuzzleChest.cs
index d00e57ddb..271a06410 100644
--- a/Projects/Scripts/Engines/Khaldun/PuzzleChest.cs
+++ b/Projects/Scripts/Engines/Khaldun/PuzzleChest.cs
@@ -99,17 +99,17 @@ namespace Server.Items
public static PuzzleChestCylinder RandomCylinder()
{
- switch (Utility.Random(8))
+ return Utility.Random(8) switch
{
- case 0: return PuzzleChestCylinder.LightBlue;
- case 1: return PuzzleChestCylinder.Blue;
- case 2: return PuzzleChestCylinder.Green;
- case 3: return PuzzleChestCylinder.Orange;
- case 4: return PuzzleChestCylinder.Purple;
- case 5: return PuzzleChestCylinder.Red;
- case 6: return PuzzleChestCylinder.DarkBlue;
- default: return PuzzleChestCylinder.Yellow;
- }
+ 0 => PuzzleChestCylinder.LightBlue,
+ 1 => PuzzleChestCylinder.Blue,
+ 2 => PuzzleChestCylinder.Green,
+ 3 => PuzzleChestCylinder.Orange,
+ 4 => PuzzleChestCylinder.Purple,
+ 5 => PuzzleChestCylinder.Red,
+ 6 => PuzzleChestCylinder.DarkBlue,
+ _ => PuzzleChestCylinder.Yellow
+ };
}
public bool Matches(PuzzleChestSolution solution, out int cylinders, out int colors)
diff --git a/Projects/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs b/Projects/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs
index ae284cb5a..4292a91dd 100644
--- a/Projects/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs
+++ b/Projects/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs
@@ -60,7 +60,7 @@ namespace Server.Engines.MLQuests.Gumps
}
case 1: // Okay
{
- if (m_Owner == null || m_Owner.CheckComplete(m_From))
+ if (m_Owner?.CheckComplete(m_From) != false)
Offer(m_Owner, m_From, m_Race);
break;
@@ -149,7 +149,7 @@ namespace Server.Engines.MLQuests.Gumps
AnimalForm.UnderTransformation(from) || !from.CanBeginAction() ||
from.IsBodyMod) // TODO: Does this cover everything?
from.SendLocalizedMessage(1073648); // You may only proceed while in your original state...
- else if (from.Spell != null && from.Spell.IsCasting)
+ else if (from.Spell?.IsCasting == true)
from.SendLocalizedMessage(1073649); // One may not proceed while embracing magic...
else if (from.Poisoned)
from.SendLocalizedMessage(1073652); // You must be healthy to proceed...
diff --git a/Projects/Scripts/Engines/MLQuests/Items/RewardBags.cs b/Projects/Scripts/Engines/MLQuests/Items/RewardBags.cs
index 53db84abe..fdc057e4a 100644
--- a/Projects/Scripts/Engines/MLQuests/Items/RewardBags.cs
+++ b/Projects/Scripts/Engines/MLQuests/Items/RewardBags.cs
@@ -18,26 +18,15 @@ namespace Server.Engines.MLQuests.Items
for (; done < itemCount; ++done)
{
- Item loot = null;
-
- switch (Utility.Random(5))
+ var loot = Utility.Random(5) switch
{
- case 0:
- loot = Loot.RandomWeapon(false, true);
- break;
- case 1:
- loot = Loot.RandomArmor(false, true);
- break;
- case 2:
- loot = Loot.RandomRangedWeapon(false, true);
- break;
- case 3:
- loot = Loot.RandomJewelry();
- break;
- case 4:
- loot = Loot.RandomHat(false);
- break;
- }
+ 0 => (Item)Loot.RandomWeapon(false, true),
+ 1 => Loot.RandomArmor(false, true),
+ 2 => Loot.RandomRangedWeapon(false, true),
+ 3 => Loot.RandomJewelry(),
+ 4 => Loot.RandomHat(false),
+ _ => null
+ };
if (loot == null)
continue;
diff --git a/Projects/Scripts/Engines/MLQuests/MLQuestContext.cs b/Projects/Scripts/Engines/MLQuests/MLQuestContext.cs
index 81b713dbb..052f04544 100644
--- a/Projects/Scripts/Engines/MLQuests/MLQuestContext.cs
+++ b/Projects/Scripts/Engines/MLQuests/MLQuestContext.cs
@@ -259,7 +259,7 @@ namespace Server.Engines.MLQuests
MLQuest quest = MLQuestSystem.ReadQuestRef(reader);
DateTime nextAvailable = reader.ReadDateTime();
- if (quest == null || !quest.RecordCompletion)
+ if (quest?.RecordCompletion != true)
return null; // forget about this record
return new MLDoneQuestInfo(quest, nextAvailable);
diff --git a/Projects/Scripts/Engines/MLQuests/MLQuestEntry.cs b/Projects/Scripts/Engines/MLQuests/MLQuestEntry.cs
index db7ce184d..84e28db5a 100644
--- a/Projects/Scripts/Engines/MLQuests/MLQuestEntry.cs
+++ b/Projects/Scripts/Engines/MLQuests/MLQuestEntry.cs
@@ -335,12 +335,11 @@ namespace Server.Engines.MLQuests
foreach (Item rewardItem in rewards)
{
- string rewardName = rewardItem.Name ?? string.Concat("#", rewardItem.LabelNumber);
+ string rewardName = rewardItem.Name ?? $"#{rewardItem.LabelNumber}";
if (rewardItem.Stackable)
Player.SendLocalizedMessage(1115917,
- string.Concat(rewardItem.Amount, "\t",
- rewardName)); // You receive a reward: ~1_QUANTITY~ ~2_ITEM~
+ $"{rewardItem.Amount}\t{rewardName}"); // You receive a reward: ~1_QUANTITY~ ~2_ITEM~
else
Player.SendLocalizedMessage(1074360, rewardName); // You receive a reward: ~1_REWARD~
}
diff --git a/Projects/Scripts/Engines/MLQuests/QuestArea.cs b/Projects/Scripts/Engines/MLQuests/QuestArea.cs
index 1aa0a02f3..92e2986a4 100644
--- a/Projects/Scripts/Engines/MLQuests/QuestArea.cs
+++ b/Projects/Scripts/Engines/MLQuests/QuestArea.cs
@@ -45,7 +45,7 @@ namespace Server.Engines.MLQuests
if (!found)
Console.WriteLine("Warning: QuestArea region '{0}' does not exist (ForceMap = {1})", RegionName,
- ForceMap == null ? "-null-" : ForceMap.ToString());
+ ForceMap?.ToString() ?? "-null-");
}
}
}
diff --git a/Projects/Scripts/Engines/Party/Party.cs b/Projects/Scripts/Engines/Party/Party.cs
index 45bfd02fc..015ccbea4 100644
--- a/Projects/Scripts/Engines/Party/Party.cs
+++ b/Projects/Scripts/Engines/Party/Party.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using Server.Commands;
using Server.Factions;
using Server.Network;
using Server.Targeting;
diff --git a/Projects/Scripts/Engines/Party/PartyCommands.cs b/Projects/Scripts/Engines/Party/PartyCommands.cs
index 5ffc4e249..431d5d3e9 100644
--- a/Projects/Scripts/Engines/Party/PartyCommands.cs
+++ b/Projects/Scripts/Engines/Party/PartyCommands.cs
@@ -98,7 +98,7 @@ namespace Server.Engines.PartySystem
Party p = Party.Get(leader);
- if (leader == null || p == null || !p.Candidates.Contains(from))
+ if (leader == null || p?.Candidates.Contains(from) != true)
from.SendLocalizedMessage(3000222); // No one has invited you to be in a party.
else if (p.Members.Count + p.Candidates.Count <= Party.Capacity)
p.OnAccept(from);
@@ -111,7 +111,7 @@ namespace Server.Engines.PartySystem
Party p = Party.Get(leader);
- if (leader == null || p == null || !p.Candidates.Contains(from))
+ if (leader == null || p?.Candidates.Contains(from) != true)
from.SendLocalizedMessage(3000222); // No one has invited you to be in a party.
else
p.OnDecline(from, leader);
diff --git a/Projects/Scripts/Engines/Pathing/FastMovement.cs b/Projects/Scripts/Engines/Pathing/FastMovement.cs
index 2d3416b40..d71530a80 100644
--- a/Projects/Scripts/Engines/Pathing/FastMovement.cs
+++ b/Projects/Scripts/Engines/Pathing/FastMovement.cs
@@ -44,8 +44,8 @@ namespace Server.Movement
bool checkDiagonals = ((int)d & 0x1) == 0x1;
Offset(d, ref xForward, ref yForward);
- Offset((Direction)(((int)d - 1) & 0x7), ref xLeft, ref yLeft);
- Offset((Direction)(((int)d + 1) & 0x7), ref xRight, ref yRight);
+ Offset((Direction)((int)d - 1 & 0x7), ref xLeft, ref yLeft);
+ Offset((Direction)((int)d + 1 & 0x7), ref xRight, ref yRight);
if (xForward < 0 || yForward < 0 || xForward >= map.Width || yForward >= map.Height)
{
diff --git a/Projects/Scripts/Engines/Pathing/Movement.cs b/Projects/Scripts/Engines/Pathing/Movement.cs
index 0c5ffacd6..e04e7b1a8 100644
--- a/Projects/Scripts/Engines/Pathing/Movement.cs
+++ b/Projects/Scripts/Engines/Pathing/Movement.cs
@@ -53,8 +53,8 @@ namespace Server.Movement
bool checkDiagonals = ((int)d & 0x1) == 0x1;
Offset(d, ref xForward, ref yForward);
- Offset((Direction)(((int)d - 1) & 0x7), ref xLeft, ref yLeft);
- Offset((Direction)(((int)d + 1) & 0x7), ref xRight, ref yRight);
+ Offset((Direction)((int)d - 1 & 0x7), ref xLeft, ref yLeft);
+ Offset((Direction)((int)d + 1 & 0x7), ref xRight, ref yRight);
if (xForward < 0 || yForward < 0 || xForward >= map.Width || yForward >= map.Height)
{
@@ -235,15 +235,15 @@ namespace Server.Movement
if (m.Player && m.AccessLevel < AccessLevel.GameMaster)
{
if (!(Check(map, m, itemsLeft, mobsLeft, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk,
- out _) && Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim,
- m.CantWalk, out _)))
+ out _) && Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim,
+ m.CantWalk, out _)))
moveIsOk = false;
}
else
{
if (!(Check(map, m, itemsLeft, mobsLeft, xLeft, yLeft, startTop, startZ, m.CanSwim, m.CantWalk,
- out _) || Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim,
- m.CantWalk, out _)))
+ out _) || Check(map, m, itemsRight, mobsRight, xRight, yRight, startTop, startZ, m.CanSwim,
+ m.CantWalk, out _)))
moveIsOk = false;
}
diff --git a/Projects/Scripts/Engines/Pathing/MovementPath.cs b/Projects/Scripts/Engines/Pathing/MovementPath.cs
index a7baebebf..17a7f7409 100644
--- a/Projects/Scripts/Engines/Pathing/MovementPath.cs
+++ b/Projects/Scripts/Engines/Pathing/MovementPath.cs
@@ -1,5 +1,4 @@
using System;
-using Server.Commands;
using Server.Items;
using Server.PathAlgorithms;
using Server.PathAlgorithms.FastAStar;
diff --git a/Projects/Scripts/Engines/Plants/MainPlantGump.cs b/Projects/Scripts/Engines/Plants/MainPlantGump.cs
index f4db3fe4e..835b8ed10 100644
--- a/Projects/Scripts/Engines/Plants/MainPlantGump.cs
+++ b/Projects/Scripts/Engines/Plants/MainPlantGump.cs
@@ -317,8 +317,7 @@ namespace Server.Engines.Plants
{
from.Target = new PlantPourTarget(m_Plant);
from.SendLocalizedMessage(1060808,
- "#" + m_Plant
- .GetLocalizedPlantStatus()); // Target the container you wish to use to water the ~1_val~.
+ $"#{m_Plant.GetLocalizedPlantStatus()}"); // Target the container you wish to use to water the ~1_val~.
}
else
{
@@ -386,8 +385,7 @@ namespace Server.Engines.Plants
from.Target = new PlantPourTarget(m_Plant);
from.SendLocalizedMessage(1060808,
- "#" + m_Plant
- .GetLocalizedPlantStatus()); // Target the container you wish to use to water the ~1_val~.
+ $"#{m_Plant.GetLocalizedPlantStatus()}"); // Target the container you wish to use to water the ~1_val~.
return;
}
diff --git a/Projects/Scripts/Engines/Plants/MiscItems/GreenThorns.cs b/Projects/Scripts/Engines/Plants/MiscItems/GreenThorns.cs
index f57c30053..513f8c6ca 100644
--- a/Projects/Scripts/Engines/Plants/MiscItems/GreenThorns.cs
+++ b/Projects/Scripts/Engines/Plants/MiscItems/GreenThorns.cs
@@ -444,36 +444,18 @@ namespace Server.Items
Item reagents;
int amount = Utility.RandomMinMax(10, 25);
- switch (Utility.Random(9))
+ reagents = Utility.Random(9) switch
{
- case 0:
- reagents = new BlackPearl(amount);
- break;
- case 1:
- reagents = new Bloodmoss(amount);
- break;
- case 2:
- reagents = new Garlic(amount);
- break;
- case 3:
- reagents = new Ginseng(amount);
- break;
- case 4:
- reagents = new MandrakeRoot(amount);
- break;
- case 5:
- reagents = new Nightshade(amount);
- break;
- case 6:
- reagents = new SulfurousAsh(amount);
- break;
- case 7:
- reagents = new SpidersSilk(amount);
- break;
- default:
- reagents = new FertileDirt(amount);
- break;
- }
+ 0 => (Item)new BlackPearl(amount),
+ 1 => new Bloodmoss(amount),
+ 2 => new Garlic(amount),
+ 3 => new Ginseng(amount),
+ 4 => new MandrakeRoot(amount),
+ 5 => new Nightshade(amount),
+ 6 => new SulfurousAsh(amount),
+ 7 => new SpidersSilk(amount),
+ _ => new FertileDirt(amount)
+ };
if (!SpawnItem(reagents))
reagents.Delete();
diff --git a/Projects/Scripts/Engines/Plants/PlantBowl.cs b/Projects/Scripts/Engines/Plants/PlantBowl.cs
index 59d35fa5a..ea54023c9 100644
--- a/Projects/Scripts/Engines/Plants/PlantBowl.cs
+++ b/Projects/Scripts/Engines/Plants/PlantBowl.cs
@@ -87,9 +87,9 @@ namespace Server.Engines.Plants
int tileID;
if (obj is Static staticObj && !staticObj.Movable)
- tileID = (staticObj.ItemID & 0x3FFF) | 0x4000;
+ tileID = staticObj.ItemID & 0x3FFF | 0x4000;
else if (obj is StaticTarget staticTarget)
- tileID = (staticTarget.ItemID & 0x3FFF) | 0x4000;
+ tileID = staticTarget.ItemID & 0x3FFF | 0x4000;
else if (obj is LandTarget landTarget)
tileID = landTarget.TileID;
else
diff --git a/Projects/Scripts/Engines/Plants/PlantHue.cs b/Projects/Scripts/Engines/Plants/PlantHue.cs
index a00d4f296..b19b76e39 100644
--- a/Projects/Scripts/Engines/Plants/PlantHue.cs
+++ b/Projects/Scripts/Engines/Plants/PlantHue.cs
@@ -89,13 +89,13 @@ namespace Server.Engines.Plants
public static PlantHue RandomFirstGeneration()
{
- switch (Utility.Random(4))
+ return Utility.Random(4) switch
{
- case 0: return PlantHue.Plain;
- case 1: return PlantHue.Red;
- case 2: return PlantHue.Blue;
- default: return PlantHue.Yellow;
- }
+ 0 => PlantHue.Plain,
+ 1 => PlantHue.Red,
+ 2 => PlantHue.Blue,
+ _ => PlantHue.Yellow
+ };
}
public static bool CanReproduce(PlantHue plantHue) => (plantHue & PlantHue.Reproduces) != PlantHue.None;
diff --git a/Projects/Scripts/Engines/Plants/PlantItem.cs b/Projects/Scripts/Engines/Plants/PlantItem.cs
index bc4f71965..6e825842b 100644
--- a/Projects/Scripts/Engines/Plants/PlantItem.cs
+++ b/Projects/Scripts/Engines/Plants/PlantItem.cs
@@ -320,7 +320,7 @@ namespace Server.Engines.Plants
else if (m_PlantStatus != PlantStatus.BowlOfDirt)
{
from.SendLocalizedMessage(1080389,
- "#" + GetLocalizedPlantStatus()); // This bowl of dirt already has a ~1_val~ in it!
+ $"#{GetLocalizedPlantStatus()}"); // This bowl of dirt already has a ~1_val~ in it!
}
else if (PlantSystem.Water < 2)
{
diff --git a/Projects/Scripts/Engines/Plants/PlantSystem.cs b/Projects/Scripts/Engines/Plants/PlantSystem.cs
index 2ad368e9a..25539101c 100644
--- a/Projects/Scripts/Engines/Plants/PlantSystem.cs
+++ b/Projects/Scripts/Engines/Plants/PlantSystem.cs
@@ -388,13 +388,13 @@ namespace Server.Engines.Plants
public int GetLocalizedHealth()
{
- switch (Health)
+ return Health switch
{
- case PlantHealth.Dying: return 1060825; // dying
- case PlantHealth.Wilted: return 1060824; // wilted
- case PlantHealth.Healthy: return 1060823; // healthy
- default: return 1060822; // vibrant
- }
+ PlantHealth.Dying => 1060825, // dying
+ PlantHealth.Wilted => 1060824, // wilted
+ PlantHealth.Healthy => 1060823, // healthy
+ _ => 1060822
+ };
}
public static void Configure()
@@ -681,4 +681,4 @@ namespace Server.Engines.Plants
writer.Write(m_LeftResources);
}
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Engines/Plants/PlantType.cs b/Projects/Scripts/Engines/Plants/PlantType.cs
index f448ff239..aaeb5ea27 100644
--- a/Projects/Scripts/Engines/Plants/PlantType.cs
+++ b/Projects/Scripts/Engines/Plants/PlantType.cs
@@ -176,61 +176,61 @@ namespace Server.Engines.Plants
public static PlantType RandomFirstGeneration()
{
- switch (Utility.Random(3))
+ return Utility.Random(3) switch
{
- case 0: return PlantType.CampionFlowers;
- case 1: return PlantType.Fern;
- default: return PlantType.TribarrelCactus;
- }
+ 0 => PlantType.CampionFlowers,
+ 1 => PlantType.Fern,
+ _ => PlantType.TribarrelCactus
+ };
}
public static PlantType RandomPeculiarGroupOne()
{
- switch (Utility.Random(6))
+ return Utility.Random(6) switch
{
- case 0: return PlantType.Cactus;
- case 1: return PlantType.FlaxFlowers;
- case 2: return PlantType.FoxgloveFlowers;
- case 3: return PlantType.HopsEast;
- case 4: return PlantType.CocoaTree;
- default: return PlantType.OrfluerFlowers;
- }
+ 0 => PlantType.Cactus,
+ 1 => PlantType.FlaxFlowers,
+ 2 => PlantType.FoxgloveFlowers,
+ 3 => PlantType.HopsEast,
+ 4 => PlantType.CocoaTree,
+ _ => PlantType.OrfluerFlowers
+ };
}
public static PlantType RandomPeculiarGroupTwo()
{
- switch (Utility.Random(5))
+ return Utility.Random(5) switch
{
- case 0: return PlantType.CypressTwisted;
- case 1: return PlantType.HedgeShort;
- case 2: return PlantType.JuniperBush;
- case 3: return PlantType.CocoaTree;
- default: return PlantType.SnowdropPatch;
- }
+ 0 => PlantType.CypressTwisted,
+ 1 => PlantType.HedgeShort,
+ 2 => PlantType.JuniperBush,
+ 3 => PlantType.CocoaTree,
+ _ => PlantType.SnowdropPatch
+ };
}
public static PlantType RandomPeculiarGroupThree()
{
- switch (Utility.Random(5))
+ return Utility.Random(5) switch
{
- case 0: return PlantType.Cattails;
- case 1: return PlantType.PoppyPatch;
- case 2: return PlantType.SpiderTree;
- case 3: return PlantType.CocoaTree;
- default: return PlantType.WaterLily;
- }
+ 0 => PlantType.Cattails,
+ 1 => PlantType.PoppyPatch,
+ 2 => PlantType.SpiderTree,
+ 3 => PlantType.CocoaTree,
+ _ => PlantType.WaterLily
+ };
}
public static PlantType RandomPeculiarGroupFour()
{
- switch (Utility.Random(5))
+ return Utility.Random(5) switch
{
- case 0: return PlantType.CypressStraight;
- case 1: return PlantType.HedgeTall;
- case 2: return PlantType.HopsSouth;
- case 3: return PlantType.CocoaTree;
- default: return PlantType.SugarCanes;
- }
+ 0 => PlantType.CypressStraight,
+ 1 => PlantType.HedgeTall,
+ 2 => PlantType.HopsSouth,
+ 3 => PlantType.CocoaTree,
+ _ => PlantType.SugarCanes
+ };
}
public static PlantType RandomBonsai(double increaseRatio)
diff --git a/Projects/Scripts/Engines/Plants/Seed.cs b/Projects/Scripts/Engines/Plants/Seed.cs
index 69f026b04..86c3ad4e5 100644
--- a/Projects/Scripts/Engines/Plants/Seed.cs
+++ b/Projects/Scripts/Engines/Plants/Seed.cs
@@ -74,13 +74,13 @@ namespace Server.Engines.Plants
public static Seed RandomPeculiarSeed(int group)
{
- switch (group)
+ return @group switch
{
- case 1: return new Seed(PlantTypeInfo.RandomPeculiarGroupOne(), PlantHue.Plain);
- case 2: return new Seed(PlantTypeInfo.RandomPeculiarGroupTwo(), PlantHue.Plain);
- case 3: return new Seed(PlantTypeInfo.RandomPeculiarGroupThree(), PlantHue.Plain);
- default: return new Seed(PlantTypeInfo.RandomPeculiarGroupFour(), PlantHue.Plain);
- }
+ 1 => new Seed(PlantTypeInfo.RandomPeculiarGroupOne(), PlantHue.Plain),
+ 2 => new Seed(PlantTypeInfo.RandomPeculiarGroupTwo(), PlantHue.Plain),
+ 3 => new Seed(PlantTypeInfo.RandomPeculiarGroupThree(), PlantHue.Plain),
+ _ => new Seed(PlantTypeInfo.RandomPeculiarGroupFour(), PlantHue.Plain)
+ };
}
private int GetLabel(out string args)
diff --git a/Projects/Scripts/Engines/Quests/Collector/Items/PaintedImage.cs b/Projects/Scripts/Engines/Quests/Collector/Items/PaintedImage.cs
index 1bf2a39d6..00724a0ca 100644
--- a/Projects/Scripts/Engines/Quests/Collector/Items/PaintedImage.cs
+++ b/Projects/Scripts/Engines/Quests/Collector/Items/PaintedImage.cs
@@ -34,13 +34,13 @@ namespace Server.Engines.Quests.Collector
public override void AddNameProperty(ObjectPropertyList list)
{
ImageTypeInfo info = ImageTypeInfo.Get(m_Image);
- list.Add(1060847, "#1055126\t#" + info.Name); // a painted image of:
+ list.Add(1060847, $"#1055126\t#{info.Name}"); // a painted image of:
}
public override void OnSingleClick(Mobile from)
{
ImageTypeInfo info = ImageTypeInfo.Get(m_Image);
- LabelTo(from, 1060847, "#1055126\t#" + info.Name); // a painted image of:
+ LabelTo(from, 1060847, $"#1055126\t#{info.Name}"); // a painted image of:
}
public override void OnDoubleClick(Mobile from)
diff --git a/Projects/Scripts/Engines/Quests/Collector/Objectives.cs b/Projects/Scripts/Engines/Quests/Collector/Objectives.cs
index 147d3f146..c59bd2a2b 100644
--- a/Projects/Scripts/Engines/Quests/Collector/Objectives.cs
+++ b/Projects/Scripts/Engines/Quests/Collector/Objectives.cs
@@ -132,18 +132,12 @@ namespace Server.Engines.Quests.Collector
public void InitTheater()
{
- switch (Utility.Random(3))
+ m_Theater = Utility.Random(3) switch
{
- case 1:
- m_Theater = Theater.Britain;
- break;
- case 2:
- m_Theater = Theater.Nujelm;
- break;
- default:
- m_Theater = Theater.Jhelom;
- break;
- }
+ 1 => Theater.Britain,
+ 2 => Theater.Nujelm,
+ _ => Theater.Jhelom
+ };
}
public bool IsInRightTheater()
@@ -155,14 +149,13 @@ namespace Server.Engines.Quests.Collector
if (region == null)
return false;
- switch (m_Theater)
+ return m_Theater switch
{
- case Theater.Britain: return region.IsPartOf("Britain");
- case Theater.Nujelm: return region.IsPartOf("Nujel'm");
- case Theater.Jhelom: return region.IsPartOf("Jhelom");
-
- default: return false;
- }
+ Theater.Britain => region.IsPartOf("Britain"),
+ Theater.Nujelm => region.IsPartOf("Nujel'm"),
+ Theater.Jhelom => region.IsPartOf("Jhelom"),
+ _ => false
+ };
}
public override void OnComplete()
diff --git a/Projects/Scripts/Engines/Quests/Core/QuestSystem.cs b/Projects/Scripts/Engines/Quests/Core/QuestSystem.cs
index a2d82ea75..01397d2a0 100644
--- a/Projects/Scripts/Engines/Quests/Core/QuestSystem.cs
+++ b/Projects/Scripts/Engines/Quests/Core/QuestSystem.cs
@@ -625,11 +625,11 @@ namespace Server.Engines.Quests
{
c16 &= 0x7FFF;
- int r = ((c16 >> 10) & 0x1F) << 3;
- int g = ((c16 >> 05) & 0x1F) << 3;
- int b = ((c16 >> 00) & 0x1F) << 3;
+ int r = (c16 >> 10 & 0x1F) << 3;
+ int g = (c16 >> 05 & 0x1F) << 3;
+ int b = (c16 & 0x1F) << 3;
- return (r << 16) | (g << 8) | (b << 0);
+ return r << 16 | g << 8 | b;
}
public static int C16216(int c16) => c16 & 0x7FFF;
@@ -638,11 +638,11 @@ namespace Server.Engines.Quests
{
c32 &= 0xFFFFFF;
- int r = ((c32 >> 16) & 0xFF) >> 3;
- int g = ((c32 >> 08) & 0xFF) >> 3;
- int b = ((c32 >> 00) & 0xFF) >> 3;
+ int r = (c32 >> 16 & 0xFF) >> 3;
+ int g = (c32 >> 08 & 0xFF) >> 3;
+ int b = (c32 & 0xFF) >> 3;
- return (r << 10) | (g << 5) | (b << 0);
+ return r << 10 | g << 5 | b;
}
public static string Color(string text, int color) => $"{text}";
diff --git a/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs b/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs
index 7d4aedbef..af1c6b58f 100644
--- a/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs
+++ b/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs
@@ -182,7 +182,7 @@ namespace Server.Engines.Quests.Necro
if (m is PlayerMobile && !m.Frozen && !m.Alive && InRange(m, 4) && !InRange(oldLocation, 4) && InLOS(m))
{
- if (m.Map == null || !m.Map.CanFit(m.Location, 16, false, false))
+ if (m.Map?.CanFit(m.Location, 16, false, false) != true)
{
m.SendLocalizedMessage(502391); // Thou can not be resurrected there!
}
diff --git a/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/Emino.cs b/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/Emino.cs
index f5ee388b1..c8abd3920 100644
--- a/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/Emino.cs
+++ b/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/Emino.cs
@@ -194,7 +194,7 @@ namespace Server.Engines.Quests.Ninja
if (!m.Frozen && !m.Alive && InRange(m, 4) && !InRange(oldLocation, 4) && InLOS(m))
{
- if (m.Map == null || !m.Map.CanFit(m.Location, 16, false, false))
+ if (m.Map?.CanFit(m.Location, 16, false, false) != true)
{
m.SendLocalizedMessage(502391); // Thou can not be resurrected there!
}
diff --git a/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/Zoel.cs b/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/Zoel.cs
index 789e3b236..c62259282 100644
--- a/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/Zoel.cs
+++ b/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/Zoel.cs
@@ -92,7 +92,7 @@ namespace Server.Engines.Quests.Ninja
if (!m.Frozen && !m.Alive && InRange(m, 4) && !InRange(oldLocation, 4) && InLOS(m))
{
- if (m.Map == null || !m.Map.CanFit(m.Location, 16, false, false))
+ if (m.Map?.CanFit(m.Location, 16, false, false) != true)
{
m.SendLocalizedMessage(502391); // Thou can not be resurrected there!
}
diff --git a/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs b/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs
index 4bbcec568..da1761fac 100644
--- a/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs
+++ b/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs
@@ -122,7 +122,7 @@ namespace Server.Engines.Quests.Samurai
obj.Complete();
obj = qs.FindObjective();
- if (obj != null && ((FifthTrialIntroObjective)obj).StolenTreasure)
+ if (((FifthTrialIntroObjective)obj)?.StolenTreasure == true)
qs.AddConversation(new SixthTrialIntroConversation(true));
else
qs.AddConversation(new SixthTrialIntroConversation(false));
diff --git a/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/HaochisGuardsman.cs b/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/HaochisGuardsman.cs
index 37ba44c88..0030bf8da 100644
--- a/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/HaochisGuardsman.cs
+++ b/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/HaochisGuardsman.cs
@@ -64,19 +64,12 @@ namespace Server.Engines.Quests.Samurai
break;
}
- Item weapon;
- switch (Utility.Random(3))
+ var weapon = Utility.Random(3) switch
{
- case 0:
- weapon = new NoDachi();
- break;
- case 1:
- weapon = new Lajatang();
- break;
- default:
- weapon = new Wakizashi();
- break;
- }
+ 0 => (Item)new NoDachi(),
+ 1 => new Lajatang(),
+ _ => new Wakizashi()
+ };
weapon.Movable = false;
AddItem(weapon);
diff --git a/Projects/Scripts/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs b/Projects/Scripts/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs
index 0e1776fde..38ec26b2c 100644
--- a/Projects/Scripts/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs
+++ b/Projects/Scripts/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs
@@ -58,61 +58,26 @@ namespace Server.Engines.Quests.Naturalist
{
Seed reward;
- PlantType type;
- switch (Utility.Random(17))
+ var type = Utility.Random(17) switch
{
- case 0:
- type = PlantType.CampionFlowers;
- break;
- case 1:
- type = PlantType.Poppies;
- break;
- case 2:
- type = PlantType.Snowdrops;
- break;
- case 3:
- type = PlantType.Bulrushes;
- break;
- case 4:
- type = PlantType.Lilies;
- break;
- case 5:
- type = PlantType.PampasGrass;
- break;
- case 6:
- type = PlantType.Rushes;
- break;
- case 7:
- type = PlantType.ElephantEarPlant;
- break;
- case 8:
- type = PlantType.Fern;
- break;
- case 9:
- type = PlantType.PonytailPalm;
- break;
- case 10:
- type = PlantType.SmallPalm;
- break;
- case 11:
- type = PlantType.CenturyPlant;
- break;
- case 12:
- type = PlantType.WaterPlant;
- break;
- case 13:
- type = PlantType.SnakePlant;
- break;
- case 14:
- type = PlantType.PricklyPearCactus;
- break;
- case 15:
- type = PlantType.BarrelCactus;
- break;
- default:
- type = PlantType.TribarrelCactus;
- break;
- }
+ 0 => PlantType.CampionFlowers,
+ 1 => PlantType.Poppies,
+ 2 => PlantType.Snowdrops,
+ 3 => PlantType.Bulrushes,
+ 4 => PlantType.Lilies,
+ 5 => PlantType.PampasGrass,
+ 6 => PlantType.Rushes,
+ 7 => PlantType.ElephantEarPlant,
+ 8 => PlantType.Fern,
+ 9 => PlantType.PonytailPalm,
+ 10 => PlantType.SmallPalm,
+ 11 => PlantType.CenturyPlant,
+ 12 => PlantType.WaterPlant,
+ 13 => PlantType.SnakePlant,
+ 14 => PlantType.PricklyPearCactus,
+ 15 => PlantType.BarrelCactus,
+ _ => PlantType.TribarrelCactus
+ };
if (study.StudiedSpecialNest)
{
@@ -120,19 +85,12 @@ namespace Server.Engines.Quests.Naturalist
}
else
{
- PlantHue hue;
- switch (Utility.Random(3))
+ var hue = Utility.Random(3) switch
{
- case 0:
- hue = PlantHue.Pink;
- break;
- case 1:
- hue = PlantHue.Magenta;
- break;
- default:
- hue = PlantHue.Aqua;
- break;
- }
+ 0 => PlantHue.Pink,
+ 1 => PlantHue.Magenta,
+ _ => PlantHue.Aqua
+ };
reward = new Seed(type, hue);
}
diff --git a/Projects/Scripts/Engines/Quests/The Summoning/Conversations.cs b/Projects/Scripts/Engines/Quests/The Summoning/Conversations.cs
index f002f9448..77ce26b56 100644
--- a/Projects/Scripts/Engines/Quests/The Summoning/Conversations.cs
+++ b/Projects/Scripts/Engines/Quests/The Summoning/Conversations.cs
@@ -34,7 +34,7 @@ namespace Server.Engines.Quests.Doom
System.From.SendMessage("Internal error: unable to find summoning altar. Quest unable to continue.");
System.Cancel();
}
- else if (altar.Daemon == null || !altar.Daemon.Alive)
+ else if (altar.Daemon?.Alive != true)
{
BoneDemon daemon = new BoneDemon();
diff --git a/Projects/Scripts/Engines/Quests/The Summoning/Items/BellOfTheDead.cs b/Projects/Scripts/Engines/Quests/The Summoning/Items/BellOfTheDead.cs
index dceef8b76..69a2e1f27 100644
--- a/Projects/Scripts/Engines/Quests/The Summoning/Items/BellOfTheDead.cs
+++ b/Projects/Scripts/Engines/Quests/The Summoning/Items/BellOfTheDead.cs
@@ -83,7 +83,7 @@ namespace Server.Engines.Quests.Doom
2023, 0);
Effects.PlaySound(loc, Map, 0x1FE);
- Chyloth = new Chyloth { Direction = (Direction)(7 & (4 + (int)from.GetDirectionTo(loc))) };
+ Chyloth = new Chyloth { Direction = (Direction)(7 & 4 + (int)from.GetDirectionTo(loc)) };
Chyloth.MoveToWorld(loc, Map);
diff --git a/Projects/Scripts/Engines/Quests/The Summoning/Items/SummoningAltar.cs b/Projects/Scripts/Engines/Quests/The Summoning/Items/SummoningAltar.cs
index ae7d8f3f7..86cebfe00 100644
--- a/Projects/Scripts/Engines/Quests/The Summoning/Items/SummoningAltar.cs
+++ b/Projects/Scripts/Engines/Quests/The Summoning/Items/SummoningAltar.cs
@@ -28,7 +28,7 @@ namespace Server.Engines.Quests.Doom
public void CheckDaemon()
{
- if (m_Daemon == null || !m_Daemon.Alive)
+ if (m_Daemon?.Alive != true)
{
m_Daemon = null;
Hue = 0;
diff --git a/Projects/Scripts/Engines/Quests/The Summoning/Objectives.cs b/Projects/Scripts/Engines/Quests/The Summoning/Objectives.cs
index f67562ef0..8340b2ae8 100644
--- a/Projects/Scripts/Engines/Quests/The Summoning/Objectives.cs
+++ b/Projects/Scripts/Engines/Quests/The Summoning/Objectives.cs
@@ -28,7 +28,7 @@ namespace Server.Engines.Quests.Doom
System.From.SendMessage("Internal error: unable to find summoning altar. Quest unable to continue.");
System.Cancel();
}
- else if (altar.Daemon == null || !altar.Daemon.Alive)
+ else if (altar.Daemon?.Alive != true)
{
System.AddConversation(new VanquishDaemonConversation());
}
@@ -85,7 +85,7 @@ namespace Server.Engines.Quests.Doom
public override void CheckProgress()
{
- if (m_Daemon == null || !m_Daemon.Alive)
+ if (m_Daemon?.Alive != true)
Complete();
}
diff --git a/Projects/Scripts/Engines/Quests/The Summoning/TheSummoningQuest.cs b/Projects/Scripts/Engines/Quests/The Summoning/TheSummoningQuest.cs
index 59b3fc75e..c4f0d0475 100644
--- a/Projects/Scripts/Engines/Quests/The Summoning/TheSummoningQuest.cs
+++ b/Projects/Scripts/Engines/Quests/The Summoning/TheSummoningQuest.cs
@@ -42,7 +42,7 @@ namespace Server.Engines.Quests.Doom
{
SummoningAltar altar = Victoria.Altar;
- if (altar != null && (altar.Daemon == null || !altar.Daemon.Alive))
+ if (altar != null && altar.Daemon?.Alive != true)
if (From.Map == Victoria.Map && From.InRange(Victoria, 8))
{
WaitForSummon = false;
@@ -56,7 +56,7 @@ namespace Server.Engines.Quests.Doom
public static int GetDaemonBonesFor(BaseCreature creature)
{
- if (creature == null || creature.Controlled || creature.Summoned)
+ if (creature?.Controlled != false || creature.Summoned)
return 0;
int fame = creature.Fame;
diff --git a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs
index 07563d0ac..c50c0665c 100644
--- a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs
+++ b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs
@@ -68,22 +68,13 @@ namespace Server.Engines.Quests.Haven
public void DoFireEffect(IPoint3D target)
{
- Point3D from;
- switch (CannonDirection)
+ var from = CannonDirection switch
{
- case CannonDirection.North:
- from = new Point3D(X, Y - 1, Z);
- break;
- case CannonDirection.East:
- from = new Point3D(X + 1, Y, Z);
- break;
- case CannonDirection.South:
- from = new Point3D(X, Y + 1, Z);
- break;
- default:
- from = new Point3D(X - 1, Y, Z);
- break;
- }
+ CannonDirection.North => new Point3D(X, Y - 1, Z),
+ CannonDirection.East => new Point3D(X + 1, Y, Z),
+ CannonDirection.South => new Point3D(X, Y + 1, Z),
+ _ => new Point3D(X - 1, Y, Z)
+ };
Effects.SendLocationEffect(from, Map, 0x36B0, 16, 1);
Effects.PlaySound(from, Map, 0x11D);
@@ -104,22 +95,13 @@ namespace Server.Engines.Quests.Haven
if (!(Canoneer?.Deleted == false && Canoneer.Active))
return;
- bool canFire;
- switch (CannonDirection)
+ var canFire = CannonDirection switch
{
- case CannonDirection.North:
- canFire = m.X >= X - 7 && m.X <= X + 7 && m.Y == Y - 7 && oldLocation.Y < Y - 7;
- break;
- case CannonDirection.East:
- canFire = m.Y >= Y - 7 && m.Y <= Y + 7 && m.X == X + 7 && oldLocation.X > X + 7;
- break;
- case CannonDirection.South:
- canFire = m.X >= X - 7 && m.X <= X + 7 && m.Y == Y + 7 && oldLocation.Y > Y + 7;
- break;
- default:
- canFire = m.Y >= Y - 7 && m.Y <= Y + 7 && m.X == X - 7 && oldLocation.X < X - 7;
- break;
- }
+ CannonDirection.North => (m.X >= X - 7 && m.X <= X + 7 && m.Y == Y - 7 && oldLocation.Y < Y - 7),
+ CannonDirection.East => (m.Y >= Y - 7 && m.Y <= Y + 7 && m.X == X + 7 && oldLocation.X > X + 7),
+ CannonDirection.South => (m.X >= X - 7 && m.X <= X + 7 && m.Y == Y + 7 && oldLocation.Y > Y + 7),
+ _ => (m.Y >= Y - 7 && m.Y <= Y + 7 && m.X == X - 7 && oldLocation.X < X - 7)
+ };
if (canFire && Canoneer.WillFire(this, m))
Fire(Canoneer, m);
diff --git a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaFighter.cs b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaFighter.cs
index ff495ebac..28a4e6619 100644
--- a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaFighter.cs
+++ b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaFighter.cs
@@ -33,28 +33,15 @@ namespace Server.Engines.Quests.Haven
AddItem(new LeatherGloves());
AddItem(new LeatherGorget());
- Item weapon;
- switch (Utility.Random(6))
+ var weapon = Utility.Random(6) switch
{
- case 0:
- weapon = new Broadsword();
- break;
- case 1:
- weapon = new Cutlass();
- break;
- case 2:
- weapon = new Katana();
- break;
- case 3:
- weapon = new Longsword();
- break;
- case 4:
- weapon = new Scimitar();
- break;
- default:
- weapon = new VikingSword();
- break;
- }
+ 0 => (Item)new Broadsword(),
+ 1 => new Cutlass(),
+ 2 => new Katana(),
+ 3 => new Longsword(),
+ 4 => new Scimitar(),
+ _ => new VikingSword()
+ };
weapon.Movable = false;
AddItem(weapon);
diff --git a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Schmendrick.cs b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Schmendrick.cs
index d1873495f..414e2202c 100644
--- a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Schmendrick.cs
+++ b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Schmendrick.cs
@@ -112,7 +112,7 @@ namespace Server.Engines.Quests.Haven
if (m is PlayerMobile && !m.Frozen && !m.Alive && InRange(m, 4) && !InRange(oldLocation, 4) && InLOS(m))
{
- if (m.Map == null || !m.Map.CanFit(m.Location, 16, false, false))
+ if (m.Map?.CanFit(m.Location, 16, false, false) != true)
{
m.SendLocalizedMessage(502391); // Thou can not be resurrected there!
}
diff --git a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Uzeraan.cs b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Uzeraan.cs
index cfc84fee1..ffd3ae0dc 100644
--- a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Uzeraan.cs
+++ b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Uzeraan.cs
@@ -305,28 +305,15 @@ namespace Server.Engines.Quests.Haven
}
else
{
- BaseWeapon weapon;
- switch (Utility.Random(6))
+ var weapon = Utility.Random(6) switch
{
- case 0:
- weapon = new Broadsword();
- break;
- case 1:
- weapon = new Cutlass();
- break;
- case 2:
- weapon = new Katana();
- break;
- case 3:
- weapon = new Longsword();
- break;
- case 4:
- weapon = new Scimitar();
- break;
- default:
- weapon = new VikingSword();
- break;
- }
+ 0 => (BaseWeapon)new Broadsword(),
+ 1 => new Cutlass(),
+ 2 => new Katana(),
+ 3 => new Longsword(),
+ 4 => new Scimitar(),
+ _ => new VikingSword()
+ };
if (Core.AOS)
{
@@ -392,7 +379,7 @@ namespace Server.Engines.Quests.Haven
if (m is PlayerMobile && !m.Frozen && !m.Alive && InRange(m, 4) && !InRange(oldLocation, 4) && InLOS(m))
{
- if (m.Map == null || !m.Map.CanFit(m.Location, 16, false, false))
+ if (m.Map?.CanFit(m.Location, 16, false, false) != true)
{
m.SendLocalizedMessage(502391); // Thou can not be resurrected there!
}
diff --git a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Objectives.cs b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Objectives.cs
index a5e4016a0..b023c610f 100644
--- a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Objectives.cs
+++ b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Objectives.cs
@@ -76,27 +76,23 @@ namespace Server.Engines.Quests.Haven
{
get
{
- switch (Step)
+ return Step switch
{
- case KillHordeMinionsStep.First:
- /* Find the mountain pass beyond the house which lies at the
+ KillHordeMinionsStep.First =>
+ /* Find the mountain pass beyond the house which lies at the
* end of the runic road.
*
* Assist the city Militia by slaying Horde Minions
*/
- return 1049089;
-
- case KillHordeMinionsStep.LearnKarma:
- /* You have just gained some Karma
+ 1049089,
+ KillHordeMinionsStep.LearnKarma =>
+ /* You have just gained some Karma
* for killing the horde minion. Learn
* how this affects your Paladin abilities.
*/
- return 1060389;
-
- default:
- // Continue driving back the Horde Minions, as Uzeraan instructed you to do.
- return 1060507;
- }
+ 1060389,
+ _ => 1060507
+ };
}
}
@@ -105,12 +101,12 @@ namespace Server.Engines.Quests.Haven
get
{
if (System.From.Profession == 5) // paladin
- switch (Step)
+ return Step switch
{
- case KillHordeMinionsStep.First: return 1;
- case KillHordeMinionsStep.LearnKarma: return 2;
- default: return 5;
- }
+ KillHordeMinionsStep.First => 1,
+ KillHordeMinionsStep.LearnKarma => 2,
+ _ => 5
+ };
return 5;
}
diff --git a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs
index 0f604e0bd..e19696888 100644
--- a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs
+++ b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs
@@ -66,12 +66,12 @@ namespace Server.Engines.Quests.Haven
{
get
{
- switch (From.Profession)
+ return From.Profession switch
{
- case 1: return 0x15C9; // warrior
- case 2: return 0x15C1; // magician
- default: return 0x15D3; // paladin
- }
+ 1 => 0x15C9, // warrior
+ 2 => 0x15C1, // magician
+ _ => 0x15D3
+ };
}
}
@@ -164,4 +164,4 @@ namespace Server.Engines.Quests.Haven
return false;
}
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Engines/Quests/Witch Apprentice/Objectives.cs b/Projects/Scripts/Engines/Quests/Witch Apprentice/Objectives.cs
index b3456553c..777ab0fa8 100644
--- a/Projects/Scripts/Engines/Quests/Witch Apprentice/Objectives.cs
+++ b/Projects/Scripts/Engines/Quests/Witch Apprentice/Objectives.cs
@@ -288,24 +288,20 @@ namespace Server.Engines.Quests.Hag
get
{
if (!BlackheartMet)
- switch (Step)
+ return Step switch
{
- case 1:
- /* You must gather each ingredient on the Hag's list so that she can cook
+ 1 =>
+ /* You must gather each ingredient on the Hag's list so that she can cook
* up her vile Magic Brew. The first ingredient is :
*/
- return 1055019;
- case 2:
- /* You must gather each ingredient on the Hag's list so that she can cook
+ 1055019,
+ 2 =>
+ /* You must gather each ingredient on the Hag's list so that she can cook
* up her vile Magic Brew. The second ingredient is :
*/
- return 1055044;
- default:
- /* You must gather each ingredient on the Hag's list so that she can cook
- * up her vile Magic Brew. The final ingredient is :
- */
- return 1055045;
- }
+ 1055044,
+ _ => 1055045
+ };
/* You are still attempting to obtain a jug of Captain Blackheart's
* Whiskey, but the drunkard Captain refuses to share his unique brew.
@@ -375,7 +371,7 @@ namespace Server.Engines.Quests.Hag
if (creature.GetType() == type)
{
System.From.SendLocalizedMessage(1055043,
- "#" + info.Name); // You gather a ~1_INGREDIENT_NAME~ from the corpse.
+ $"#{info.Name}"); // You gather a ~1_INGREDIENT_NAME~ from the corpse.
CurProgress++;
diff --git a/Projects/Scripts/Engines/Spawner/Spawner.cs b/Projects/Scripts/Engines/Spawner/Spawner.cs
index dad488bab..e6c0d77e1 100644
--- a/Projects/Scripts/Engines/Spawner/Spawner.cs
+++ b/Projects/Scripts/Engines/Spawner/Spawner.cs
@@ -955,21 +955,20 @@ namespace Server.Mobiles
public static string ConvertTypes(string type)
{
type = type.ToLower();
- switch (type)
+ return type switch
{
- case "wheat": return "WheatSheaf";
- case "noxxiousmage": return "NoxiousMage";
- case "noxxiousarcher": return "NoxiousArcher";
- case "noxxiouswarrior": return "NoxiousWarrior";
- case "noxxiouswarlord": return "NoxiousWarlord";
- case "obsidian": return "obsidianstatue";
- case "adeepwaterelemental": return "deepwaterelemental";
- case "noxskeleton": return "poisonskeleton";
- case "earthcaller": return "earthsummoner";
- case "bonedemon": return "bonedaemon";
- }
-
- return type;
+ "wheat" => "WheatSheaf",
+ "noxxiousmage" => "NoxiousMage",
+ "noxxiousarcher" => "NoxiousArcher",
+ "noxxiouswarrior" => "NoxiousWarrior",
+ "noxxiouswarlord" => "NoxiousWarlord",
+ "obsidian" => "obsidianstatue",
+ "adeepwaterelemental" => "deepwaterelemental",
+ "noxskeleton" => "poisonskeleton",
+ "earthcaller" => "earthsummoner",
+ "bonedemon" => "bonedaemon",
+ _ => type
+ };
}
private class InternalTimer : Timer
diff --git a/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs b/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs
index 342c4740a..98650495c 100644
--- a/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs
+++ b/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs
@@ -432,13 +432,13 @@ namespace Server.Mobiles
if (Statue != null) t = Statue.StatueType;
- switch (t)
+ return t switch
{
- case StatueType.Marble: return 1076189;
- case StatueType.Jade: return 1076188;
- case StatueType.Bronze: return 1076190;
- default: return 1076173;
- }
+ StatueType.Marble => 1076189,
+ StatueType.Jade => 1076188,
+ StatueType.Bronze => 1076190,
+ _ => 1076173
+ };
}
}
diff --git a/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs b/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs
index 8353e5a0d..b1c29d81f 100644
--- a/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs
+++ b/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs
@@ -27,7 +27,7 @@ namespace Server.Items
{
Point3D point = new Point3D(p.X, p.Y, p.Z);
- if (map == null || !map.CanFit(point, 20))
+ if (map?.CanFit(point, 20) != true)
return false;
BaseHouse house = BaseHouse.FindHouseAt(point, map, 20);
@@ -113,13 +113,13 @@ namespace Server.Items
public int GetTypeNumber(StatueType type)
{
- switch (type)
+ return type switch
{
- case StatueType.Marble: return 1076181;
- case StatueType.Jade: return 1076180;
- case StatueType.Bronze: return 1076230;
- default: return 1076181;
- }
+ StatueType.Marble => 1076181,
+ StatueType.Jade => 1076180,
+ StatueType.Bronze => 1076230,
+ _ => 1076181
+ };
}
}
}
diff --git a/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs b/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs
index 4d719b32e..48e429d14 100644
--- a/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs
+++ b/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs
@@ -72,14 +72,14 @@ namespace Server.Gumps
{
case StatueMaterial.Antique:
- switch (type)
+ return type switch
{
- case StatueType.Bronze: return 1076187;
- case StatueType.Jade: return 1076186;
- case StatueType.Marble: return 1076182;
- }
+ StatueType.Bronze => 1076187,
+ StatueType.Jade => 1076186,
+ StatueType.Marble => 1076182,
+ _ => 1076187
+ };
- return 1076187;
case StatueMaterial.Dark:
if (type == StatueType.Marble)
@@ -94,18 +94,18 @@ namespace Server.Gumps
private int GetDirectionNumber(Direction direction)
{
- switch (direction)
+ return direction switch
{
- case Direction.North: return 1075389;
- case Direction.Right: return 1075388;
- case Direction.East: return 1075387;
- case Direction.Down: return 1076204;
- case Direction.South: return 1075386;
- case Direction.Left: return 1075391;
- case Direction.West: return 1075390;
- case Direction.Up: return 1076205;
- default: return 1075386;
- }
+ Direction.North => 1075389,
+ Direction.Right => 1075388,
+ Direction.East => 1075387,
+ Direction.Down => 1076204,
+ Direction.South => 1075386,
+ Direction.Left => 1075391,
+ Direction.West => 1075390,
+ Direction.Up => 1076205,
+ _ => 1075386
+ };
}
public override void OnResponse(NetState state, RelayInfo info)
diff --git a/Projects/Scripts/Engines/VeteranRewards/RewardChoiceGump.cs b/Projects/Scripts/Engines/VeteranRewards/RewardChoiceGump.cs
index 3fe04c1d1..102d07a25 100644
--- a/Projects/Scripts/Engines/VeteranRewards/RewardChoiceGump.cs
+++ b/Projects/Scripts/Engines/VeteranRewards/RewardChoiceGump.cs
@@ -50,14 +50,8 @@ namespace Server.Engines.VeteranRewards
AddPage(1);
- AddHtml(60, 35, 500, 70, "Ultima Online Rewards Program
" +
- "Thank you for being a part of the Ultima Online community for a full " +
- intervalAsString + ". " +
- "As a token of our appreciation, you may select from the following in-game reward items listed below. " +
- "The gift items will be attributed to the character you have logged-in with on the shard you are on when you chose the item(s). " +
- "The number of rewards you are entitled to are listed below and are for your entire account. " +
- "To read more about these rewards before making a selection, feel free to visit the uo.com site at " +
- "http://www.uo.com/rewards.", true, true);
+ AddHtml(60, 35, 500, 70,
+ $"Ultima Online Rewards Program
Thank you for being a part of the Ultima Online community for a full {intervalAsString}. As a token of our appreciation, you may select from the following in-game reward items listed below. The gift items will be attributed to the character you have logged-in with on the shard you are on when you chose the item(s). The number of rewards you are entitled to are listed below and are for your entire account. To read more about these rewards before making a selection, feel free to visit the uo.com site at http://www.uo.com/rewards.", true, true);
RewardSystem.ComputeRewardInfo(m_From, out int cur, out int max);
diff --git a/Projects/Scripts/Engines/Virtues/Honor.cs b/Projects/Scripts/Engines/Virtues/Honor.cs
index 5bab37931..576d0d42d 100644
--- a/Projects/Scripts/Engines/Virtues/Honor.cs
+++ b/Projects/Scripts/Engines/Virtues/Honor.cs
@@ -26,14 +26,13 @@ namespace Server
private static int GetHonorDuration(PlayerMobile from)
{
- switch (VirtueHelper.GetLevel(from, VirtueName.Honor))
+ return VirtueHelper.GetLevel(from, VirtueName.Honor) switch
{
- case VirtueLevel.Seeker: return 30;
- case VirtueLevel.Follower: return 90;
- case VirtueLevel.Knight: return 300;
-
- default: return 0;
- }
+ VirtueLevel.Seeker => 30,
+ VirtueLevel.Follower => 90,
+ VirtueLevel.Knight => 300,
+ _ => 0
+ };
}
private static void EmbraceHonor(PlayerMobile pm)
diff --git a/Projects/Scripts/Engines/Virtues/VirtueGump.cs b/Projects/Scripts/Engines/Virtues/VirtueGump.cs
index 0277fb64e..9f9780989 100644
--- a/Projects/Scripts/Engines/Virtues/VirtueGump.cs
+++ b/Projects/Scripts/Engines/Virtues/VirtueGump.cs
@@ -86,20 +86,16 @@ namespace Server
private static void EventSink_VirtueMacroRequest(VirtueMacroRequestEventArgs e)
{
- int virtueID = 0;
-
- switch (e.VirtueID)
+ var virtueID = e.VirtueID switch
{
- case 0: // Honor
- virtueID = 107;
- break;
- case 1: // Sacrifice
- virtueID = 110;
- break;
- case 2: // Valor;
- virtueID = 112;
- break;
- }
+ 0 => // Honor
+ 107,
+ 1 => // Sacrifice
+ 110,
+ 2 => // Valor;
+ 112,
+ _ => 0
+ };
EventSink_VirtueItemRequest(new VirtueItemRequestEventArgs(e.Mobile, e.Mobile, virtueID));
}
diff --git a/Projects/Scripts/Gumps/AddDoorGump.cs b/Projects/Scripts/Gumps/AddDoorGump.cs
index 178b1cb1d..e03575788 100644
--- a/Projects/Scripts/Gumps/AddDoorGump.cs
+++ b/Projects/Scripts/Gumps/AddDoorGump.cs
@@ -1,5 +1,4 @@
using System;
-using Server.Commands;
using Server.Items;
using Server.Network;
diff --git a/Projects/Scripts/Gumps/AddGump.cs b/Projects/Scripts/Gumps/AddGump.cs
index 69d24becc..686d1f4d6 100644
--- a/Projects/Scripts/Gumps/AddGump.cs
+++ b/Projects/Scripts/Gumps/AddGump.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
-using Server.Commands;
using Server.Network;
using Server.Targeting;
@@ -158,7 +157,7 @@ namespace Server.Gumps
case 1: // Search
{
TextRelay te = info.GetTextEntry(0);
- string match = te == null ? "" : te.Text.Trim();
+ string match = te?.Text.Trim() ?? "";
if (match.Length < 3)
{
diff --git a/Projects/Scripts/Gumps/AdminGump.cs b/Projects/Scripts/Gumps/AdminGump.cs
index be038d50d..fbc3db4b3 100644
--- a/Projects/Scripts/Gumps/AdminGump.cs
+++ b/Projects/Scripts/Gumps/AdminGump.cs
@@ -186,8 +186,8 @@ namespace Server.Gumps
case AdminGumpPage.Information_Perf:
{
AddLabel(20, 130, LabelHue, "Cycles Per Second:");
- AddLabel(40, 150, LabelHue, "Current: " + Core.CyclesPerSecond.ToString("N2"));
- AddLabel(40, 170, LabelHue, "Average: " + Core.AverageCPS.ToString("N2"));
+ AddLabel(40, 150, LabelHue, $"Current: {Core.CyclesPerSecond:N2}");
+ AddLabel(40, 170, LabelHue, $"Average: {Core.AverageCPS:N2}");
StringBuilder sb = new StringBuilder();
@@ -450,7 +450,7 @@ namespace Server.Gumps
Account a = m.Account as Account;
AddLabel(20, y, LabelHue, "Account:");
- AddLabel(200, y, a != null && a.Banned ? RedHue : LabelHue, a == null ? "(no account)" : a.Username);
+ AddLabel(200, y, a?.Banned == true ? RedHue : LabelHue, a == null ? "(no account)" : a.Username);
AddButton(380, y, 0xFA5, 0xFA7, GetButtonID(7, 14));
y += 20;
@@ -1292,10 +1292,8 @@ namespace Server.Gumps
IPAddress[] theirAddresses = acct.LoginIPs;
for (int i = 0; i < theirAddresses.Length; ++i)
- {
if (!table.ContainsKey(theirAddresses[i]))
table[theirAddresses[i]] = new List{ acct };
- }
}
List>> tableEntries = table.ToList();
@@ -2390,33 +2388,17 @@ namespace Server.Gumps
if (!(m_State is Account a))
break;
- AccessLevel newLevel;
-
- switch (index)
+ var newLevel = index switch
{
- default:
- case 20:
- newLevel = AccessLevel.Player;
- break;
- case 21:
- newLevel = AccessLevel.Counselor;
- break;
- case 22:
- newLevel = AccessLevel.GameMaster;
- break;
- case 23:
- newLevel = AccessLevel.Seer;
- break;
- case 24:
- newLevel = AccessLevel.Administrator;
- break;
- case 33:
- newLevel = AccessLevel.Developer;
- break;
- case 34:
- newLevel = AccessLevel.Owner;
- break;
- }
+ 20 => AccessLevel.Player,
+ 21 => AccessLevel.Counselor,
+ 22 => AccessLevel.GameMaster,
+ 23 => AccessLevel.Seer,
+ 24 => AccessLevel.Administrator,
+ 33 => AccessLevel.Developer,
+ 34 => AccessLevel.Owner,
+ _ => AccessLevel.Player
+ };
if (newLevel < from.AccessLevel || from.AccessLevel == AccessLevel.Owner)
{
diff --git a/Projects/Scripts/Gumps/CategorizedAddGump.cs b/Projects/Scripts/Gumps/CategorizedAddGump.cs
index 8609a35e4..f3e49ed66 100644
--- a/Projects/Scripts/Gumps/CategorizedAddGump.cs
+++ b/Projects/Scripts/Gumps/CategorizedAddGump.cs
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
-using Server.Commands;
using Server.Network;
namespace Server.Gumps
diff --git a/Projects/Scripts/Gumps/ClientGump.cs b/Projects/Scripts/Gumps/ClientGump.cs
index 345d2ebb1..357851480 100644
--- a/Projects/Scripts/Gumps/ClientGump.cs
+++ b/Projects/Scripts/Gumps/ClientGump.cs
@@ -149,7 +149,7 @@ namespace Server.Gumps
}
if (from != focus && focus.Hidden && from.AccessLevel < focus.AccessLevel &&
- (!(focus is PlayerMobile) || !((PlayerMobile)focus).VisibilityList.Contains(from)))
+ (focus as PlayerMobile)?.VisibilityList.Contains(from) != true)
{
from.SendMessage("That character is no longer visible.");
return;
diff --git a/Projects/Scripts/Gumps/CommentsGump.cs b/Projects/Scripts/Gumps/CommentsGump.cs
index a30c88c75..f884de9b6 100644
--- a/Projects/Scripts/Gumps/CommentsGump.cs
+++ b/Projects/Scripts/Gumps/CommentsGump.cs
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using Server.Accounting;
-using Server.Commands;
using Server.Network;
using Server.Prompts;
using Server.Targeting;
diff --git a/Projects/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs b/Projects/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs
index c4bb0d5e1..c5eb72a9a 100644
--- a/Projects/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs
+++ b/Projects/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs
@@ -47,23 +47,13 @@ namespace Server.Gumps
!Guild.NewGuildSystem && GuildGump.BadLeader(m_Mobile, m_Guild))
return;
- GuildType newType;
-
- switch (info.ButtonID)
+ var newType = info.ButtonID switch
{
- default:
- newType = m_Guild.Type;
- break;
- case 1:
- newType = GuildType.Regular;
- break;
- case 2:
- newType = GuildType.Order;
- break;
- case 3:
- newType = GuildType.Chaos;
- break;
- }
+ 1 => GuildType.Regular,
+ 2 => GuildType.Order,
+ 3 => GuildType.Chaos,
+ _ => m_Guild.Type
+ };
if (m_Guild.Type != newType)
{
diff --git a/Projects/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs b/Projects/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs
index b3039432e..404295ca4 100644
--- a/Projects/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs
+++ b/Projects/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs
@@ -31,7 +31,7 @@ namespace Server.Guilds
AddImageTiled(67, 116, 156, 22, 0xBBC);
AddHtmlLocalized(70, 117, 150, 20, 1063025, 0x0); // Alliance
- if (guild.Alliance != null && guild.Alliance.IsMember(guild))
+ if (guild.Alliance?.IsMember(guild) == true)
{
AddHtml(233, 118, 320, 26, guild.Alliance.Name);
AddButton(40, 120, 0x4B9, 0x4BA, 6); //Alliance Roster
@@ -119,7 +119,7 @@ namespace Server.Guilds
case 6:
{
//Alliance Roster
- if (guild.Alliance != null && guild.Alliance.IsMember(guild))
+ if (guild.Alliance?.IsMember(guild) == true)
pm.SendGump(new AllianceInfo.AllianceRosterGump(pm, guild, guild.Alliance));
break;
diff --git a/Projects/Scripts/Gumps/Guilds/New Guild System/OtherGuildInfo.cs b/Projects/Scripts/Gumps/Guilds/New Guild System/OtherGuildInfo.cs
index c5c79da11..6ae8e735d 100644
--- a/Projects/Scripts/Gumps/Guilds/New Guild System/OtherGuildInfo.cs
+++ b/Projects/Scripts/Gumps/Guilds/New Guild System/OtherGuildInfo.cs
@@ -356,7 +356,7 @@ namespace Server.Guilds
guild.AcceptedWars.Remove(activeWar);
- if (otherAlliance != null && otherAlliance.IsMember(otherGuild))
+ if (otherAlliance?.IsMember(otherGuild) == true)
{
otherAlliance.AllianceMessage(1070739,
guild.Alliance != null
@@ -523,7 +523,7 @@ namespace Server.Guilds
else if (alliance?.IsMember(guild) == true)
{
guild.Alliance = null; //Calls alliance.Removeguild
-// alliance.RemoveGuild( guild );
+ // alliance.RemoveGuild( guild );
m_Other.InvalidateWarNotoriety();
diff --git a/Projects/Scripts/Gumps/Guilds/New Guild System/War Declaration gump.cs b/Projects/Scripts/Gumps/Guilds/New Guild System/War Declaration gump.cs
index e8bdad429..3fe208642 100644
--- a/Projects/Scripts/Gumps/Guilds/New Guild System/War Declaration gump.cs
+++ b/Projects/Scripts/Gumps/Guilds/New Guild System/War Declaration gump.cs
@@ -23,11 +23,11 @@ namespace Server.Guilds
AddHtmlLocalized(65, 95, 200, 20, 1063009, 0x14AF); // Duration of War
AddHtmlLocalized(65, 120, 400, 20, 1063010, 0x0); // Enter the number of hours the war will last.
AddBackground(65, 150, 40, 30, 0x2486);
- AddTextEntry(70, 154, 50, 30, 0x481, 10, war != null ? war.WarLength.Hours.ToString() : "0");
+ AddTextEntry(70, 154, 50, 30, 0x481, 10, war?.WarLength.Hours.ToString() ?? "0");
AddHtmlLocalized(65, 195, 200, 20, 1063011, 0x14AF); // Victory Condition
AddHtmlLocalized(65, 220, 400, 20, 1063012, 0x0); // Enter the winning number of kills.
AddBackground(65, 250, 40, 30, 0x2486);
- AddTextEntry(70, 254, 50, 30, 0x481, 11, war != null ? war.MaxKills.ToString() : "0");
+ AddTextEntry(70, 254, 50, 30, 0x481, 11, war?.MaxKills.ToString() ?? "0");
AddBackground(190, 270, 130, 26, 0x2486);
AddButton(195, 275, 0x845, 0x846, 0);
AddHtmlLocalized(220, 273, 90, 26, 1006045, 0x0); // Cancel
diff --git a/Projects/Scripts/Gumps/HouseDemolishGump.cs b/Projects/Scripts/Gumps/HouseDemolishGump.cs
index 5860a8b6c..1ec189cff 100644
--- a/Projects/Scripts/Gumps/HouseDemolishGump.cs
+++ b/Projects/Scripts/Gumps/HouseDemolishGump.cs
@@ -122,7 +122,7 @@ namespace Server.Gumps
{
int worth = check.Worth;
- if (m_Mobile.Account != null && m_Mobile.Account.DepositGold(worth))
+ if (m_Mobile.Account?.DepositGold(worth) == true)
{
check.Delete();
diff --git a/Projects/Scripts/Gumps/HouseGump.cs b/Projects/Scripts/Gumps/HouseGump.cs
index e809ab6e2..c3a65e70a 100644
--- a/Projects/Scripts/Gumps/HouseGump.cs
+++ b/Projects/Scripts/Gumps/HouseGump.cs
@@ -362,7 +362,7 @@ namespace Server.Gumps
{
string val = values[i];
- string v = current.Length == 0 ? val : current + ' ' + val;
+ string v = current.Length == 0 ? val : $"{current}{' '}{val}";
if (v.Length < 10)
{
diff --git a/Projects/Scripts/Gumps/HouseGumpAOS.cs b/Projects/Scripts/Gumps/HouseGumpAOS.cs
index f2afc2343..a29c9454e 100644
--- a/Projects/Scripts/Gumps/HouseGumpAOS.cs
+++ b/Projects/Scripts/Gumps/HouseGumpAOS.cs
@@ -291,7 +291,7 @@ namespace Server.Gumps
int vendors = house.PlayerVendors.Count + house.VendorRentalContracts.Count;
AddHtmlLocalized(10, 350, 300, 20, 1062391, LabelColor); // Vendor Count
- AddLabel(310, 350, LabelHue, vendors + " / " + maxVendors);
+ AddLabel(310, 350, LabelHue, $"{vendors} / {maxVendors}");
}
else
{
@@ -484,7 +484,7 @@ namespace Server.Gumps
if (m?.Deleted != false)
return "(unowned)";
- return String.IsNullOrWhiteSpace(m.Name) ? "(no name)" : m.Name.Trim();
+ return string.IsNullOrWhiteSpace(m.Name) ? "(no name)" : m.Name.Trim();
}
private string GetDateTime(DateTime val) => val == DateTime.MinValue ? "" : val.ToString("yyyy'-'MM'-'dd HH':'mm':'ss");
@@ -563,10 +563,10 @@ namespace Server.Gumps
AddButton(10 + xoffset, 150 + yoffset, 4005, 4007, GetButtonID(button, i));
if (accountOf && m.Player && m.Account != null)
- name = "Account of " + name;
+ name = $"Account of {name}";
if (leadingStar)
- name = "* " + name;
+ name = $"* {name}";
AddLabel(button > 0 ? 45 + xoffset : 10 + xoffset, 150 + yoffset, labelHue, name);
++index;
@@ -1404,7 +1404,7 @@ namespace Server.Gumps
{
string val = values[i];
- string v = current.Length == 0 ? val : current + ' ' + val;
+ string v = current.Length == 0 ? val : $"{current}{' '}{val}";
if (v.Length < 10)
{
diff --git a/Projects/Scripts/Gumps/PetResurrectGump.cs b/Projects/Scripts/Gumps/PetResurrectGump.cs
index 4a1bb41ee..494505e9e 100644
--- a/Projects/Scripts/Gumps/PetResurrectGump.cs
+++ b/Projects/Scripts/Gumps/PetResurrectGump.cs
@@ -42,7 +42,7 @@ namespace Server.Gumps
if (info.ButtonID == 1)
{
- if (m_Pet.Map == null || !m_Pet.Map.CanFit(m_Pet.Location, 16, false, false))
+ if (m_Pet.Map?.CanFit(m_Pet.Location, 16, false, false) != true)
{
from.SendLocalizedMessage(503256); // You fail to resurrect the creature.
return;
diff --git a/Projects/Scripts/Gumps/Props/SetGump.cs b/Projects/Scripts/Gumps/Props/SetGump.cs
index 8332f257f..918eab063 100644
--- a/Projects/Scripts/Gumps/Props/SetGump.cs
+++ b/Projects/Scripts/Gumps/Props/SetGump.cs
@@ -230,7 +230,7 @@ namespace Server.Gumps
try
{
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name,
- toSet == null ? "(null)" : toSet.ToString());
+ toSet?.ToString() ?? "(null)");
m_Property.SetValue(m_Object, toSet, null);
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
}
diff --git a/Projects/Scripts/Gumps/Props/SetObjectGump.cs b/Projects/Scripts/Gumps/Props/SetObjectGump.cs
index e69f80c62..30d79a680 100644
--- a/Projects/Scripts/Gumps/Props/SetObjectGump.cs
+++ b/Projects/Scripts/Gumps/Props/SetObjectGump.cs
@@ -237,16 +237,11 @@ namespace Server.Gumps
IEntity toSet = World.FindEntity(serial);
if (toSet == null)
- {
m_Mobile.SendMessage("No object with that serial was found.");
- }
else if (!m_Type.IsInstanceOfType(toSet))
- {
m_Mobile.SendMessage("The object with that serial could not be assigned to a property of type : {0}",
m_Type.Name);
- }
else
- {
try
{
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name,
@@ -258,7 +253,6 @@ namespace Server.Gumps
{
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
}
- }
}
catch
{
diff --git a/Projects/Scripts/Gumps/ReportMurderer.cs b/Projects/Scripts/Gumps/ReportMurderer.cs
index 41b8a71b6..5ae15f756 100644
--- a/Projects/Scripts/Gumps/ReportMurderer.cs
+++ b/Projects/Scripts/Gumps/ReportMurderer.cs
@@ -27,38 +27,34 @@ namespace Server.Gumps
foreach ( AggressorInfo ai in m.Aggressors )
{
if ( ai.Attacker.Player && ai.CanReportMurder && !ai.Reported )
- {
if (!Core.SE || !((PlayerMobile)m).RecentlyReported.Contains(ai.Attacker))
{
killers.Add(ai.Attacker);
ai.Reported = true;
ai.CanReportMurder = false;
}
- }
- if ( ai.Attacker.Player && (DateTime.UtcNow - ai.LastCombatTime) < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Attacker ) )
+ if ( ai.Attacker.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Attacker ) )
toGive.Add( ai.Attacker );
}
foreach ( AggressorInfo ai in m.Aggressed )
- {
- if ( ai.Defender.Player && (DateTime.UtcNow - ai.LastCombatTime) < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Defender ) )
+ if ( ai.Defender.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Defender ) )
toGive.Add( ai.Defender );
- }
foreach ( Mobile g in toGive )
{
int n = Notoriety.Compute( g, m );
int theirKarma = m.Karma, ourKarma = g.Karma;
- bool innocent = ( n == Notoriety.Innocent );
- bool criminal = ( n == Notoriety.Criminal || n == Notoriety.Murderer );
+ bool innocent = n == Notoriety.Innocent;
+ bool criminal = n == Notoriety.Criminal || n == Notoriety.Murderer;
int fameAward = m.Fame / 200;
int karmaAward = 0;
if ( innocent )
- karmaAward = ( ourKarma > -2500 ? -850 : -110 - (m.Karma / 100) );
+ karmaAward = ourKarma > -2500 ? -850 : -110 - m.Karma / 100;
else if ( criminal )
karmaAward = 50;
@@ -159,13 +155,8 @@ namespace Server.Gumps
pk.SendLocalizedMessage(1049067);//You have been reported for murder!
if (pk.Kills == 5)
- {
pk.SendLocalizedMessage(502134);//You are now known as a murderer!
- }
- else if (SkillHandlers.Stealing.SuspendOnMurder && pk.Kills == 1 && pk.NpcGuild == NpcGuild.ThievesGuild)
- {
- pk.SendLocalizedMessage(501562); // You have been suspended by the Thieves Guild.
- }
+ else if (SkillHandlers.Stealing.SuspendOnMurder && pk.Kills == 1 && pk.NpcGuild == NpcGuild.ThievesGuild) pk.SendLocalizedMessage(501562); // You have been suspended by the Thieves Guild.
}
}
break;
diff --git a/Projects/Scripts/Gumps/ResurrectGump.cs b/Projects/Scripts/Gumps/ResurrectGump.cs
index 18d26166c..71b3ecac6 100644
--- a/Projects/Scripts/Gumps/ResurrectGump.cs
+++ b/Projects/Scripts/Gumps/ResurrectGump.cs
@@ -162,12 +162,13 @@ namespace Server.Gumps
{
VirtueLevel level = VirtueHelper.GetLevel( m_Healer, VirtueName.Compassion );
- switch( level )
+ from.Hits = level switch
{
- case VirtueLevel.Seeker: from.Hits = AOS.Scale( from.HitsMax, 20 ); break;
- case VirtueLevel.Follower: from.Hits = AOS.Scale( from.HitsMax, 40 ); break;
- case VirtueLevel.Knight: from.Hits = AOS.Scale( from.HitsMax, 80 ); break;
- }
+ VirtueLevel.Seeker => AOS.Scale(from.HitsMax, 20),
+ VirtueLevel.Follower => AOS.Scale(from.HitsMax, 40),
+ VirtueLevel.Knight => AOS.Scale(from.HitsMax, 80),
+ _ => from.Hits
+ };
}
if ( m_FromSacrifice && from is PlayerMobile mobile )
@@ -200,7 +201,7 @@ namespace Server.Gumps
if ( !Core.AOS && from.ShortTermMurders >= 5 )
{
- double loss = (100.0 - (4.0 + (from.ShortTermMurders / 5.0))) / 100.0; // 5 to 15% loss
+ double loss = (100.0 - (4.0 + from.ShortTermMurders / 5.0)) / 100.0; // 5 to 15% loss
if ( loss < 0.85 )
loss = 0.85;
@@ -215,10 +216,8 @@ namespace Server.Gumps
from.RawDex = (int)(from.RawDex * loss);
for( int s = 0; s < from.Skills.Length; s++ )
- {
if ( from.Skills[s].Base * loss > 35 )
from.Skills[s].Base *= loss;
- }
}
if ( from.Alive && m_HitsScalar > 0 )
diff --git a/Projects/Scripts/Gumps/SetSecureLevelGump.cs b/Projects/Scripts/Gumps/SetSecureLevelGump.cs
index 498c4200a..149491e73 100644
--- a/Projects/Scripts/Gumps/SetSecureLevelGump.cs
+++ b/Projects/Scripts/Gumps/SetSecureLevelGump.cs
@@ -62,26 +62,15 @@ namespace Server.Gumps
public override void OnResponse(NetState state, RelayInfo info)
{
- SecureLevel level = m_Info.Level;
-
- switch (info.ButtonID)
+ var level = info.ButtonID switch
{
- case 1:
- level = SecureLevel.Owner;
- break;
- case 2:
- level = SecureLevel.CoOwners;
- break;
- case 3:
- level = SecureLevel.Friends;
- break;
- case 4:
- level = SecureLevel.Anyone;
- break;
- case 5:
- level = SecureLevel.Guild;
- break;
- }
+ 1 => SecureLevel.Owner,
+ 2 => SecureLevel.CoOwners,
+ 3 => SecureLevel.Friends,
+ 4 => SecureLevel.Anyone,
+ 5 => SecureLevel.Guild,
+ _ => m_Info.Level
+ };
if (m_Info.Level == level)
{
diff --git a/Projects/Scripts/Gumps/TithingGump.cs b/Projects/Scripts/Gumps/TithingGump.cs
index fef118119..3b2786608 100644
--- a/Projects/Scripts/Gumps/TithingGump.cs
+++ b/Projects/Scripts/Gumps/TithingGump.cs
@@ -66,23 +66,14 @@ namespace Server.Gumps
case 3:
case 4:
{
- int offer = 0;
-
- switch (info.ButtonID)
+ var offer = info.ButtonID switch
{
- case 1:
- offer = m_Offer - 100;
- break;
- case 2:
- offer = 0;
- break;
- case 3:
- offer = m_Offer + 100;
- break;
- case 4:
- offer = m_From.TotalGold;
- break;
- }
+ 1 => (m_Offer - 100),
+ 2 => 0,
+ 3 => (m_Offer + 100),
+ 4 => m_From.TotalGold,
+ _ => 0
+ };
m_From.SendGump(new TithingGump(m_From, offer));
break;
diff --git a/Projects/Scripts/Gumps/ToTAdminGump.cs b/Projects/Scripts/Gumps/ToTAdminGump.cs
index da81acf3c..cb74d3bb1 100644
--- a/Projects/Scripts/Gumps/ToTAdminGump.cs
+++ b/Projects/Scripts/Gumps/ToTAdminGump.cs
@@ -1,5 +1,4 @@
using System;
-using Server.Commands;
using Server.Misc;
using Server.Network;
@@ -72,7 +71,7 @@ namespace Server.Gumps
int dropButtonID = isThisDropEra ? 2361 : 2360;
int rewardButtonID = isThisRewardEra ? 2361 : 2360;
- AddLabel(10, 70 + yoffset, 2100, "ToT " + (i + 1));
+ AddLabel(10, 70 + yoffset, 2100, $"ToT {i + 1}");
AddButton(75, 75 + yoffset, dropButtonID, dropButtonID, 2 + i * 2);
AddLabel(90, 70 + yoffset, isThisDropEra ? 167 : 137, isThisDropEra ? "Active" : "Inactive");
AddButton(180, 75 + yoffset, rewardButtonID, rewardButtonID, 2 + i * 2 + 1);
@@ -105,13 +104,13 @@ namespace Server.Gumps
{
selectedToT = button / 2;
TreasuresOfTokuno.DropEra = (TreasuresOfTokunoEra)selectedToT;
- from.SendMessage("Treasures of Tokuno " + selectedToT + " Drops have been enabled");
+ from.SendMessage($"Treasures of Tokuno {selectedToT} Drops have been enabled");
}
else
{
selectedToT = (button - 1) / 2;
TreasuresOfTokuno.RewardEra = (TreasuresOfTokunoEra)selectedToT;
- from.SendMessage("Treasures of Tokuno " + selectedToT + " Rewards have been enabled");
+ from.SendMessage($"Treasures of Tokuno {selectedToT} Rewards have been enabled");
}
}
}
diff --git a/Projects/Scripts/Gumps/VendorInventoryGump.cs b/Projects/Scripts/Gumps/VendorInventoryGump.cs
index 4c5062d05..84435f090 100644
--- a/Projects/Scripts/Gumps/VendorInventoryGump.cs
+++ b/Projects/Scripts/Gumps/VendorInventoryGump.cs
@@ -98,8 +98,7 @@ namespace Server.Gumps
}
from.SendLocalizedMessage(1062436,
- totalItems + "\t" +
- inventory.Gold); // The vendor you selected had ~1_COUNT~ items in its inventory, and ~2_AMOUNT~ gold in its account.
+ $"{totalItems}\t{inventory.Gold}"); // The vendor you selected had ~1_COUNT~ items in its inventory, and ~2_AMOUNT~ gold in its account.
int givenGold = Banker.DepositUpTo(from, inventory.Gold);
inventory.Gold -= givenGold;
@@ -107,8 +106,7 @@ namespace Server.Gumps
from.SendLocalizedMessage(1060397,
givenGold.ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box.
from.SendLocalizedMessage(1062437,
- givenToBackpack + "\t" +
- givenToBankBox); // ~1_COUNT~ items have been removed from the shop inventory and placed in your backpack. ~2_BANKCOUNT~ items were removed from the shop inventory and placed in your bank box.
+ $"{givenToBackpack}\t{givenToBankBox}"); // ~1_COUNT~ items have been removed from the shop inventory and placed in your backpack. ~2_BANKCOUNT~ items were removed from the shop inventory and placed in your bank box.
if (inventory.Gold > 0 || inventory.Items.Count > 0)
{
diff --git a/Projects/Scripts/Gumps/VendorRentalGumps.cs b/Projects/Scripts/Gumps/VendorRentalGumps.cs
index 91c22f341..01c140d51 100644
--- a/Projects/Scripts/Gumps/VendorRentalGumps.cs
+++ b/Projects/Scripts/Gumps/VendorRentalGumps.cs
@@ -144,10 +144,7 @@ namespace Server.Gumps
{
int index = info.ButtonID & 0xF;
- if ( index < VendorRentalDuration.Instances.Length )
- {
- SetContractDuration( from, VendorRentalDuration.Instances[index] );
- }
+ if ( index < VendorRentalDuration.Instances.Length ) SetContractDuration( from, VendorRentalDuration.Instances[index] );
}
else
{
diff --git a/Projects/Scripts/Gumps/ViewHousesGump.cs b/Projects/Scripts/Gumps/ViewHousesGump.cs
index d4a545850..e44842f95 100644
--- a/Projects/Scripts/Gumps/ViewHousesGump.cs
+++ b/Projects/Scripts/Gumps/ViewHousesGump.cs
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using Server.Accounting;
-using Server.Commands;
using Server.Items;
using Server.Multis;
using Server.Network;
diff --git a/Projects/Scripts/Gumps/WarningGump.cs b/Projects/Scripts/Gumps/WarningGump.cs
index b6e9338b7..3c9a63dac 100644
--- a/Projects/Scripts/Gumps/WarningGump.cs
+++ b/Projects/Scripts/Gumps/WarningGump.cs
@@ -36,8 +36,8 @@ namespace Server.Gumps
if ( cancelButton )
{
- AddButton( 10 + ((width - 20) / 2), height - 30, 4005, 4007, 0 );
- AddHtmlLocalized( 40 + ((width - 20) / 2), height - 30, 170, 20, 1011012, 32767 ); // CANCEL
+ AddButton( 10 + (width - 20) / 2, height - 30, 4005, 4007, 0 );
+ AddHtmlLocalized( 40 + (width - 20) / 2, height - 30, 170, 20, 1011012, 32767 ); // CANCEL
}
}
diff --git a/Projects/Scripts/Gumps/WhoGump.cs b/Projects/Scripts/Gumps/WhoGump.cs
index 963415f5e..85263057b 100644
--- a/Projects/Scripts/Gumps/WhoGump.cs
+++ b/Projects/Scripts/Gumps/WhoGump.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using Server.Commands;
using Server.Mobiles;
using Server.Network;
@@ -68,7 +67,7 @@ namespace Server.Gumps
private static readonly int EntryCount = 15;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
- private static readonly int TotalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (EntryCount + 1));
+ private static readonly int TotalHeight = OffsetSize + (EntryHeight + OffsetSize) * (EntryCount + 1);
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
@@ -81,10 +80,6 @@ namespace Server.Gumps
{
public static readonly IComparer Instance = new InternalComparer();
- public InternalComparer()
- {
- }
-
public int Compare( Mobile x, Mobile y )
{
if ( x == null || y == null )
@@ -114,7 +109,7 @@ namespace Server.Gumps
public static List BuildList(Mobile owner, string rawFilter)
{
- string filter = String.IsNullOrWhiteSpace(rawFilter) ? null : rawFilter.Trim().ToLower();
+ string filter = string.IsNullOrWhiteSpace(rawFilter) ? null : rawFilter.Trim().ToLower();
List list = new List();
List states = NetState.Instances;
@@ -158,7 +153,7 @@ namespace Server.Gumps
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
- int emptyWidth = TotalWidth - PrevWidth - NextWidth - (OffsetSize * 4) - (OldStyle ? SetWidth + OffsetSize : 0);
+ int emptyWidth = TotalWidth - PrevWidth - NextWidth - OffsetSize * 4 - (OldStyle ? SetWidth + OffsetSize : 0);
if ( !OldStyle )
AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, EntryGumpID );
@@ -169,7 +164,7 @@ namespace Server.Gumps
x += emptyWidth + OffsetSize;
if ( OldStyle )
- AddImageTiled( x, y, TotalWidth - (OffsetSize * 3) - SetWidth, EntryHeight, HeaderGumpID );
+ AddImageTiled( x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID );
else
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
diff --git a/Projects/Scripts/Gumps/YoungGumps.cs b/Projects/Scripts/Gumps/YoungGumps.cs
index fc0a31cc7..f94a949dc 100644
--- a/Projects/Scripts/Gumps/YoungGumps.cs
+++ b/Projects/Scripts/Gumps/YoungGumps.cs
@@ -79,10 +79,7 @@ namespace Server.Gumps
if ( info.ButtonID == 1 )
{
- if ( from.Account is Account acc )
- {
- acc.RemoveYoungStatus( 502085 ); // You have chosen to renounce your `Young' player status.
- }
+ if ( from.Account is Account acc ) acc.RemoveYoungStatus( 502085 ); // You have chosen to renounce your `Young' player status.
}
else
{
diff --git a/Projects/Scripts/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs b/Projects/Scripts/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs
index 7f6be722c..92c816247 100644
--- a/Projects/Scripts/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs
+++ b/Projects/Scripts/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs
@@ -46,7 +46,7 @@ namespace Server.Items
public bool CouldFit(IPoint3D p, Map map)
{
- if (map == null || !map.CanFit(p.X, p.Y, p.Z, ItemData.Height))
+ if (map?.CanFit(p.X, p.Y, p.Z, ItemData.Height) != true)
return false;
if (FacingSouth)
diff --git a/Projects/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs b/Projects/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs
index b0cdb8ed4..e93873910 100644
--- a/Projects/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs
+++ b/Projects/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs
@@ -301,13 +301,13 @@ namespace Server.Engines.Events
public static Point3D RandomMoongate(Mobile target)
{
- switch (target.Map.MapID)
+ return target.Map.MapID switch
{
- case 2: return Ilshenar_Locations[Utility.Random(Ilshenar_Locations.Length)];
- case 3: return Malas_Locations[Utility.Random(Malas_Locations.Length)];
- case 4: return Tokuno_Locations[Utility.Random(Tokuno_Locations.Length)];
- default: return Felucca_Locations[Utility.Random(Felucca_Locations.Length)];
- }
+ 2 => Ilshenar_Locations[Utility.Random(Ilshenar_Locations.Length)],
+ 3 => Malas_Locations[Utility.Random(Malas_Locations.Length)],
+ 4 => Tokuno_Locations[Utility.Random(Tokuno_Locations.Length)],
+ _ => Felucca_Locations[Utility.Random(Felucca_Locations.Length)]
+ };
}
public override void Serialize(GenericWriter writer)
diff --git a/Projects/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs b/Projects/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs
index bcd51cb10..699edc9e9 100644
--- a/Projects/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs
+++ b/Projects/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs
@@ -76,10 +76,7 @@ namespace Server.Engines.Events
m_DeathQueue.Clear();
- if ( DateTime.UtcNow <= HolidaySettings.FinishHalloween )
- {
- m_ClearTimer.Stop();
- }
+ if ( DateTime.UtcNow <= HolidaySettings.FinishHalloween ) m_ClearTimer.Stop();
}
private static void Timer_Callback()
@@ -89,20 +86,18 @@ namespace Server.Engines.Events
if ( DateTime.UtcNow <= HolidaySettings.FinishHalloween )
{
for( int index = 0; m_DeathQueue.Count > 0 && index < m_DeathQueue.Count; index++ )
- {
if ( !ReAnimated.ContainsKey( m_DeathQueue[ index ] ) )
{
player = m_DeathQueue[ index ];
break;
}
- }
if (player?.Deleted == false && ReAnimated.Count < m_TotalZombieLimit )
{
Map map = Utility.RandomBool() ? Map.Trammel : Map.Felucca;
- Point3D home = ( GetRandomPointInRect( m_Cemetaries[ Utility.Random( m_Cemetaries.Length ) ], map ));
+ Point3D home = GetRandomPointInRect( m_Cemetaries[ Utility.Random( m_Cemetaries.Length ) ], map );
if ( map.CanSpawnMobile( home ) )
{
@@ -141,13 +136,13 @@ namespace Server.Engines.Events
{
Name = $"{name}'s bones";
- switch( Utility.Random( 10 ) )
+ Hue = Utility.Random(10) switch
{
- case 0: Hue = 0xa09; break;
- case 1: Hue = 0xa93; break;
- case 2: Hue = 0xa47; break;
- default: break;
- }
+ 0 => 0xa09,
+ 1 => 0xa93,
+ 2 => 0xa47,
+ _ => Hue
+ };
}
public PlayerBones( Serial serial )
@@ -223,8 +218,8 @@ namespace Server.Engines.Events
case 2: PackItem( new Torso() ); break;
case 3: PackItem( new Bone() ); break;
case 4: PackItem( new RibCage() ); break;
- case 5: if (m_DeadPlayer?.Deleted == false) { PackItem( new PlayerBones( m_DeadPlayer.Name ) ); } break;
- default: break;
+ case 5: if (m_DeadPlayer?.Deleted == false) PackItem( new PlayerBones( m_DeadPlayer.Name ) );
+ break;
}
AddLoot( LootPack.Meager );
@@ -242,13 +237,9 @@ namespace Server.Engines.Events
public override void OnDelete()
{
if ( HalloweenHauntings.ReAnimated != null )
- {
if (m_DeadPlayer?.Deleted == false)
- {
if ( HalloweenHauntings.ReAnimated.ContainsKey( m_DeadPlayer ) )
HalloweenHauntings.ReAnimated.Remove( m_DeadPlayer );
- }
- }
}
public override void Serialize( GenericWriter writer )
diff --git a/Projects/Scripts/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs b/Projects/Scripts/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs
index 124e0cc1b..695de338a 100644
--- a/Projects/Scripts/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs
+++ b/Projects/Scripts/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs
@@ -26,7 +26,7 @@ namespace Server.Items
set { m_To = value; InvalidateProperties(); }
}
- public bool IsSigned => ( m_From != null && m_To != null );
+ public bool IsSigned => m_From != null && m_To != null;
[Constructible]
public CupidsArrow()
diff --git a/Projects/Scripts/Items/Addons/ArcheryButteAddon.cs b/Projects/Scripts/Items/Addons/ArcheryButteAddon.cs
index 5e32e5fa9..1727f1873 100644
--- a/Projects/Scripts/Items/Addons/ArcheryButteAddon.cs
+++ b/Projects/Scripts/Items/Addons/ArcheryButteAddon.cs
@@ -76,10 +76,6 @@ namespace Server.Items
Total += score;
Count += 1;
}
-
- public ScoreEntry()
- {
- }
}
private Dictionary m_Entries;
@@ -103,7 +99,7 @@ namespace Server.Items
return;
}
- if ( DateTime.UtcNow < (LastUse + UseDelay) )
+ if ( DateTime.UtcNow < LastUse + UseDelay )
return;
Point3D worldLoc = GetWorldLocation();
@@ -206,7 +202,7 @@ namespace Server.Items
splitScore = 5;
}
- bool split = ( isKnown && ((Arrows + Bolts) * 0.02) > Utility.RandomDouble() );
+ bool split = isKnown && (Arrows + Bolts) * 0.02 > Utility.RandomDouble();
if ( split )
{
diff --git a/Projects/Scripts/Items/Addons/BaseAddonContainerDeed.cs b/Projects/Scripts/Items/Addons/BaseAddonContainerDeed.cs
index 2247376b0..56819d015 100644
--- a/Projects/Scripts/Items/Addons/BaseAddonContainerDeed.cs
+++ b/Projects/Scripts/Items/Addons/BaseAddonContainerDeed.cs
@@ -79,12 +79,11 @@ namespace Server.Items
int version = reader.ReadInt();
- switch (version)
+ m_Resource = version switch
{
- case 1:
- m_Resource = (CraftResource)reader.ReadInt();
- break;
- }
+ 1 => (CraftResource)reader.ReadInt(),
+ _ => m_Resource
+ };
}
public override void OnDoubleClick(Mobile from)
diff --git a/Projects/Scripts/Items/Addons/SHTeleporter.cs b/Projects/Scripts/Items/Addons/SHTeleporter.cs
index 73210e1bb..04b3be296 100644
--- a/Projects/Scripts/Items/Addons/SHTeleporter.cs
+++ b/Projects/Scripts/Items/Addons/SHTeleporter.cs
@@ -1,6 +1,5 @@
using System;
using System.Linq;
-using Server.Commands;
using Server.Mobiles;
namespace Server.Items
diff --git a/Projects/Scripts/Items/Aquarium/Aquarium.cs b/Projects/Scripts/Items/Aquarium/Aquarium.cs
index 5caec12ea..c7247e0da 100644
--- a/Projects/Scripts/Items/Aquarium/Aquarium.cs
+++ b/Projects/Scripts/Items/Aquarium/Aquarium.cs
@@ -316,8 +316,8 @@ namespace Server.Items
if (decorations > 0)
LabelTo(from, 1074249, (Items.Count - LiveCreatures - DeadCreatures).ToString()); // Decorations: ~1_NUM~
- LabelTo(from, 1074250, "#" + FoodNumber()); // Food state: ~1_STATE~
- LabelTo(from, 1074251, "#" + WaterNumber()); // Water state: ~1_STATE~
+ LabelTo(from, 1074250, $"#{FoodNumber()}"); // Food state: ~1_STATE~
+ LabelTo(from, 1074251, $"#{WaterNumber()}"); // Water state: ~1_STATE~
if (m_Food.State == (int)FoodState.Dead)
LabelTo(from, 1074577, $"{m_Food.Added}\t{m_Food.Improve}"); // Food Added: ~1_CUR~ Needed: ~2_NEED~
diff --git a/Projects/Scripts/Items/Aquarium/AquariumFishingNet.cs b/Projects/Scripts/Items/Aquarium/AquariumFishingNet.cs
index c617d1507..0bcf7f6eb 100644
--- a/Projects/Scripts/Items/Aquarium/AquariumFishingNet.cs
+++ b/Projects/Scripts/Items/Aquarium/AquariumFishingNet.cs
@@ -82,29 +82,29 @@ namespace Server.Items
if (max > 20)
max = 20;
- switch (Utility.Random(max))
+ return Utility.Random(max) switch
{
- case 0: return new MinocBlueFish();
- case 1: return new Shrimp();
- case 2: return new FandancerFish();
- case 3: return new GoldenBroadtail();
- case 4: return new RedDartFish();
- case 5: return new AlbinoCourtesanFish();
- case 6: return new MakotoCourtesanFish();
- case 7: return new NujelmHoneyFish();
- case 8: return new Jellyfish();
- case 9: return new SpeckledCrab();
- case 10: return new LongClawCrab();
- case 11: return new AlbinoFrog();
- case 12: return new KillerFrog();
- case 13: return new VesperReefTiger();
- case 14: return new PurpleFrog();
- case 15: return new BritainCrownFish();
- case 16: return new YellowFinBluebelly();
- case 17: return new SpottedBuccaneer();
- case 18: return new SpinedScratcherFish();
- default: return new SmallMouthSuckerFin();
- }
+ 0 => (BaseFish)new MinocBlueFish(),
+ 1 => new Shrimp(),
+ 2 => new FandancerFish(),
+ 3 => new GoldenBroadtail(),
+ 4 => new RedDartFish(),
+ 5 => new AlbinoCourtesanFish(),
+ 6 => new MakotoCourtesanFish(),
+ 7 => new NujelmHoneyFish(),
+ 8 => new Jellyfish(),
+ 9 => new SpeckledCrab(),
+ 10 => new LongClawCrab(),
+ 11 => new AlbinoFrog(),
+ 12 => new KillerFrog(),
+ 13 => new VesperReefTiger(),
+ 14 => new PurpleFrog(),
+ 15 => new BritainCrownFish(),
+ 16 => new YellowFinBluebelly(),
+ 17 => new SpottedBuccaneer(),
+ 18 => new SpinedScratcherFish(),
+ _ => new SmallMouthSuckerFin()
+ };
}
return new MinocBlueFish();
diff --git a/Projects/Scripts/Items/Armor/BaseArmor.cs b/Projects/Scripts/Items/Armor/BaseArmor.cs
index fcdfa6688..59fd460df 100644
--- a/Projects/Scripts/Items/Armor/BaseArmor.cs
+++ b/Projects/Scripts/Items/Armor/BaseArmor.cs
@@ -440,23 +440,21 @@ namespace Server.Items
{
get
{
- switch (Layer)
+ return Layer switch
{
- default:
- case Layer.Neck: return ArmorBodyType.Gorget;
- case Layer.TwoHanded: return ArmorBodyType.Shield;
- case Layer.Gloves: return ArmorBodyType.Gloves;
- case Layer.Helm: return ArmorBodyType.Helmet;
- case Layer.Arms: return ArmorBodyType.Arms;
-
- case Layer.InnerLegs:
- case Layer.OuterLegs:
- case Layer.Pants: return ArmorBodyType.Legs;
-
- case Layer.InnerTorso:
- case Layer.OuterTorso:
- case Layer.Shirt: return ArmorBodyType.Chest;
- }
+ Layer.Neck => ArmorBodyType.Gorget,
+ Layer.TwoHanded => ArmorBodyType.Shield,
+ Layer.Gloves => ArmorBodyType.Gloves,
+ Layer.Helm => ArmorBodyType.Helmet,
+ Layer.Arms => ArmorBodyType.Arms,
+ Layer.InnerLegs => ArmorBodyType.Legs,
+ Layer.OuterLegs => ArmorBodyType.Legs,
+ Layer.Pants => ArmorBodyType.Legs,
+ Layer.InnerTorso => ArmorBodyType.Chest,
+ Layer.OuterTorso => ArmorBodyType.Chest,
+ Layer.Shirt => ArmorBodyType.Chest,
+ _ => ArmorBodyType.Gorget
+ };
}
}
@@ -765,15 +763,14 @@ namespace Server.Items
public int GetProtOffset()
{
- switch (m_Protection)
+ return m_Protection switch
{
- case ArmorProtectionLevel.Guarding: return 1;
- case ArmorProtectionLevel.Hardening: return 2;
- case ArmorProtectionLevel.Fortification: return 3;
- case ArmorProtectionLevel.Invulnerability: return 4;
- }
-
- return 0;
+ ArmorProtectionLevel.Guarding => 1,
+ ArmorProtectionLevel.Hardening => 2,
+ ArmorProtectionLevel.Fortification => 3,
+ ArmorProtectionLevel.Invulnerability => 4,
+ _ => 0
+ };
}
public int GetDurabilityBonus()
@@ -1206,39 +1203,19 @@ namespace Server.Items
}
else
{
- OreInfo info;
-
- switch (reader.ReadInt())
+ var info = reader.ReadInt() switch
{
- default:
- case 0:
- info = OreInfo.Iron;
- break;
- case 1:
- info = OreInfo.DullCopper;
- break;
- case 2:
- info = OreInfo.ShadowIron;
- break;
- case 3:
- info = OreInfo.Copper;
- break;
- case 4:
- info = OreInfo.Bronze;
- break;
- case 5:
- info = OreInfo.Gold;
- break;
- case 6:
- info = OreInfo.Agapite;
- break;
- case 7:
- info = OreInfo.Verite;
- break;
- case 8:
- info = OreInfo.Valorite;
- break;
- }
+ 0 => OreInfo.Iron,
+ 1 => OreInfo.DullCopper,
+ 2 => OreInfo.ShadowIron,
+ 3 => OreInfo.Copper,
+ 4 => OreInfo.Bronze,
+ 5 => OreInfo.Gold,
+ 6 => OreInfo.Agapite,
+ 7 => OreInfo.Verite,
+ 8 => OreInfo.Valorite,
+ _ => OreInfo.Iron
+ };
m_Resource = CraftResources.GetFromOreInfo(info, mat);
}
@@ -1311,13 +1288,13 @@ namespace Server.Items
string modName = Serial.ToString();
if (strBonus != 0)
- m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero));
+ m.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero));
if (dexBonus != 0)
- m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero));
+ m.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero));
if (intBonus != 0)
- m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero));
+ m.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero));
}
m?.CheckStatTimers();
@@ -1424,13 +1401,13 @@ namespace Server.Items
string modName = Serial.ToString();
if (strBonus != 0)
- from.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero));
+ from.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero));
if (dexBonus != 0)
- from.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero));
+ from.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero));
if (intBonus != 0)
- from.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero));
+ from.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero));
}
return base.OnEquip(from);
@@ -1442,9 +1419,9 @@ namespace Server.Items
{
string modName = Serial.ToString();
- m.RemoveStatMod(modName + "Str");
- m.RemoveStatMod(modName + "Dex");
- m.RemoveStatMod(modName + "Int");
+ m.RemoveStatMod($"{modName}Str");
+ m.RemoveStatMod($"{modName}Dex");
+ m.RemoveStatMod($"{modName}Int");
if (Core.AOS)
SkillBonuses.Remove();
@@ -1460,65 +1437,27 @@ namespace Server.Items
public override void AddNameProperty(ObjectPropertyList list)
{
- int oreType;
-
- switch (m_Resource)
+ var oreType = m_Resource switch
{
- case CraftResource.DullCopper:
- oreType = 1053108;
- break; // dull copper
- case CraftResource.ShadowIron:
- oreType = 1053107;
- break; // shadow iron
- case CraftResource.Copper:
- oreType = 1053106;
- break; // copper
- case CraftResource.Bronze:
- oreType = 1053105;
- break; // bronze
- case CraftResource.Gold:
- oreType = 1053104;
- break; // golden
- case CraftResource.Agapite:
- oreType = 1053103;
- break; // agapite
- case CraftResource.Verite:
- oreType = 1053102;
- break; // verite
- case CraftResource.Valorite:
- oreType = 1053101;
- break; // valorite
- case CraftResource.SpinedLeather:
- oreType = 1061118;
- break; // spined
- case CraftResource.HornedLeather:
- oreType = 1061117;
- break; // horned
- case CraftResource.BarbedLeather:
- oreType = 1061116;
- break; // barbed
- case CraftResource.RedScales:
- oreType = 1060814;
- break; // red
- case CraftResource.YellowScales:
- oreType = 1060818;
- break; // yellow
- case CraftResource.BlackScales:
- oreType = 1060820;
- break; // black
- case CraftResource.GreenScales:
- oreType = 1060819;
- break; // green
- case CraftResource.WhiteScales:
- oreType = 1060821;
- break; // white
- case CraftResource.BlueScales:
- oreType = 1060815;
- break; // blue
- default:
- oreType = 0;
- break;
- }
+ CraftResource.DullCopper => 1053108,
+ CraftResource.ShadowIron => 1053107,
+ CraftResource.Copper => 1053106,
+ CraftResource.Bronze => 1053105,
+ CraftResource.Gold => 1053104,
+ CraftResource.Agapite => 1053103,
+ CraftResource.Verite => 1053102,
+ CraftResource.Valorite => 1053101,
+ CraftResource.SpinedLeather => 1061118,
+ CraftResource.HornedLeather => 1061117,
+ CraftResource.BarbedLeather => 1061116,
+ CraftResource.RedScales => 1060814,
+ CraftResource.YellowScales => 1060818,
+ CraftResource.BlackScales => 1060820,
+ CraftResource.GreenScales => 1060819,
+ CraftResource.WhiteScales => 1060821,
+ CraftResource.BlueScales => 1060815,
+ _ => 0
+ };
if (m_Quality == ArmorQuality.Exceptional)
{
@@ -1621,7 +1560,7 @@ namespace Server.Items
if ((prop = GetLuckBonus() + Attributes.Luck) != 0)
list.Add(1060436, prop.ToString()); // luck ~1_val~
- if ((prop = ArmorAttributes.MageArmor) != 0)
+ if (ArmorAttributes.MageArmor != 0)
list.Add(1060437); // mage armor
if ((prop = Attributes.BonusMana) != 0)
@@ -1630,7 +1569,7 @@ namespace Server.Items
if ((prop = Attributes.RegenMana) != 0)
list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~
- if ((prop = Attributes.NightSight) != 0)
+ if (Attributes.NightSight != 0)
list.Add(1060441); // night sight
if ((prop = Attributes.ReflectPhysical) != 0)
@@ -1645,7 +1584,7 @@ namespace Server.Items
if ((prop = ArmorAttributes.SelfRepair) != 0)
list.Add(1060450, prop.ToString()); // self repair ~1_val~
- if ((prop = Attributes.SpellChanneling) != 0)
+ if (Attributes.SpellChanneling != 0)
list.Add(1060482); // spell channeling
if ((prop = Attributes.SpellDamage) != 0)
diff --git a/Projects/Scripts/Items/Body Parts/Head.cs b/Projects/Scripts/Items/Body Parts/Head.cs
index 4179a929e..96086f183 100644
--- a/Projects/Scripts/Items/Body Parts/Head.cs
+++ b/Projects/Scripts/Items/Body Parts/Head.cs
@@ -40,17 +40,12 @@ namespace Server.Items
if (PlayerName == null)
return base.DefaultName;
- switch (HeadType)
+ return HeadType switch
{
- default:
- return $"the head of {PlayerName}";
-
- case HeadType.Duel:
- return $"the head of {PlayerName}, taken in a duel";
-
- case HeadType.Tournament:
- return $"the head of {PlayerName}, taken in a tournament";
- }
+ HeadType.Duel => $"the head of {PlayerName}, taken in a duel",
+ HeadType.Tournament => $"the head of {PlayerName}, taken in a tournament",
+ _ => $"the head of {PlayerName}"
+ };
}
}
diff --git a/Projects/Scripts/Items/Books/BaseBook.cs b/Projects/Scripts/Items/Books/BaseBook.cs
index 010e314f4..754cabba2 100644
--- a/Projects/Scripts/Items/Books/BaseBook.cs
+++ b/Projects/Scripts/Items/Books/BaseBook.cs
@@ -165,7 +165,7 @@ namespace Server.Items
if (Writable)
flags |= SaveFlags.Writable;
- if (content == null || !content.IsMatch(Pages))
+ if (content?.IsMatch(Pages) != true)
flags |= SaveFlags.Content;
diff --git a/Projects/Scripts/Items/Champion Artifacts/Decorative/Futon.cs b/Projects/Scripts/Items/Champion Artifacts/Decorative/Futon.cs
index 538095e6f..62096fea8 100644
--- a/Projects/Scripts/Items/Champion Artifacts/Decorative/Futon.cs
+++ b/Projects/Scripts/Items/Champion Artifacts/Decorative/Futon.cs
@@ -14,22 +14,14 @@ namespace Server.Items
public void Flip()
{
- switch (ItemID)
+ ItemID = ItemID switch
{
- case 0x295C:
- ItemID = 0x295D;
- break;
- case 0x295E:
- ItemID = 0x295F;
- break;
-
- case 0x295D:
- ItemID = 0x295C;
- break;
- case 0x295F:
- ItemID = 0x295E;
- break;
- }
+ 0x295C => 0x295D,
+ 0x295E => 0x295F,
+ 0x295D => 0x295C,
+ 0x295F => 0x295E,
+ _ => ItemID
+ };
}
public override void Serialize(GenericWriter writer)
diff --git a/Projects/Scripts/Items/Clothing/BaseClothing.cs b/Projects/Scripts/Items/Clothing/BaseClothing.cs
index 2ff921345..06ee87907 100644
--- a/Projects/Scripts/Items/Clothing/BaseClothing.cs
+++ b/Projects/Scripts/Items/Clothing/BaseClothing.cs
@@ -436,13 +436,13 @@ namespace Server.Items
string modName = Serial.ToString();
if (strBonus != 0)
- parent.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero));
+ parent.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero));
if (dexBonus != 0)
- parent.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero));
+ parent.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero));
if (intBonus != 0)
- parent.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero));
+ parent.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero));
}
public static void ValidateMobile(Mobile m)
@@ -518,9 +518,9 @@ namespace Server.Items
string modName = Serial.ToString();
- mob.RemoveStatMod(modName + "Str");
- mob.RemoveStatMod(modName + "Dex");
- mob.RemoveStatMod(modName + "Int");
+ mob.RemoveStatMod($"{modName}Str");
+ mob.RemoveStatMod($"{modName}Dex");
+ mob.RemoveStatMod($"{modName}Int");
mob.CheckStatTimers();
}
@@ -565,65 +565,27 @@ namespace Server.Items
public override void AddNameProperty(ObjectPropertyList list)
{
- int oreType;
-
- switch (m_Resource)
+ var oreType = m_Resource switch
{
- case CraftResource.DullCopper:
- oreType = 1053108;
- break; // dull copper
- case CraftResource.ShadowIron:
- oreType = 1053107;
- break; // shadow iron
- case CraftResource.Copper:
- oreType = 1053106;
- break; // copper
- case CraftResource.Bronze:
- oreType = 1053105;
- break; // bronze
- case CraftResource.Gold:
- oreType = 1053104;
- break; // golden
- case CraftResource.Agapite:
- oreType = 1053103;
- break; // agapite
- case CraftResource.Verite:
- oreType = 1053102;
- break; // verite
- case CraftResource.Valorite:
- oreType = 1053101;
- break; // valorite
- case CraftResource.SpinedLeather:
- oreType = 1061118;
- break; // spined
- case CraftResource.HornedLeather:
- oreType = 1061117;
- break; // horned
- case CraftResource.BarbedLeather:
- oreType = 1061116;
- break; // barbed
- case CraftResource.RedScales:
- oreType = 1060814;
- break; // red
- case CraftResource.YellowScales:
- oreType = 1060818;
- break; // yellow
- case CraftResource.BlackScales:
- oreType = 1060820;
- break; // black
- case CraftResource.GreenScales:
- oreType = 1060819;
- break; // green
- case CraftResource.WhiteScales:
- oreType = 1060821;
- break; // white
- case CraftResource.BlueScales:
- oreType = 1060815;
- break; // blue
- default:
- oreType = 0;
- break;
- }
+ CraftResource.DullCopper => 1053108,
+ CraftResource.ShadowIron => 1053107,
+ CraftResource.Copper => 1053106,
+ CraftResource.Bronze => 1053105,
+ CraftResource.Gold => 1053104,
+ CraftResource.Agapite => 1053103,
+ CraftResource.Verite => 1053102,
+ CraftResource.Valorite => 1053101,
+ CraftResource.SpinedLeather => 1061118,
+ CraftResource.HornedLeather => 1061117,
+ CraftResource.BarbedLeather => 1061116,
+ CraftResource.RedScales => 1060814,
+ CraftResource.YellowScales => 1060818,
+ CraftResource.BlackScales => 1060820,
+ CraftResource.GreenScales => 1060819,
+ CraftResource.WhiteScales => 1060821,
+ CraftResource.BlueScales => 1060815,
+ _ => 0
+ };
if (oreType != 0)
list.Add(1053099, "#{0}\t{1}", oreType, GetNameString()); // ~1_oretype~ ~2_armortype~
diff --git a/Projects/Scripts/Items/Construction/Ankhs.cs b/Projects/Scripts/Items/Construction/Ankhs.cs
index 850bd4c10..261b2d091 100644
--- a/Projects/Scripts/Items/Construction/Ankhs.cs
+++ b/Projects/Scripts/Items/Construction/Ankhs.cs
@@ -31,7 +31,7 @@ namespace Server.Items
{
m.SendLocalizedMessage(500446); // That is too far away.
}
- else if (m.Map != null && m.Map.CanFit(m.Location, 16, false, false))
+ else if (m.Map?.CanFit(m.Location, 16, false, false) == true)
{
m.CloseGump();
m.SendGump(new ResurrectGump(m, ResurrectMessage.VirtueShrine));
diff --git a/Projects/Scripts/Items/Construction/Doors/BaseDoor.cs b/Projects/Scripts/Items/Construction/Doors/BaseDoor.cs
index 00e5889d3..c4a7cf322 100644
--- a/Projects/Scripts/Items/Construction/Doors/BaseDoor.cs
+++ b/Projects/Scripts/Items/Construction/Doors/BaseDoor.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using Server.Commands;
using Server.Network;
using Server.Targeting;
diff --git a/Projects/Scripts/Items/Containers/BaseTreasureChest.cs b/Projects/Scripts/Items/Containers/BaseTreasureChest.cs
index d907bf111..6a717c220 100644
--- a/Projects/Scripts/Items/Containers/BaseTreasureChest.cs
+++ b/Projects/Scripts/Items/Containers/BaseTreasureChest.cs
@@ -95,32 +95,16 @@ namespace Server.Items
protected virtual void SetLockLevel()
{
- switch (Level)
+ RequiredSkill = Level switch
{
- case TreasureLevel.Level1:
- RequiredSkill = LockLevel = 5;
- break;
-
- case TreasureLevel.Level2:
- RequiredSkill = LockLevel = 20;
- break;
-
- case TreasureLevel.Level3:
- RequiredSkill = LockLevel = 50;
- break;
-
- case TreasureLevel.Level4:
- RequiredSkill = LockLevel = 70;
- break;
-
- case TreasureLevel.Level5:
- RequiredSkill = LockLevel = 90;
- break;
-
- case TreasureLevel.Level6:
- RequiredSkill = LockLevel = 100;
- break;
- }
+ TreasureLevel.Level1 => (LockLevel = 5),
+ TreasureLevel.Level2 => (LockLevel = 20),
+ TreasureLevel.Level3 => (LockLevel = 50),
+ TreasureLevel.Level4 => (LockLevel = 70),
+ TreasureLevel.Level5 => (LockLevel = 90),
+ TreasureLevel.Level6 => (LockLevel = 100),
+ _ => RequiredSkill
+ };
}
private void StartResetTimer()
diff --git a/Projects/Scripts/Items/Containers/FurnitureContainer.cs b/Projects/Scripts/Items/Containers/FurnitureContainer.cs
index 19cf6d72c..c850807d8 100644
--- a/Projects/Scripts/Items/Containers/FurnitureContainer.cs
+++ b/Projects/Scripts/Items/Containers/FurnitureContainer.cs
@@ -335,21 +335,14 @@ namespace Server.Items
t.Start();
m_Table[c] = t;
- switch (c.ItemID)
+ c.ItemID = c.ItemID switch
{
- case 0xA4D:
- c.ItemID = 0xA4C;
- break;
- case 0xA4F:
- c.ItemID = 0xA4E;
- break;
- case 0xA51:
- c.ItemID = 0xA50;
- break;
- case 0xA53:
- c.ItemID = 0xA52;
- break;
- }
+ 0xA4D => 0xA4C,
+ 0xA4F => 0xA4E,
+ 0xA51 => 0xA50,
+ 0xA53 => 0xA52,
+ _ => c.ItemID
+ };
}
return true;
@@ -364,21 +357,14 @@ namespace Server.Items
}
if (c is Armoire || c is FancyArmoire)
- switch (c.ItemID)
+ c.ItemID = c.ItemID switch
{
- case 0xA4C:
- c.ItemID = 0xA4D;
- break;
- case 0xA4E:
- c.ItemID = 0xA4F;
- break;
- case 0xA50:
- c.ItemID = 0xA51;
- break;
- case 0xA52:
- c.ItemID = 0xA53;
- break;
- }
+ 0xA4C => 0xA4D,
+ 0xA4E => 0xA4F,
+ 0xA50 => 0xA51,
+ 0xA52 => 0xA53,
+ _ => c.ItemID
+ };
}
}
diff --git a/Projects/Scripts/Items/Containers/MarkContainer.cs b/Projects/Scripts/Items/Containers/MarkContainer.cs
index 2f6185e85..f5fbe2a94 100644
--- a/Projects/Scripts/Items/Containers/MarkContainer.cs
+++ b/Projects/Scripts/Items/Containers/MarkContainer.cs
@@ -1,6 +1,5 @@
using System;
using System.Linq;
-using Server.Commands;
namespace Server.Items
{
@@ -115,7 +114,7 @@ namespace Server.Items
}
private static void CreateMalasPassage(int x, int y, int z, int xTarget, int yTarget, int zTarget, bool bone,
-bool locked)
+ bool locked)
{
Point3D location = new Point3D(x, y, z);
diff --git a/Projects/Scripts/Items/Containers/ParagonChest.cs b/Projects/Scripts/Items/Containers/ParagonChest.cs
index cdc00abb7..39f8ac0f3 100644
--- a/Projects/Scripts/Items/Containers/ParagonChest.cs
+++ b/Projects/Scripts/Items/Containers/ParagonChest.cs
@@ -79,22 +79,14 @@ namespace Server.Items
public void Flip()
{
- switch (ItemID)
+ ItemID = ItemID switch
{
- case 0x9AB:
- ItemID = 0xE7C;
- break;
- case 0xE7C:
- ItemID = 0x9AB;
- break;
-
- case 0xE40:
- ItemID = 0xE41;
- break;
- case 0xE41:
- ItemID = 0xE40;
- break;
- }
+ 0x9AB => 0xE7C,
+ 0xE7C => 0x9AB,
+ 0xE40 => 0xE41,
+ 0xE41 => 0xE40,
+ _ => ItemID
+ };
}
private void Fill(int level)
@@ -104,24 +96,15 @@ namespace Server.Items
TrapLevel = level;
Locked = true;
- switch (level)
+ RequiredSkill = level switch
{
- case 1:
- RequiredSkill = 36;
- break;
- case 2:
- RequiredSkill = 76;
- break;
- case 3:
- RequiredSkill = 84;
- break;
- case 4:
- RequiredSkill = 92;
- break;
- case 5:
- RequiredSkill = 100;
- break;
- }
+ 1 => 36,
+ 2 => 76,
+ 3 => 84,
+ 4 => 92,
+ 5 => 100,
+ _ => RequiredSkill
+ };
LockLevel = RequiredSkill - 10;
MaxLockLevel = RequiredSkill + 40;
diff --git a/Projects/Scripts/Items/Containers/SalvageBag.cs b/Projects/Scripts/Items/Containers/SalvageBag.cs
index aea19b987..cea584359 100644
--- a/Projects/Scripts/Items/Containers/SalvageBag.cs
+++ b/Projects/Scripts/Items/Containers/SalvageBag.cs
@@ -63,35 +63,18 @@ namespace Server.Items
if (craftResource.Amount < 2)
return false; // Not enough metal to resmelt
- double difficulty = 0.0;
-
- switch (resource)
+ var difficulty = resource switch
{
- case CraftResource.DullCopper:
- difficulty = 65.0;
- break;
- case CraftResource.ShadowIron:
- difficulty = 70.0;
- break;
- case CraftResource.Copper:
- difficulty = 75.0;
- break;
- case CraftResource.Bronze:
- difficulty = 80.0;
- break;
- case CraftResource.Gold:
- difficulty = 85.0;
- break;
- case CraftResource.Agapite:
- difficulty = 90.0;
- break;
- case CraftResource.Verite:
- difficulty = 95.0;
- break;
- case CraftResource.Valorite:
- difficulty = 99.0;
- break;
- }
+ CraftResource.DullCopper => 65.0,
+ CraftResource.ShadowIron => 70.0,
+ CraftResource.Copper => 75.0,
+ CraftResource.Bronze => 80.0,
+ CraftResource.Gold => 85.0,
+ CraftResource.Agapite => 90.0,
+ CraftResource.Verite => 95.0,
+ CraftResource.Valorite => 99.0,
+ _ => 0.0
+ };
Type resourceType = info.ResourceTypes[0];
Item ingot = (Item)Activator.CreateInstance(resourceType);
@@ -224,7 +207,7 @@ namespace Server.Items
private void SalvageCloth(Mobile from)
{
Scissors scissors = from.Backpack.FindItemByType();
-
+
if (scissors == null)
{
from.SendLocalizedMessage(1079823); // You need scissors in order to salvage cloth.
@@ -253,16 +236,13 @@ namespace Server.Items
from.SendLocalizedMessage(1079974,
$"{salvaged}\t{salvaged + notSalvaged}"); // Salvaged: ~1_COUNT~/~2_NUM~ tailored items
-
+
Item[] items = FindItemsByType(new[]{
typeof(Leather), typeof(Cloth), typeof(SpinedLeather), typeof(HornedLeather), typeof(BarbedLeather),
typeof(Bandage), typeof(Bone)
});
- for (int i = 0; i < items.Length; i++)
- {
- from.AddToBackpack(items[i]);
- }
+ for (int i = 0; i < items.Length; i++) from.AddToBackpack(items[i]);
}
private void SalvageAll(Mobile from)
@@ -376,4 +356,4 @@ namespace Server.Items
#endregion
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Items/Containers/TreasureMapChest.cs b/Projects/Scripts/Items/Containers/TreasureMapChest.cs
index ed88814a9..a0ccfcde4 100644
--- a/Projects/Scripts/Items/Containers/TreasureMapChest.cs
+++ b/Projects/Scripts/Items/Containers/TreasureMapChest.cs
@@ -159,27 +159,16 @@ namespace Server.Items
cont.TrapPower = level * 25;
cont.TrapLevel = level;
- switch (level)
+ cont.RequiredSkill = level switch
{
- case 1:
- cont.RequiredSkill = 36;
- break;
- case 2:
- cont.RequiredSkill = 76;
- break;
- case 3:
- cont.RequiredSkill = 84;
- break;
- case 4:
- cont.RequiredSkill = 92;
- break;
- case 5:
- cont.RequiredSkill = 100;
- break;
- case 6:
- cont.RequiredSkill = 100;
- break;
- }
+ 1 => 36,
+ 2 => 76,
+ 3 => 84,
+ 4 => 92,
+ 5 => 100,
+ 6 => 100,
+ _ => cont.RequiredSkill
+ };
cont.LockLevel = cont.RequiredSkill - 10;
cont.MaxLockLevel = cont.RequiredSkill + 40;
@@ -195,32 +184,16 @@ namespace Server.Items
if (Core.SE)
{
- switch (level)
+ numberItems = level switch
{
- case 1:
- numberItems = 5;
- break;
- case 2:
- numberItems = 10;
- break;
- case 3:
- numberItems = 15;
- break;
- case 4:
- numberItems = 38;
- break;
- case 5:
- numberItems = 50;
- break;
- case 6:
- numberItems = 60;
- break;
- default:
- numberItems = 0;
- break;
- }
-
- ;
+ 1 => 5,
+ 2 => 10,
+ 3 => 15,
+ 4 => 38,
+ 5 => 50,
+ 6 => 60,
+ _ => 0
+ };
}
else
{
diff --git a/Projects/Scripts/Items/Decoration Artifacts/StealableArtifactsSpawner.cs b/Projects/Scripts/Items/Decoration Artifacts/StealableArtifactsSpawner.cs
index 659928399..016c792ec 100644
--- a/Projects/Scripts/Items/Decoration Artifacts/StealableArtifactsSpawner.cs
+++ b/Projects/Scripts/Items/Decoration Artifacts/StealableArtifactsSpawner.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using Server.Commands;
namespace Server.Items
{
diff --git a/Projects/Scripts/Items/Deeds/BarkeepContract.cs b/Projects/Scripts/Items/Deeds/BarkeepContract.cs
index afd9c239f..ed28041ac 100644
--- a/Projects/Scripts/Items/Deeds/BarkeepContract.cs
+++ b/Projects/Scripts/Items/Deeds/BarkeepContract.cs
@@ -54,7 +54,7 @@ namespace Server.Items
{
BaseHouse house = BaseHouse.FindHouseAt(from);
- if (house == null || !house.IsOwner(from))
+ if (house?.IsOwner(from) != true)
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, false,
"You are not the full owner of this house.");
@@ -90,4 +90,4 @@ namespace Server.Items
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Items/Deeds/HolidayTreeDeed.cs b/Projects/Scripts/Items/Deeds/HolidayTreeDeed.cs
index 2444dd3b4..c56b3b341 100644
--- a/Projects/Scripts/Items/Deeds/HolidayTreeDeed.cs
+++ b/Projects/Scripts/Items/Deeds/HolidayTreeDeed.cs
@@ -63,7 +63,7 @@ namespace Server.Items
BaseHouse house = BaseHouse.FindHouseAt(loc, map, 20);
- if (house == null || !house.IsFriend(from))
+ if (house?.IsFriend(from) != true)
{
from.SendLocalizedMessage(1005701); // The holiday tree can only be placed in your house.
return false;
diff --git a/Projects/Scripts/Items/Deeds/VendorRentalContract.cs b/Projects/Scripts/Items/Deeds/VendorRentalContract.cs
index 03b325947..d01c567a9 100644
--- a/Projects/Scripts/Items/Deeds/VendorRentalContract.cs
+++ b/Projects/Scripts/Items/Deeds/VendorRentalContract.cs
@@ -149,7 +149,7 @@ namespace Server.Items
BaseHouse house = BaseHouse.FindHouseAt(from);
- if (house == null || !house.IsOwner(from))
+ if (house?.IsOwner(from) != true)
{
from.SendLocalizedMessage(
1062333); // You must be standing inside of a house that you own to make use of this contract.
@@ -258,7 +258,7 @@ namespace Server.Items
BaseHouse house = BaseHouse.FindHouseAt(pLocation, map, 0);
- if (house == null || !house.IsOwner(from))
+ if (house?.IsOwner(from) != true)
{
from.SendLocalizedMessage(1062338); // The location being rented out must be inside of your house.
}
@@ -340,4 +340,4 @@ namespace Server.Items
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Items/Farming/FarmableCrop.cs b/Projects/Scripts/Items/Farming/FarmableCrop.cs
index 7e3adb4e0..13a73a60b 100644
--- a/Projects/Scripts/Items/Farming/FarmableCrop.cs
+++ b/Projects/Scripts/Items/Farming/FarmableCrop.cs
@@ -71,12 +71,11 @@ namespace Server.Items
int version = reader.ReadEncodedInt();
- switch (version)
+ m_Picked = version switch
{
- case 0:
- m_Picked = reader.ReadBool();
- break;
- }
+ 0 => reader.ReadBool(),
+ _ => m_Picked
+ };
if (m_Picked)
{
diff --git a/Projects/Scripts/Items/Food/Beverage.cs b/Projects/Scripts/Items/Food/Beverage.cs
index 3e5e9268c..379c0c13e 100644
--- a/Projects/Scripts/Items/Food/Beverage.cs
+++ b/Projects/Scripts/Items/Food/Beverage.cs
@@ -298,17 +298,16 @@ namespace Server.Items
if (IsEmpty)
return ItemID >= 0x1F81 && ItemID <= 0x1F84 ? ItemID : 0x1F81;
- switch (Content)
+ return Content switch
{
- case BeverageType.Ale: return ItemID == 0x9EF ? 0x9EF : 0x9EE;
- case BeverageType.Cider: return ItemID >= 0x1F7D && ItemID <= 0x1F80 ? ItemID : 0x1F7D;
- case BeverageType.Liquor: return ItemID >= 0x1F85 && ItemID <= 0x1F88 ? ItemID : 0x1F85;
- case BeverageType.Milk: return ItemID >= 0x1F89 && ItemID <= 0x1F8C ? ItemID : 0x1F89;
- case BeverageType.Wine: return ItemID >= 0x1F8D && ItemID <= 0x1F90 ? ItemID : 0x1F8D;
- case BeverageType.Water: return ItemID >= 0x1F91 && ItemID <= 0x1F94 ? ItemID : 0x1F91;
- }
-
- return 0;
+ BeverageType.Ale => (ItemID == 0x9EF ? 0x9EF : 0x9EE),
+ BeverageType.Cider => (ItemID >= 0x1F7D && ItemID <= 0x1F80 ? ItemID : 0x1F7D),
+ BeverageType.Liquor => (ItemID >= 0x1F85 && ItemID <= 0x1F88 ? ItemID : 0x1F85),
+ BeverageType.Milk => (ItemID >= 0x1F89 && ItemID <= 0x1F8C ? ItemID : 0x1F89),
+ BeverageType.Wine => (ItemID >= 0x1F8D && ItemID <= 0x1F90 ? ItemID : 0x1F8D),
+ BeverageType.Water => (ItemID >= 0x1F91 && ItemID <= 0x1F94 ? ItemID : 0x1F91),
+ _ => 0
+ };
}
public override void Serialize(GenericWriter writer)
@@ -665,7 +664,7 @@ namespace Server.Items
{
BaseHouse house = BaseHouse.FindHouseAt(this);
- if (house == null || !house.HasLockedDownItem(this))
+ if (house?.HasLockedDownItem(this) != true)
{
if (message)
from.SendLocalizedMessage(502946, "", 0x59); // That belongs to someone else.
@@ -846,23 +845,14 @@ namespace Server.Items
if (ContainsAlchohol)
{
- int bac = 0;
-
- switch (Content)
+ var bac = Content switch
{
- case BeverageType.Ale:
- bac = 1;
- break;
- case BeverageType.Wine:
- bac = 2;
- break;
- case BeverageType.Cider:
- bac = 3;
- break;
- case BeverageType.Liquor:
- bac = 4;
- break;
- }
+ BeverageType.Ale => 1,
+ BeverageType.Wine => 2,
+ BeverageType.Cider => 3,
+ BeverageType.Liquor => 4,
+ _ => 0
+ };
from.BAC += bac;
diff --git a/Projects/Scripts/Items/Food/Cooking.cs b/Projects/Scripts/Items/Food/Cooking.cs
index a3a7136df..ca8a09e2a 100644
--- a/Projects/Scripts/Items/Food/Cooking.cs
+++ b/Projects/Scripts/Items/Food/Cooking.cs
@@ -7,17 +7,12 @@ namespace Server.Items
{
public static int RandomChoice(int itemID1, int itemID2)
{
- int iRet = 0;
- switch (Utility.Random(2))
+ var iRet = Utility.Random(2) switch
{
- default:
- case 0:
- iRet = itemID1;
- break;
- case 1:
- iRet = itemID2;
- break;
- }
+ 0 => itemID1,
+ 1 => itemID2,
+ _ => itemID1
+ };
return iRet;
}
diff --git a/Projects/Scripts/Items/Food/Food.cs b/Projects/Scripts/Items/Food/Food.cs
index cdf5ca6eb..079643b1c 100644
--- a/Projects/Scripts/Items/Food/Food.cs
+++ b/Projects/Scripts/Items/Food/Food.cs
@@ -122,24 +122,15 @@ namespace Server.Items
{
case 1:
{
- switch (reader.ReadInt())
+ Poison = reader.ReadInt() switch
{
- case 0:
- Poison = null;
- break;
- case 1:
- Poison = Poison.Lesser;
- break;
- case 2:
- Poison = Poison.Regular;
- break;
- case 3:
- Poison = Poison.Greater;
- break;
- case 4:
- Poison = Poison.Deadly;
- break;
- }
+ 0 => null,
+ 1 => Poison.Lesser,
+ 2 => Poison.Regular,
+ 3 => Poison.Greater,
+ 4 => Poison.Deadly,
+ _ => Poison
+ };
break;
}
diff --git a/Projects/Scripts/Items/Games/Mahjong/MahjongPacketHandlers.cs b/Projects/Scripts/Items/Games/Mahjong/MahjongPacketHandlers.cs
index f2cf92560..9683f3363 100644
--- a/Projects/Scripts/Items/Games/Mahjong/MahjongPacketHandlers.cs
+++ b/Projects/Scripts/Items/Games/Mahjong/MahjongPacketHandlers.cs
@@ -58,24 +58,24 @@ namespace Server.Engines.Mahjong
private static MahjongPieceDirection GetDirection(int value)
{
- switch (value)
+ return value switch
{
- case 0: return MahjongPieceDirection.Up;
- case 1: return MahjongPieceDirection.Left;
- case 2: return MahjongPieceDirection.Down;
- default: return MahjongPieceDirection.Right;
- }
+ 0 => MahjongPieceDirection.Up,
+ 1 => MahjongPieceDirection.Left,
+ 2 => MahjongPieceDirection.Down,
+ _ => MahjongPieceDirection.Right
+ };
}
private static MahjongWind GetWind(int value)
{
- switch (value)
+ return value switch
{
- case 0: return MahjongWind.North;
- case 1: return MahjongWind.East;
- case 2: return MahjongWind.South;
- default: return MahjongWind.West;
- }
+ 0 => MahjongWind.North,
+ 1 => MahjongWind.East,
+ 2 => MahjongWind.South,
+ _ => MahjongWind.West
+ };
}
public static void ExitGame(MahjongGame game, NetState state, PacketReader pvSrc)
@@ -90,7 +90,7 @@ namespace Server.Engines.Mahjong
public static void GivePoints(MahjongGame game, NetState state, PacketReader pvSrc)
{
- if (game == null || !game.Players.IsInGamePlayer(state.Mobile))
+ if (game?.Players.IsInGamePlayer(state.Mobile) != true)
return;
int to = pvSrc.ReadByte();
@@ -101,7 +101,7 @@ namespace Server.Engines.Mahjong
public static void RollDice(MahjongGame game, NetState state, PacketReader pvSrc)
{
- if (game == null || !game.Players.IsInGamePlayer(state.Mobile))
+ if (game?.Players.IsInGamePlayer(state.Mobile) != true)
return;
game.Dices.RollDices(state.Mobile);
@@ -109,7 +109,7 @@ namespace Server.Engines.Mahjong
public static void BuildWalls(MahjongGame game, NetState state, PacketReader pvSrc)
{
- if (game == null || !game.Players.IsInGameDealer(state.Mobile))
+ if (game?.Players.IsInGameDealer(state.Mobile) != true)
return;
game.ResetWalls(state.Mobile);
@@ -117,7 +117,7 @@ namespace Server.Engines.Mahjong
public static void ResetScores(MahjongGame game, NetState state, PacketReader pvSrc)
{
- if (game == null || !game.Players.IsInGameDealer(state.Mobile))
+ if (game?.Players.IsInGameDealer(state.Mobile) != true)
return;
game.Players.ResetScores(MahjongGame.BaseScore);
@@ -125,7 +125,7 @@ namespace Server.Engines.Mahjong
public static void AssignDealer(MahjongGame game, NetState state, PacketReader pvSrc)
{
- if (game == null || !game.Players.IsInGameDealer(state.Mobile))
+ if (game?.Players.IsInGameDealer(state.Mobile) != true)
return;
int position = pvSrc.ReadByte();
@@ -135,7 +135,7 @@ namespace Server.Engines.Mahjong
public static void OpenSeat(MahjongGame game, NetState state, PacketReader pvSrc)
{
- if (game == null || !game.Players.IsInGameDealer(state.Mobile))
+ if (game?.Players.IsInGameDealer(state.Mobile) != true)
return;
int position = pvSrc.ReadByte();
@@ -148,7 +148,7 @@ namespace Server.Engines.Mahjong
public static void ChangeOption(MahjongGame game, NetState state, PacketReader pvSrc)
{
- if (game == null || !game.Players.IsInGameDealer(state.Mobile))
+ if (game?.Players.IsInGameDealer(state.Mobile) != true)
return;
pvSrc.ReadInt16();
@@ -162,7 +162,7 @@ namespace Server.Engines.Mahjong
public static void MoveWallBreakIndicator(MahjongGame game, NetState state, PacketReader pvSrc)
{
- if (game == null || !game.Players.IsInGameDealer(state.Mobile))
+ if (game?.Players.IsInGameDealer(state.Mobile) != true)
return;
int y = pvSrc.ReadInt16();
@@ -173,7 +173,7 @@ namespace Server.Engines.Mahjong
public static void TogglePublicHand(MahjongGame game, NetState state, PacketReader pvSrc)
{
- if (game == null || !game.Players.IsInGamePlayer(state.Mobile))
+ if (game?.Players.IsInGamePlayer(state.Mobile) != true)
return;
pvSrc.ReadInt16();
@@ -186,7 +186,7 @@ namespace Server.Engines.Mahjong
public static void MoveTile(MahjongGame game, NetState state, PacketReader pvSrc)
{
- if (game == null || !game.Players.IsInGamePlayer(state.Mobile))
+ if (game?.Players.IsInGamePlayer(state.Mobile) != true)
return;
int number = pvSrc.ReadByte();
@@ -217,7 +217,7 @@ namespace Server.Engines.Mahjong
public static void MoveDealerIndicator(MahjongGame game, NetState state, PacketReader pvSrc)
{
- if (game == null || !game.Players.IsInGameDealer(state.Mobile))
+ if (game?.Players.IsInGameDealer(state.Mobile) != true)
return;
MahjongPieceDirection direction = GetDirection(pvSrc.ReadByte());
diff --git a/Projects/Scripts/Items/Jewels/BaseJewel.cs b/Projects/Scripts/Items/Jewels/BaseJewel.cs
index 944144bb9..7281f3655 100644
--- a/Projects/Scripts/Items/Jewels/BaseJewel.cs
+++ b/Projects/Scripts/Items/Jewels/BaseJewel.cs
@@ -197,13 +197,13 @@ namespace Server.Items
string modName = Serial.ToString();
if (strBonus != 0)
- from.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero));
+ from.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero));
if (dexBonus != 0)
- from.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero));
+ from.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero));
if (intBonus != 0)
- from.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero));
+ from.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero));
}
from.CheckStatTimers();
@@ -218,9 +218,9 @@ namespace Server.Items
string modName = Serial.ToString();
- from.RemoveStatMod(modName + "Str");
- from.RemoveStatMod(modName + "Dex");
- from.RemoveStatMod(modName + "Int");
+ from.RemoveStatMod($"{modName}Str");
+ from.RemoveStatMod($"{modName}Dex");
+ from.RemoveStatMod($"{modName}Int");
from.CheckStatTimers();
}
@@ -279,7 +279,7 @@ namespace Server.Items
if ((prop = Attributes.RegenMana) != 0)
list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~
- if ((prop = Attributes.NightSight) != 0)
+ if (Attributes.NightSight != 0)
list.Add(1060441); // night sight
if ((prop = Attributes.ReflectPhysical) != 0)
@@ -291,7 +291,7 @@ namespace Server.Items
if ((prop = Attributes.RegenHits) != 0)
list.Add(1060444, prop.ToString()); // hit point regeneration ~1_val~
- if ((prop = Attributes.SpellChanneling) != 0)
+ if (Attributes.SpellChanneling != 0)
list.Add(1060482); // spell channeling
if ((prop = Attributes.SpellDamage) != 0)
@@ -374,13 +374,13 @@ namespace Server.Items
string modName = Serial.ToString();
if (strBonus != 0)
- m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero));
+ m.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero));
if (dexBonus != 0)
- m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero));
+ m.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero));
if (intBonus != 0)
- m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero));
+ m.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero));
}
m?.CheckStatTimers();
diff --git a/Projects/Scripts/Items/Lights/RedHangingLantern.cs b/Projects/Scripts/Items/Lights/RedHangingLantern.cs
index 26df79f5d..79aaacb7f 100644
--- a/Projects/Scripts/Items/Lights/RedHangingLantern.cs
+++ b/Projects/Scripts/Items/Lights/RedHangingLantern.cs
@@ -43,22 +43,14 @@ namespace Server.Items
{
Light = LightType.Circle300;
- switch (ItemID)
+ ItemID = ItemID switch
{
- case 0x24C2:
- ItemID = 0x24C4;
- break;
- case 0x24C1:
- ItemID = 0x24C3;
- break;
-
- case 0x24C4:
- ItemID = 0x24C2;
- break;
- case 0x24C3:
- ItemID = 0x24C1;
- break;
- }
+ 0x24C2 => 0x24C4,
+ 0x24C1 => 0x24C3,
+ 0x24C4 => 0x24C2,
+ 0x24C3 => 0x24C1,
+ _ => ItemID
+ };
}
public override void Serialize(GenericWriter writer)
diff --git a/Projects/Scripts/Items/Lights/WallSconce.cs b/Projects/Scripts/Items/Lights/WallSconce.cs
index 2f01399b4..d0265e4a9 100644
--- a/Projects/Scripts/Items/Lights/WallSconce.cs
+++ b/Projects/Scripts/Items/Lights/WallSconce.cs
@@ -46,22 +46,14 @@ namespace Server.Items
else if (Light == LightType.NorthBig)
Light = LightType.WestBig;
- switch (ItemID)
+ ItemID = ItemID switch
{
- case 0x9FB:
- ItemID = 0xA00;
- break;
- case 0x9FD:
- ItemID = 0xA02;
- break;
-
- case 0xA00:
- ItemID = 0x9FB;
- break;
- case 0xA02:
- ItemID = 0x9FD;
- break;
- }
+ 0x9FB => 0xA00,
+ 0x9FD => 0xA02,
+ 0xA00 => 0x9FB,
+ 0xA02 => 0x9FD,
+ _ => ItemID
+ };
}
public override void Serialize(GenericWriter writer)
diff --git a/Projects/Scripts/Items/Lights/WallTorch.cs b/Projects/Scripts/Items/Lights/WallTorch.cs
index eb0be6321..91d9c42ae 100644
--- a/Projects/Scripts/Items/Lights/WallTorch.cs
+++ b/Projects/Scripts/Items/Lights/WallTorch.cs
@@ -46,22 +46,14 @@ namespace Server.Items
else if (Light == LightType.NorthBig)
Light = LightType.WestBig;
- switch (ItemID)
+ ItemID = ItemID switch
{
- case 0xA05:
- ItemID = 0xA0A;
- break;
- case 0xA07:
- ItemID = 0xA0C;
- break;
-
- case 0xA0A:
- ItemID = 0xA05;
- break;
- case 0xA0C:
- ItemID = 0xA07;
- break;
- }
+ 0xA05 => 0xA0A,
+ 0xA07 => 0xA0C,
+ 0xA0A => 0xA05,
+ 0xA0C => 0xA07,
+ _ => ItemID
+ };
}
public override void Serialize(GenericWriter writer)
diff --git a/Projects/Scripts/Items/Lights/WhiteHangingLantern.cs b/Projects/Scripts/Items/Lights/WhiteHangingLantern.cs
index 1c0cd8749..1c0523d80 100644
--- a/Projects/Scripts/Items/Lights/WhiteHangingLantern.cs
+++ b/Projects/Scripts/Items/Lights/WhiteHangingLantern.cs
@@ -43,22 +43,14 @@ namespace Server.Items
{
Light = LightType.Circle300;
- switch (ItemID)
+ ItemID = ItemID switch
{
- case 0x24C6:
- ItemID = 0x24C8;
- break;
- case 0x24C5:
- ItemID = 0x24C7;
- break;
-
- case 0x24C8:
- ItemID = 0x24C6;
- break;
- case 0x24C7:
- ItemID = 0x24C5;
- break;
- }
+ 0x24C6 => 0x24C8,
+ 0x24C5 => 0x24C7,
+ 0x24C8 => 0x24C6,
+ 0x24C7 => 0x24C5,
+ _ => ItemID
+ };
}
public override void Serialize(GenericWriter writer)
diff --git a/Projects/Scripts/Items/Maps/TreasureMap.cs b/Projects/Scripts/Items/Maps/TreasureMap.cs
index 7d03d0fbf..066f240eb 100644
--- a/Projects/Scripts/Items/Maps/TreasureMap.cs
+++ b/Projects/Scripts/Items/Maps/TreasureMap.cs
@@ -370,17 +370,16 @@ namespace Server.Items
private double GetMinSkillLevel()
{
- switch (m_Level)
+ return m_Level switch
{
- case 1: return -3.0;
- case 2: return 41.0;
- case 3: return 51.0;
- case 4: return 61.0;
- case 5: return 70.0;
- case 6: return 70.0;
-
- default: return 0.0;
- }
+ 1 => -3.0,
+ 2 => 41.0,
+ 3 => 51.0,
+ 4 => 61.0,
+ 5 => 70.0,
+ 6 => 70.0,
+ _ => 0.0
+ };
}
private bool HasRequiredSkill(Mobile from) => from.Skills.Cartography.Value >= GetMinSkillLevel();
@@ -652,34 +651,17 @@ namespace Server.Items
{
Direction dir = Utility.GetDirection(targ3D, chest3D0);
- string sDir;
- switch (dir)
+ var sDir = dir switch
{
- case Direction.North:
- sDir = "north";
- break;
- case Direction.Right:
- sDir = "northeast";
- break;
- case Direction.East:
- sDir = "east";
- break;
- case Direction.Down:
- sDir = "southeast";
- break;
- case Direction.South:
- sDir = "south";
- break;
- case Direction.Left:
- sDir = "southwest";
- break;
- case Direction.West:
- sDir = "west";
- break;
- default:
- sDir = "northwest";
- break;
- }
+ Direction.North => "north",
+ Direction.Right => "northeast",
+ Direction.East => "east",
+ Direction.Down => "southeast",
+ Direction.South => "south",
+ Direction.Left => "southwest",
+ Direction.West => "west",
+ _ => "northwest"
+ };
from.SendAsciiMessage(0x44, "Try looking for the treasure chest more to the {0}.", sDir);
}
@@ -818,19 +800,12 @@ namespace Server.Items
m_TreasureMap.Completed = true;
m_TreasureMap.CompletedBy = m_From;
- int spawns;
- switch (m_TreasureMap.Level)
+ var spawns = m_TreasureMap.Level switch
{
- case 0:
- spawns = 3;
- break;
- case 1:
- spawns = 0;
- break;
- default:
- spawns = 4;
- break;
- }
+ 0 => 3,
+ 1 => 0,
+ _ => 4
+ };
for (int i = 0; i < spawns; ++i)
{
diff --git a/Projects/Scripts/Items/Minor Artifacts/ML/BloodwoodSpirit.cs b/Projects/Scripts/Items/Minor Artifacts/ML/BloodwoodSpirit.cs
index 435615145..8e8cbd68f 100644
--- a/Projects/Scripts/Items/Minor Artifacts/ML/BloodwoodSpirit.cs
+++ b/Projects/Scripts/Items/Minor Artifacts/ML/BloodwoodSpirit.cs
@@ -36,7 +36,7 @@ namespace Server.Items
int version = reader.ReadInt();
- if (version == 0 && (Protection == null || Protection.IsEmpty))
+ if (version == 0 && Protection?.IsEmpty != false)
Protection = GetRandomProtection(false);
}
}
diff --git a/Projects/Scripts/Items/Minor Artifacts/ML/TotemOfVoid.cs b/Projects/Scripts/Items/Minor Artifacts/ML/TotemOfVoid.cs
index 68492720e..a9de8bc76 100644
--- a/Projects/Scripts/Items/Minor Artifacts/ML/TotemOfVoid.cs
+++ b/Projects/Scripts/Items/Minor Artifacts/ML/TotemOfVoid.cs
@@ -40,7 +40,7 @@ namespace Server.Items
int version = reader.ReadInt();
- if (version == 0 && (Protection == null || Protection.IsEmpty))
+ if (version == 0 && Protection?.IsEmpty != false)
Protection = GetRandomProtection(false);
}
}
diff --git a/Projects/Scripts/Items/Misc/BankCheck.cs b/Projects/Scripts/Items/Misc/BankCheck.cs
index 140a57247..a07a360dd 100644
--- a/Projects/Scripts/Items/Misc/BankCheck.cs
+++ b/Projects/Scripts/Items/Misc/BankCheck.cs
@@ -117,7 +117,7 @@ namespace Server.Items
owner = box.Owner;
}
- if (owner?.Account == null || !owner.Account.DepositGold(Worth)) return;
+ if (owner?.Account?.DepositGold(Worth) != true) return;
if (tradeInfo != null)
{
@@ -151,7 +151,7 @@ namespace Server.Items
1041361,
"",
AffixType.Append,
- string.Concat(" ", m_Worth.ToString()),
+ $" {m_Worth}",
"")); // A bank check:
}
@@ -174,7 +174,7 @@ namespace Server.Items
int deposited = 0;
int toAdd = m_Worth;
- if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(toAdd))
+ if (AccountGold.Enabled && from.Account?.DepositGold(toAdd) == true)
{
deposited = toAdd;
toAdd = 0;
diff --git a/Projects/Scripts/Items/Misc/CommunicationCrystals.cs b/Projects/Scripts/Items/Misc/CommunicationCrystals.cs
index e67ff411e..d660b678f 100644
--- a/Projects/Scripts/Items/Misc/CommunicationCrystals.cs
+++ b/Projects/Scripts/Items/Misc/CommunicationCrystals.cs
@@ -342,9 +342,9 @@ namespace Server.Items
string text = $"{from.Name} says {message}";
if (RootParent is Mobile mobile)
- mobile.SendMessage(0x2B2, "Crystal: " + text);
+ mobile.SendMessage(0x2B2, $"Crystal: {text}");
else if (RootParent is Item item)
- item.PublicOverheadMessage(MessageType.Regular, 0x2B2, false, "Crystal: " + text);
+ item.PublicOverheadMessage(MessageType.Regular, 0x2B2, false, $"Crystal: {text}");
else
PublicOverheadMessage(MessageType.Regular, 0x2B2, false, text);
}
diff --git a/Projects/Scripts/Items/Misc/DeceitBrazier.cs b/Projects/Scripts/Items/Misc/DeceitBrazier.cs
index 2b7d9ed83..352921f9d 100644
--- a/Projects/Scripts/Items/Misc/DeceitBrazier.cs
+++ b/Projects/Scripts/Items/Misc/DeceitBrazier.cs
@@ -151,7 +151,7 @@ namespace Server.Items
if (NextSpawn < DateTime.UtcNow) // means we haven't spawned anything if the next spawn is below
if (Utility.InRange(m.Location, Location, 1) && !Utility.InRange(oldLocation, Location, 1) && m.Player &&
!(m.AccessLevel > AccessLevel.Player || m.Hidden))
- if (m_Timer == null || !m_Timer.Running)
+ if (m_Timer?.Running != true)
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(2), HeedWarning);
base.OnMovement(m, oldLocation);
diff --git a/Projects/Scripts/Items/Misc/Firebomb.cs b/Projects/Scripts/Items/Misc/Firebomb.cs
index 71c702a73..6ab46e1a2 100644
--- a/Projects/Scripts/Items/Misc/Firebomb.cs
+++ b/Projects/Scripts/Items/Misc/Firebomb.cs
@@ -48,7 +48,7 @@ namespace Server.Items
return;
}
- if (Core.AOS && (from.Paralyzed || from.Frozen || from.Spell != null && from.Spell.IsCasting))
+ if (Core.AOS && (from.Paralyzed || from.Frozen || from.Spell?.IsCasting == true))
{
// to prevent exploiting for pvp
from.SendLocalizedMessage(1075857); // You cannot use that while paralyzed.
diff --git a/Projects/Scripts/Items/Misc/FlippableAttribute.cs b/Projects/Scripts/Items/Misc/FlippableAttribute.cs
index 40540d265..7f8c20041 100644
--- a/Projects/Scripts/Items/Misc/FlippableAttribute.cs
+++ b/Projects/Scripts/Items/Misc/FlippableAttribute.cs
@@ -1,5 +1,4 @@
using System;
-using Server.Commands;
using Server.Targeting;
namespace Server.Items
diff --git a/Projects/Scripts/Items/Misc/Gold.cs b/Projects/Scripts/Items/Misc/Gold.cs
index 59497e15e..4a8553f01 100644
--- a/Projects/Scripts/Items/Misc/Gold.cs
+++ b/Projects/Scripts/Items/Misc/Gold.cs
@@ -73,7 +73,7 @@ namespace Server.Items
owner = box.Owner;
}
- if (owner?.Account == null || !owner.Account.DepositGold(Amount)) return;
+ if (owner?.Account?.DepositGold(Amount) != true) return;
if (tradeInfo != null)
{
diff --git a/Projects/Scripts/Items/Misc/InteriorDecorator.cs b/Projects/Scripts/Items/Misc/InteriorDecorator.cs
index f3506643c..8e01befe1 100644
--- a/Projects/Scripts/Items/Misc/InteriorDecorator.cs
+++ b/Projects/Scripts/Items/Misc/InteriorDecorator.cs
@@ -117,20 +117,13 @@ namespace Server.Items
public override void OnResponse(NetState sender, RelayInfo info)
{
- DecorateCommand command = DecorateCommand.None;
-
- switch (info.ButtonID)
+ var command = info.ButtonID switch
{
- case 1:
- command = DecorateCommand.Turn;
- break;
- case 2:
- command = DecorateCommand.Up;
- break;
- case 3:
- command = DecorateCommand.Down;
- break;
- }
+ 1 => DecorateCommand.Turn,
+ 2 => DecorateCommand.Up,
+ 3 => DecorateCommand.Down,
+ _ => DecorateCommand.None
+ };
if (command != DecorateCommand.None)
{
@@ -203,7 +196,7 @@ namespace Server.Items
}
}
- if (house == null || !house.IsCoOwner(from))
+ if (house?.IsCoOwner(from) != true)
{
from.SendLocalizedMessage(502092); // You must be in your house to do this.
}
diff --git a/Projects/Scripts/Items/Misc/Origami.cs b/Projects/Scripts/Items/Misc/Origami.cs
index c673eb468..19d3d5705 100644
--- a/Projects/Scripts/Items/Misc/Origami.cs
+++ b/Projects/Scripts/Items/Misc/Origami.cs
@@ -23,29 +23,16 @@ namespace Server.Items
{
Delete();
- Item i = null;
-
- switch (Utility.Random(from.BAC >= 5 ? 6 : 5))
+ var i = Utility.Random(from.BAC >= 5 ? 6 : 5) switch
{
- case 0:
- i = new OrigamiButterfly();
- break;
- case 1:
- i = new OrigamiSwan();
- break;
- case 2:
- i = new OrigamiFrog();
- break;
- case 3:
- i = new OrigamiShape();
- break;
- case 4:
- i = new OrigamiSongbird();
- break;
- case 5:
- i = new OrigamiFish();
- break;
- }
+ 0 => (Item)new OrigamiButterfly(),
+ 1 => new OrigamiSwan(),
+ 2 => new OrigamiFrog(),
+ 3 => new OrigamiShape(),
+ 4 => new OrigamiSongbird(),
+ 5 => new OrigamiFish(),
+ _ => null
+ };
if (i != null)
from.AddToBackpack(i);
@@ -224,4 +211,4 @@ namespace Server.Items
int version = reader.ReadEncodedInt();
}
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Items/Misc/PlayerBulletinBoards.cs b/Projects/Scripts/Items/Misc/PlayerBulletinBoards.cs
index 967f5760f..2789f301d 100644
--- a/Projects/Scripts/Items/Misc/PlayerBulletinBoards.cs
+++ b/Projects/Scripts/Items/Misc/PlayerBulletinBoards.cs
@@ -162,7 +162,7 @@ namespace Server.Items
{
BaseHouse house = BaseHouse.FindHouseAt( this );
- if ( house == null || !house.HasLockedDownItem( this ) )
+ if ( house?.HasLockedDownItem( this ) != true )
from.SendLocalizedMessage( 1062396 ); // This bulletin board must be locked down in a house to be usable.
else if ( !from.InRange( GetWorldLocation(), 2 ) || !from.InLOS( this ) )
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
@@ -196,7 +196,7 @@ namespace Server.Items
BaseHouse house = m_House;
BasePlayerBB board = m_Board;
- if ( house == null || !house.HasLockedDownItem( board ) )
+ if ( house?.HasLockedDownItem( board ) != true )
{
from.SendLocalizedMessage( 1062396 ); // This bulletin board must be locked down in a house to be usable.
return;
@@ -212,10 +212,7 @@ namespace Server.Items
from.SendLocalizedMessage( 1062398 ); // You are not allowed to post to this bulletin board.
return;
}
- if ( m_Greeting && !house.IsOwner( from ) )
- {
- return;
- }
+ if ( m_Greeting && !house.IsOwner( from ) ) return;
text = text.Trim();
@@ -272,7 +269,7 @@ namespace Server.Items
BaseHouse house = m_House;
BasePlayerBB board = m_Board;
- if ( house == null || !house.HasLockedDownItem( board ) )
+ if ( house?.HasLockedDownItem( board ) != true )
{
from.SendLocalizedMessage( 1062396 ); // This bulletin board must be locked down in a house to be usable.
return;
@@ -363,7 +360,7 @@ namespace Server.Items
BaseHouse house = m_House;
BasePlayerBB board = m_Board;
- if ( house == null || !house.HasLockedDownItem( board ) )
+ if ( house?.HasLockedDownItem( board ) != true )
{
from.SendLocalizedMessage( 1062396 ); // This bulletin board must be locked down in a house to be usable.
return;
diff --git a/Projects/Scripts/Items/Misc/PoolOfAcid.cs b/Projects/Scripts/Items/Misc/PoolOfAcid.cs
index e3fefdb3c..5b16ad0e6 100644
--- a/Projects/Scripts/Items/Misc/PoolOfAcid.cs
+++ b/Projects/Scripts/Items/Misc/PoolOfAcid.cs
@@ -48,7 +48,7 @@ namespace Server.Items
if ( age > m_Duration ) {
Delete();
} else {
- if ( !m_Drying && age > (m_Duration - age) )
+ if ( !m_Drying && age > m_Duration - age )
{
m_Drying = true;
ItemID = 0x122B;
@@ -57,12 +57,8 @@ namespace Server.Items
List toDamage = new List();
foreach( Mobile m in GetMobilesInRange( 0 ) )
- {
if ( m.Alive && !m.IsDeadBondedPet && (!(m is BaseCreature bc) || bc.Controlled || bc.Summoned) )
- {
toDamage.Add( m );
- }
- }
for ( int i = 0; i < toDamage.Count; i++ )
Damage( toDamage[i] );
diff --git a/Projects/Scripts/Items/Misc/PowerGenerator.cs b/Projects/Scripts/Items/Misc/PowerGenerator.cs
index d0d0006d9..db1d950c4 100644
--- a/Projects/Scripts/Items/Misc/PowerGenerator.cs
+++ b/Projects/Scripts/Items/Misc/PowerGenerator.cs
@@ -132,21 +132,13 @@ namespace Server.Items
{
PathDirection dir = choices[Utility.Random(count)];
- switch (dir)
+ current = dir switch
{
- case PathDirection.Left:
- current = new Node(current.X - 1, current.Y);
- break;
- case PathDirection.Up:
- current = new Node(current.X, current.Y - 1);
- break;
- case PathDirection.Right:
- current = new Node(current.X + 1, current.Y);
- break;
- default:
- current = new Node(current.X, current.Y + 1);
- break;
- }
+ PathDirection.Left => new Node(current.X - 1, current.Y),
+ PathDirection.Up => new Node(current.X, current.Y - 1),
+ PathDirection.Right => new Node(current.X + 1, current.Y),
+ _ => new Node(current.X, current.Y + 1)
+ };
stack[stackSize++] = current;
@@ -391,19 +383,12 @@ namespace Server.Items
private void AddNode(int x, int y, NodeHue hue)
{
- int id;
- switch (hue)
+ var id = hue switch
{
- case NodeHue.Gray:
- id = 0x25F8;
- break;
- case NodeHue.Blue:
- id = 0x868;
- break;
- default:
- id = 0x9A8;
- break;
- }
+ NodeHue.Gray => 0x25F8,
+ NodeHue.Blue => 0x868,
+ _ => 0x9A8
+ };
AddImage(x, y, id);
}
diff --git a/Projects/Scripts/Items/Misc/PublicMoongate.cs b/Projects/Scripts/Items/Misc/PublicMoongate.cs
index 4ba1a79a1..c0af37445 100644
--- a/Projects/Scripts/Items/Misc/PublicMoongate.cs
+++ b/Projects/Scripts/Items/Misc/PublicMoongate.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using Server.Commands;
using Server.Factions;
using Server.Gumps;
using Server.Mobiles;
diff --git a/Projects/Scripts/Items/Misc/UnholyBone.cs b/Projects/Scripts/Items/Misc/UnholyBone.cs
index 8d6784673..236a41a1e 100644
--- a/Projects/Scripts/Items/Misc/UnholyBone.cs
+++ b/Projects/Scripts/Items/Misc/UnholyBone.cs
@@ -85,48 +85,22 @@ namespace Server.Items
if (m_Item.Deleted)
return;
- Mobile spawn;
-
- switch (Utility.Random(12))
+ var spawn = Utility.Random(12) switch
{
- default:
- case 0:
- spawn = new Skeleton();
- break;
- case 1:
- spawn = new Zombie();
- break;
- case 2:
- spawn = new Wraith();
- break;
- case 3:
- spawn = new Spectre();
- break;
- case 4:
- spawn = new Ghoul();
- break;
- case 5:
- spawn = new Mummy();
- break;
- case 6:
- spawn = new Bogle();
- break;
- case 7:
- spawn = new RottingCorpse();
- break;
- case 8:
- spawn = new BoneKnight();
- break;
- case 9:
- spawn = new SkeletalKnight();
- break;
- case 10:
- spawn = new Lich();
- break;
- case 11:
- spawn = new LichLord();
- break;
- }
+ 0 => (Mobile)new Skeleton(),
+ 1 => new Zombie(),
+ 2 => new Wraith(),
+ 3 => new Spectre(),
+ 4 => new Ghoul(),
+ 5 => new Mummy(),
+ 6 => new Bogle(),
+ 7 => new RottingCorpse(),
+ 8 => new BoneKnight(),
+ 9 => new SkeletalKnight(),
+ 10 => new Lich(),
+ 11 => new LichLord(),
+ _ => new Skeleton()
+ };
spawn.MoveToWorld(m_Item.Location, m_Item.Map);
diff --git a/Projects/Scripts/Items/Misc/Waypoint.cs b/Projects/Scripts/Items/Misc/Waypoint.cs
index a0cc0d02d..7661994f5 100644
--- a/Projects/Scripts/Items/Misc/Waypoint.cs
+++ b/Projects/Scripts/Items/Misc/Waypoint.cs
@@ -1,4 +1,3 @@
-using Server.Commands;
using Server.Targeting;
namespace Server.Items
diff --git a/Projects/Scripts/Items/Misc/WindChimes.cs b/Projects/Scripts/Items/Misc/WindChimes.cs
index d76d8d7b5..03dc3bc00 100644
--- a/Projects/Scripts/Items/Misc/WindChimes.cs
+++ b/Projects/Scripts/Items/Misc/WindChimes.cs
@@ -55,13 +55,9 @@ namespace Server.Items
public override void OnDoubleClick(Mobile from)
{
if (IsOwner(from))
- {
from.SendGump(new OnOffGump(this));
- }
else
- {
from.SendLocalizedMessage(502691); // You must be the owner to use this.
- }
}
public override void Serialize(GenericWriter writer)
diff --git a/Projects/Scripts/Items/Quivers/BaseQuiver.cs b/Projects/Scripts/Items/Quivers/BaseQuiver.cs
index b3a4f691e..f38f31d44 100644
--- a/Projects/Scripts/Items/Quivers/BaseQuiver.cs
+++ b/Projects/Scripts/Items/Quivers/BaseQuiver.cs
@@ -172,11 +172,9 @@ namespace Server.Items
public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight)
{
if (CheckType(item))
- {
return Items.Count >= DefaultMaxItems && !checkItems && Ammo?.Deleted == false &&
Ammo.Amount + item.Amount <= m_Capacity || item.Amount <= m_Capacity &&
base.CheckHold(m, item, message, checkItems, plusItems, plusWeight);
- }
if (message)
m.SendLocalizedMessage(1074836); // The container can not hold that type of object.
diff --git a/Projects/Scripts/Items/Resources/Blacksmithing/Ingots.cs b/Projects/Scripts/Items/Resources/Blacksmithing/Ingots.cs
index 7418eaf2b..ce681e54c 100644
--- a/Projects/Scripts/Items/Resources/Blacksmithing/Ingots.cs
+++ b/Projects/Scripts/Items/Resources/Blacksmithing/Ingots.cs
@@ -68,41 +68,19 @@ namespace Server.Items
}
case 0:
{
- OreInfo info;
-
- switch (reader.ReadInt())
+ var info = reader.ReadInt() switch
{
- case 0:
- info = OreInfo.Iron;
- break;
- case 1:
- info = OreInfo.DullCopper;
- break;
- case 2:
- info = OreInfo.ShadowIron;
- break;
- case 3:
- info = OreInfo.Copper;
- break;
- case 4:
- info = OreInfo.Bronze;
- break;
- case 5:
- info = OreInfo.Gold;
- break;
- case 6:
- info = OreInfo.Agapite;
- break;
- case 7:
- info = OreInfo.Verite;
- break;
- case 8:
- info = OreInfo.Valorite;
- break;
- default:
- info = null;
- break;
- }
+ 0 => OreInfo.Iron,
+ 1 => OreInfo.DullCopper,
+ 2 => OreInfo.ShadowIron,
+ 3 => OreInfo.Copper,
+ 4 => OreInfo.Bronze,
+ 5 => OreInfo.Gold,
+ 6 => OreInfo.Agapite,
+ 7 => OreInfo.Verite,
+ 8 => OreInfo.Valorite,
+ _ => null
+ };
m_Resource = CraftResources.GetFromOreInfo(info);
break;
diff --git a/Projects/Scripts/Items/Resources/Blacksmithing/Ore.cs b/Projects/Scripts/Items/Resources/Blacksmithing/Ore.cs
index 1fabf6123..f5791660e 100644
--- a/Projects/Scripts/Items/Resources/Blacksmithing/Ore.cs
+++ b/Projects/Scripts/Items/Resources/Blacksmithing/Ore.cs
@@ -69,41 +69,19 @@ namespace Server.Items
}
case 0:
{
- OreInfo info;
-
- switch (reader.ReadInt())
+ var info = reader.ReadInt() switch
{
- case 0:
- info = OreInfo.Iron;
- break;
- case 1:
- info = OreInfo.DullCopper;
- break;
- case 2:
- info = OreInfo.ShadowIron;
- break;
- case 3:
- info = OreInfo.Copper;
- break;
- case 4:
- info = OreInfo.Bronze;
- break;
- case 5:
- info = OreInfo.Gold;
- break;
- case 6:
- info = OreInfo.Agapite;
- break;
- case 7:
- info = OreInfo.Verite;
- break;
- case 8:
- info = OreInfo.Valorite;
- break;
- default:
- info = null;
- break;
- }
+ 0 => OreInfo.Iron,
+ 1 => OreInfo.DullCopper,
+ 2 => OreInfo.ShadowIron,
+ 3 => OreInfo.Copper,
+ 4 => OreInfo.Bronze,
+ 5 => OreInfo.Gold,
+ 6 => OreInfo.Agapite,
+ 7 => OreInfo.Verite,
+ 8 => OreInfo.Valorite,
+ _ => null
+ };
m_Resource = CraftResources.GetFromOreInfo(info);
break;
@@ -297,38 +275,18 @@ namespace Server.Items
if (IsForge(targeted))
{
- double difficulty;
-
- switch (m_Ore.Resource)
+ var difficulty = m_Ore.Resource switch
{
- default:
- difficulty = 50.0;
- break;
- case CraftResource.DullCopper:
- difficulty = 65.0;
- break;
- case CraftResource.ShadowIron:
- difficulty = 70.0;
- break;
- case CraftResource.Copper:
- difficulty = 75.0;
- break;
- case CraftResource.Bronze:
- difficulty = 80.0;
- break;
- case CraftResource.Gold:
- difficulty = 85.0;
- break;
- case CraftResource.Agapite:
- difficulty = 90.0;
- break;
- case CraftResource.Verite:
- difficulty = 95.0;
- break;
- case CraftResource.Valorite:
- difficulty = 99.0;
- break;
- }
+ CraftResource.DullCopper => 65.0,
+ CraftResource.ShadowIron => 70.0,
+ CraftResource.Copper => 75.0,
+ CraftResource.Bronze => 80.0,
+ CraftResource.Gold => 85.0,
+ CraftResource.Agapite => 90.0,
+ CraftResource.Verite => 95.0,
+ CraftResource.Valorite => 99.0,
+ _ => 50.0
+ };
double minSkill = difficulty - 25.0;
double maxSkill = difficulty + 25.0;
diff --git a/Projects/Scripts/Items/Shields/ChaosShield.cs b/Projects/Scripts/Items/Shields/ChaosShield.cs
index 94e10a69f..e81280f93 100644
--- a/Projects/Scripts/Items/Shields/ChaosShield.cs
+++ b/Projects/Scripts/Items/Shields/ChaosShield.cs
@@ -54,7 +54,7 @@ namespace Server.Items
public virtual bool Validate(Mobile m)
{
- if (m == null || !m.Player || m.AccessLevel != AccessLevel.Player || Core.AOS)
+ if (m?.Player != true || m.AccessLevel != AccessLevel.Player || Core.AOS)
return true;
if (!(m.Guild is Guild g) || g.Type != GuildType.Chaos)
diff --git a/Projects/Scripts/Items/Shields/OrderShield.cs b/Projects/Scripts/Items/Shields/OrderShield.cs
index a560814b4..d98f1e1e5 100644
--- a/Projects/Scripts/Items/Shields/OrderShield.cs
+++ b/Projects/Scripts/Items/Shields/OrderShield.cs
@@ -57,7 +57,7 @@ namespace Server.Items
public virtual bool Validate(Mobile m)
{
- if (Core.AOS || m == null || !m.Player || m.AccessLevel != AccessLevel.Player)
+ if (Core.AOS || m?.Player != true || m.AccessLevel != AccessLevel.Player)
return true;
if (!(m.Guild is Guild g) || g.Type != GuildType.Order)
diff --git a/Projects/Scripts/Items/Skill Items/Camping/Campfire.cs b/Projects/Scripts/Items/Skill Items/Camping/Campfire.cs
index cf03a99f5..cbe187746 100644
--- a/Projects/Scripts/Items/Skill Items/Camping/Campfire.cs
+++ b/Projects/Scripts/Items/Skill Items/Camping/Campfire.cs
@@ -46,17 +46,12 @@ namespace Server.Items
{
get
{
- switch (ItemID)
+ return ItemID switch
{
- case 0xDE3:
- return CampfireStatus.Burning;
-
- case 0xDE9:
- return CampfireStatus.Extinguishing;
-
- default:
- return CampfireStatus.Off;
- }
+ 0xDE3 => CampfireStatus.Burning,
+ 0xDE9 => CampfireStatus.Extinguishing,
+ _ => CampfireStatus.Off
+ };
}
set
{
diff --git a/Projects/Scripts/Items/Skill Items/Carpenter Items/Board.cs b/Projects/Scripts/Items/Skill Items/Carpenter Items/Board.cs
index ad877ea4b..8ee3ec5af 100644
--- a/Projects/Scripts/Items/Skill Items/Carpenter Items/Board.cs
+++ b/Projects/Scripts/Items/Skill Items/Carpenter Items/Board.cs
@@ -45,14 +45,13 @@ namespace Server.Items
if (m_Resource >= CraftResource.OakWood && m_Resource <= CraftResource.YewWood)
return 1075052 + ((int)m_Resource - (int)CraftResource.OakWood);
- switch (m_Resource)
+ return m_Resource switch
{
- case CraftResource.Bloodwood: return 1075055;
- case CraftResource.Frostwood: return 1075056;
- case CraftResource.Heartwood: return 1075062; //WHY Osi. Why?
- }
-
- return LabelNumber;
+ CraftResource.Bloodwood => 1075055,
+ CraftResource.Frostwood => 1075056,
+ CraftResource.Heartwood => 1075062, //WHY Osi. Why?
+ _ => LabelNumber
+ };
}
}
diff --git a/Projects/Scripts/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs b/Projects/Scripts/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs
index e63840cd1..db5d8c74d 100644
--- a/Projects/Scripts/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs
+++ b/Projects/Scripts/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs
@@ -299,24 +299,14 @@ namespace Server.Items
for (int i = 0; map != null && i < count; ++i)
{
- BaseCreature spawn;
-
- switch (Utility.Random(4))
+ var spawn = Utility.Random(4) switch
{
- default:
- case 0:
- spawn = new SeaSerpent();
- break;
- case 1:
- spawn = new DeepSeaSerpent();
- break;
- case 2:
- spawn = new WaterElemental();
- break;
- case 3:
- spawn = new Kraken();
- break;
- }
+ 0 => (BaseCreature)new SeaSerpent(),
+ 1 => new DeepSeaSerpent(),
+ 2 => new WaterElemental(),
+ 3 => new Kraken(),
+ _ => new SeaSerpent()
+ };
Spawn(p, map, spawn);
diff --git a/Projects/Scripts/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs b/Projects/Scripts/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs
index 908c8207e..26bbbabf4 100644
--- a/Projects/Scripts/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs
+++ b/Projects/Scripts/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs
@@ -123,7 +123,7 @@ namespace Server.Items
public virtual void DisplayDurabilityTo(Mobile m)
{
- LabelToAffix(m, 1017323, AffixType.Append, ": " + m_UsesRemaining); // Durability
+ LabelToAffix(m, 1017323, AffixType.Append, $": {m_UsesRemaining}"); // Durability
}
public override void OnSingleClick(Mobile from)
diff --git a/Projects/Scripts/Items/Skill Items/Magical/Misc/PotionKeg.cs b/Projects/Scripts/Items/Skill Items/Magical/Misc/PotionKeg.cs
index 9bef5d574..47957d5ad 100644
--- a/Projects/Scripts/Items/Skill Items/Magical/Misc/PotionKeg.cs
+++ b/Projects/Scripts/Items/Skill Items/Magical/Misc/PotionKeg.cs
@@ -295,43 +295,34 @@ namespace Server.Items
public BasePotion FillBottle()
{
- switch (m_Type)
+ return m_Type switch
{
- default:
- case PotionEffect.Nightsight: return new NightSightPotion();
-
- case PotionEffect.CureLesser: return new LesserCurePotion();
- case PotionEffect.Cure: return new CurePotion();
- case PotionEffect.CureGreater: return new GreaterCurePotion();
-
- case PotionEffect.Agility: return new AgilityPotion();
- case PotionEffect.AgilityGreater: return new GreaterAgilityPotion();
-
- case PotionEffect.Strength: return new StrengthPotion();
- case PotionEffect.StrengthGreater: return new GreaterStrengthPotion();
-
- case PotionEffect.PoisonLesser: return new LesserPoisonPotion();
- case PotionEffect.Poison: return new PoisonPotion();
- case PotionEffect.PoisonGreater: return new GreaterPoisonPotion();
- case PotionEffect.PoisonDeadly: return new DeadlyPoisonPotion();
-
- case PotionEffect.Refresh: return new RefreshPotion();
- case PotionEffect.RefreshTotal: return new TotalRefreshPotion();
-
- case PotionEffect.HealLesser: return new LesserHealPotion();
- case PotionEffect.Heal: return new HealPotion();
- case PotionEffect.HealGreater: return new GreaterHealPotion();
-
- case PotionEffect.ExplosionLesser: return new LesserExplosionPotion();
- case PotionEffect.Explosion: return new ExplosionPotion();
- case PotionEffect.ExplosionGreater: return new GreaterExplosionPotion();
-
- case PotionEffect.Conflagration: return new ConflagrationPotion();
- case PotionEffect.ConflagrationGreater: return new GreaterConflagrationPotion();
-
- case PotionEffect.ConfusionBlast: return new ConfusionBlastPotion();
- case PotionEffect.ConfusionBlastGreater: return new GreaterConfusionBlastPotion();
- }
+ PotionEffect.Nightsight => (BasePotion)new NightSightPotion(),
+ PotionEffect.CureLesser => new LesserCurePotion(),
+ PotionEffect.Cure => new CurePotion(),
+ PotionEffect.CureGreater => new GreaterCurePotion(),
+ PotionEffect.Agility => new AgilityPotion(),
+ PotionEffect.AgilityGreater => new GreaterAgilityPotion(),
+ PotionEffect.Strength => new StrengthPotion(),
+ PotionEffect.StrengthGreater => new GreaterStrengthPotion(),
+ PotionEffect.PoisonLesser => new LesserPoisonPotion(),
+ PotionEffect.Poison => new PoisonPotion(),
+ PotionEffect.PoisonGreater => new GreaterPoisonPotion(),
+ PotionEffect.PoisonDeadly => new DeadlyPoisonPotion(),
+ PotionEffect.Refresh => new RefreshPotion(),
+ PotionEffect.RefreshTotal => new TotalRefreshPotion(),
+ PotionEffect.HealLesser => new LesserHealPotion(),
+ PotionEffect.Heal => new HealPotion(),
+ PotionEffect.HealGreater => new GreaterHealPotion(),
+ PotionEffect.ExplosionLesser => new LesserExplosionPotion(),
+ PotionEffect.Explosion => new ExplosionPotion(),
+ PotionEffect.ExplosionGreater => new GreaterExplosionPotion(),
+ PotionEffect.Conflagration => new ConflagrationPotion(),
+ PotionEffect.ConflagrationGreater => new GreaterConflagrationPotion(),
+ PotionEffect.ConfusionBlast => new ConfusionBlastPotion(),
+ PotionEffect.ConfusionBlastGreater => new GreaterConfusionBlastPotion(),
+ _ => new NightSightPotion()
+ };
}
public static void Initialize()
diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs
index 42bf8fd11..228286c26 100644
--- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs
+++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs
@@ -22,7 +22,7 @@ namespace Server.Items
public override void Drink(Mobile from)
{
- if (Core.AOS && (from.Paralyzed || from.Frozen || from.Spell != null && from.Spell.IsCasting))
+ if (Core.AOS && (from.Paralyzed || from.Frozen || from.Spell?.IsCasting == true))
{
from.SendLocalizedMessage(1062725); // You can not use that potion while paralyzed.
return;
@@ -251,7 +251,6 @@ namespace Server.Items
return;
foreach (Mobile m in m_Item.GetMobilesInRange(0))
- {
if (m.Z + 16 > m_Item.Z && m_Item.Z + 12 > m.Z && (!Core.AOS || m != from) &&
SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false))
{
@@ -260,7 +259,6 @@ namespace Server.Items
AOS.Damage(m, from, m_Item.GetDamage(), 0, 100, 0, 0, 0);
m.PlaySound(0x208);
}
- }
}
}
}
diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs
index 87dab3ec9..86e78abed 100644
--- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs
+++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs
@@ -23,7 +23,7 @@ namespace Server.Items
public override void Drink(Mobile from)
{
- if (Core.AOS && (from.Paralyzed || from.Frozen || from.Spell != null && from.Spell.IsCasting))
+ if (Core.AOS && (from.Paralyzed || from.Frozen || from.Spell?.IsCasting == true))
{
from.SendLocalizedMessage(1062725); // You can not use that potion while paralyzed.
return;
diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs
index e4d0a5341..84957e0fb 100644
--- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs
+++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs
@@ -62,7 +62,7 @@ namespace Server.Items
public override void Drink(Mobile from)
{
- if (Core.AOS && (from.Paralyzed || from.Frozen || from.Spell != null && from.Spell.IsCasting))
+ if (Core.AOS && (from.Paralyzed || from.Frozen || from.Spell?.IsCasting == true))
{
from.SendLocalizedMessage(1062725); // You can not use a purple potion while paralyzed.
return;
diff --git a/Projects/Scripts/Items/Skill Items/Magical/Spellbook.cs b/Projects/Scripts/Items/Skill Items/Magical/Spellbook.cs
index a55c16924..ca99ee343 100644
--- a/Projects/Scripts/Items/Skill Items/Magical/Spellbook.cs
+++ b/Projects/Scripts/Items/Skill Items/Magical/Spellbook.cs
@@ -284,33 +284,17 @@ namespace Server.Items
if (!DesignContext.Check(from))
return; // They are customizing
- SpellbookType type;
-
- switch (e.Type)
+ var type = e.Type switch
{
- default:
- case 1:
- type = SpellbookType.Regular;
- break;
- case 2:
- type = SpellbookType.Necromancer;
- break;
- case 3:
- type = SpellbookType.Paladin;
- break;
- case 4:
- type = SpellbookType.Ninja;
- break;
- case 5:
- type = SpellbookType.Samurai;
- break;
- case 6:
- type = SpellbookType.Arcanist;
- break;
- case 7:
- type = SpellbookType.Mystic;
- break;
- }
+ 1 => SpellbookType.Regular,
+ 2 => SpellbookType.Necromancer,
+ 3 => SpellbookType.Paladin,
+ 4 => SpellbookType.Ninja,
+ 5 => SpellbookType.Samurai,
+ 6 => SpellbookType.Arcanist,
+ 7 => SpellbookType.Mystic,
+ _ => SpellbookType.Regular
+ };
Spellbook book = Find(from, -1, type);
@@ -453,10 +437,8 @@ namespace Server.Items
Container pack = from.Backpack;
for (int i = 0; i < pack?.Items.Count; ++i)
- {
if (pack.Items[i] is Spellbook sp)
list.Add(sp);
- }
return list;
}
@@ -541,13 +523,13 @@ namespace Server.Items
string modName = Serial.ToString();
if (strBonus != 0)
- from.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero));
+ from.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero));
if (dexBonus != 0)
- from.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero));
+ from.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero));
if (intBonus != 0)
- from.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero));
+ from.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero));
}
from.CheckStatTimers();
@@ -562,9 +544,9 @@ namespace Server.Items
string modName = Serial.ToString();
- from.RemoveStatMod(modName + "Str");
- from.RemoveStatMod(modName + "Dex");
- from.RemoveStatMod(modName + "Int");
+ from.RemoveStatMod($"{modName}Str");
+ from.RemoveStatMod($"{modName}Dex");
+ from.RemoveStatMod($"{modName}Int");
from.CheckStatTimers();
}
@@ -574,7 +556,7 @@ namespace Server.Items
{
spellID -= BookOffset;
- return spellID >= 0 && spellID < BookCount && (m_Content & ((ulong)1 << spellID)) != 0;
+ return spellID >= 0 && spellID < BookCount && (m_Content & (ulong)1 << spellID) != 0;
}
public void DisplayTo(Mobile to)
@@ -848,13 +830,13 @@ namespace Server.Items
string modName = Serial.ToString();
if (strBonus != 0)
- m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero));
+ m.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero));
if (dexBonus != 0)
- m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero));
+ m.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero));
if (intBonus != 0)
- m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero));
+ m.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero));
}
m.CheckStatTimers();
diff --git a/Projects/Scripts/Items/Skill Items/Misc/Bandage.cs b/Projects/Scripts/Items/Skill Items/Misc/Bandage.cs
index 831f1734f..752c68f87 100644
--- a/Projects/Scripts/Items/Skill Items/Misc/Bandage.cs
+++ b/Projects/Scripts/Items/Skill Items/Misc/Bandage.cs
@@ -234,7 +234,7 @@ namespace Server.Items
|| Core.SE && petPatient is FactionWarHorse && petPatient.ControlMaster == Healer
) //TODO: Dbl check doesn't check for faction of the horse here?
{
- if (Patient.Map == null || !Patient.Map.CanFit(Patient.Location, 16, false, false))
+ if (Patient.Map?.CanFit(Patient.Location, 16, false, false) != true)
{
healerNumber = 501042; // Target can not be resurrected at that location.
patientNumber = 502391; // Thou can not be resurrected there!
@@ -442,7 +442,7 @@ namespace Server.Items
{
healer.SendLocalizedMessage(500955); // That being is not damaged!
}
- else if (!patient.Alive && (patient.Map == null || !patient.Map.CanFit(patient.Location, 16, false, false)))
+ else if (!patient.Alive && patient.Map?.CanFit(patient.Location, 16, false, false) != true)
{
healer.SendLocalizedMessage(501042); // Target cannot be resurrected at that location.
}
diff --git a/Projects/Scripts/Items/Skill Items/Misc/RepairDeed.cs b/Projects/Scripts/Items/Skill Items/Misc/RepairDeed.cs
index 3cd3ef76e..f6e6d8641 100644
--- a/Projects/Scripts/Items/Skill Items/Misc/RepairDeed.cs
+++ b/Projects/Scripts/Items/Skill Items/Misc/RepairDeed.cs
@@ -118,15 +118,12 @@ namespace Server.Items
if (skill >= 5)
return 1061123 + skill - 5;
- switch (skill)
+ return skill switch
{
- case 4:
- return "a Novice";
- case 3:
- return "a Neophyte";
- default:
- return "a Newbie"; //On OSI, it shouldn't go below 50, but, this is for 'custom' support.
- }
+ 4 => "a Novice",
+ 3 => "a Neophyte",
+ _ => "a Newbie"
+ };
}
public static RepairSkillType GetTypeFor(CraftSystem s)
diff --git a/Projects/Scripts/Items/Skill Items/Tools/BaseTool.cs b/Projects/Scripts/Items/Skill Items/Tools/BaseTool.cs
index d8a6a2d46..520d48c6f 100644
--- a/Projects/Scripts/Items/Skill Items/Tools/BaseTool.cs
+++ b/Projects/Scripts/Items/Skill Items/Tools/BaseTool.cs
@@ -128,7 +128,7 @@ namespace Server.Items
public virtual void DisplayDurabilityTo(Mobile m)
{
- LabelToAffix(m, 1017323, AffixType.Append, ": " + m_UsesRemaining); // Durability
+ LabelToAffix(m, 1017323, AffixType.Append, $": {m_UsesRemaining}"); // Durability
}
public static bool CheckAccessible(Item tool, Mobile m) => tool.IsChildOf(m) || tool.Parent == m;
diff --git a/Projects/Scripts/Items/Special/11th Year promo/EarringsOfProtection.cs b/Projects/Scripts/Items/Special/11th Year promo/EarringsOfProtection.cs
index 388f3686f..f5a3d2aa8 100644
--- a/Projects/Scripts/Items/Special/11th Year promo/EarringsOfProtection.cs
+++ b/Projects/Scripts/Items/Special/11th Year promo/EarringsOfProtection.cs
@@ -83,28 +83,27 @@
public static AosElementAttribute GetTypes(int value)
{
- switch (value)
+ return value switch
{
- case 0: return AosElementAttribute.Physical;
- case 1: return AosElementAttribute.Fire;
- case 2: return AosElementAttribute.Cold;
- case 3: return AosElementAttribute.Poison;
- default: return AosElementAttribute.Energy;
- }
+ 0 => AosElementAttribute.Physical,
+ 1 => AosElementAttribute.Fire,
+ 2 => AosElementAttribute.Cold,
+ 3 => AosElementAttribute.Poison,
+ _ => AosElementAttribute.Energy
+ };
}
public static int GetItemData(AosElementAttribute element, bool label)
{
- switch (element)
+ return element switch
{
- case AosElementAttribute.Physical: return label ? 1071091 : 0; // Earring of Protection (Physical) 1071091
- case AosElementAttribute.Fire: return label ? 1071092 : 0x4ec; // Earring of Protection (Fire) 1071092
- case AosElementAttribute.Cold: return label ? 1071093 : 0x4f2; // Earring of Protection (Cold) 1071093
- case AosElementAttribute.Poison: return label ? 1071094 : 0x4f8; // Earring of Protection (Poison) 1071094
- case AosElementAttribute.Energy: return label ? 1071095 : 0x4fe; // Earring of Protection (Energy) 1071095
-
- default: return -1;
- }
+ AosElementAttribute.Physical => (label ? 1071091 : 0), // Earring of Protection (Physical) 1071091
+ AosElementAttribute.Fire => (label ? 1071092 : 0x4ec), // Earring of Protection (Fire) 1071092
+ AosElementAttribute.Cold => (label ? 1071093 : 0x4f2), // Earring of Protection (Cold) 1071093
+ AosElementAttribute.Poison => (label ? 1071094 : 0x4f8), // Earring of Protection (Poison) 1071094
+ AosElementAttribute.Energy => (label ? 1071095 : 0x4fe), // Earring of Protection (Energy) 1071095
+ _ => -1
+ };
}
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs b/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs
index a5e75ee43..e5d2fcfb0 100644
--- a/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs
+++ b/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs
@@ -294,21 +294,13 @@ namespace Server.Items
public static MusicName RandomTrack(DawnsMusicRarity rarity)
{
- MusicName[] list;
-
- switch (rarity)
+ var list = rarity switch
{
- default:
- case DawnsMusicRarity.Common:
- list = m_CommonTracks;
- break;
- case DawnsMusicRarity.Uncommon:
- list = m_UncommonTracks;
- break;
- case DawnsMusicRarity.Rare:
- list = m_RareTracks;
- break;
- }
+ DawnsMusicRarity.Common => m_CommonTracks,
+ DawnsMusicRarity.Uncommon => m_UncommonTracks,
+ DawnsMusicRarity.Rare => m_RareTracks,
+ _ => m_CommonTracks
+ };
return list[Utility.Random(list.Length)];
}
diff --git a/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs b/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs
index 9bc48dcf4..41aafd951 100644
--- a/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs
+++ b/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs
@@ -71,7 +71,7 @@ namespace Server.Items
public virtual void DisplayDurabilityTo(Mobile m)
{
- LabelToAffix(m, 1017323, AffixType.Append, ": " + m_UsesRemaining); // Durability
+ LabelToAffix(m, 1017323, AffixType.Append, $": {m_UsesRemaining}"); // Durability
}
public override void OnSingleClick(Mobile from)
diff --git a/Projects/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs b/Projects/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs
index dc8fbe79e..66526ce98 100644
--- a/Projects/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs
+++ b/Projects/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs
@@ -74,7 +74,7 @@ namespace Server.Items
Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x53E, 0x540));
}
- if (m_Timer == null || !m_Timer.Running)
+ if (m_Timer?.Running != true)
(m_Timer = new InternalTimer(m)).Start();
}
diff --git a/Projects/Scripts/Items/Special/Heritage Items/WallTorch.cs b/Projects/Scripts/Items/Special/Heritage Items/WallTorch.cs
index 779769a63..5a5b5c96c 100644
--- a/Projects/Scripts/Items/Special/Heritage Items/WallTorch.cs
+++ b/Projects/Scripts/Items/Special/Heritage Items/WallTorch.cs
@@ -19,21 +19,14 @@ namespace Server.Items
{
if (from.InRange(Location, 2))
{
- switch (ItemID)
+ ItemID = ItemID switch
{
- case 0x3D98:
- ItemID = 0x3D9B;
- break;
- case 0x3D9B:
- ItemID = 0x3D98;
- break;
- case 0x3D94:
- ItemID = 0x3D97;
- break;
- case 0x3D97:
- ItemID = 0x3D94;
- break;
- }
+ 0x3D98 => 0x3D9B,
+ 0x3D9B => 0x3D98,
+ 0x3D94 => 0x3D97,
+ 0x3D97 => 0x3D94,
+ _ => ItemID
+ };
Effects.PlaySound(Location, Map, 0x3BE);
}
diff --git a/Projects/Scripts/Items/Special/Holiday/Wreath.cs b/Projects/Scripts/Items/Special/Holiday/Wreath.cs
index 1cc64e9bc..b724f9cc5 100644
--- a/Projects/Scripts/Items/Special/Holiday/Wreath.cs
+++ b/Projects/Scripts/Items/Special/Holiday/Wreath.cs
@@ -247,7 +247,7 @@ namespace Server.Items
BaseHouse house = BaseHouse.FindHouseAt(loc, from.Map, 16);
- if (house == null || !house.IsCoOwner(from))
+ if (house?.IsCoOwner(from) != true)
{
from.SendLocalizedMessage(1042036); // That location is not in your house.
return;
diff --git a/Projects/Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs b/Projects/Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs
index 52a3b6a62..899830459 100644
--- a/Projects/Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs
+++ b/Projects/Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs
@@ -187,24 +187,14 @@ namespace Server.Items
return string.Empty;
if (deed.IsExpired)
- return "" +
- "This deed once entitled the bearer to build a house on the plot of land " +
- $"located at {HouseRaffleStone.FormatLocation(deed.PlotLocation, deed.PlotFacet, false)} on the {deed.PlotFacet} facet.
" +
- "The deed has expired, and now the indicated plot of land " +
- "is subject to normal house construction rules.
" +
- "This deed functions as a recall rune marked for the location of the plot it represents." +
- "";
+ return
+ $"This deed once entitled the bearer to build a house on the plot of land located at {HouseRaffleStone.FormatLocation(deed.PlotLocation, deed.PlotFacet, false)} on the {deed.PlotFacet} facet.
The deed has expired, and now the indicated plot of land is subject to normal house construction rules.
This deed functions as a recall rune marked for the location of the plot it represents.";
int daysLeft = (int)Math.Ceiling((deed.Stone.Started + deed.Stone.Duration +
HouseRaffleStone.ExpirationTime - DateTime.UtcNow).TotalDays);
- return "" + "This deed entitles the bearer to build a house on the plot of land " +
- $"located at {HouseRaffleStone.FormatLocation(deed.PlotLocation, deed.PlotFacet, false)} on the {deed.PlotFacet} facet.
" +
- $"The deed will expire after {daysLeft} more day{(daysLeft == 1 ? "" : "s")} have passed, and at that time the right to place " +
- "a house reverts to normal house construction rules.
" +
- "This deed functions as a recall rune marked for the location of the plot it represents.
" +
- "To place a house on the deeded plot, you must simply have this deed in your backpack " +
- "or bank box when using a House Placement Tool there." + "";
+ return
+ $"This deed entitles the bearer to build a house on the plot of land located at {HouseRaffleStone.FormatLocation(deed.PlotLocation, deed.PlotFacet, false)} on the {deed.PlotFacet} facet.
The deed will expire after {daysLeft} more day{(daysLeft == 1 ? "" : "s")} have passed, and at that time the right to place a house reverts to normal house construction rules.
This deed functions as a recall rune marked for the location of the plot it represents.
To place a house on the deeded plot, you must simply have this deed in your backpack or bank box when using a House Placement Tool there.";
}
}
}
diff --git a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastBackpack.cs b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastBackpack.cs
index 06ffeb582..7c0607f8c 100644
--- a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastBackpack.cs
+++ b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastBackpack.cs
@@ -81,19 +81,13 @@ namespace Server.Items
if (i == 5)
random = 0;
- switch (random)
+ organ = random switch
{
- default:
- case 0:
- organ = new PlagueBeastRockOrgan();
- break;
- case 1:
- organ = new PlagueBeastMaidenOrgan();
- break;
- case 2:
- organ = new PlagueBeastRubbleOrgan();
- break;
- }
+ 0 => (PlagueBeastOrgan)new PlagueBeastRockOrgan(),
+ 1 => new PlagueBeastMaidenOrgan(),
+ 2 => new PlagueBeastRubbleOrgan(),
+ _ => new PlagueBeastRockOrgan()
+ };
organs.Add(organ);
AddInnard(organ, m_Positions[random, i, 0], m_Positions[random, i, 1]);
diff --git a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastInnard.cs b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastInnard.cs
index 217c474cc..663098772 100644
--- a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastInnard.cs
+++ b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastInnard.cs
@@ -63,7 +63,7 @@ namespace Server.Items
PlagueBeastLord owner = Owner;
- if (owner == null || !owner.Alive)
+ if (owner?.Alive != true)
Delete();
}
}
diff --git a/Projects/Scripts/Items/Special/Solen Items/BagOfSending.cs b/Projects/Scripts/Items/Special/Solen Items/BagOfSending.cs
index 612b9cb5f..33832fb3d 100644
--- a/Projects/Scripts/Items/Special/Solen Items/BagOfSending.cs
+++ b/Projects/Scripts/Items/Special/Solen Items/BagOfSending.cs
@@ -52,18 +52,13 @@ namespace Server.Items
{
m_BagOfSendingHue = value;
- switch (value)
+ Hue = value switch
{
- case BagOfSendingHue.Yellow:
- Hue = 0x8A5;
- break;
- case BagOfSendingHue.Blue:
- Hue = 0x8AD;
- break;
- case BagOfSendingHue.Red:
- Hue = 0x89B;
- break;
- }
+ BagOfSendingHue.Yellow => 0x8A5,
+ BagOfSendingHue.Blue => 0x8AD,
+ BagOfSendingHue.Red => 0x89B,
+ _ => Hue
+ };
}
}
@@ -111,12 +106,12 @@ namespace Server.Items
public static BagOfSendingHue RandomHue()
{
- switch (Utility.Random(3))
+ return Utility.Random(3) switch
{
- case 0: return BagOfSendingHue.Yellow;
- case 1: return BagOfSendingHue.Blue;
- default: return BagOfSendingHue.Red;
- }
+ 0 => BagOfSendingHue.Yellow,
+ 1 => BagOfSendingHue.Blue,
+ _ => BagOfSendingHue.Red
+ };
}
public override void GetProperties(ObjectPropertyList list)
diff --git a/Projects/Scripts/Items/Special/Solen Items/BallOfSummoning.cs b/Projects/Scripts/Items/Special/Solen Items/BallOfSummoning.cs
index e807a7fed..24a0bee0e 100644
--- a/Projects/Scripts/Items/Special/Solen Items/BallOfSummoning.cs
+++ b/Projects/Scripts/Items/Special/Solen Items/BallOfSummoning.cs
@@ -102,7 +102,7 @@ namespace Server.Items
list.Add(1054131,
m_Charges + (PetName.Length == 0
? "\t "
- : "\t" + PetName)); // a crystal ball of pet summoning: [charges: ~1_charges~] : [linked pet: ~2_petName~]
+ : $"\t{PetName}")); // a crystal ball of pet summoning: [charges: ~1_charges~] : [linked pet: ~2_petName~]
}
public override void OnSingleClick(Mobile from)
@@ -110,7 +110,7 @@ namespace Server.Items
LabelTo(from, 1054131,
m_Charges + (PetName.Length == 0
? "\t "
- : "\t" + PetName)); // a crystal ball of pet summoning: [charges: ~1_charges~] : [linked pet: ~2_petName~]
+ : $"\t{PetName}")); // a crystal ball of pet summoning: [charges: ~1_charges~] : [linked pet: ~2_petName~]
}
public override void GetContextMenuEntries(Mobile from, List list)
diff --git a/Projects/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs b/Projects/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs
index e24e2907b..4417b9b8e 100644
--- a/Projects/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs
+++ b/Projects/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs
@@ -104,7 +104,7 @@ namespace Server.Items
list.Add(1054000,
m_Charges + (m_Inscription.Length == 0
? "\t "
- : " :\t" + m_Inscription)); // a bracelet of binding : ~1_val~ ~2_val~
+ : $" :\t{m_Inscription}")); // a bracelet of binding : ~1_val~ ~2_val~
}
public override void OnSingleClick(Mobile from)
@@ -112,7 +112,7 @@ namespace Server.Items
LabelTo(from, 1054000,
m_Charges + (m_Inscription.Length == 0
? "\t "
- : " :\t" + m_Inscription)); // a bracelet of binding : ~1_val~ ~2_val~
+ : $" :\t{m_Inscription}")); // a bracelet of binding : ~1_val~ ~2_val~
}
public override void GetContextMenuEntries(Mobile from, List list)
diff --git a/Projects/Scripts/Items/Special/SoulStone.cs b/Projects/Scripts/Items/Special/SoulStone.cs
index 786d8055f..ea64d856e 100644
--- a/Projects/Scripts/Items/Special/SoulStone.cs
+++ b/Projects/Scripts/Items/Special/SoulStone.cs
@@ -192,7 +192,7 @@ namespace Server.Items
return false;
}
- if (from.Spell != null && from.Spell.IsCasting)
+ if (from.Spell?.IsCasting == true)
{
from.SendLocalizedMessage(1070733); // You may not use a Soulstone while your character is casting a spell.
return false;
@@ -914,21 +914,14 @@ namespace Server.Items
public void Flip()
{
- switch (ItemID)
+ ItemID = ItemID switch
{
- case 0x2ADC:
- ItemID = 0x2AEC;
- break;
- case 0x2ADD:
- ItemID = 0x2AED;
- break;
- case 0x2AEC:
- ItemID = 0x2ADC;
- break;
- case 0x2AED:
- ItemID = 0x2ADD;
- break;
- }
+ 0x2ADC => 0x2AEC,
+ 0x2ADD => 0x2AED,
+ 0x2AEC => 0x2ADC,
+ 0x2AED => 0x2ADD,
+ _ => ItemID
+ };
}
public override void Serialize(GenericWriter writer)
diff --git a/Projects/Scripts/Items/Special/Special Scrolls/ScrollofAlacrity.cs b/Projects/Scripts/Items/Special/Special Scrolls/ScrollofAlacrity.cs
index 710d2764a..1728e261d 100644
--- a/Projects/Scripts/Items/Special/Special Scrolls/ScrollofAlacrity.cs
+++ b/Projects/Scripts/Items/Special/Special Scrolls/ScrollofAlacrity.cs
@@ -43,20 +43,15 @@ namespace Server.Items
MLQuestContext context = MLQuestSystem.GetContext(pm);
if (context != null)
- {
foreach (MLQuestInstance instance in context.QuestInstances)
- {
- foreach (BaseObjectiveInstance objective in instance.Objectives)
+ foreach (BaseObjectiveInstance objective in instance.Objectives)
+ if (!objective.Expired && objective is GainSkillObjectiveInstance objectiveInstance &&
+ objectiveInstance.Handles(Skill))
{
- if (!objective.Expired && objective is GainSkillObjectiveInstance objectiveInstance &&
- objectiveInstance.Handles(Skill))
- {
- from.SendMessage("You are already under the effect of an enhanced skillgain quest.");
- return false;
- }
+ from.SendMessage("You are already under the effect of an enhanced skillgain quest.");
+ return false;
}
- }
- }
+
#endregion
if (pm.AcceleratedStart > DateTime.UtcNow)
diff --git a/Projects/Scripts/Items/Special/Special Scrolls/ScrollofTranscendence.cs b/Projects/Scripts/Items/Special/Special Scrolls/ScrollofTranscendence.cs
index 281962fcd..3eeefe93c 100644
--- a/Projects/Scripts/Items/Special/Special Scrolls/ScrollofTranscendence.cs
+++ b/Projects/Scripts/Items/Special/Special Scrolls/ScrollofTranscendence.cs
@@ -54,20 +54,15 @@ namespace Server.Items
MLQuestContext context = MLQuestSystem.GetContext(pm);
if (context != null)
- {
foreach (MLQuestInstance instance in context.QuestInstances)
- {
- foreach (BaseObjectiveInstance objective in instance.Objectives)
+ foreach (BaseObjectiveInstance objective in instance.Objectives)
+ if (!objective.Expired && objective is GainSkillObjectiveInstance objectiveInstance &&
+ objectiveInstance.Handles(Skill))
{
- if (!objective.Expired && objective is GainSkillObjectiveInstance objectiveInstance &&
- objectiveInstance.Handles(Skill))
- {
- from.SendMessage("You are already under the effect of an enhanced skillgain quest.");
- return false;
- }
+ from.SendMessage("You are already under the effect of an enhanced skillgain quest.");
+ return false;
}
- }
- }
+
#endregion
if (pm.AcceleratedStart > DateTime.UtcNow)
diff --git a/Projects/Scripts/Items/Special/Special Scrolls/SpecialScroll.cs b/Projects/Scripts/Items/Special/Special Scrolls/SpecialScroll.cs
index 374b46a0e..40fefa434 100644
--- a/Projects/Scripts/Items/Special/Special Scrolls/SpecialScroll.cs
+++ b/Projects/Scripts/Items/Special/Special Scrolls/SpecialScroll.cs
@@ -36,7 +36,7 @@ namespace Server.Items
[CommandProperty(AccessLevel.GameMaster)]
public double Value{ get; set; }
- public virtual string GetNameLocalized() => string.Concat("#", AosSkillBonuses.GetLabel(Skill).ToString());
+ public virtual string GetNameLocalized() => $"#{AosSkillBonuses.GetLabel(Skill)}";
public virtual string GetName()
{
diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs b/Projects/Scripts/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs
index a15105637..4d81265d3 100644
--- a/Projects/Scripts/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs
+++ b/Projects/Scripts/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs
@@ -284,15 +284,12 @@ namespace Server.Items
public void OnOptionSelected(Mobile from, int option)
{
- switch (option)
+ m_East = option switch
{
- case 1:
- m_East = false;
- break;
- case 2:
- m_East = true;
- break;
- }
+ 1 => false,
+ 2 => true,
+ _ => m_East
+ };
if (!Deleted)
base.OnDoubleClick(from);
diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/Banner.cs b/Projects/Scripts/Items/Special/Veteran Rewards/Banner.cs
index 29463fe73..899f29c3c 100644
--- a/Projects/Scripts/Items/Special/Veteran Rewards/Banner.cs
+++ b/Projects/Scripts/Items/Special/Veteran Rewards/Banner.cs
@@ -38,7 +38,7 @@ namespace Server.Items
public bool CouldFit(IPoint3D p, Map map)
{
- if (map == null || !map.CanFit(p.X, p.Y, p.Z, ItemData.Height))
+ if (map?.CanFit(p.X, p.Y, p.Z, ItemData.Height) != true)
return false;
if (FacingSouth)
diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/Cannon.cs b/Projects/Scripts/Items/Special/Veteran Rewards/Cannon.cs
index a39989919..3c7c68035 100644
--- a/Projects/Scripts/Items/Special/Veteran Rewards/Cannon.cs
+++ b/Projects/Scripts/Items/Special/Veteran Rewards/Cannon.cs
@@ -175,17 +175,13 @@ namespace Server.Items
if (keg?.Deleted != false || keg.Held != 100)
return 0;
- switch (keg.Type)
+ return keg.Type switch
{
- case PotionEffect.ExplosionLesser:
- return 5;
- case PotionEffect.Explosion:
- return 10;
- case PotionEffect.ExplosionGreater:
- return 15;
- default:
- return 0;
- }
+ PotionEffect.ExplosionLesser => 5,
+ PotionEffect.Explosion => 10,
+ PotionEffect.ExplosionGreater => 15,
+ _ => 0
+ };
}
public void Fill(Mobile from, PotionKeg keg)
diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs b/Projects/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs
index 27347c66d..e9d4e05a5 100644
--- a/Projects/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs
+++ b/Projects/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs
@@ -179,14 +179,14 @@ namespace Server.Items
public static int GetWestItemID(int east)
{
- switch (east)
+ return east switch
{
- case 0x1582: return 0x1635;
- case 0x1583: return 0x1634;
- case 0x1584: return 0x1637;
- case 0x1585: return 0x1636;
- default: return east + 1;
- }
+ 0x1582 => 0x1635,
+ 0x1583 => 0x1634,
+ 0x1584 => 0x1637,
+ 0x1585 => 0x1636,
+ _ => (east + 1)
+ };
}
private class InternalGump : Gump
diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/FlamingHead.cs b/Projects/Scripts/Items/Special/Veteran Rewards/FlamingHead.cs
index 61a2bf149..bd6d280ec 100644
--- a/Projects/Scripts/Items/Special/Veteran Rewards/FlamingHead.cs
+++ b/Projects/Scripts/Items/Special/Veteran Rewards/FlamingHead.cs
@@ -38,7 +38,7 @@ namespace Server.Items
public bool CouldFit(IPoint3D p, Map map)
{
- if (map == null || !map.CanFit(p.X, p.Y, p.Z, ItemData.Height))
+ if (map?.CanFit(p.X, p.Y, p.Z, ItemData.Height) != true)
return false;
if (Type == StoneFaceTrapType.NorthWestWall)
diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs b/Projects/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs
index 53ec046e0..2c96c32fa 100644
--- a/Projects/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs
+++ b/Projects/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs
@@ -48,7 +48,7 @@ namespace Server.Items
public bool CouldFit(IPoint3D p, Map map)
{
- if (map == null || !map.CanFit(p.X, p.Y, p.Z, ItemData.Height))
+ if (map?.CanFit(p.X, p.Y, p.Z, ItemData.Height) != true)
return false;
if (FacingSouth)
@@ -198,12 +198,12 @@ namespace Server.Items
public static int GetWestItemID(int south)
{
- switch (south)
+ return south switch
{
- case 0x1B1E: return 0x1B1D;
- case 0x1B7F: return 0x1B7C;
- default: return south + 1;
- }
+ 0x1B1E => 0x1B1D,
+ 0x1B7F => 0x1B7C,
+ _ => (south + 1)
+ };
}
private class InternalGump : Gump
diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/MiningCart.cs b/Projects/Scripts/Items/Special/Veteran Rewards/MiningCart.cs
index e3c3b4926..b2ad8b81a 100644
--- a/Projects/Scripts/Items/Special/Veteran Rewards/MiningCart.cs
+++ b/Projects/Scripts/Items/Special/Veteran Rewards/MiningCart.cs
@@ -146,38 +146,19 @@ namespace Server.Items
case MiningCartType.OreEast:
if (Ore > 0)
{
- Item ingots = null;
-
- switch (Utility.Random(9))
+ var ingots = Utility.Random(9) switch
{
- case 0:
- ingots = new IronIngot();
- break;
- case 1:
- ingots = new DullCopperIngot();
- break;
- case 2:
- ingots = new ShadowIronIngot();
- break;
- case 3:
- ingots = new CopperIngot();
- break;
- case 4:
- ingots = new BronzeIngot();
- break;
- case 5:
- ingots = new GoldIngot();
- break;
- case 6:
- ingots = new AgapiteIngot();
- break;
- case 7:
- ingots = new VeriteIngot();
- break;
- case 8:
- ingots = new ValoriteIngot();
- break;
- }
+ 0 => (Item)new IronIngot(),
+ 1 => new DullCopperIngot(),
+ 2 => new ShadowIronIngot(),
+ 3 => new CopperIngot(),
+ 4 => new BronzeIngot(),
+ 5 => new GoldIngot(),
+ 6 => new AgapiteIngot(),
+ 7 => new VeriteIngot(),
+ 8 => new ValoriteIngot(),
+ _ => null
+ };
int amount = Math.Min(10, Ore);
ingots.Amount = amount;
@@ -203,58 +184,26 @@ namespace Server.Items
case MiningCartType.GemEast:
if (Gems > 0)
{
- Item gems = null;
-
- switch (Utility.Random(15))
+ var gems = Utility.Random(15) switch
{
- case 0:
- gems = new Amber();
- break;
- case 1:
- gems = new Amethyst();
- break;
- case 2:
- gems = new Citrine();
- break;
- case 3:
- gems = new Diamond();
- break;
- case 4:
- gems = new Emerald();
- break;
- case 5:
- gems = new Ruby();
- break;
- case 6:
- gems = new Sapphire();
- break;
- case 7:
- gems = new StarSapphire();
- break;
- case 8:
- gems = new Tourmaline();
- break;
-
+ 0 => (Item)new Amber(),
+ 1 => new Amethyst(),
+ 2 => new Citrine(),
+ 3 => new Diamond(),
+ 4 => new Emerald(),
+ 5 => new Ruby(),
+ 6 => new Sapphire(),
+ 7 => new StarSapphire(),
+ 8 => new Tourmaline(),
// Mondain's Legacy gems
- case 9:
- gems = new PerfectEmerald();
- break;
- case 10:
- gems = new DarkSapphire();
- break;
- case 11:
- gems = new Turquoise();
- break;
- case 12:
- gems = new EcruCitrine();
- break;
- case 13:
- gems = new FireRuby();
- break;
- case 14:
- gems = new BlueDiamond();
- break;
- }
+ 9 => new PerfectEmerald(),
+ 10 => new DarkSapphire(),
+ 11 => new Turquoise(),
+ 12 => new EcruCitrine(),
+ 13 => new FireRuby(),
+ 14 => new BlueDiamond(),
+ _ => null
+ };
int amount = Math.Min(5, Gems);
gems.Amount = amount;
diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/PottedCactus.cs b/Projects/Scripts/Items/Special/Veteran Rewards/PottedCactus.cs
index d4e317e4b..e2bd0b2a6 100644
--- a/Projects/Scripts/Items/Special/Veteran Rewards/PottedCactus.cs
+++ b/Projects/Scripts/Items/Special/Veteran Rewards/PottedCactus.cs
@@ -48,12 +48,11 @@ namespace Server.Items
int version = reader.ReadEncodedInt();
- switch (version)
+ m_IsRewardItem = version switch
{
- case 1:
- m_IsRewardItem = reader.ReadBool();
- break;
- }
+ 1 => reader.ReadBool(),
+ _ => m_IsRewardItem
+ };
}
}
diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/TreeStump.cs b/Projects/Scripts/Items/Special/Veteran Rewards/TreeStump.cs
index a86615836..c3a7ec765 100644
--- a/Projects/Scripts/Items/Special/Veteran Rewards/TreeStump.cs
+++ b/Projects/Scripts/Items/Special/Veteran Rewards/TreeStump.cs
@@ -96,32 +96,17 @@ namespace Server.Items
{
if (m_Logs > 0)
{
- Item logs = null;
-
- switch (Utility.Random(7))
+ var logs = Utility.Random(7) switch
{
- case 0:
- logs = new Log();
- break;
- case 1:
- logs = new AshLog();
- break;
- case 2:
- logs = new OakLog();
- break;
- case 3:
- logs = new YewLog();
- break;
- case 4:
- logs = new HeartwoodLog();
- break;
- case 5:
- logs = new BloodwoodLog();
- break;
- case 6:
- logs = new FrostwoodLog();
- break;
- }
+ 0 => new Log(),
+ 1 => new AshLog(),
+ 2 => new OakLog(),
+ 3 => new YewLog(),
+ 4 => new HeartwoodLog(),
+ 5 => new BloodwoodLog(),
+ 6 => new FrostwoodLog(),
+ _ => null
+ };
int amount = Math.Min(10, m_Logs);
logs.Amount = amount;
@@ -242,21 +227,14 @@ namespace Server.Items
public void OnOptionSelected(Mobile from, int option)
{
- switch (option)
+ m_ItemID = option switch
{
- case 1:
- m_ItemID = 0xE56;
- break;
- case 2:
- m_ItemID = 0xE58;
- break;
- case 3:
- m_ItemID = 0xE57;
- break;
- case 4:
- m_ItemID = 0xE59;
- break;
- }
+ 1 => 0xE56,
+ 2 => 0xE58,
+ 3 => 0xE57,
+ 4 => 0xE59,
+ _ => m_ItemID
+ };
if (!Deleted)
base.OnDoubleClick(from);
diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/WeaponEngravingTool.cs b/Projects/Scripts/Items/Special/Veteran Rewards/WeaponEngravingTool.cs
index 1aedb0211..481b6c4c5 100644
--- a/Projects/Scripts/Items/Special/Veteran Rewards/WeaponEngravingTool.cs
+++ b/Projects/Scripts/Items/Special/Veteran Rewards/WeaponEngravingTool.cs
@@ -245,34 +245,34 @@ namespace Server.Items
public override void OnResponse(NetState state, RelayInfo info)
{
- if (m_Tool?.Deleted != false || m_Target?.Deleted != false)
+ if (m_Tool?.Deleted != false || m_Target?.Deleted != false)
return;
- if (info.ButtonID != (int)Buttons.Okay)
- {
- state.Mobile.SendLocalizedMessage(1072363); // The object was not engraved.
- return;
- }
+ if (info.ButtonID != (int)Buttons.Okay)
+ {
+ state.Mobile.SendLocalizedMessage(1072363); // The object was not engraved.
+ return;
+ }
- TextRelay relay = info.GetTextEntry((int)Buttons.Text);
+ TextRelay relay = info.GetTextEntry((int)Buttons.Text);
- if (relay == null)
- return;
+ if (relay == null)
+ return;
- if (string.IsNullOrEmpty(relay.Text))
- {
- m_Target.EngravedText = null;
- state.Mobile.SendLocalizedMessage(1072362); // You remove the engraving from the object.
- }
- else
- {
- m_Target.EngravedText = Utility.FixHtml(relay.Text.Length > 64 ?
- relay.Text.Substring(0, 64) : relay.Text);
- state.Mobile.SendLocalizedMessage(1072361); // You engraved the object.
- m_Target.InvalidateProperties();
- m_Tool.UsesRemaining -= 1;
- m_Tool.InvalidateProperties();
- }
+ if (string.IsNullOrEmpty(relay.Text))
+ {
+ m_Target.EngravedText = null;
+ state.Mobile.SendLocalizedMessage(1072362); // You remove the engraving from the object.
+ }
+ else
+ {
+ m_Target.EngravedText = Utility.FixHtml(relay.Text.Length > 64 ?
+ relay.Text.Substring(0, 64) : relay.Text);
+ state.Mobile.SendLocalizedMessage(1072361); // You engraved the object.
+ m_Target.InvalidateProperties();
+ m_Tool.UsesRemaining -= 1;
+ m_Tool.InvalidateProperties();
+ }
}
private enum Buttons
diff --git a/Projects/Scripts/Items/Talismans/BaseTalisman.cs b/Projects/Scripts/Items/Talismans/BaseTalisman.cs
index 2d6ec4b6a..bcc408f9b 100644
--- a/Projects/Scripts/Items/Talismans/BaseTalisman.cs
+++ b/Projects/Scripts/Items/Talismans/BaseTalisman.cs
@@ -1,5 +1,4 @@
using System;
-using Server.Commands;
using Server.Mobiles;
using Server.Spells.Fifth;
using Server.Spells.First;
@@ -307,7 +306,7 @@ namespace Server.Items
list.Add(1072400,
m_Summoner?.Name ?? "Unknown"); // Talisman of ~1_name~ Summoning
else if (m_Removal != TalismanRemoval.None)
- list.Add(1072389, "#" + (1072000 + (int)m_Removal)); // Talisman of ~1_name~
+ list.Add(1072389, $"#{1072000 + (int)m_Removal}"); // Talisman of ~1_name~
else
base.AddNameProperty(list);
}
@@ -336,11 +335,11 @@ namespace Server.Items
list.Add(1075085); // Requirement: Mondain's Legacy
if (m_Killer?.IsEmpty == false && m_Killer.Amount > 0)
- list.Add(1072388, "{0}\t{1}", m_Killer.Name != null ? m_Killer.Name.ToString() : "Unknown",
+ list.Add(1072388, "{0}\t{1}", m_Killer.Name?.ToString() ?? "Unknown",
m_Killer.Amount); // ~1_NAME~ Killer: +~2_val~%
- if (m_Protection != null && !m_Protection.IsEmpty && m_Protection.Amount > 0)
- list.Add(1072387, "{0}\t{1}", m_Protection.Name != null ? m_Protection.Name.ToString() : "Unknown",
+ if (m_Protection?.IsEmpty == false && m_Protection.Amount > 0)
+ list.Add(1072387, "{0}\t{1}", m_Protection.Name?.ToString() ?? "Unknown",
m_Protection.Amount); // ~1_NAME~ Protection: +~2_val~%
if (m_ExceptionalBonus != 0)
@@ -397,7 +396,7 @@ namespace Server.Items
if ((prop = Attributes.RegenMana) != 0)
list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~
- if ((prop = Attributes.NightSight) != 0)
+ if (Attributes.NightSight != 0)
list.Add(1060441); // night sight
if ((prop = Attributes.ReflectPhysical) != 0)
@@ -409,7 +408,7 @@ namespace Server.Items
if ((prop = Attributes.RegenHits) != 0)
list.Add(1060444, prop.ToString()); // hit point regeneration ~1_val~
- if ((prop = Attributes.SpellChanneling) != 0)
+ if (Attributes.SpellChanneling != 0)
list.Add(1060482); // spell channeling
if ((prop = Attributes.SpellDamage) != 0)
@@ -894,7 +893,7 @@ namespace Server.Items
public virtual void StartTimer()
{
- if (m_Timer == null || !m_Timer.Running)
+ if (m_Timer?.Running != true)
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10), Slice);
}
diff --git a/Projects/Scripts/Items/Traps/GasTrap.cs b/Projects/Scripts/Items/Traps/GasTrap.cs
index 4057251ec..a6950be9c 100644
--- a/Projects/Scripts/Items/Traps/GasTrap.cs
+++ b/Projects/Scripts/Items/Traps/GasTrap.cs
@@ -37,14 +37,13 @@ namespace Server.Items
{
get
{
- switch (ItemID)
+ return ItemID switch
{
- case 0x113C: return GasTrapType.NorthWall;
- case 0x1147: return GasTrapType.WestWall;
- case 0x11A8: return GasTrapType.Floor;
- }
-
- return GasTrapType.WestWall;
+ 0x113C => GasTrapType.NorthWall,
+ 0x1147 => GasTrapType.WestWall,
+ 0x11A8 => GasTrapType.Floor,
+ _ => GasTrapType.WestWall
+ };
}
set => ItemID = GetBaseID(value);
}
@@ -56,14 +55,13 @@ namespace Server.Items
public static int GetBaseID(GasTrapType type)
{
- switch (type)
+ return type switch
{
- case GasTrapType.NorthWall: return 0x113C;
- case GasTrapType.WestWall: return 0x1147;
- case GasTrapType.Floor: return 0x11A8;
- }
-
- return 0;
+ GasTrapType.NorthWall => 0x113C,
+ GasTrapType.WestWall => 0x1147,
+ GasTrapType.Floor => 0x11A8,
+ _ => 0
+ };
}
public override void OnTrigger(Mobile from)
diff --git a/Projects/Scripts/Items/Traps/SawTrap.cs b/Projects/Scripts/Items/Traps/SawTrap.cs
index ca6419dea..7b1de8d2c 100644
--- a/Projects/Scripts/Items/Traps/SawTrap.cs
+++ b/Projects/Scripts/Items/Traps/SawTrap.cs
@@ -28,15 +28,14 @@ namespace Server.Items
{
get
{
- switch (ItemID)
+ return ItemID switch
{
- case 0x1103: return SawTrapType.NorthWall;
- case 0x1116: return SawTrapType.WestWall;
- case 0x11AC: return SawTrapType.NorthFloor;
- case 0x11B1: return SawTrapType.WestFloor;
- }
-
- return SawTrapType.NorthWall;
+ 0x1103 => SawTrapType.NorthWall,
+ 0x1116 => SawTrapType.WestWall,
+ 0x11AC => SawTrapType.NorthFloor,
+ 0x11B1 => SawTrapType.WestFloor,
+ _ => SawTrapType.NorthWall
+ };
}
set => ItemID = GetBaseID(value);
}
@@ -48,15 +47,14 @@ namespace Server.Items
public static int GetBaseID(SawTrapType type)
{
- switch (type)
+ return type switch
{
- case SawTrapType.NorthWall: return 0x1103;
- case SawTrapType.WestWall: return 0x1116;
- case SawTrapType.NorthFloor: return 0x11AC;
- case SawTrapType.WestFloor: return 0x11B1;
- }
-
- return 0;
+ SawTrapType.NorthWall => 0x1103,
+ SawTrapType.WestWall => 0x1116,
+ SawTrapType.NorthFloor => 0x11AC,
+ SawTrapType.WestFloor => 0x11B1,
+ _ => 0
+ };
}
public override void OnTrigger(Mobile from)
diff --git a/Projects/Scripts/Items/Traps/SpikeTrap.cs b/Projects/Scripts/Items/Traps/SpikeTrap.cs
index 41ed063a7..0a4a636df 100644
--- a/Projects/Scripts/Items/Traps/SpikeTrap.cs
+++ b/Projects/Scripts/Items/Traps/SpikeTrap.cs
@@ -28,23 +28,22 @@ namespace Server.Items
{
get
{
- switch (ItemID)
+ return ItemID switch
{
- case 4360:
- case 4361:
- case 4366: return SpikeTrapType.WestWall;
- case 4379:
- case 4380:
- case 4385: return SpikeTrapType.NorthWall;
- case 4506:
- case 4507:
- case 4511: return SpikeTrapType.WestFloor;
- case 4512:
- case 4513:
- case 4517: return SpikeTrapType.NorthFloor;
- }
-
- return SpikeTrapType.WestWall;
+ 4360 => SpikeTrapType.WestWall,
+ 4361 => SpikeTrapType.WestWall,
+ 4366 => SpikeTrapType.WestWall,
+ 4379 => SpikeTrapType.NorthWall,
+ 4380 => SpikeTrapType.NorthWall,
+ 4385 => SpikeTrapType.NorthWall,
+ 4506 => SpikeTrapType.WestFloor,
+ 4507 => SpikeTrapType.WestFloor,
+ 4511 => SpikeTrapType.WestFloor,
+ 4512 => SpikeTrapType.NorthFloor,
+ 4513 => SpikeTrapType.NorthFloor,
+ 4517 => SpikeTrapType.NorthFloor,
+ _ => SpikeTrapType.WestWall
+ };
}
set
{
@@ -73,31 +72,28 @@ namespace Server.Items
public static int GetBaseID(SpikeTrapType type)
{
- switch (type)
+ return type switch
{
- case SpikeTrapType.WestWall: return 4360;
- case SpikeTrapType.NorthWall: return 4379;
- case SpikeTrapType.WestFloor: return 4506;
- case SpikeTrapType.NorthFloor: return 4512;
- }
-
- return 0;
+ SpikeTrapType.WestWall => 4360,
+ SpikeTrapType.NorthWall => 4379,
+ SpikeTrapType.WestFloor => 4506,
+ SpikeTrapType.NorthFloor => 4512,
+ _ => 0
+ };
}
public static int GetExtendedID(SpikeTrapType type) => GetBaseID(type) + GetExtendedOffset(type);
public static int GetExtendedOffset(SpikeTrapType type)
{
- switch (type)
+ return type switch
{
- case SpikeTrapType.WestWall: return 6;
- case SpikeTrapType.NorthWall: return 6;
-
- case SpikeTrapType.WestFloor: return 5;
- case SpikeTrapType.NorthFloor: return 5;
- }
-
- return 0;
+ SpikeTrapType.WestWall => 6,
+ SpikeTrapType.NorthWall => 6,
+ SpikeTrapType.WestFloor => 5,
+ SpikeTrapType.NorthFloor => 5,
+ _ => 0
+ };
}
public override void OnTrigger(Mobile from)
diff --git a/Projects/Scripts/Items/Traps/StoneFaceTrap.cs b/Projects/Scripts/Items/Traps/StoneFaceTrap.cs
index 3b50cfb86..2aab141f8 100644
--- a/Projects/Scripts/Items/Traps/StoneFaceTrap.cs
+++ b/Projects/Scripts/Items/Traps/StoneFaceTrap.cs
@@ -24,20 +24,19 @@ namespace Server.Items
{
get
{
- switch (ItemID)
+ return ItemID switch
{
- case 0x10F5:
- case 0x10F6:
- case 0x10F7: return StoneFaceTrapType.NorthWestWall;
- case 0x10FC:
- case 0x10FD:
- case 0x10FE: return StoneFaceTrapType.NorthWall;
- case 0x110F:
- case 0x1110:
- case 0x1111: return StoneFaceTrapType.WestWall;
- }
-
- return StoneFaceTrapType.NorthWestWall;
+ 0x10F5 => StoneFaceTrapType.NorthWestWall,
+ 0x10F6 => StoneFaceTrapType.NorthWestWall,
+ 0x10F7 => StoneFaceTrapType.NorthWestWall,
+ 0x10FC => StoneFaceTrapType.NorthWall,
+ 0x10FD => StoneFaceTrapType.NorthWall,
+ 0x10FE => StoneFaceTrapType.NorthWall,
+ 0x110F => StoneFaceTrapType.WestWall,
+ 0x1110 => StoneFaceTrapType.WestWall,
+ 0x1111 => StoneFaceTrapType.WestWall,
+ _ => StoneFaceTrapType.NorthWestWall
+ };
}
set
{
@@ -66,26 +65,24 @@ namespace Server.Items
public static int GetBaseID(StoneFaceTrapType type)
{
- switch (type)
+ return type switch
{
- case StoneFaceTrapType.NorthWestWall: return 0x10F5;
- case StoneFaceTrapType.NorthWall: return 0x10FC;
- case StoneFaceTrapType.WestWall: return 0x110F;
- }
-
- return 0;
+ StoneFaceTrapType.NorthWestWall => 0x10F5,
+ StoneFaceTrapType.NorthWall => 0x10FC,
+ StoneFaceTrapType.WestWall => 0x110F,
+ _ => 0
+ };
}
public static int GetFireID(StoneFaceTrapType type)
{
- switch (type)
+ return type switch
{
- case StoneFaceTrapType.NorthWestWall: return 0x10F7;
- case StoneFaceTrapType.NorthWall: return 0x10FE;
- case StoneFaceTrapType.WestWall: return 0x1111;
- }
-
- return 0;
+ StoneFaceTrapType.NorthWestWall => 0x10F7,
+ StoneFaceTrapType.NorthWall => 0x10FE,
+ StoneFaceTrapType.WestWall => 0x1111,
+ _ => 0
+ };
}
public override void OnTrigger(Mobile from)
diff --git a/Projects/Scripts/Items/TreasureChests/TreasureChestLevel2.cs b/Projects/Scripts/Items/TreasureChests/TreasureChestLevel2.cs
index b607d7d19..def84626b 100644
--- a/Projects/Scripts/Items/TreasureChests/TreasureChestLevel2.cs
+++ b/Projects/Scripts/Items/TreasureChests/TreasureChestLevel2.cs
@@ -20,7 +20,6 @@ namespace Server.Items
RequiredSkill = 72;
LockLevel = RequiredSkill - Utility.Random(1, 10);
MaxLockLevel = RequiredSkill + Utility.Random(1, 10);
- ;
// According to OSI, loot in level 2 chest is:
// Gold 80 - 150
@@ -122,12 +121,12 @@ namespace Server.Items
break;
case 6: // Keg
- ItemID = UseFirstItemId ? 0xe7f : 0xe7f;
+ ItemID = 0xe7f;
GumpID = 0x3e;
break;
case 7: // Barrel
- ItemID = UseFirstItemId ? 0xe77 : 0xe77;
+ ItemID = 0xe77;
GumpID = 0x3e;
break;
}
@@ -145,4 +144,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Items/TreasureChests/TreasureChestLevel3.cs b/Projects/Scripts/Items/TreasureChests/TreasureChestLevel3.cs
index a11d41e75..32bd240e3 100644
--- a/Projects/Scripts/Items/TreasureChests/TreasureChestLevel3.cs
+++ b/Projects/Scripts/Items/TreasureChests/TreasureChestLevel3.cs
@@ -20,7 +20,6 @@ namespace Server.Items
RequiredSkill = 84;
LockLevel = RequiredSkill - Utility.Random(1, 10);
MaxLockLevel = RequiredSkill + Utility.Random(1, 10);
- ;
// According to OSI, loot in level 3 chest is:
// Gold 250 - 350
@@ -158,4 +157,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Items/TreasureChests/TreasureChestLevel4.cs b/Projects/Scripts/Items/TreasureChests/TreasureChestLevel4.cs
index 11616eed2..bda08124e 100644
--- a/Projects/Scripts/Items/TreasureChests/TreasureChestLevel4.cs
+++ b/Projects/Scripts/Items/TreasureChests/TreasureChestLevel4.cs
@@ -20,7 +20,6 @@ namespace Server.Items
RequiredSkill = 92;
LockLevel = RequiredSkill - Utility.Random(1, 10);
MaxLockLevel = RequiredSkill + Utility.Random(1, 10);
- ;
// According to OSI, loot in level 4 chest is:
// Gold 500 - 900
@@ -167,4 +166,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Items/Wands/BaseWand.cs b/Projects/Scripts/Items/Wands/BaseWand.cs
index d5a75526b..656850536 100644
--- a/Projects/Scripts/Items/Wands/BaseWand.cs
+++ b/Projects/Scripts/Items/Wands/BaseWand.cs
@@ -213,44 +213,21 @@ namespace Server.Items
}
else
{
- int num = 0;
-
- switch (m_WandEffect)
+ var num = m_WandEffect switch
{
- case WandEffect.Clumsiness:
- num = 3002011;
- break;
- case WandEffect.Identification:
- num = 1044063;
- break;
- case WandEffect.Healing:
- num = 3002014;
- break;
- case WandEffect.Feeblemindedness:
- num = 3002013;
- break;
- case WandEffect.Weakness:
- num = 3002018;
- break;
- case WandEffect.MagicArrow:
- num = 3002015;
- break;
- case WandEffect.Harming:
- num = 3002022;
- break;
- case WandEffect.Fireball:
- num = 3002028;
- break;
- case WandEffect.GreaterHealing:
- num = 3002039;
- break;
- case WandEffect.Lightning:
- num = 3002040;
- break;
- case WandEffect.ManaDraining:
- num = 3002041;
- break;
- }
+ WandEffect.Clumsiness => 3002011,
+ WandEffect.Identification => 1044063,
+ WandEffect.Healing => 3002014,
+ WandEffect.Feeblemindedness => 3002013,
+ WandEffect.Weakness => 3002018,
+ WandEffect.MagicArrow => 3002015,
+ WandEffect.Harming => 3002022,
+ WandEffect.Fireball => 3002028,
+ WandEffect.GreaterHealing => 3002039,
+ WandEffect.Lightning => 3002040,
+ WandEffect.ManaDraining => 3002041,
+ _ => 0
+ };
if (num > 0)
attrs.Add(new EquipInfoAttribute(num, m_Charges));
diff --git a/Projects/Scripts/Items/Weapons/BaseWeapon.cs b/Projects/Scripts/Items/Weapons/BaseWeapon.cs
index 95eed3882..c3a156618 100644
--- a/Projects/Scripts/Items/Weapons/BaseWeapon.cs
+++ b/Projects/Scripts/Items/Weapons/BaseWeapon.cs
@@ -425,13 +425,13 @@ namespace Server.Items
string modName = Serial.ToString();
if (strBonus != 0)
- m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero));
+ m.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero));
if (dexBonus != 0)
- m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero));
+ m.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero));
if (intBonus != 0)
- m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero));
+ m.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero));
}
from.NextCombatTime = Core.TickCount + (int)GetDelay(from).TotalMilliseconds;
@@ -477,9 +477,9 @@ namespace Server.Items
string modName = Serial.ToString();
- m.RemoveStatMod(modName + "Str");
- m.RemoveStatMod(modName + "Dex");
- m.RemoveStatMod(modName + "Int");
+ m.RemoveStatMod($"{modName}Str");
+ m.RemoveStatMod($"{modName}Dex");
+ m.RemoveStatMod($"{modName}Int");
if (weapon != null)
m.NextCombatTime = Core.TickCount + (int)weapon.GetDelay(m).TotalMilliseconds;
@@ -559,11 +559,11 @@ namespace Server.Items
BaseWeapon atkWeapon = attacker.Weapon as BaseWeapon;
BaseWeapon defWeapon = defender.Weapon as BaseWeapon;
- Skill atkSkill = attacker.Skills[atkWeapon.Skill];
+ Skill atkSkill = attacker.Skills[atkWeapon?.Skill ?? SkillName.Wrestling];
// Skill defSkill = defender.Skills[defWeapon.Skill];
- double atkValue = atkWeapon.GetAttackSkillValue(attacker, defender);
- double defValue = defWeapon.GetDefendSkillValue(attacker, defender);
+ double atkValue = atkWeapon?.GetAttackSkillValue(attacker, defender) ?? 0.0;
+ double defValue = defWeapon?.GetDefendSkillValue(attacker, defender) ?? 0.0;
double ourValue, theirValue;
@@ -832,8 +832,8 @@ namespace Server.Items
if (shield != null)
{
- chance = (parry - bushidoNonRacial) /
- 400.0; // As per OSI, no genitive effect from the Racial stuffs, ie, 120 parry and '0' bushido with humans
+ // As per OSI, no genitive effect from the Racial stuffs, ie, 120 parry and '0' bushido with humans
+ chance = (parry - bushidoNonRacial) / 400.0;
if (chance < 0) // chance shouldn't go below 0
chance = 0;
@@ -858,7 +858,7 @@ namespace Server.Items
BaseWeapon weapon = defender.Weapon as BaseWeapon;
- double divisor = weapon.Layer == Layer.OneHanded ? 48000.0 : 41140.0;
+ double divisor = weapon?.Layer == Layer.OneHanded ? 48000.0 : 41140.0;
chance = parry * bushido / divisor;
@@ -1207,10 +1207,7 @@ namespace Server.Items
type = 3;
}
- if (nrgy < low)
- {
- type = 4;
- }
+ if (nrgy < low) type = 4;
phys = fire = cold = pois = nrgy = chaos = direct = 0;
@@ -1251,7 +1248,7 @@ namespace Server.Items
int lifeLeech = 0;
int stamLeech = 0;
int manaLeech = 0;
- int wraithLeech = 0;
+ int wraithLeech;
if ((int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitLeechHits) * propertyBonus) >
Utility.Random(100))
@@ -1458,8 +1455,8 @@ namespace Server.Items
public virtual CheckSlayerResult CheckSlayers(Mobile attacker, Mobile defender)
{
BaseWeapon atkWeapon = attacker.Weapon as BaseWeapon;
- SlayerEntry atkSlayer = SlayerGroup.GetEntryByName(atkWeapon.Slayer);
- SlayerEntry atkSlayer2 = SlayerGroup.GetEntryByName(atkWeapon.Slayer2);
+ SlayerEntry atkSlayer = SlayerGroup.GetEntryByName(atkWeapon?.Slayer ?? SlayerName.None);
+ SlayerEntry atkSlayer2 = SlayerGroup.GetEntryByName(atkWeapon?.Slayer2 ?? SlayerName.None);
if (atkWeapon is ButchersWarCleaver && TalismanSlayer.Slays(TalismanSlayerName.Bovine, defender))
return CheckSlayerResult.Slayer;
@@ -1914,13 +1911,6 @@ namespace Server.Items
switch (Animation)
{
default:
- case WeaponAnimation.Wrestle:
- case WeaponAnimation.Bash1H:
- case WeaponAnimation.Pierce1H:
- case WeaponAnimation.Slash1H:
- case WeaponAnimation.Bash2H:
- case WeaponAnimation.Pierce2H:
- case WeaponAnimation.Slash2H:
action = Utility.Random(4, 3);
break;
case WeaponAnimation.ShootBow: return; // 7
@@ -1934,27 +1924,19 @@ namespace Server.Items
if (!from.Mounted)
action = (int)Animation;
else
- switch (Animation)
+ action = Animation switch
{
- default:
- case WeaponAnimation.Wrestle:
- case WeaponAnimation.Bash1H:
- case WeaponAnimation.Pierce1H:
- case WeaponAnimation.Slash1H:
- action = 26;
- break;
- case WeaponAnimation.Bash2H:
- case WeaponAnimation.Pierce2H:
- case WeaponAnimation.Slash2H:
- action = 29;
- break;
- case WeaponAnimation.ShootBow:
- action = 27;
- break;
- case WeaponAnimation.ShootXBow:
- action = 28;
- break;
- }
+ WeaponAnimation.Wrestle => 26,
+ WeaponAnimation.Bash1H => 26,
+ WeaponAnimation.Pierce1H => 26,
+ WeaponAnimation.Slash1H => 26,
+ WeaponAnimation.Bash2H => 29,
+ WeaponAnimation.Pierce2H => 29,
+ WeaponAnimation.Slash2H => 29,
+ WeaponAnimation.ShootBow => 27,
+ WeaponAnimation.ShootXBow => 28,
+ _ => 26
+ };
break;
}
@@ -1999,65 +1981,27 @@ namespace Server.Items
public override void AddNameProperty(ObjectPropertyList list)
{
- int oreType;
-
- switch (m_Resource)
+ var oreType = m_Resource switch
{
- case CraftResource.DullCopper:
- oreType = 1053108;
- break; // dull copper
- case CraftResource.ShadowIron:
- oreType = 1053107;
- break; // shadow iron
- case CraftResource.Copper:
- oreType = 1053106;
- break; // copper
- case CraftResource.Bronze:
- oreType = 1053105;
- break; // bronze
- case CraftResource.Gold:
- oreType = 1053104;
- break; // golden
- case CraftResource.Agapite:
- oreType = 1053103;
- break; // agapite
- case CraftResource.Verite:
- oreType = 1053102;
- break; // verite
- case CraftResource.Valorite:
- oreType = 1053101;
- break; // valorite
- case CraftResource.SpinedLeather:
- oreType = 1061118;
- break; // spined
- case CraftResource.HornedLeather:
- oreType = 1061117;
- break; // horned
- case CraftResource.BarbedLeather:
- oreType = 1061116;
- break; // barbed
- case CraftResource.RedScales:
- oreType = 1060814;
- break; // red
- case CraftResource.YellowScales:
- oreType = 1060818;
- break; // yellow
- case CraftResource.BlackScales:
- oreType = 1060820;
- break; // black
- case CraftResource.GreenScales:
- oreType = 1060819;
- break; // green
- case CraftResource.WhiteScales:
- oreType = 1060821;
- break; // white
- case CraftResource.BlueScales:
- oreType = 1060815;
- break; // blue
- default:
- oreType = 0;
- break;
- }
+ CraftResource.DullCopper => 1053108,
+ CraftResource.ShadowIron => 1053107,
+ CraftResource.Copper => 1053106,
+ CraftResource.Bronze => 1053105,
+ CraftResource.Gold => 1053104,
+ CraftResource.Agapite => 1053103,
+ CraftResource.Verite => 1053102,
+ CraftResource.Valorite => 1053101,
+ CraftResource.SpinedLeather => 1061118,
+ CraftResource.HornedLeather => 1061117,
+ CraftResource.BarbedLeather => 1061116,
+ CraftResource.RedScales => 1060814,
+ CraftResource.YellowScales => 1060818,
+ CraftResource.BlackScales => 1060820,
+ CraftResource.GreenScales => 1060819,
+ CraftResource.WhiteScales => 1060821,
+ CraftResource.BlueScales => 1060815,
+ _ => 0
+ };
if (oreType != 0)
list.Add(1053099, "#{0}\t{1}", oreType, GetNameString()); // ~1_oretype~ ~2_armortype~
@@ -2160,7 +2104,7 @@ namespace Server.Items
if (Core.ML && ranged?.Balanced == true)
list.Add(1072792); // Balanced
- if ((prop = WeaponAttributes.UseBestSkill) != 0)
+ if (WeaponAttributes.UseBestSkill != 0)
list.Add(1060400); // use best weapon skill
if ((prop = GetDamageBonus() + Attributes.WeaponDamage) != 0)
@@ -2262,7 +2206,7 @@ namespace Server.Items
if ((prop = Attributes.RegenMana) != 0)
list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~
- if ((prop = Attributes.NightSight) != 0)
+ if (Attributes.NightSight != 0)
list.Add(1060441); // night sight
if ((prop = Attributes.ReflectPhysical) != 0)
@@ -2277,7 +2221,7 @@ namespace Server.Items
if ((prop = WeaponAttributes.SelfRepair) != 0)
list.Add(1060450, prop.ToString()); // self repair ~1_val~
- if ((prop = Attributes.SpellChanneling) != 0)
+ if (Attributes.SpellChanneling != 0)
list.Add(1060482); // spell channeling
if ((prop = Attributes.SpellDamage) != 0)
@@ -3551,13 +3495,13 @@ namespace Server.Items
string modName = Serial.ToString();
if (strBonus != 0)
- parentMobile.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero));
+ parentMobile.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero));
if (dexBonus != 0)
- parentMobile.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero));
+ parentMobile.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero));
if (intBonus != 0)
- parentMobile.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero));
+ parentMobile.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero));
}
parentMobile?.CheckStatTimers();
diff --git a/Projects/Scripts/Misc/AOS.cs b/Projects/Scripts/Misc/AOS.cs
index ac0c559eb..cbf8d4487 100644
--- a/Projects/Scripts/Misc/AOS.cs
+++ b/Projects/Scripts/Misc/AOS.cs
@@ -136,7 +136,7 @@ namespace Server
#region Dragon Barding
- if ((from?.Player != true) && m.Player && m.Mount is SwampDragon pet)
+ if (from?.Player != true && m.Player && m.Mount is SwampDragon pet)
if (pet.HasBarding)
{
int percent = pet.BardingExceptional ? 20 : 10;
@@ -194,26 +194,26 @@ namespace Server
public static int GetStatus(Mobile from, int index)
{
- switch (index)
+ return index switch
{
// TODO: Account for buffs/debuffs
- case 0: return from.GetMaxResistance(ResistanceType.Physical);
- case 1: return from.GetMaxResistance(ResistanceType.Fire);
- case 2: return from.GetMaxResistance(ResistanceType.Cold);
- case 3: return from.GetMaxResistance(ResistanceType.Poison);
- case 4: return from.GetMaxResistance(ResistanceType.Energy);
- case 5: return AosAttributes.GetValue(from, AosAttribute.DefendChance);
- case 6: return 45;
- case 7: return AosAttributes.GetValue(from, AosAttribute.AttackChance);
- case 8: return AosAttributes.GetValue(from, AosAttribute.WeaponSpeed);
- case 9: return AosAttributes.GetValue(from, AosAttribute.WeaponDamage);
- case 10: return AosAttributes.GetValue(from, AosAttribute.LowerRegCost);
- case 11: return AosAttributes.GetValue(from, AosAttribute.SpellDamage);
- case 12: return AosAttributes.GetValue(from, AosAttribute.CastRecovery);
- case 13: return AosAttributes.GetValue(from, AosAttribute.CastSpeed);
- case 14: return AosAttributes.GetValue(from, AosAttribute.LowerManaCost);
- default: return 0;
- }
+ 0 => from.GetMaxResistance(ResistanceType.Physical),
+ 1 => from.GetMaxResistance(ResistanceType.Fire),
+ 2 => from.GetMaxResistance(ResistanceType.Cold),
+ 3 => from.GetMaxResistance(ResistanceType.Poison),
+ 4 => from.GetMaxResistance(ResistanceType.Energy),
+ 5 => AosAttributes.GetValue(from, AosAttribute.DefendChance),
+ 6 => 45,
+ 7 => AosAttributes.GetValue(from, AosAttribute.AttackChance),
+ 8 => AosAttributes.GetValue(from, AosAttribute.WeaponSpeed),
+ 9 => AosAttributes.GetValue(from, AosAttribute.WeaponDamage),
+ 10 => AosAttributes.GetValue(from, AosAttribute.LowerRegCost),
+ 11 => AosAttributes.GetValue(from, AosAttribute.SpellDamage),
+ 12 => AosAttributes.GetValue(from, AosAttribute.CastRecovery),
+ 13 => AosAttributes.GetValue(from, AosAttribute.CastSpeed),
+ 14 => AosAttributes.GetValue(from, AosAttribute.LowerManaCost),
+ _ => 0
+ };
}
}
@@ -522,13 +522,13 @@ namespace Server
string modName = Owner.Serial.ToString();
if (strBonus != 0)
- to.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero));
+ to.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero));
if (dexBonus != 0)
- to.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero));
+ to.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero));
if (intBonus != 0)
- to.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero));
+ to.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero));
}
to.CheckStatTimers();
@@ -538,9 +538,9 @@ namespace Server
{
string modName = Owner.Serial.ToString();
- from.RemoveStatMod(modName + "Str");
- from.RemoveStatMod(modName + "Dex");
- from.RemoveStatMod(modName + "Int");
+ from.RemoveStatMod($"{modName}Str");
+ from.RemoveStatMod($"{modName}Dex");
+ from.RemoveStatMod($"{modName}Int");
from.CheckStatTimers();
}
@@ -995,21 +995,19 @@ namespace Server
public void GetProperties(ObjectPropertyList list)
{
for (int i = 0; i < 5; ++i)
- {
if (GetValues(i, out SkillName skill, out double bonus))
list.Add(1060451 + i, "#{0}\t{1}", GetLabel(skill), bonus);
- }
}
public static int GetLabel(SkillName skill)
{
- switch (skill)
+ return skill switch
{
- case SkillName.EvalInt: return 1002070; // Evaluate Intelligence
- case SkillName.Forensics: return 1002078; // Forensic Evaluation
- case SkillName.Lockpicking: return 1002097; // Lockpicking
- default: return 1044060 + (int)skill;
- }
+ SkillName.EvalInt => 1002070, // Evaluate Intelligence
+ SkillName.Forensics => 1002078, // Forensic Evaluation
+ SkillName.Lockpicking => 1002097, // Lockpicking
+ _ => (1044060 + (int)skill)
+ };
}
public void AddTo(Mobile m)
diff --git a/Projects/Scripts/Misc/Assistants.cs b/Projects/Scripts/Misc/Assistants.cs
deleted file mode 100644
index b93429e0b..000000000
--- a/Projects/Scripts/Misc/Assistants.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Server.Gumps;
-using Server.Network;
-
-namespace Server.Misc
-{
- public static class Assistants
- {
- private static class Settings
- {
- [Flags]
- public enum Features : ulong
- {
- None = 0,
-
- FilterWeather = 1 << 0, // Weather Filter
- FilterLight = 1 << 1, // Light Filter
- SmartTarget = 1 << 2, // Smart Last Target
- RangedTarget = 1 << 3, // Range Check Last Target
- AutoOpenDoors = 1 << 4, // Automatically Open Doors
- DequipOnCast = 1 << 5, // Unequip Weapon on spell cast
- AutoPotionEquip = 1 << 6, // Un/re-equip weapon on potion use
- PoisonedChecks = 1 << 7, // Block heal If poisoned/Macro If Poisoned condition/Heal or Cure self
- LoopedMacros = 1 << 8, // Disallow looping or recursive macros
- UseOnceAgent = 1 << 9, // The use once agent
- RestockAgent = 1 << 10, // The restock agent
- SellAgent = 1 << 11, // The sell agent
- BuyAgent = 1 << 12, // The buy agent
- PotionHotkeys = 1 << 13, // All potion hotkeys
- RandomTargets = 1 << 14, // All random target hotkeys (not target next, last target, target self)
- ClosestTargets = 1 << 15, // All closest target hotkeys
- OverheadHealth = 1 << 16, // Health and Mana/Stam messages shown over player's heads
- AutolootAgent = 1 << 17, // The autoloot agent
- BoneCutterAgent = 1 << 18, // The bone cutter agent
- AdvancedMacros = 1 << 19, // Advanced macro engine
- AutoRemount = 1 << 20, // Auto remount after dismount
- AutoBandage = 1 << 21, // Auto bandage friends, self, last and mount option
- EnemyTargetShare = 1 << 22, // Enemy target share on guild, party or alliance chat
- FilterSeason = 1 << 23, // Season Filter
- SpellTargetShare = 1 << 24, // Spell target share on guild, party or alliance chat
-
- All = ulong.MaxValue
- }
-
- public const bool Enabled = false;
- public const bool KickOnFailure = true; // It will also kick clients running without assistants
-
- public const string WarningMessage = "The server was unable to negotiate features with your assistant. "
- + "You must download and run an updated version of UOSteam"
- + " or Razor."
- + "
Make sure you've checked the option Negotiate features with server, "
- + "once you have this box checked you may log in and play normally."
- + "
You will be disconnected shortly.";
-
- public static readonly TimeSpan HandshakeTimeout = TimeSpan.FromSeconds(30.0);
- public static readonly TimeSpan DisconnectDelay = TimeSpan.FromSeconds(15.0);
-
- public static Features DisallowedFeatures{ get; private set; } = Features.None;
-
- public static void Configure()
- {
- //DisallowFeature( Features.FilterWeather );
- }
-
- public static void DisallowFeature(Features feature)
- {
- SetDisallowed(feature, true);
- }
-
- public static void AllowFeature(Features feature)
- {
- SetDisallowed(feature, false);
- }
-
- public static void SetDisallowed(Features feature, bool value)
- {
- if (value)
- DisallowedFeatures |= feature;
- else
- DisallowedFeatures &= ~feature;
- }
- }
-
- private static class Negotiator
- {
- private static Dictionary m_Dictionary = new Dictionary();
-
- public static void Initialize()
- {
-/* if (Settings.Enabled)
- {
- EventSink.Login += EventSink_Login;
- ProtocolExtensions.Register(0xFF, true, OnHandshakeResponse);
- }*/
- }
-
- private static void EventSink_Login(LoginEventArgs e)
- {
- Mobile m = e.Mobile;
-
- if (m?.NetState != null && m.NetState.Running)
- {
- m.Send(new BeginHandshake());
-
- if (Settings.KickOnFailure)
- m.Send(new BeginHandshake());
-
- if (m_Dictionary.TryGetValue(m, out Timer t))
- t.Stop();
-
- m_Dictionary[m] = t = Timer.DelayCall(Settings.HandshakeTimeout, OnHandshakeTimeout, m);
- t.Start();
- }
- }
-
- private static void OnHandshakeResponse(NetState state, PacketReader pvSrc)
- {
- pvSrc.Trace(state);
-
- if (state?.Mobile == null || !state.Running)
- return;
-
- Mobile m = state.Mobile;
- if (m_Dictionary.TryGetValue(m, out Timer t))
- {
- t.Stop();
-
- m_Dictionary.Remove(m);
- }
- }
-
- private static void OnHandshakeTimeout(Mobile m)
- {
- if (m == null)
- return;
-
- m_Dictionary.Remove(m);
-
-// if (!Settings.KickOnFailure)
-// {
-// Console.WriteLine("Player '{0}' failed to negotiate features.", m);
-// }
-
- if (m.NetState?.Running == true)
- {
- m.SendGump(new WarningGump(1060635, 30720, Settings.WarningMessage, 0xFFC000, 420, 250));
-
- if (m.AccessLevel <= AccessLevel.Player)
- {
- Timer t;
- m_Dictionary[m] = t = Timer.DelayCall(Settings.DisconnectDelay, OnForceDisconnect, m);
- t.Start();
- }
- }
- }
-
- private static void OnForceDisconnect(Mobile m)
- {
- if (m == null)
- return;
-
- if (m.NetState != null && m.NetState.Running)
- m.NetState.Dispose();
-
- m_Dictionary.Remove(m);
-
- Console.WriteLine("Player {0} kicked (Failed assistant handshake)", m);
- }
-
- private sealed class BeginHandshake : ProtocolExtension
- {
- public BeginHandshake()
- : base(0xFE, 8)
- {
- m_Stream.Write((uint)((ulong)Settings.DisallowedFeatures >> 32));
- m_Stream.Write((uint)((ulong)Settings.DisallowedFeatures & 0xFFFFFFFF));
- }
- }
- }
- }
-}
diff --git a/Projects/Scripts/Misc/AutoRestart.cs b/Projects/Scripts/Misc/AutoRestart.cs
index 2ee1f6b6b..39ac545b0 100644
--- a/Projects/Scripts/Misc/AutoRestart.cs
+++ b/Projects/Scripts/Misc/AutoRestart.cs
@@ -1,5 +1,4 @@
using System;
-using Server.Commands;
namespace Server.Misc
{
diff --git a/Projects/Scripts/Misc/AutoSave.cs b/Projects/Scripts/Misc/AutoSave.cs
index 2a36ed745..1d206f72b 100644
--- a/Projects/Scripts/Misc/AutoSave.cs
+++ b/Projects/Scripts/Misc/AutoSave.cs
@@ -1,6 +1,5 @@
using System;
using System.IO;
-using Server.Commands;
namespace Server.Misc
{
diff --git a/Projects/Scripts/Misc/DoorGenerator.cs b/Projects/Scripts/Misc/DoorGenerator.cs
index a95e8807b..865160c48 100644
--- a/Projects/Scripts/Misc/DoorGenerator.cs
+++ b/Projects/Scripts/Misc/DoorGenerator.cs
@@ -1,4 +1,3 @@
-using Server.Commands;
using Server.Items;
using Server.Network;
diff --git a/Projects/Scripts/Misc/Gifts/Winter2004/Mistletoe.cs b/Projects/Scripts/Misc/Gifts/Winter2004/Mistletoe.cs
index d6ab59855..2dc45a0fd 100644
--- a/Projects/Scripts/Misc/Gifts/Winter2004/Mistletoe.cs
+++ b/Projects/Scripts/Misc/Gifts/Winter2004/Mistletoe.cs
@@ -253,7 +253,7 @@ namespace Server.Items
BaseHouse house = BaseHouse.FindHouseAt(loc, from.Map, 16);
- if (house == null || !house.IsCoOwner(from))
+ if (house?.IsCoOwner(from) != true)
{
from.SendLocalizedMessage(1042036); // That location is not in your house.
return;
diff --git a/Projects/Scripts/Misc/Guild.cs b/Projects/Scripts/Misc/Guild.cs
index b63a27646..9f6f2ec8c 100644
--- a/Projects/Scripts/Misc/Guild.cs
+++ b/Projects/Scripts/Misc/Guild.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using Server.Commands;
using Server.Commands.Generic;
using Server.Gumps;
using Server.Items;
@@ -146,7 +145,7 @@ namespace Server.Guilds
public void CheckLeader()
{
- if (m_Leader == null || m_Leader.Disbanded)
+ if (m_Leader?.Disbanded != false)
{
CalculateAllianceLeader();
diff --git a/Projects/Scripts/Misc/InhumanSpeech.cs b/Projects/Scripts/Misc/InhumanSpeech.cs
index ab20965f7..90f365068 100644
--- a/Projects/Scripts/Misc/InhumanSpeech.cs
+++ b/Projects/Scripts/Misc/InhumanSpeech.cs
@@ -401,10 +401,8 @@ namespace Server.Misc
List keywordsFound = new List();
for ( int i = 0; i < split.Length; ++i )
- {
if (m_KeywordHash.TryGetValue( split[i], out string keyword ))
keywordsFound.Add( keyword );
- }
if ( keywordsFound.Count > 0 )
{
@@ -461,7 +459,7 @@ namespace Server.Misc
}
}
- int maxWords = (split.Length / 2) + 1;
+ int maxWords = split.Length / 2 + 1;
if ( maxWords < 2 )
maxWords = 2;
@@ -501,7 +499,7 @@ namespace Server.Misc
if ( (Flags & IHSFlags.OnMovement) == 0 )
return; // not enabled
- if ( !mover.Player || (mover.Hidden && mover.AccessLevel > AccessLevel.Player) )
+ if ( !mover.Player || mover.Hidden && mover.AccessLevel > AccessLevel.Player )
return;
if ( !mob.InRange( mover, 5 ) || mob.InRange( oldLocation, 5 ) )
@@ -522,16 +520,13 @@ namespace Server.Misc
return; // 90% chance to do nothing; 10% chance to talk
if ( amount < 5 )
- {
SayRandomTranslate( mob,
"Ouch!",
"Me not hurt bad!",
"Thou fight bad.",
"Thy blows soft!",
"You bad with weapon!" );
- }
else
- {
SayRandomTranslate( mob,
"Ouch! Me hurt!",
"No, kill me not!",
@@ -540,7 +535,6 @@ namespace Server.Misc
"Oof! That hurt!",
"Aaah! That hurt...",
"Good blow!" );
- }
}
public void OnConstruct( Mobile mob )
@@ -553,9 +547,5 @@ namespace Server.Misc
mob.Say( ConstructSentance( wordCount ) );
mob.PlaySound( Sound );
}
-
- public InhumanSpeech()
- {
- }
}
}
diff --git a/Projects/Scripts/Misc/LanguageStatistics.cs b/Projects/Scripts/Misc/LanguageStatistics.cs
index 7221b42f5..f5cac3106 100644
--- a/Projects/Scripts/Misc/LanguageStatistics.cs
+++ b/Projects/Scripts/Misc/LanguageStatistics.cs
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.IO;
using Server.Accounting;
-using Server.Commands;
namespace Server.Misc
{
diff --git a/Projects/Scripts/Misc/LightCycle.cs b/Projects/Scripts/Misc/LightCycle.cs
index bafcc0295..90155d0fa 100644
--- a/Projects/Scripts/Misc/LightCycle.cs
+++ b/Projects/Scripts/Misc/LightCycle.cs
@@ -1,5 +1,4 @@
using System;
-using Server.Commands;
using Server.Items;
using Server.Network;
diff --git a/Projects/Scripts/Misc/Loot.cs b/Projects/Scripts/Misc/Loot.cs
index ace2e2c7a..8c839e963 100644
--- a/Projects/Scripts/Misc/Loot.cs
+++ b/Projects/Scripts/Misc/Loot.cs
@@ -623,24 +623,14 @@ namespace Server
public static SpellScroll RandomScroll(int minIndex, int maxIndex, SpellbookType type)
{
- Type[] types;
-
- switch (type)
+ var types = type switch
{
- default:
- case SpellbookType.Regular:
- types = RegularScrollTypes;
- break;
- case SpellbookType.Necromancer:
- types = Core.SE ? SENecromancyScrollTypes : NecromancyScrollTypes;
- break;
- case SpellbookType.Paladin:
- types = PaladinScrollTypes;
- break;
- case SpellbookType.Arcanist:
- types = ArcanistScrollTypes;
- break;
- }
+ SpellbookType.Regular => RegularScrollTypes,
+ SpellbookType.Necromancer => (Core.SE ? SENecromancyScrollTypes : NecromancyScrollTypes),
+ SpellbookType.Paladin => PaladinScrollTypes,
+ SpellbookType.Arcanist => ArcanistScrollTypes,
+ _ => RegularScrollTypes
+ };
return Construct(types, Utility.RandomMinMax(minIndex, maxIndex)) as SpellScroll;
}
diff --git a/Projects/Scripts/Misc/NameVerification.cs b/Projects/Scripts/Misc/NameVerification.cs
index 67b76d1d5..44ef8f68e 100644
--- a/Projects/Scripts/Misc/NameVerification.cs
+++ b/Projects/Scripts/Misc/NameVerification.cs
@@ -1,5 +1,3 @@
-using Server.Commands;
-
namespace Server.Misc
{
public class NameVerification
diff --git a/Projects/Scripts/Misc/Notoriety.cs b/Projects/Scripts/Misc/Notoriety.cs
index a5ebf5459..ea42bc887 100644
--- a/Projects/Scripts/Misc/Notoriety.cs
+++ b/Projects/Scripts/Misc/Notoriety.cs
@@ -320,8 +320,7 @@ namespace Server.Misc
#region Dueling
if (pmFrom != null && pmTarg != null)
- if (pmFrom.DuelContext != null && pmFrom.DuelContext.StartedBeginCountdown && !pmFrom.DuelContext.Finished &&
- pmFrom.DuelContext == pmTarg.DuelContext)
+ if (pmFrom.DuelContext?.StartedBeginCountdown == true && !pmFrom.DuelContext.Finished && pmFrom.DuelContext == pmTarg.DuelContext)
return pmFrom.DuelContext.IsAlly(pmFrom, pmTarg) ? Notoriety.Ally : Notoriety.Enemy;
#endregion
diff --git a/Projects/Scripts/Misc/ProfanityProtection.cs b/Projects/Scripts/Misc/ProfanityProtection.cs
index 08e37dcec..514589214 100644
--- a/Projects/Scripts/Misc/ProfanityProtection.cs
+++ b/Projects/Scripts/Misc/ProfanityProtection.cs
@@ -1,5 +1,3 @@
-using Server.Network;
-
namespace Server.Misc
{
public enum ProfanityAction
diff --git a/Projects/Scripts/Misc/RaceDefinitions.cs b/Projects/Scripts/Misc/RaceDefinitions.cs
index f6b0db296..eb9720308 100644
--- a/Projects/Scripts/Misc/RaceDefinitions.cs
+++ b/Projects/Scripts/Misc/RaceDefinitions.cs
@@ -49,18 +49,18 @@ namespace Server.Misc
public override int RandomHair(bool female) //Random hair doesn't include baldness
{
- switch (Utility.Random(9))
+ return Utility.Random(9) switch
{
- case 0: return 0x203B; //Short
- case 1: return 0x203C; //Long
- case 2: return 0x203D; //Pony Tail
- case 3: return 0x2044; //Mohawk
- case 4: return 0x2045; //Pageboy
- case 5: return 0x2047; //Afro
- case 6: return 0x2049; //Pig tails
- case 7: return 0x204A; //Krisna
- default: return female ? 0x2046 : 0x2048; //Buns or Receding Hair
- }
+ 0 => 0x203B, //Short
+ 1 => 0x203C, //Long
+ 2 => 0x203D, //Pony Tail
+ 3 => 0x2044, //Mohawk
+ 4 => 0x2045, //Pageboy
+ 5 => 0x2047, //Afro
+ 6 => 0x2049, //Pig tails
+ 7 => 0x204A, //Krisna
+ _ => (female ? 0x2046 : 0x2048)
+ };
}
public override bool ValidateFacialHair(bool female, int itemID)
@@ -158,17 +158,17 @@ namespace Server.Misc
public override int RandomHair(bool female) //Random hair doesn't include baldness
{
- switch (Utility.Random(8))
+ return Utility.Random(8) switch
{
- case 0: return 0x2FC0; //Long Feather
- case 1: return 0x2FC1; //Short
- case 2: return 0x2FC2; //Mullet
- case 3: return 0x2FCE; //Knob
- case 4: return 0x2FCF; //Braided
- case 5: return 0x2FD1; //Spiked
- case 6: return female ? 0x2FCC : 0x2FBF; //Flower or Mid-long
- default: return female ? 0x2FD0 : 0x2FCD; //Bun or Long
- }
+ 0 => 0x2FC0, //Long Feather
+ 1 => 0x2FC1, //Short
+ 2 => 0x2FC2, //Mullet
+ 3 => 0x2FCE, //Knob
+ 4 => 0x2FCF, //Braided
+ 5 => 0x2FD1, //Spiked
+ 6 => (female ? 0x2FCC : 0x2FBF), //Flower or Mid-long
+ _ => (female ? 0x2FD0 : 0x2FCD)
+ };
}
public override bool ValidateFacialHair(bool female, int itemID) => itemID == 0;
@@ -239,29 +239,19 @@ namespace Server.Misc
return 0;
if (!female)
return 0x4258 + Utility.Random(8);
- switch (Utility.Random(9))
+ return Utility.Random(9) switch
{
- case 0:
- return 0x4261;
- case 1:
- return 0x4262;
- case 2:
- return 0x4273;
- case 3:
- return 0x4274;
- case 4:
- return 0x4275;
- case 5:
- return 0x42B0;
- case 6:
- return 0x42B1;
- case 7:
- return 0x42AA;
- case 8:
- return 0x42AB;
- }
-
- return 0;
+ 0 => 0x4261,
+ 1 => 0x4262,
+ 2 => 0x4273,
+ 3 => 0x4274,
+ 4 => 0x4275,
+ 5 => 0x42B0,
+ 6 => 0x42B1,
+ 7 => 0x42AA,
+ 8 => 0x42AB,
+ _ => 0
+ };
}
public override bool ValidateFacialHair(bool female, int itemID) => !female && itemID >= 0x42AD && itemID <= 0x42B0;
@@ -286,4 +276,4 @@ namespace Server.Misc
#endregion
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Misc/RegenRates.cs b/Projects/Scripts/Misc/RegenRates.cs
index ecf5cee08..457a2f56b 100644
--- a/Projects/Scripts/Misc/RegenRates.cs
+++ b/Projects/Scripts/Misc/RegenRates.cs
@@ -202,13 +202,13 @@ namespace Server.Misc
if (ar == null || ar.ArmorAttributes.MageArmor != 0 || ar.Attributes.SpellChanneling != 0)
return 0.0;
- switch (ar.MeditationAllowance)
+ return ar.MeditationAllowance switch
{
- default:
- case ArmorMeditationAllowance.None: return ar.BaseArmorRatingScaled;
- case ArmorMeditationAllowance.Half: return ar.BaseArmorRatingScaled / 2.0;
- case ArmorMeditationAllowance.All: return 0.0;
- }
+ ArmorMeditationAllowance.None => ar.BaseArmorRatingScaled,
+ ArmorMeditationAllowance.Half => (ar.BaseArmorRatingScaled / 2.0),
+ ArmorMeditationAllowance.All => 0.0,
+ _ => ar.BaseArmorRatingScaled
+ };
}
}
}
diff --git a/Projects/Scripts/Misc/ResourceInfo.cs b/Projects/Scripts/Misc/ResourceInfo.cs
index c2a493552..e962f3993 100644
--- a/Projects/Scripts/Misc/ResourceInfo.cs
+++ b/Projects/Scripts/Misc/ResourceInfo.cs
@@ -94,10 +94,6 @@ namespace Server.Items
public int RunicMaxIntensity { get; set; }
- public CraftAttributeInfo()
- {
- }
-
public static readonly CraftAttributeInfo Blank;
public static readonly CraftAttributeInfo DullCopper, ShadowIron, Copper, Bronze, Golden, Agapite, Verite, Valorite;
public static readonly CraftAttributeInfo Spined, Horned, Barbed;
@@ -462,7 +458,7 @@ namespace Server.Items
///
/// Returns true if '' is None, Iron, RegularLeather or RegularWood. False if otherwise.
///
- public static bool IsStandard( CraftResource resource ) => ( resource == CraftResource.None || resource == CraftResource.Iron || resource == CraftResource.RegularLeather || resource == CraftResource.RegularWood );
+ public static bool IsStandard( CraftResource resource ) => resource == CraftResource.None || resource == CraftResource.Iron || resource == CraftResource.RegularLeather || resource == CraftResource.RegularWood;
private static Dictionary m_TypeTable;
@@ -493,15 +489,14 @@ namespace Server.Items
///
public static CraftResourceInfo GetInfo( CraftResource resource )
{
- CraftResourceInfo[] list = null;
-
- switch ( GetType( resource ) )
+ var list = GetType(resource) switch
{
- case CraftResourceType.Metal: list = m_MetalInfo; break;
- case CraftResourceType.Leather: list = Core.AOS ? m_AOSLeatherInfo : m_LeatherInfo; break;
- case CraftResourceType.Scales: list = m_ScaleInfo; break;
- case CraftResourceType.Wood: list = m_WoodInfo; break;
- }
+ CraftResourceType.Metal => m_MetalInfo,
+ CraftResourceType.Leather => (Core.AOS ? m_AOSLeatherInfo : m_LeatherInfo),
+ CraftResourceType.Scales => m_ScaleInfo,
+ CraftResourceType.Wood => m_WoodInfo,
+ _ => null
+ };
if ( list != null )
{
@@ -539,15 +534,14 @@ namespace Server.Items
///
public static CraftResource GetStart( CraftResource resource )
{
- switch ( GetType( resource ) )
+ return GetType(resource) switch
{
- case CraftResourceType.Metal: return CraftResource.Iron;
- case CraftResourceType.Leather: return CraftResource.RegularLeather;
- case CraftResourceType.Scales: return CraftResource.RedScales;
- case CraftResourceType.Wood: return CraftResource.RegularWood;
- }
-
- return CraftResource.None;
+ CraftResourceType.Metal => CraftResource.Iron,
+ CraftResourceType.Leather => CraftResource.RegularLeather,
+ CraftResourceType.Scales => CraftResource.RedScales,
+ CraftResourceType.Wood => CraftResource.RegularWood,
+ _ => CraftResource.None
+ };
}
///
@@ -590,7 +584,7 @@ namespace Server.Items
{
CraftResourceInfo info = GetInfo( resource );
- return ( info == null ? string.Empty : info.Name );
+ return info == null ? string.Empty : info.Name;
}
///
diff --git a/Projects/Scripts/Misc/SkillCheck.cs b/Projects/Scripts/Misc/SkillCheck.cs
index db0db8148..c0ead7ea3 100644
--- a/Projects/Scripts/Misc/SkillCheck.cs
+++ b/Projects/Scripts/Misc/SkillCheck.cs
@@ -262,14 +262,13 @@ namespace Server.Misc
public static bool CanLower(Mobile from, Stat stat)
{
- switch (stat)
+ return stat switch
{
- case Stat.Str: return from.StrLock == StatLockType.Down && from.RawStr > 10;
- case Stat.Dex: return from.DexLock == StatLockType.Down && from.RawDex > 10;
- case Stat.Int: return from.IntLock == StatLockType.Down && from.RawInt > 10;
- }
-
- return false;
+ Stat.Str => (from.StrLock == StatLockType.Down && from.RawStr > 10),
+ Stat.Dex => (from.DexLock == StatLockType.Down && from.RawDex > 10),
+ Stat.Int => (from.IntLock == StatLockType.Down && from.RawInt > 10),
+ _ => false
+ };
}
public static bool CanRaise(Mobile from, Stat stat)
@@ -278,14 +277,13 @@ namespace Server.Misc
if (from.RawStatTotal >= from.StatCap)
return false;
- switch (stat)
+ return stat switch
{
- case Stat.Str: return from.StrLock == StatLockType.Up && from.RawStr < 125;
- case Stat.Dex: return from.DexLock == StatLockType.Up && from.RawDex < 125;
- case Stat.Int: return from.IntLock == StatLockType.Up && from.RawInt < 125;
- }
-
- return false;
+ Stat.Str => (from.StrLock == StatLockType.Up && from.RawStr < 125),
+ Stat.Dex => (from.DexLock == StatLockType.Up && from.RawDex < 125),
+ Stat.Int => (from.IntLock == StatLockType.Up && from.RawInt < 125),
+ _ => false
+ };
}
public static void IncreaseStat(Mobile from, Stat stat, bool atrophy)
@@ -399,4 +397,4 @@ namespace Server.Misc
IncreaseStat(from, stat, atrophy);
}
}
-}
\ No newline at end of file
+}
diff --git a/Projects/Scripts/Misc/SocketOptions.cs b/Projects/Scripts/Misc/SocketOptions.cs
index 330962b3d..d51fb20e5 100644
--- a/Projects/Scripts/Misc/SocketOptions.cs
+++ b/Projects/Scripts/Misc/SocketOptions.cs
@@ -1,7 +1,5 @@
-using System;
using System.Net;
using System.Net.Sockets;
-using Server.Network;
namespace Server
{
diff --git a/Projects/Scripts/Misc/TextDefinition.cs b/Projects/Scripts/Misc/TextDefinition.cs
index c3e1ab285..7586e1610 100644
--- a/Projects/Scripts/Misc/TextDefinition.cs
+++ b/Projects/Scripts/Misc/TextDefinition.cs
@@ -57,14 +57,13 @@ namespace Server
{
int type = reader.ReadEncodedInt();
- switch (type)
+ return type switch
{
- case 0: return new TextDefinition();
- case 1: return new TextDefinition(reader.ReadEncodedInt());
- case 2: return new TextDefinition(reader.ReadString());
- }
-
- return null;
+ 0 => new TextDefinition(),
+ 1 => new TextDefinition(reader.ReadEncodedInt()),
+ 2 => new TextDefinition(reader.ReadString()),
+ _ => null
+ };
}
public static void AddTo(ObjectPropertyList list, TextDefinition def)
@@ -163,6 +162,6 @@ namespace Server
return isInteger ? new TextDefinition(i) : new TextDefinition(value);
}
- public static bool IsNullOrEmpty(TextDefinition def) => def == null || def.IsEmpty;
+ public static bool IsNullOrEmpty(TextDefinition def) => def?.IsEmpty != false;
}
}
diff --git a/Projects/Scripts/Misc/Titles.cs b/Projects/Scripts/Misc/Titles.cs
index 40d2f03f9..2ff78569f 100644
--- a/Projects/Scripts/Misc/Titles.cs
+++ b/Projects/Scripts/Misc/Titles.cs
@@ -215,7 +215,7 @@ namespace Server.Misc
m.SendLocalizedMessage(1019063); // You have lost a little karma.
}
- if (!Core.AOS && wasPositiveKarma && m.Karma < 0 && pm != null && !pm.KarmaLocked)
+ if (!Core.AOS && wasPositiveKarma && m.Karma < 0 && pm?.KarmaLocked == false)
{
pm.KarmaLocked = true;
m.SendLocalizedMessage(1042511, "",
@@ -326,9 +326,9 @@ namespace Server.Misc
string skillTitle = highest.Info.Title;
if (mob.Female && skillTitle.EndsWith("man"))
- skillTitle = skillTitle.Substring(0, skillTitle.Length - 3) + "woman";
+ skillTitle = $"{skillTitle.Substring(0, skillTitle.Length - 3)}woman";
- return string.Concat(skillLevel, " ", skillTitle);
+ return $"{skillLevel} {skillTitle}";
}
return null;
@@ -361,12 +361,12 @@ namespace Server.Misc
private static int GetTableType(Skill skill)
{
- switch (skill.SkillName)
+ return skill.SkillName switch
{
- default: return 0;
- case SkillName.Bushido: return 1;
- case SkillName.Ninjitsu: return 2;
- }
+ SkillName.Bushido => 1,
+ SkillName.Ninjitsu => 2,
+ _ => 0
+ };
}
private static int GetTableIndex(Skill skill)
diff --git a/Projects/Scripts/Misc/ToggleItem.cs b/Projects/Scripts/Misc/ToggleItem.cs
index ca6c4592c..e823279d8 100644
--- a/Projects/Scripts/Misc/ToggleItem.cs
+++ b/Projects/Scripts/Misc/ToggleItem.cs
@@ -1,4 +1,3 @@
-using Server.Commands;
using Server.Commands.Generic;
namespace Server.Items
diff --git a/Projects/Scripts/Misc/VendorGenerator.cs b/Projects/Scripts/Misc/VendorGenerator.cs
index 9c0c26a1c..40451ac82 100644
--- a/Projects/Scripts/Misc/VendorGenerator.cs
+++ b/Projects/Scripts/Misc/VendorGenerator.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Server.Commands;
using Server.Mobiles;
namespace Server
@@ -123,9 +122,9 @@ namespace Server
World.Broadcast(0x35, true, "Generating vendor spawns for {0}, please wait.", map);
for (int i = 0; i < regions.Length; ++i)
- for (int x = 0; x < map.Width; ++x)
- for (int y = 0; y < map.Height; ++y)
- CheckPoint(map, regions[i].X + x, regions[i].Y + y);
+ for (int x = 0; x < map.Width; ++x)
+ for (int y = 0; y < map.Height; ++y)
+ CheckPoint(map, regions[i].X + x, regions[i].Y + y);
for (int i = 0; i < m_ShopList.Count; ++i)
{
diff --git a/Projects/Scripts/Misc/Weather.cs b/Projects/Scripts/Misc/Weather.cs
index b385591e4..34d3aa2c4 100644
--- a/Projects/Scripts/Misc/Weather.cs
+++ b/Projects/Scripts/Misc/Weather.cs
@@ -130,10 +130,8 @@ namespace Server.Misc
public virtual bool IntersectsWith( Rectangle2D area )
{
for ( int i = 0; i < Area.Length; ++i )
- {
if ( CheckIntersection( area, Area[i] ) )
return true;
- }
return false;
}
diff --git a/Projects/Scripts/Misc/WebStatus.cs b/Projects/Scripts/Misc/WebStatus.cs
index 59d403446..f0ada5366 100644
--- a/Projects/Scripts/Misc/WebStatus.cs
+++ b/Projects/Scripts/Misc/WebStatus.cs
@@ -101,7 +101,7 @@ namespace Server.Misc
op.WriteLine("");
op.WriteLine("");
op.WriteLine(" ");
- op.WriteLine(" " + ServerList.ServerName + " Server Status");
+ op.WriteLine($" {ServerList.ServerName} Server Status");
op.WriteLine(" ");
op.WriteLine("