Formatting #2 (#59)

This commit is contained in:
Kamron Batman 2019-10-05 00:37:03 -07:00 committed by GitHub
parent 096d39609e
commit 8e9221bb5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
400 changed files with 3688 additions and 5969 deletions

View file

@ -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
};
}
}
}
}

View file

@ -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)];
}

View file

@ -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)

View file

@ -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();
}

View file

@ -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);
}

View file

@ -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;

View file

@ -187,24 +187,14 @@ namespace Server.Items
return string.Empty;
if (deed.IsExpired)
return "<bodytextblack>" +
"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.<br><br>" +
"The deed has expired, and now the indicated plot of land " +
"is subject to normal house construction rules.<br><br>" +
"This deed functions as a recall rune marked for the location of the plot it represents." +
"</bodytextblack>";
return
$"<bodytextblack>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.<br><br>The deed has expired, and now the indicated plot of land is subject to normal house construction rules.<br><br>This deed functions as a recall rune marked for the location of the plot it represents.</bodytextblack>";
int daysLeft = (int)Math.Ceiling((deed.Stone.Started + deed.Stone.Duration +
HouseRaffleStone.ExpirationTime - DateTime.UtcNow).TotalDays);
return "<bodytextblack>" + "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.<br><br>" +
$"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.<br><br>" +
"This deed functions as a recall rune marked for the location of the plot it represents.<br><br>" +
"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." + "</bodytextblack>";
return
$"<bodytextblack>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.<br><br>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.<br><br>This deed functions as a recall rune marked for the location of the plot it represents.<br><br>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.</bodytextblack>";
}
}
}

View file

@ -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]);

View file

@ -63,7 +63,7 @@ namespace Server.Items
PlagueBeastLord owner = Owner;
if (owner == null || !owner.Alive)
if (owner?.Alive != true)
Delete();
}
}

View file

@ -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)

View file

@ -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<ContextMenuEntry> list)

View file

@ -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<ContextMenuEntry> list)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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()
{

View file

@ -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);

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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;

View file

@ -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
};
}
}

View file

@ -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);

View file

@ -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