Adds style cop (#109)

This commit is contained in:
Kamron Batman 2020-04-26 00:16:02 -07:00 • committed by GitHub
parent 3e715bcb60
commit 556a17aba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1725 changed files with 33831 additions and 38046 deletions

View file

@ -6,7 +6,7 @@ namespace Server
public class CompassionVirtue
{
private const int LossAmount = 500;
private static TimeSpan LossDelay = TimeSpan.FromDays(7.0);
private static readonly TimeSpan LossDelay = TimeSpan.FromDays(7.0);
public static void Initialize()
{
@ -28,7 +28,7 @@ namespace Server
if (pm.LastCompassionLoss + LossDelay < DateTime.UtcNow)
{
VirtueHelper.Atrophy(from, VirtueName.Compassion, LossAmount);
//OSI has no cliloc message for losing compassion. Weird.
// OSI has no cliloc message for losing compassion. Weird.
pm.LastCompassionLoss = DateTime.UtcNow;
}
}

View file

@ -81,7 +81,7 @@ namespace Server
pm.SendLocalizedMessage(1063235); // You embrace your honor
Timer.DelayCall(TimeSpan.FromSeconds(duration),
delegate
() =>
{
pm.HonorActive = false;
pm.LastHonorUse = DateTime.UtcNow;
@ -116,20 +116,20 @@ namespace Server
return;
}
if (target.Body.IsHuman && (!(target is BaseCreature cret) || !cret.AlwaysAttackable && !cret.AlwaysMurderer))
if (target.Body.IsHuman && (!(target is BaseCreature cret) || (!cret.AlwaysAttackable && !cret.AlwaysMurderer)))
{
if (reg?.IsDisabled() != true)
{
//Allow honor on blue if Out of guardzone
// Allow honor on blue if Out of guardzone
}
else if ((map?.Rules & MapRules.HarmfulRestrictions) == 0)
{
//Allow honor on blue if in Fel
// Allow honor on blue if in Fel
}
else
{
source.SendLocalizedMessage(1001018); // You cannot perform negative acts
return; //cannot honor in trammel town on blue
return; // cannot honor in trammel town on blue
}
}
@ -173,18 +173,18 @@ namespace Server
public interface IHonorTarget
{
HonorContext ReceivedHonorContext{ get; set; }
HonorContext ReceivedHonorContext { get; set; }
}
public class HonorContext
{
private FirstHit m_FirstHit;
private double m_HonorDamage;
private Point3D m_InitialLocation;
private Map m_InitialMap;
private readonly Point3D m_InitialLocation;
private readonly Map m_InitialMap;
private bool m_Poisoned;
private InternalTimer m_Timer;
private readonly InternalTimer m_Timer;
private int m_TotalDamage;
public HonorContext(PlayerMobile source, Mobile target)
@ -206,17 +206,17 @@ namespace Server
source.m_hontime = DateTime.UtcNow + TimeSpan.FromMinutes(40);
Timer.DelayCall(TimeSpan.FromMinutes(40),
delegate
() =>
{
if (source.m_hontime < DateTime.UtcNow && source.SentHonorContext != null) Cancel();
});
}
public PlayerMobile Source{ get; }
public PlayerMobile Source { get; }
public Mobile Target{ get; }
public Mobile Target { get; }
public int PerfectionDamageBonus{ get; private set; }
public int PerfectionDamageBonus { get; private set; }
public int PerfectionLuckBonus => PerfectionDamageBonus * PerfectionDamageBonus / 10;
@ -252,8 +252,8 @@ namespace Server
if (from == Source)
{
if (Target.CanSee(Source) && Target.InLOS(Source) && (Source.InRange(Target, 1)
|| Source.Location == m_InitialLocation &&
Source.Map == m_InitialMap))
|| (Source.Location == m_InitialLocation &&
Source.Map == m_InitialMap)))
m_HonorDamage += amount;
else
m_HonorDamage += amount * 0.8;
@ -339,17 +339,17 @@ namespace Server
return;
double dGain =
targetFame / 100.0 * (m_HonorDamage / m_TotalDamage); //Initial honor gain is 100th of the monsters honor
targetFame / 100.0 * (m_HonorDamage / m_TotalDamage); // Initial honor gain is 100th of the monsters honor
if (m_HonorDamage == m_TotalDamage && m_FirstHit == FirstHit.Granted)
dGain = dGain * 1.5; //honor gain is increased alot more if the combat was fully honorable
dGain = dGain * 1.5; // honor gain is increased alot more if the combat was fully honorable
else
dGain = dGain * 0.9;
int gain = Math.Min((int)dGain, 200);
if (gain < 1)
gain = 1; //Minimum gain of 1 honor when the honor is under the monsters fame
gain = 1; // Minimum gain of 1 honor when the honor is under the monsters fame
if (VirtueHelper.IsHighestPath(Source, VirtueName.Honor))
{
@ -386,7 +386,7 @@ namespace Server
private class InternalTimer : Timer
{
private HonorContext m_Context;
private readonly HonorContext m_Context;
public InternalTimer(HonorContext context) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) => m_Context = context;

View file

@ -9,7 +9,7 @@ namespace Server
public class JusticeVirtue
{
private const int LossAmount = 950;
private static TimeSpan LossDelay = TimeSpan.FromDays(7.0);
private static readonly TimeSpan LossDelay = TimeSpan.FromDays(7.0);
public static void Initialize()
{
@ -177,8 +177,8 @@ namespace Server
public class AcceptProtectorGump : Gump
{
private PlayerMobile m_Protectee;
private PlayerMobile m_Protector;
private readonly PlayerMobile m_Protectee;
private readonly PlayerMobile m_Protector;
public AcceptProtectorGump(PlayerMobile protector, PlayerMobile protectee) : base(150, 50)
{

View file

@ -9,8 +9,8 @@ namespace Server
public class SacrificeVirtue
{
private const int LossAmount = 500;
private static TimeSpan GainDelay = TimeSpan.FromDays(1.0);
private static TimeSpan LossDelay = TimeSpan.FromDays(7.0);
private static readonly TimeSpan GainDelay = TimeSpan.FromDays(1.0);
private static readonly TimeSpan LossDelay = TimeSpan.FromDays(7.0);
public static void Initialize()
{

View file

@ -8,7 +8,7 @@ namespace Server
public class ValorVirtue
{
private const int LossAmount = 250;
private static TimeSpan LossDelay = TimeSpan.FromDays(7.0);
private static readonly TimeSpan LossDelay = TimeSpan.FromDays(7.0);
public static void Initialize()
{
@ -64,34 +64,34 @@ namespace Server
VirtueLevel vl = VirtueHelper.GetLevel(from, VirtueName.Valor);
if (idol.Spawn.Active)
{
if (idol.Spawn.Champion != null) //TODO: Message?
if (idol.Spawn.Champion != null) // TODO: Message?
return;
int needed, consumed;
switch (idol.Spawn.GetSubLevel())
{
case 0:
{
needed = consumed = 2500;
break;
}
{
needed = consumed = 2500;
break;
}
case 1:
{
needed = consumed = 5000;
break;
}
{
needed = consumed = 5000;
break;
}
case 2:
{
needed = 10000;
consumed = 7500;
break;
}
{
needed = 10000;
consumed = 7500;
break;
}
default:
{
needed = 20000;
consumed = 10000;
break;
}
{
needed = 20000;
consumed = 10000;
break;
}
}
if (from.Virtues.GetValue((int)VirtueName.Valor) >= needed)

View file

@ -8,9 +8,9 @@ namespace Server
public class VirtueGump : Gump
{
private static Dictionary<int, OnVirtueUsed> m_Callbacks = new Dictionary<int, OnVirtueUsed>();
private static readonly Dictionary<int, OnVirtueUsed> m_Callbacks = new Dictionary<int, OnVirtueUsed>();
private static int[] m_Table = {
private static readonly int[] m_Table = {
0x0481, 0x0963, 0x0965,
0x060A, 0x060F, 0x002A,
0x08A4, 0x08A7, 0x0034,
@ -21,7 +21,8 @@ namespace Server
0x0543, 0x0547, 0x0061
};
private Mobile m_Beholder, m_Beheld;
private readonly Mobile m_Beholder;
private readonly Mobile m_Beheld;
public VirtueGump(Mobile beholder, Mobile beheld) : base(0, 0)
{
@ -83,7 +84,6 @@ namespace Server
beholder.SendLocalizedMessage(1052066); // That virtue is not active yet.
}
private static void EventSink_VirtueMacroRequest(Mobile beholder, int virtue)
{
var virtueID = virtue switch
@ -121,8 +121,7 @@ namespace Server
return 2402;
if (value >= 30000)
value = 20000; //Sanity
value = 20000; // Sanity
int vl;
@ -137,7 +136,6 @@ namespace Server
else
vl = 1;
return m_Table[index * 3 + vl];
}
@ -149,7 +147,7 @@ namespace Server
private class InternalEntry : GumpImage
{
private static byte[] m_Class = StringToBuffer(" class=VirtueGumpItem");
private static readonly byte[] m_Class = StringToBuffer(" class=VirtueGumpItem");
public InternalEntry(int x, int y, int gumpID, int hue) : base(x, y, gumpID, hue)
{

View file

@ -5,10 +5,10 @@ namespace Server
{
public class VirtueInfoGump : Gump
{
private Mobile m_Beholder;
private int m_Desc;
private string m_Page;
private VirtueName m_Virtue;
private readonly Mobile m_Beholder;
private readonly int m_Desc;
private readonly string m_Page;
private readonly VirtueName m_Virtue;
public VirtueInfoGump(Mobile beholder, VirtueName virtue, int description, string webPage = null) : base(0, 0)
{
@ -47,7 +47,6 @@ namespace Server
for (int i = 0; i < 10; ++i)
AddImage(95 + i * 17, 50, i < dots ? 2362 : 2360);
if (value < 1)
valueDesc = 1052044; // You have not started on the path of this Virtue.
else if (value < 400)
@ -67,7 +66,6 @@ namespace Server
else
valueDesc = 1052050; // You have achieved the highest path in this Virtue.
AddHtmlLocalized(157, 73, 200, 40, 1051000 + (int)virtue);
AddHtmlLocalized(75, 95, 220, 140, description);
AddHtmlLocalized(70, 224, 229, 60, valueDesc);
@ -84,18 +82,18 @@ namespace Server
switch (info.ButtonID)
{
case 1:
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, m_Virtue, m_Desc, m_Page));
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, m_Virtue, m_Desc, m_Page));
if (m_Page != null)
state.Send(new LaunchBrowser(m_Page)); //No message about web browser starting on OSI
break;
}
if (m_Page != null)
state.Send(new LaunchBrowser(m_Page)); // No message about web browser starting on OSI
break;
}
case 2:
{
m_Beholder.SendGump(new VirtueStatusGump(m_Beholder));
break;
}
{
m_Beholder.SendGump(new VirtueStatusGump(m_Beholder));
break;
}
}
}
}

View file

@ -5,7 +5,7 @@ namespace Server
{
public class VirtueStatusGump : Gump
{
private Mobile m_Beholder;
private readonly Mobile m_Beholder;
public VirtueStatusGump(Mobile beholder) : base(0, 0)
{
@ -52,55 +52,55 @@ namespace Server
switch (info.ButtonID)
{
case 1:
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Humility, 1052051));
break;
}
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Humility, 1052051));
break;
}
case 2:
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Sacrifice, 1052053,
@"http://update.uo.com/design_389.html"));
break;
}
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Sacrifice, 1052053,
@"http://update.uo.com/design_389.html"));
break;
}
case 3:
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Compassion, 1053000,
@"http://update.uo.com/design_412.html"));
break;
}
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Compassion, 1053000,
@"http://update.uo.com/design_412.html"));
break;
}
case 4:
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Spirituality, 1052056));
break;
}
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Spirituality, 1052056));
break;
}
case 5:
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Valor, 1054033,
@"http://update.uo.com/design_427.html"));
break;
}
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Valor, 1054033,
@"http://update.uo.com/design_427.html"));
break;
}
case 6:
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Honor, 1052058,
@"http://guide.uo.com/virtues_2.html"));
break;
}
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Honor, 1052058,
@"http://guide.uo.com/virtues_2.html"));
break;
}
case 7:
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Justice, 1052059,
@"http://update.uo.com/design_413.html"));
break;
}
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Justice, 1052059,
@"http://update.uo.com/design_413.html"));
break;
}
case 8:
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Honesty, 1052060));
break;
}
{
m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Honesty, 1052060));
break;
}
case 9:
{
m_Beholder.SendGump(new VirtueGump(m_Beholder, m_Beholder));
break;
}
{
m_Beholder.SendGump(new VirtueGump(m_Beholder, m_Beholder));
break;
}
}
}
}