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

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

View file

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

View file

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Commands;
namespace Server.Factions
{

View file

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

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Server.Commands;
using Server.Targeting;
namespace Server.Factions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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