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

@ -1,5 +1,4 @@
using System;
using Server.Commands;
using Server.Items;
using Server.Network;

View file

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

View file

@ -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<Account>{ acct };
}
}
List<KeyValuePair<IPAddress, List<Account>>> 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)
{

View file

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

View file

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

View file

@ -1,6 +1,5 @@
using System.Collections.Generic;
using Server.Accounting;
using Server.Commands;
using Server.Network;
using Server.Prompts;
using Server.Targeting;

View file

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

View file

@ -31,7 +31,7 @@ namespace Server.Guilds
AddImageTiled(67, 116, 156, 22, 0xBBC);
AddHtmlLocalized(70, 117, 150, 20, 1063025, 0x0); // <i>Alliance</i>
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;

View file

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

View file

@ -23,11 +23,11 @@ namespace Server.Guilds
AddHtmlLocalized(65, 95, 200, 20, 1063009, 0x14AF); // <i>Duration of War</i>
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); // <i>Victory Condition</i>
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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,5 @@
using System.Collections.Generic;
using Server.Accounting;
using Server.Commands;
using Server.Items;
using Server.Multis;
using Server.Network;

View file

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

View file

@ -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<Mobile> 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<Mobile> BuildList(Mobile owner, string rawFilter)
{
string filter = String.IsNullOrWhiteSpace(rawFilter) ? null : rawFilter.Trim().ToLower();
string filter = string.IsNullOrWhiteSpace(rawFilter) ? null : rawFilter.Trim().ToLower();
List<Mobile> list = new List<Mobile>();
List<NetState> 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 );

View file

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