Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -1,130 +1,141 @@
using System;
using Server.Engines.CannedEvil;
using Server.Mobiles;
using Server.Targeting;
using Server.Engines.CannedEvil;
namespace Server
{
public class ValorVirtue
{
private static TimeSpan LossDelay = TimeSpan.FromDays( 7.0 );
private const int LossAmount = 250;
public class ValorVirtue
{
private const int LossAmount = 250;
private static TimeSpan LossDelay = TimeSpan.FromDays(7.0);
public static void Initialize()
{
VirtueGump.Register( 112, OnVirtueUsed );
}
public static void Initialize()
{
VirtueGump.Register(112, OnVirtueUsed);
}
public static void OnVirtueUsed( Mobile from )
{
if ( from.Alive )
{
from.SendLocalizedMessage( 1054034 ); // Target the Champion Idol of the Champion you wish to challenge!.
from.Target = new InternalTarget();
}
}
public static void OnVirtueUsed(Mobile from)
{
if (from.Alive)
{
from.SendLocalizedMessage(1054034); // Target the Champion Idol of the Champion you wish to challenge!.
from.Target = new InternalTarget();
}
}
public static void CheckAtrophy( Mobile from )
{
if ( !(from is PlayerMobile pm) )
return;
public static void CheckAtrophy(Mobile from)
{
if (!(from is PlayerMobile pm))
return;
try
{
if ( (pm.LastValorLoss + LossDelay) < DateTime.UtcNow )
{
if ( VirtueHelper.Atrophy( from, VirtueName.Valor, LossAmount ) )
from.SendLocalizedMessage( 1054040 ); // You have lost some Valor.
try
{
if (pm.LastValorLoss + LossDelay < DateTime.UtcNow)
{
if (VirtueHelper.Atrophy(from, VirtueName.Valor, LossAmount))
from.SendLocalizedMessage(1054040); // You have lost some Valor.
pm.LastValorLoss = DateTime.UtcNow;
}
}
catch
{
}
}
pm.LastValorLoss = DateTime.UtcNow;
}
}
catch
{
}
}
public static void Valor( Mobile from, object targ )
{
if ( !(targ is IdolOfTheChampion idol) || idol.Deleted || idol.Spawn == null || idol.Spawn.Deleted )
from.SendLocalizedMessage( 1054035 ); // You must target a Champion Idol to challenge the Champion's spawn!
else if ( from.Hidden )
from.SendLocalizedMessage( 1052015 ); // You cannot do that while hidden.
else if ( idol.Spawn.HasBeenAdvanced )
from.SendLocalizedMessage( 1054038 ); // The Champion of this region has already been challenged!
else
{
VirtueLevel vl = VirtueHelper.GetLevel( from, VirtueName.Valor );
if ( idol.Spawn.Active )
{
if ( idol.Spawn.Champion != null ) //TODO: Message?
return;
public static void Valor(Mobile from, object targ)
{
if (!(targ is IdolOfTheChampion idol) || idol.Deleted || idol.Spawn == null || idol.Spawn.Deleted)
{
from.SendLocalizedMessage(1054035); // You must target a Champion Idol to challenge the Champion's spawn!
}
else if (from.Hidden)
{
from.SendLocalizedMessage(1052015); // You cannot do that while hidden.
}
else if (idol.Spawn.HasBeenAdvanced)
{
from.SendLocalizedMessage(1054038); // The Champion of this region has already been challenged!
}
else
{
VirtueLevel vl = VirtueHelper.GetLevel(from, VirtueName.Valor);
if (idol.Spawn.Active)
{
if (idol.Spawn.Champion != null) //TODO: Message?
return;
int needed, consumed;
switch( idol.Spawn.GetSubLevel() )
{
case 0:
{
needed = consumed = 2500;
break;
}
case 1:
{
needed = consumed = 5000;
break;
}
case 2:
{
needed = 10000;
consumed = 7500;
break;
}
default:
{
needed = 20000;
consumed = 10000;
break;
}
}
int needed, consumed;
switch (idol.Spawn.GetSubLevel())
{
case 0:
{
needed = consumed = 2500;
break;
}
case 1:
{
needed = consumed = 5000;
break;
}
case 2:
{
needed = 10000;
consumed = 7500;
break;
}
default:
{
needed = 20000;
consumed = 10000;
break;
}
}
if ( from.Virtues.GetValue( (int)VirtueName.Valor ) >= needed )
{
VirtueHelper.Atrophy( from, VirtueName.Valor, consumed );
from.SendLocalizedMessage( 1054037 ); // Your challenge is heard by the Champion of this region! Beware its wrath!
idol.Spawn.HasBeenAdvanced = true;
idol.Spawn.AdvanceLevel();
}
else
from.SendLocalizedMessage( 1054039 ); // The Champion of this region ignores your challenge. You must further prove your valor.
}
else
{
if ( vl == VirtueLevel.Knight )
{
VirtueHelper.Atrophy( from, VirtueName.Valor, 11000 );
from.SendLocalizedMessage( 1054037 ); // Your challenge is heard by the Champion of this region! Beware its wrath!
idol.Spawn.EndRestart();
idol.Spawn.HasBeenAdvanced = true;
}
else
{
from.SendLocalizedMessage( 1054036 ); // You must be a Knight of Valor to summon the champion's spawn in this manner!
}
}
}
if (from.Virtues.GetValue((int)VirtueName.Valor) >= needed)
{
VirtueHelper.Atrophy(from, VirtueName.Valor, consumed);
from.SendLocalizedMessage(
1054037); // Your challenge is heard by the Champion of this region! Beware its wrath!
idol.Spawn.HasBeenAdvanced = true;
idol.Spawn.AdvanceLevel();
}
else
{
from.SendLocalizedMessage(
1054039); // The Champion of this region ignores your challenge. You must further prove your valor.
}
}
else
{
if (vl == VirtueLevel.Knight)
{
VirtueHelper.Atrophy(from, VirtueName.Valor, 11000);
from.SendLocalizedMessage(
1054037); // Your challenge is heard by the Champion of this region! Beware its wrath!
idol.Spawn.EndRestart();
idol.Spawn.HasBeenAdvanced = true;
}
else
{
from.SendLocalizedMessage(
1054036); // You must be a Knight of Valor to summon the champion's spawn in this manner!
}
}
}
}
}
private class InternalTarget : Target
{
public InternalTarget() : base(14, false, TargetFlags.None)
{
}
private class InternalTarget : Target
{
public InternalTarget() : base( 14, false, TargetFlags.None )
{
}
protected override void OnTarget( Mobile from, object targeted )
{
Valor( from, targeted );
}
}
}
}
protected override void OnTarget(Mobile from, object targeted)
{
Valor(from, targeted);
}
}
}
}