Fixes casting checks

This commit is contained in:
Kamron Batman 2018-08-19 01:38:55 +08:00
parent 7ea00fbf4f
commit 03dd5f1926
431 changed files with 5616 additions and 6250 deletions

View file

@ -242,9 +242,9 @@ namespace Server.Accounting
/// </summary>
public bool Inactive
{
get
get
{
if( this.AccessLevel != AccessLevel.Player )
if ( this.AccessLevel != AccessLevel.Player )
return false;
TimeSpan inactiveLength = DateTime.UtcNow - m_LastLogin;
@ -263,9 +263,7 @@ namespace Server.Accounting
{
for ( int i = 0; i < m_Mobiles.Length; i++ )
{
PlayerMobile m = m_Mobiles[i] as PlayerMobile;
if ( m != null && m.NetState != null )
if ( m_Mobiles[i] is PlayerMobile m && m.NetState != null )
return m_TotalGameTime + ( DateTime.UtcNow - m.SessionStart );
}
@ -511,9 +509,7 @@ namespace Server.Accounting
private static void EventSink_Connected( ConnectedEventArgs e )
{
Account acc = e.Mobile.Account as Account;
if ( acc == null )
if ( !(e.Mobile.Account is Account acc) )
return;
if ( acc.Young && acc.m_YoungTimer == null )
@ -525,9 +521,7 @@ namespace Server.Accounting
private static void EventSink_Disconnected( DisconnectedEventArgs e )
{
Account acc = e.Mobile.Account as Account;
if ( acc == null )
if ( !(e.Mobile.Account is Account acc) )
return;
if ( acc.m_YoungTimer != null )
@ -536,8 +530,7 @@ namespace Server.Accounting
acc.m_YoungTimer = null;
}
PlayerMobile m = e.Mobile as PlayerMobile;
if ( m == null )
if ( !(e.Mobile is PlayerMobile m) )
return;
acc.m_TotalGameTime += DateTime.UtcNow - m.SessionStart;
@ -545,14 +538,10 @@ namespace Server.Accounting
private static void EventSink_Login( LoginEventArgs e )
{
PlayerMobile m = e.Mobile as PlayerMobile;
if ( m == null )
if ( !(e.Mobile is PlayerMobile m) )
return;
Account acc = m.Account as Account;
if ( acc == null )
if ( !(m.Account is Account acc) )
return;
if ( m.Young && acc.Young )
@ -570,9 +559,7 @@ namespace Server.Accounting
for ( int i = 0; i < m_Mobiles.Length; i++ )
{
PlayerMobile m = m_Mobiles[i] as PlayerMobile;
if ( m != null && m.Young )
if ( m_Mobiles[i] is PlayerMobile m && m.Young )
{
m.Young = false;
@ -614,7 +601,7 @@ namespace Server.Accounting
public Account( string username, string password )
{
m_Username = username;
SetPassword( password );
m_AccessLevel = AccessLevel.Player;
@ -685,7 +672,7 @@ namespace Server.Accounting
m_Flags = Utility.GetXMLInt32( Utility.GetText( node["flags"], "0" ), 0 );
m_Created = Utility.GetXMLDateTime( Utility.GetText( node["created"], null ), DateTime.UtcNow );
m_LastLogin = Utility.GetXMLDateTime( Utility.GetText( node["lastLogin"], null ), DateTime.UtcNow );
TotalGold = Utility.GetXMLInt32( Utility.GetText(node["totalGold"], "0" ), 0 );
TotalPlat = Utility.GetXMLInt32(Utility.GetText(node["totalPlat"], "0"), 0);
@ -706,9 +693,7 @@ namespace Server.Accounting
{
for ( int i = 0; i < m_Mobiles.Length; i++ )
{
PlayerMobile m = m_Mobiles[i] as PlayerMobile;
if ( m != null )
if ( m_Mobiles[i] is PlayerMobile m )
totalGameTime += m.GameTime;
}
}
@ -776,7 +761,7 @@ namespace Server.Accounting
{
IPAddress address;
if( IPAddress.TryParse( Utility.GetText( ip, null ), out address ) )
if ( IPAddress.TryParse( Utility.GetText( ip, null ), out address ) )
{
list[count] = Utility.Intern( address );
count++;
@ -1221,8 +1206,8 @@ namespace Server.Accounting
public int CompareTo( object obj )
{
if ( obj is Account )
return this.CompareTo( (Account) obj );
if ( obj is Account account )
return this.CompareTo( account );
throw new ArgumentException();
}

View file

@ -82,9 +82,8 @@ namespace Server.Misc
public static void Password_OnCommand( CommandEventArgs e )
{
Mobile from = e.Mobile;
Account acct = from.Account as Account;
if ( acct == null )
if ( !(from.Account is Account acct) )
return;
IPAddress[] accessList = acct.LoginIPs;
@ -102,7 +101,7 @@ namespace Server.Misc
from.SendMessage( "You must specify the new password." );
return;
}
else if ( e.Length == 1 )
if ( e.Length == 1 )
{
from.SendMessage( "To prevent potential typing mistakes, you must type the password twice. Use the format:" );
from.SendMessage( "Password \"(newPassword)\" \"(repeated)\"" );
@ -172,9 +171,7 @@ namespace Server.Misc
NetState state = e.State;
int index = e.Index;
Account acct = state.Account as Account;
if ( acct == null )
if ( !(state.Account is Account acct) )
{
state.Dispose();
}
@ -315,9 +312,8 @@ namespace Server.Misc
string pw = e.Password;
e.Accepted = false;
Account acct = Accounts.GetAccount( un ) as Account;
if ( acct == null )
if ( !(Accounts.GetAccount( un ) is Account acct) )
{
if ( AutoAccountCreation && un.Trim().Length > 0 ) // To prevent someone from making an account of just '' or a bunch of meaningless spaces
{
@ -378,9 +374,7 @@ namespace Server.Misc
string un = e.Username;
string pw = e.Password;
Account acct = Accounts.GetAccount( un ) as Account;
if ( acct == null )
if ( !(Accounts.GetAccount( un ) is Account acct) )
{
e.Accepted = false;
}
@ -415,21 +409,16 @@ namespace Server.Misc
public static bool CheckAccount( Mobile mobCheck, Mobile accCheck )
{
if ( accCheck != null )
if ( accCheck?.Account is Account a )
{
Account a = accCheck.Account as Account;
if ( a != null )
for ( int i = 0; i < a.Length; ++i )
{
for ( int i = 0; i < a.Length; ++i )
{
if ( a[i] == mobCheck )
return true;
}
if ( a[i] == mobCheck )
return true;
}
}
return false;
}
}
}
}

View file

@ -34,20 +34,18 @@ namespace Server
public override bool Equals( object obj )
{
if( obj is IPAddress )
if ( obj is IPAddress )
{
return obj.Equals( m_Address );
}
else if( obj is string )
if ( obj is string s )
{
IPAddress otherAddress;
if( IPAddress.TryParse( (string)obj, out otherAddress ) )
if ( IPAddress.TryParse( s, out IPAddress otherAddress ) )
return otherAddress.Equals( m_Address );
}
else if( obj is IPFirewallEntry )
else if ( obj is IPFirewallEntry entry )
{
return m_Address.Equals( ((IPFirewallEntry)obj).m_Address );
return m_Address.Equals( entry.m_Address );
}
return false;
@ -82,31 +80,22 @@ namespace Server
public override bool Equals( object obj )
{
if( obj is string )
if ( obj is string entry )
{
string entry= (string)obj;
string[] str = entry.Split( '/' );
if( str.Length == 2 )
if ( str.Length == 2 )
{
IPAddress cidrPrefix;
if( IPAddress.TryParse( str[0], out cidrPrefix ) )
if ( IPAddress.TryParse( str[0], out IPAddress cidrPrefix ) )
{
int cidrLength;
if( int.TryParse( str[1], out cidrLength ) )
if ( int.TryParse( str[1], out int cidrLength ) )
return m_CIDRPrefix.Equals( cidrPrefix ) && m_CIDRLength.Equals( cidrLength );
}
}
}
else if( obj is CIDRFirewallEntry )
else if ( obj is CIDRFirewallEntry cidrEntry )
{
CIDRFirewallEntry entry = obj as CIDRFirewallEntry;
return m_CIDRPrefix.Equals( entry.m_CIDRPrefix ) && m_CIDRLength.Equals( entry.m_CIDRLength );
return m_CIDRPrefix.Equals( cidrEntry.m_CIDRPrefix ) && m_CIDRLength.Equals( cidrEntry.m_CIDRLength );
}
return false;
@ -131,7 +120,7 @@ namespace Server
public bool IsBlocked( IPAddress address )
{
if( !m_Valid )
if ( !m_Valid )
return false; //Why process if it's invalid? it'll return false anyway after processing it.
return Utility.IPMatch( m_Entry, address, ref m_Valid );
@ -139,17 +128,15 @@ namespace Server
public override string ToString()
{
return m_Entry.ToString();
return m_Entry;
}
public override bool Equals( object obj )
{
if( obj is string )
if ( obj is string )
return obj.Equals( m_Entry );
else if( obj is WildcardIPFirewallEntry )
return m_Entry.Equals( ((WildcardIPFirewallEntry)obj).m_Entry );
return false;
return obj is WildcardIPFirewallEntry entry && m_Entry.Equals( entry.m_Entry );
}
public override int GetHashCode()
@ -186,7 +173,7 @@ namespace Server
object toAdd;
IPAddress addr;
if( IPAddress.TryParse( line, out addr ) )
if ( IPAddress.TryParse( line, out addr ) )
toAdd = addr;
else
toAdd = line;
@ -208,35 +195,29 @@ namespace Server
public static IFirewallEntry ToFirewallEntry( object entry )
{
if( entry is IFirewallEntry )
return (IFirewallEntry)entry;
else if( entry is IPAddress )
return new IPFirewallEntry( (IPAddress)entry );
else if( entry is string )
return ToFirewallEntry( (string)entry );
if ( entry is IFirewallEntry firewallEntry )
return firewallEntry;
if ( entry is IPAddress address )
return new IPFirewallEntry( address );
if ( entry is string s )
return ToFirewallEntry( s );
return null;
}
public static IFirewallEntry ToFirewallEntry( string entry )
{
IPAddress addr;
if( IPAddress.TryParse( entry, out addr ) )
if ( IPAddress.TryParse( entry, out IPAddress addr ) )
return new IPFirewallEntry( addr );
//Try CIDR parse
string[] str = entry.Split( '/' );
if( str.Length == 2 )
if ( str.Length == 2 )
{
IPAddress cidrPrefix;
if( IPAddress.TryParse( str[0], out cidrPrefix ) )
if ( IPAddress.TryParse( str[0], out IPAddress cidrPrefix ) )
{
int cidrLength;
if( int.TryParse( str[1], out cidrLength ) )
if ( int.TryParse( str[1], out int cidrLength ) )
return new CIDRFirewallEntry( cidrPrefix, cidrLength );
}
}
@ -254,7 +235,7 @@ namespace Server
{
IFirewallEntry entry = ToFirewallEntry( obj );
if( entry != null )
if ( entry != null )
{
m_Blocked.Remove( entry );
Save();
@ -263,17 +244,17 @@ namespace Server
public static void Add( object obj )
{
if( obj is IPAddress )
Add( (IPAddress)obj );
else if( obj is string )
Add( (string)obj );
else if( obj is IFirewallEntry )
Add( (IFirewallEntry)obj );
if ( obj is IPAddress address )
Add( address );
else if ( obj is string s )
Add( s );
else if ( obj is IFirewallEntry entry )
Add( entry );
}
public static void Add( IFirewallEntry entry )
{
if( !m_Blocked.Contains( entry ) )
if ( !m_Blocked.Contains( entry ) )
m_Blocked.Add( entry );
Save();
@ -283,7 +264,7 @@ namespace Server
{
IFirewallEntry entry = ToFirewallEntry( pattern );
if( !m_Blocked.Contains( entry ) )
if ( !m_Blocked.Contains( entry ) )
m_Blocked.Add( entry );
Save();
@ -293,7 +274,7 @@ namespace Server
{
IFirewallEntry entry = new IPFirewallEntry( ip );
if( !m_Blocked.Contains( entry ) )
if ( !m_Blocked.Contains( entry ) )
m_Blocked.Add( entry );
Save();
@ -314,7 +295,7 @@ namespace Server
{
for( int i = 0; i < m_Blocked.Count; i++ )
{
if( m_Blocked[i].IsBlocked( ip ) )
if ( m_Blocked[i].IsBlocked( ip ) )
return true;
}
@ -332,7 +313,7 @@ namespace Server
contains = Utility.IPMatchCIDR( s, ip );
if( !contains )
if ( !contains )
contains = Utility.IPMatch( s, ip );
}
}
@ -341,4 +322,4 @@ namespace Server
* */
}
}
}
}

View file

@ -328,12 +328,10 @@ namespace Server.Commands
sb.AppendFormat( "0x{0:X}; ", built.Serial.Value );
if ( built is Item ) {
Container pack = packs[i];
pack.DropItem( (Item)built );
if ( built is Item item ) {
packs[i].DropItem( item );
}
else if ( built is Mobile ) {
Mobile m = (Mobile)built;
else if ( built is Mobile m ) {
m.MoveToWorld( new Point3D( start.X, start.Y, start.Z ), map );
}
}
@ -356,12 +354,10 @@ namespace Server.Commands
sb.AppendFormat( "0x{0:X}; ", built.Serial.Value );
if ( built is Item ) {
Item item = (Item)built;
if ( built is Item item ) {
item.MoveToWorld( new Point3D( x, y, z ), map );
}
else if ( built is Mobile ) {
Mobile m = (Mobile)built;
else if ( built is Mobile m ) {
m.MoveToWorld( new Point3D( x, y, z ), map );
}
}
@ -438,14 +434,12 @@ namespace Server.Commands
protected override void OnTarget( Mobile from, object o )
{
IPoint3D p = o as IPoint3D;
if ( p != null )
if ( o is IPoint3D p )
{
if ( p is Item )
p = ((Item)p).GetWorldTop();
else if ( p is Mobile )
p = ((Mobile)p).Location;
if ( p is Item item )
p = item.GetWorldTop();
else if ( p is Mobile m )
p = m.Location;
Point3D point = new Point3D( p );
Add.Invoke( from, point, point, m_Args );

View file

@ -37,12 +37,11 @@ namespace Server
protected override void OnTarget( Mobile from, object targeted )
{
IPoint3D p = targeted as IPoint3D;
if ( p == null )
if ( !(targeted is IPoint3D p) )
return;
else if ( p is Item )
p = ((Item)p).GetWorldTop();
if ( p is Item item )
p = item.GetWorldTop();
if ( m_First )
{
@ -65,4 +64,4 @@ namespace Server
}
}
}
}
}

View file

@ -6,6 +6,7 @@ using Server;
using Server.Items;
using Server.Engines.Quests.Haven;
using Server.Engines.Quests.Necro;
using Server.Mobiles;
namespace Server.Commands
{
@ -388,12 +389,10 @@ namespace Server.Commands
throw new Exception( String.Format( "Bad type: {0}", m_Type ), e );
}
if ( item is BaseAddon )
if ( item is BaseAddon addon )
{
if ( item is MaabusCoffin )
if ( addon is MaabusCoffin coffin )
{
MaabusCoffin coffin = (MaabusCoffin)item;
for ( int i = 0; i < m_Params.Length; ++i )
{
if ( m_Params[i].StartsWith( "SpawnLocation" ) )
@ -407,18 +406,18 @@ namespace Server.Commands
}
else if ( m_ItemID > 0 )
{
List<AddonComponent> comps = ((BaseAddon)item).Components;
List<AddonComponent> comps = addon.Components;
for ( int i = 0; i < comps.Count; ++i )
{
AddonComponent comp = (AddonComponent)comps[i];
AddonComponent comp = comps[i];
if ( comp.Offset == Point3D.Zero )
comp.ItemID = m_ItemID;
}
}
}
else if ( item is BaseLight )
else if ( item is BaseLight light )
{
bool unlit = false, unprotected = false;
@ -428,23 +427,21 @@ namespace Server.Commands
unlit = true;
else if ( !unprotected && m_Params[i] == "Unprotected" )
unprotected = true;
if ( unlit && unprotected )
break;
}
if ( !unlit )
((BaseLight)item).Ignite();
light.Ignite();
if ( !unprotected )
((BaseLight)item).Protected = true;
light.Protected = true;
if ( m_ItemID > 0 )
item.ItemID = m_ItemID;
light.ItemID = m_ItemID;
}
else if ( item is Server.Mobiles.Spawner )
else if ( item is Spawner sp )
{
Server.Mobiles.Spawner sp = (Server.Mobiles.Spawner)item;
sp.NextSpawn = TimeSpan.Zero;
for ( int i = 0; i < m_Params.Length; ++i )
@ -518,10 +515,8 @@ namespace Server.Commands
}
}
}
else if ( item is RecallRune )
else if ( item is RecallRune rune )
{
RecallRune rune = (RecallRune)item;
for ( int i = 0; i < m_Params.Length; ++i )
{
if ( m_Params[i].StartsWith( "Description" ) )
@ -554,10 +549,8 @@ namespace Server.Commands
}
}
}
else if ( item is SkillTeleporter )
else if ( item is SkillTeleporter st )
{
SkillTeleporter tp = (SkillTeleporter)item;
for ( int i = 0; i < m_Params.Length; ++i )
{
if ( m_Params[i].StartsWith( "Skill" ) )
@ -565,94 +558,92 @@ namespace Server.Commands
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Skill = (SkillName)Enum.Parse( typeof( SkillName ), m_Params[i].Substring( ++indexOf ), true );
st.Skill = (SkillName)Enum.Parse( typeof( SkillName ), m_Params[i].Substring( ++indexOf ), true );
}
else if ( m_Params[i].StartsWith( "RequiredFixedPoint" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Required = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) ) * 0.1;
st.Required = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) ) * 0.1;
}
else if ( m_Params[i].StartsWith( "Required" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Required = Utility.ToDouble( m_Params[i].Substring( ++indexOf ) );
st.Required = Utility.ToDouble( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "MessageString" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.MessageString = m_Params[i].Substring( ++indexOf );
st.MessageString = m_Params[i].Substring( ++indexOf );
}
else if ( m_Params[i].StartsWith( "MessageNumber" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.MessageNumber = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
st.MessageNumber = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "PointDest" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.PointDest = Point3D.Parse( m_Params[i].Substring( ++indexOf ) );
st.PointDest = Point3D.Parse( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "MapDest" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.MapDest = Map.Parse( m_Params[i].Substring( ++indexOf ) );
st.MapDest = Map.Parse( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "Creatures" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Creatures = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
st.Creatures = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "SourceEffect" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.SourceEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
st.SourceEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "DestEffect" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.DestEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
st.DestEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "SoundID" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.SoundID = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
st.SoundID = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "Delay" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Delay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
st.Delay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
}
}
if ( m_ItemID > 0 )
item.ItemID = m_ItemID;
st.ItemID = m_ItemID;
}
else if ( item is KeywordTeleporter )
else if ( item is KeywordTeleporter kt )
{
KeywordTeleporter tp = (KeywordTeleporter)item;
for ( int i = 0; i < m_Params.Length; ++i )
{
if ( m_Params[i].StartsWith( "Substring" ) )
@ -660,80 +651,78 @@ namespace Server.Commands
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Substring = m_Params[i].Substring( ++indexOf );
kt.Substring = m_Params[i].Substring( ++indexOf );
}
else if ( m_Params[i].StartsWith( "Keyword" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Keyword = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
kt.Keyword = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "Range" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Range = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
kt.Range = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "PointDest" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.PointDest = Point3D.Parse( m_Params[i].Substring( ++indexOf ) );
kt.PointDest = Point3D.Parse( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "MapDest" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.MapDest = Map.Parse( m_Params[i].Substring( ++indexOf ) );
kt.MapDest = Map.Parse( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "Creatures" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Creatures = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
kt.Creatures = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "SourceEffect" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.SourceEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
kt.SourceEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "DestEffect" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.DestEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
kt.DestEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "SoundID" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.SoundID = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
kt.SoundID = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "Delay" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Delay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
kt.Delay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
}
}
if ( m_ItemID > 0 )
item.ItemID = m_ItemID;
kt.ItemID = m_ItemID;
}
else if ( item is Teleporter )
else if ( item is Teleporter tp )
{
Teleporter tp = (Teleporter)item;
for ( int i = 0; i < m_Params.Length; ++i )
{
if ( m_Params[i].StartsWith( "PointDest" ) )
@ -788,12 +777,10 @@ namespace Server.Commands
}
if ( m_ItemID > 0 )
item.ItemID = m_ItemID;
tp.ItemID = m_ItemID;
}
else if ( item is FillableContainer )
else if ( item is FillableContainer cont )
{
FillableContainer cont = (FillableContainer) item;
for ( int i = 0; i < m_Params.Length; ++i )
{
if ( m_Params[i].StartsWith( "ContentType" ) )
@ -806,7 +793,7 @@ namespace Server.Commands
}
if ( m_ItemID > 0 )
item.ItemID = m_ItemID;
cont.ItemID = m_ItemID;
}
else if ( m_ItemID > 0 )
{
@ -832,8 +819,8 @@ namespace Server.Commands
{
int hue = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
if ( item is DyeTub )
((DyeTub)item).DyedHue = hue;
if ( item is DyeTub tub )
tub.DyedHue = hue;
else
item.Hue = hue;
}
@ -1000,27 +987,30 @@ namespace Server.Commands
item.MoveToWorld( loc, maps[j] );
++count;
if ( item is BaseDoor )
if ( item is BaseDoor door )
{
IPooledEnumerable<BaseDoor> eable = maps[j].GetItemsInRange<BaseDoor>( loc, 1 );
Type itemType = item.GetType();
Type itemType = door.GetType();
foreach ( BaseDoor link in eable )
{
if ( link != item && link.Z == item.Z && link.GetType() == itemType )
if ( link != item && link.Z == door.Z && link.GetType() == itemType )
{
((BaseDoor)item).Link = link;
link.Link = (BaseDoor)item;
door.Link = link;
link.Link = door;
break;
}
}
eable.Free();
}
else if ( item is MarkContainer )
else if ( item is MarkContainer markCont )
{
try{ ((MarkContainer)item).Target = Point3D.Parse( extra ); }
try
{
markCont.Target = Point3D.Parse( extra );
}
catch{}
}

View file

@ -6,6 +6,7 @@ using Server;
using Server.Items;
using Server.Engines.Quests.Haven;
using Server.Engines.Quests.Necro;
using Server.Mobiles;
namespace Server.Commands
{
@ -385,12 +386,10 @@ namespace Server.Commands
throw new Exception( String.Format( "Bad type: {0}", m_Type ), e );
}
if ( item is BaseAddon )
if ( item is BaseAddon addon )
{
if ( item is MaabusCoffin )
if ( addon is MaabusCoffin coffin )
{
MaabusCoffin coffin = (MaabusCoffin)item;
for ( int i = 0; i < m_Params.Length; ++i )
{
if ( m_Params[i].StartsWith( "SpawnLocation" ) )
@ -404,7 +403,7 @@ namespace Server.Commands
}
else if ( m_ItemID > 0 )
{
List<AddonComponent> comps = ((BaseAddon)item).Components;
List<AddonComponent> comps = addon.Components;
for ( int i = 0; i < comps.Count; ++i )
{
@ -415,7 +414,7 @@ namespace Server.Commands
}
}
}
else if ( item is BaseLight )
else if ( item is BaseLight light )
{
bool unlit = false, unprotected = false;
@ -425,23 +424,21 @@ namespace Server.Commands
unlit = true;
else if ( !unprotected && m_Params[i] == "Unprotected" )
unprotected = true;
if ( unlit && unprotected )
break;
}
if ( !unlit )
((BaseLight)item).Ignite();
light.Ignite();
if ( !unprotected )
((BaseLight)item).Protected = true;
light.Protected = true;
if ( m_ItemID > 0 )
item.ItemID = m_ItemID;
light.ItemID = m_ItemID;
}
else if ( item is Server.Mobiles.Spawner )
else if ( item is Spawner sp )
{
Server.Mobiles.Spawner sp = (Server.Mobiles.Spawner)item;
sp.NextSpawn = TimeSpan.Zero;
for ( int i = 0; i < m_Params.Length; ++i )
@ -515,10 +512,8 @@ namespace Server.Commands
}
}
}
else if ( item is RecallRune )
else if ( item is RecallRune rune )
{
RecallRune rune = (RecallRune)item;
for ( int i = 0; i < m_Params.Length; ++i )
{
if ( m_Params[i].StartsWith( "Description" ) )
@ -551,10 +546,8 @@ namespace Server.Commands
}
}
}
else if ( item is SkillTeleporter )
else if ( item is SkillTeleporter st )
{
SkillTeleporter tp = (SkillTeleporter)item;
for ( int i = 0; i < m_Params.Length; ++i )
{
if ( m_Params[i].StartsWith( "Skill" ) )
@ -562,94 +555,92 @@ namespace Server.Commands
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Skill = (SkillName)Enum.Parse( typeof( SkillName ), m_Params[i].Substring( ++indexOf ), true );
st.Skill = (SkillName)Enum.Parse( typeof( SkillName ), m_Params[i].Substring( ++indexOf ), true );
}
else if ( m_Params[i].StartsWith( "RequiredFixedPoint" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Required = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) ) * 0.1;
st.Required = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) ) * 0.1;
}
else if ( m_Params[i].StartsWith( "Required" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Required = Utility.ToDouble( m_Params[i].Substring( ++indexOf ) );
st.Required = Utility.ToDouble( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "MessageString" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.MessageString = m_Params[i].Substring( ++indexOf );
st.MessageString = m_Params[i].Substring( ++indexOf );
}
else if ( m_Params[i].StartsWith( "MessageNumber" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.MessageNumber = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
st.MessageNumber = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "PointDest" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.PointDest = Point3D.Parse( m_Params[i].Substring( ++indexOf ) );
st.PointDest = Point3D.Parse( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "MapDest" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.MapDest = Map.Parse( m_Params[i].Substring( ++indexOf ) );
st.MapDest = Map.Parse( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "Creatures" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Creatures = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
st.Creatures = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "SourceEffect" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.SourceEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
st.SourceEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "DestEffect" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.DestEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
st.DestEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "SoundID" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.SoundID = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
st.SoundID = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "Delay" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Delay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
st.Delay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
}
}
if ( m_ItemID > 0 )
item.ItemID = m_ItemID;
st.ItemID = m_ItemID;
}
else if ( item is KeywordTeleporter )
else if ( item is KeywordTeleporter kt )
{
KeywordTeleporter tp = (KeywordTeleporter)item;
for ( int i = 0; i < m_Params.Length; ++i )
{
if ( m_Params[i].StartsWith( "Substring" ) )
@ -657,80 +648,78 @@ namespace Server.Commands
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Substring = m_Params[i].Substring( ++indexOf );
kt.Substring = m_Params[i].Substring( ++indexOf );
}
else if ( m_Params[i].StartsWith( "Keyword" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Keyword = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
kt.Keyword = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "Range" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Range = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
kt.Range = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "PointDest" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.PointDest = Point3D.Parse( m_Params[i].Substring( ++indexOf ) );
kt.PointDest = Point3D.Parse( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "MapDest" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.MapDest = Map.Parse( m_Params[i].Substring( ++indexOf ) );
kt.MapDest = Map.Parse( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "Creatures" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Creatures = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
kt.Creatures = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "SourceEffect" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.SourceEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
kt.SourceEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "DestEffect" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.DestEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
kt.DestEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "SoundID" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.SoundID = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
kt.SoundID = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
}
else if ( m_Params[i].StartsWith( "Delay" ) )
{
int indexOf = m_Params[i].IndexOf( '=' );
if ( indexOf >= 0 )
tp.Delay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
kt.Delay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
}
}
if ( m_ItemID > 0 )
item.ItemID = m_ItemID;
kt.ItemID = m_ItemID;
}
else if ( item is Teleporter )
else if ( item is Teleporter tp )
{
Teleporter tp = (Teleporter)item;
for ( int i = 0; i < m_Params.Length; ++i )
{
if ( m_Params[i].StartsWith( "PointDest" ) )
@ -785,12 +774,10 @@ namespace Server.Commands
}
if ( m_ItemID > 0 )
item.ItemID = m_ItemID;
tp.ItemID = m_ItemID;
}
else if ( item is FillableContainer )
else if ( item is FillableContainer cont )
{
FillableContainer cont = (FillableContainer) item;
for ( int i = 0; i < m_Params.Length; ++i )
{
if ( m_Params[i].StartsWith( "ContentType" ) )
@ -803,7 +790,7 @@ namespace Server.Commands
}
if ( m_ItemID > 0 )
item.ItemID = m_ItemID;
cont.ItemID = m_ItemID;
}
else if ( m_ItemID > 0 )
{
@ -829,8 +816,8 @@ namespace Server.Commands
{
int hue = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
if ( item is DyeTub )
((DyeTub)item).DyedHue = hue;
if ( item is DyeTub tub )
tub.DyedHue = hue;
else
item.Hue = hue;
}
@ -997,27 +984,30 @@ namespace Server.Commands
item.MoveToWorld( loc, maps[j] );
++count;
if ( item is BaseDoor )
if ( item is BaseDoor door )
{
IPooledEnumerable<BaseDoor> eable = maps[j].GetItemsInRange<BaseDoor>( loc, 1 );
Type itemType = item.GetType();
Type itemType = door.GetType();
foreach ( BaseDoor link in eable )
{
if ( link != item && link.Z == item.Z && link.GetType() == itemType )
if ( link != item && link.Z == door.Z && link.GetType() == itemType )
{
((BaseDoor)item).Link = link;
link.Link = (BaseDoor)item;
door.Link = link;
link.Link = door;
break;
}
}
eable.Free();
}
else if ( item is MarkContainer )
else if ( item is MarkContainer markCont )
{
try{ ((MarkContainer)item).Target = Point3D.Parse( extra ); }
try
{
markCont.Target = Point3D.Parse( extra );
}
catch{}
}

File diff suppressed because it is too large Load diff

View file

@ -60,16 +60,14 @@ namespace Server.Commands
CommandLogging.WriteLine( from, "{0} {1} duping {2} (inBag={3}; amount={4})", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( targ ), m_InBag, m_Amount );
Item copy = (Item)targ;
Container pack;
Container pack = null;
if ( m_InBag )
{
if ( copy.Parent is Container )
pack = (Container)copy.Parent;
else if ( copy.Parent is Mobile )
pack = ( (Mobile)copy.Parent ).Backpack;
else
pack = null;
if ( copy.Parent is Container cont )
pack = cont;
else if ( copy.Parent is Mobile m )
pack = m.Backpack;
}
else
pack = from.Backpack;
@ -87,11 +85,8 @@ namespace Server.Commands
from.SendMessage( "Duping {0}...", m_Amount );
for ( int i = 0; i < m_Amount; i++ )
{
object o = c.Invoke( null );
if ( o != null && o is Item )
if ( c.Invoke( null ) is Item newItem )
{
Item newItem = (Item)o;
CopyProperties( newItem, copy );//copy.Dupe( item, copy.Amount );
copy.OnAfterDuped( newItem );
newItem.Parent = null;

View file

@ -97,16 +97,12 @@ namespace Server.Commands
xml.WriteAttributeString( "type", cte.Type.ToString() );
object obj = cte.Object;
if ( obj is Item )
if ( cte.Object is Item item )
{
Item item = (Item)obj;
int itemID = item.ItemID;
if ( item is BaseAddon && ((BaseAddon)item).Components.Count == 1 )
itemID = ((AddonComponent)(((BaseAddon)item).Components[0])).ItemID;
if ( item is BaseAddon addon && addon.Components.Count == 1 )
itemID = addon.Components[0].ItemID;
if ( itemID > TileData.MaxItemValue )
itemID = 1;
@ -123,10 +119,8 @@ namespace Server.Commands
item.Delete();
}
else if ( obj is Mobile )
else if ( cte.Object is Mobile mob )
{
Mobile mob = (Mobile)obj;
int itemID = ShrinkTable.Lookup( mob, 1 );
xml.WriteAttributeString( "gfx", XmlConvert.ToString( itemID ) );
@ -251,15 +245,15 @@ namespace Server.Commands
{
string a = null, b = null;
if ( x is CategoryEntry )
a = ((CategoryEntry)x).Title;
else if ( x is CategoryTypeEntry )
a = ((CategoryTypeEntry)x).Type.Name;
if ( x is CategoryEntry entry )
a = entry.Title;
else if ( x is CategoryTypeEntry typeEntry )
a = typeEntry.Type.Name;
if ( y is CategoryEntry )
b = ((CategoryEntry)y).Title;
else if ( y is CategoryTypeEntry )
b = ((CategoryTypeEntry)y).Type.Name;
if ( y is CategoryEntry categoryEntry )
b = categoryEntry.Title;
else if ( y is CategoryTypeEntry typeEntry )
b = typeEntry.Type.Name;
if ( a == null && b == null )
return 0;
@ -423,4 +417,4 @@ namespace Server.Commands
return (CategoryLine[])list.ToArray( typeof( CategoryLine ) );
}
}
}
}

View file

@ -76,19 +76,14 @@ namespace Server.Commands.Generic
if ( from.AccessLevel >= AccessLevel.Administrator || obj == null )
return true;
Mobile mob;
Mobile mob = null;
if ( obj is Mobile )
mob = (Mobile)obj;
else if ( obj is Item )
mob = ((Item)obj).RootParent as Mobile;
else
mob = null;
if ( obj is Mobile m )
mob = m;
else if ( obj is Item item )
mob = item.RootParent as Mobile;
if ( mob == null || mob == from || from.AccessLevel > mob.AccessLevel )
return true;
return false;
return mob == null || mob == from || from.AccessLevel > mob.AccessLevel;
}
public virtual void ExecuteList( CommandEventArgs e, ArrayList list )
@ -179,16 +174,16 @@ namespace Server.Commands.Generic
{
object obj = m_Responses[i];
if ( obj is MessageEntry )
if ( obj is MessageEntry entry )
{
from.SendMessage( ((MessageEntry)obj).ToString() );
from.SendMessage( entry.ToString() );
if ( flushToLog )
CommandLogging.WriteLine( from, ((MessageEntry)obj).ToString() );
CommandLogging.WriteLine( from, entry.ToString() );
}
else if ( obj is Gump )
else if ( obj is Gump gump )
{
from.SendGump( (Gump) obj );
from.SendGump( gump );
}
}
}
@ -202,4 +197,4 @@ namespace Server.Commands.Generic
m_Failures.Clear();
}
}
}
}

View file

@ -130,9 +130,7 @@ namespace Server.Commands.Generic
public override void Execute( CommandEventArgs e, object obj )
{
Item item = obj as Item;
if ( item != null )
if ( obj is Item item )
{
if ( e.Mobile.PlaceInBackpack( item ) )
AddResponse( "The item has been placed in your backpack." );
@ -156,9 +154,9 @@ namespace Server.Commands.Generic
public override void Execute( CommandEventArgs e, object obj )
{
if ( obj is HouseSign )
if ( obj is HouseSign sign )
{
BaseHouse house = ((HouseSign)obj).Owner;
BaseHouse house = sign.Owner;
if ( house == null )
{
@ -416,10 +414,10 @@ namespace Server.Commands.Generic
object obj = list[i];
Container cont = null;
if ( obj is Mobile )
cont = ((Mobile)obj).Backpack;
else if ( obj is Container )
cont = (Container)obj;
if ( obj is Mobile mobile )
cont = mobile.Backpack;
else if ( obj is Container container )
cont = container;
if ( cont != null )
packs.Add( cont );
@ -480,15 +478,13 @@ namespace Server.Commands.Generic
public override void Execute( CommandEventArgs e, object obj )
{
IPoint3D p = obj as IPoint3D;
if ( p == null )
if ( !(obj is IPoint3D p) )
return;
if ( p is Item )
p = ((Item)p).GetWorldTop();
else if ( p is Mobile )
p = ((Mobile)p).Location;
if ( p is Item item )
p = item.GetWorldTop();
else if ( p is Mobile m )
p = m.Location;
Add.Invoke( e.Mobile, new Point3D( p ), new Point3D( p ), e.Arguments );
}
@ -508,9 +504,7 @@ namespace Server.Commands.Generic
public override void Execute( CommandEventArgs e, object obj )
{
IPoint3D p = obj as IPoint3D;
if ( p == null )
if ( !(obj is IPoint3D p) )
return;
Mobile from = e.Mobile;
@ -560,9 +554,9 @@ namespace Server.Commands.Generic
{
Item item = mob.Items[i];
if ( item is IMountItem )
if ( item is IMountItem mountItem )
{
IMount mount = ((IMountItem)item).Mount;
IMount mount = mountItem.Mount;
if ( mount != null )
{
@ -608,11 +602,11 @@ namespace Server.Commands.Generic
public override void Execute( CommandEventArgs e, object obj )
{
if ( obj is BaseVendor )
if ( obj is BaseVendor vendor )
{
CommandLogging.WriteLine( e.Mobile, "{0} {1} restocking {2}", e.Mobile.AccessLevel, CommandLogging.Format( e.Mobile ), CommandLogging.Format( obj ) );
CommandLogging.WriteLine( e.Mobile, "{0} {1} restocking {2}", e.Mobile.AccessLevel, CommandLogging.Format( e.Mobile ), CommandLogging.Format( vendor ) );
((BaseVendor)obj).Restock();
vendor.Restock();
AddResponse( "The vendor has been restocked." );
}
else
@ -816,16 +810,16 @@ namespace Server.Commands.Generic
public override void Execute( CommandEventArgs e, object obj )
{
if ( obj is Item )
if ( obj is Item item )
{
CommandLogging.WriteLine( e.Mobile, "{0} {1} deleting {2}", e.Mobile.AccessLevel, CommandLogging.Format( e.Mobile ), CommandLogging.Format( obj ) );
((Item)obj).Delete();
CommandLogging.WriteLine( e.Mobile, "{0} {1} deleting {2}", e.Mobile.AccessLevel, CommandLogging.Format( e.Mobile ), CommandLogging.Format( item ) );
item.Delete();
AddResponse( "The item has been deleted." );
}
else if ( obj is Mobile && !((Mobile)obj).Player )
else if ( obj is Mobile mobile && !mobile.Player )
{
CommandLogging.WriteLine( e.Mobile, "{0} {1} deleting {2}", e.Mobile.AccessLevel, CommandLogging.Format( e.Mobile ), CommandLogging.Format( obj ) );
((Mobile)obj).Delete();
CommandLogging.WriteLine( e.Mobile, "{0} {1} deleting {2}", e.Mobile.AccessLevel, CommandLogging.Format( e.Mobile ), CommandLogging.Format( mobile ) );
mobile.Delete();
AddResponse( "The mobile has been deleted." );
}
else
@ -887,9 +881,7 @@ namespace Server.Commands.Generic
{
if ( mob.IsDeadBondedPet )
{
BaseCreature bc = mob as BaseCreature;
if ( bc != null )
if ( mob is BaseCreature bc )
{
CommandLogging.WriteLine( from, "{0} {1} resurrecting {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( mob ) );
@ -1048,10 +1040,7 @@ namespace Server.Commands.Generic
if ( fromState != null && targState != null )
{
Account fromAccount = fromState.Account as Account;
Account targAccount = targState.Account as Account;
if ( fromAccount != null && targAccount != null )
if ( fromState.Account is Account && targState.Account is Account targAccount )
{
CommandLogging.WriteLine( from, "{0} {1} {2} {3}", from.AccessLevel, CommandLogging.Format( from ), m_Ban ? "banning" : "kicking", CommandLogging.Format( targ ) );
@ -1095,9 +1084,7 @@ namespace Server.Commands.Generic
public override void Execute( CommandEventArgs e, object obj )
{
Item item = obj as Item;
if ( item == null )
if ( !(obj is Item item) )
return;
if ( !item.IsLockedDown && !item.IsSecure )

View file

@ -137,17 +137,13 @@ namespace Server.Commands.Generic
object obj = m_List[i];
bool isDeleted = false;
if ( obj is Item )
if ( obj is Item item )
{
Item item = (Item)obj;
if ( !(isDeleted = item.Deleted) )
AddEntryHtml( 40 + 130, item.GetType().Name );
}
else if ( obj is Mobile )
else if ( obj is Mobile mob )
{
Mobile mob = (Mobile)obj;
if ( !(isDeleted = mob.Deleted) )
AddEntryHtml( 40 + 130, mob.Name );
}
@ -231,10 +227,10 @@ namespace Server.Commands.Generic
break;
}
if ( obj is Item && !((Item)obj).Deleted )
m_From.SendGump( new InterfaceItemGump( m_From, m_Columns, m_List, m_Page, (Item) obj ) );
else if ( obj is Mobile && !((Mobile)obj).Deleted )
m_From.SendGump( new InterfaceMobileGump( m_From, m_Columns, m_List, m_Page, (Mobile) obj ) );
if ( obj is Item item && !item.Deleted )
m_From.SendGump( new InterfaceItemGump( m_From, m_Columns, m_List, m_Page, item ) );
else if ( obj is Mobile mobile && !mobile.Deleted )
m_From.SendGump( new InterfaceMobileGump( m_From, m_Columns, m_List, m_Page, mobile ) );
else
m_From.SendGump( new InterfaceGump( m_From, m_Columns, m_List, m_Page, m_Select ) );
}
@ -567,4 +563,4 @@ namespace Server.Commands.Generic
}
}
}
}
}

View file

@ -107,8 +107,8 @@ namespace Server.Commands.Generic
ext.Parse( from, args, i + 1, size - i - 1 );
if ( ext is WhereExtension )
baseType = ( ext as WhereExtension ).Conditional.Type;
if ( ext is WhereExtension extension )
baseType = extension.Conditional.Type;
parsed.Add( ext );

View file

@ -87,22 +87,22 @@ namespace Server.Commands.Generic
}
else
{
if ( m_Value is int )
method.Load( (int) m_Value );
else if ( m_Value is long )
method.Load( (long) m_Value );
else if ( m_Value is float )
method.Load( (float) m_Value );
else if ( m_Value is double )
method.Load( (double) m_Value );
else if ( m_Value is char )
method.Load( (char) m_Value );
else if ( m_Value is bool )
method.Load( (bool) m_Value );
else if ( m_Value is string )
method.Load( (string) m_Value );
else if ( m_Value is Enum )
method.Load( (Enum) m_Value );
if ( m_Value is int i )
method.Load( i );
else if ( m_Value is long l )
method.Load( l );
else if ( m_Value is float f )
method.Load( f );
else if ( m_Value is double d )
method.Load( d );
else if ( m_Value is char c )
method.Load( c );
else if ( m_Value is bool b )
method.Load( b );
else if ( m_Value is string s )
method.Load( s );
else if ( m_Value is Enum e )
method.Load( e );
else
throw new InvalidOperationException( "Unrecognized comparison value." );
}
@ -110,10 +110,8 @@ namespace Server.Commands.Generic
public void Acquire( TypeBuilder typeBuilder, ILGenerator il, string fieldName )
{
if ( m_Value is string )
if ( m_Value is string toParse )
{
string toParse = (string) m_Value;
if ( !m_Type.IsValueType && toParse == "null" )
{
m_Value = null;
@ -391,7 +389,7 @@ namespace Server.Commands.Generic
bool inverse = false;
bool couldCompare =
emitter.CompareTo( 1, delegate()
emitter.CompareTo( 1, delegate
{
m_Value.Load( emitter );
} );

View file

@ -84,7 +84,7 @@ namespace Server.Commands.Generic
emitter.Chain( prop );
bool couldCompare =
emitter.CompareTo( 1, delegate()
emitter.CompareTo( 1, delegate
{
emitter.LoadLocal( b );
emitter.Chain( prop );

View file

@ -130,7 +130,7 @@ namespace Server.Commands.Generic
emitter.Chain( prop );
bool couldCompare =
emitter.CompareTo( sign, delegate()
emitter.CompareTo( sign, delegate
{
emitter.LoadLocal( b );
emitter.Chain( prop );

View file

@ -8,7 +8,7 @@ namespace Server.Commands.Generic
{
public sealed class DistinctExtension : BaseExtension
{
public static ExtensionInfo ExtInfo = new ExtensionInfo( 30, "Distinct", -1, delegate() { return new DistinctExtension(); } );
public static ExtensionInfo ExtInfo = new ExtensionInfo( 30, "Distinct", -1, delegate { return new DistinctExtension(); } );
public static void Initialize()
{

View file

@ -6,7 +6,7 @@ namespace Server.Commands.Generic
{
public sealed class LimitExtension : BaseExtension
{
public static ExtensionInfo ExtInfo = new ExtensionInfo( 80, "Limit", 1, delegate() { return new LimitExtension(); } );
public static ExtensionInfo ExtInfo = new ExtensionInfo( 80, "Limit", 1, delegate { return new LimitExtension(); } );
public static void Initialize()
{

View file

@ -8,7 +8,7 @@ namespace Server.Commands.Generic
{
public sealed class SortExtension : BaseExtension
{
public static ExtensionInfo ExtInfo = new ExtensionInfo( 40, "Order", -1, delegate() { return new SortExtension(); } );
public static ExtensionInfo ExtInfo = new ExtensionInfo( 40, "Order", -1, delegate { return new SortExtension(); } );
public static void Initialize()
{

View file

@ -8,7 +8,7 @@ namespace Server.Commands.Generic
{
public sealed class WhereExtension : BaseExtension
{
public static ExtensionInfo ExtInfo = new ExtensionInfo( 20, "Where", -1, delegate() { return new WhereExtension(); } );
public static ExtensionInfo ExtInfo = new ExtensionInfo( 20, "Where", -1, delegate { return new WhereExtension(); } );
public static void Initialize()
{

View file

@ -121,9 +121,9 @@ namespace Server.Commands.Generic
foreach ( BaseExtension check in ext )
{
if ( check is WhereExtension )
if ( check is WhereExtension extension )
{
cond = ( check as WhereExtension ).Conditional;
cond = extension.Conditional;
break;
}
@ -234,10 +234,8 @@ namespace Server.Commands.Generic
bool flushToLog = false;
if ( obj is ArrayList )
if ( obj is ArrayList list )
{
ArrayList list = (ArrayList)obj;
if ( list.Count > 20 )
CommandLogging.Enabled = false;
else if ( list.Count == 0 )
@ -255,9 +253,7 @@ namespace Server.Commands.Generic
{
if ( command.ListOptimized )
{
ArrayList list = new ArrayList();
list.Add( obj );
command.ExecuteList( e, list );
command.ExecuteList( e, new ArrayList{ obj } );
}
else
{

View file

@ -47,7 +47,7 @@ namespace Server.Commands.Generic
if ( mob == null )
continue;
if( !BaseCommand.IsAccessible( from, mob ) )
if ( !BaseCommand.IsAccessible( from, mob ) )
continue;
if ( ext.IsValid( mob ) )
@ -64,4 +64,4 @@ namespace Server.Commands.Generic
}
}
}
}
}

View file

@ -35,7 +35,7 @@ namespace Server.Commands.Generic
{
foreach ( Mobile mob in reg.GetMobiles() )
{
if( !BaseCommand.IsAccessible( from, mob ) )
if ( !BaseCommand.IsAccessible( from, mob ) )
continue;
if ( ext.IsValid( mob ) )
@ -58,4 +58,4 @@ namespace Server.Commands.Generic
}
}
}
}
}

View file

@ -148,9 +148,8 @@ namespace Server.Commands
public static void DropHolding_OnTarget( Mobile from, object obj )
{
if ( obj is Mobile && ((Mobile)obj).Player )
if ( obj is Mobile targ && targ.Player )
{
Mobile targ = (Mobile)obj;
Item held = targ.Holding;
if ( held == null )
@ -163,15 +162,12 @@ namespace Server.Commands
{
Engines.Help.PageEntry pe = Engines.Help.PageQueue.GetEntry( targ );
if ( pe == null || pe.Handler != from )
{
if ( pe == null )
from.SendMessage( "You may only use this command on someone who has paged you." );
else
from.SendMessage( "You may only use this command if you are handling their help page." );
if ( pe?.Handler == from )
from.SendMessage( "You may only use this command if you are handling their help page." );
else
from.SendMessage( "You may only use this command on someone who has paged you." );
return;
}
return;
}
if ( targ.AddToBackpack( held ) )
@ -262,23 +258,22 @@ namespace Server.Commands
public static void GetFollowers_OnTarget( Mobile from, object obj )
{
if ( obj is PlayerMobile )
if ( obj is PlayerMobile pm )
{
PlayerMobile master = (PlayerMobile)obj;
List<Mobile> pets = master.AllFollowers;
List<Mobile> pets = pm.AllFollowers;
if ( pets.Count > 0 )
{
CommandLogging.WriteLine( from, "{0} {1} getting all followers of {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( master ) );
CommandLogging.WriteLine( from, "{0} {1} getting all followers of {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( pm ) );
from.SendMessage( "That player has {0} pet{1}.", pets.Count, pets.Count != 1 ? "s" : "" );
for ( int i = 0; i < pets.Count; ++i )
{
Mobile pet = (Mobile)pets[i];
Mobile pet = pets[i];
if ( pet is IMount )
((IMount)pet).Rider = null; // make sure it's dismounted
if ( pet is IMount mount )
mount.Rider = null; // make sure it's dismounted
pet.MoveToWorld( from.Location, from.Map );
}
@ -288,17 +283,14 @@ namespace Server.Commands
from.SendMessage( "There were no pets found for that player." );
}
}
else if ( obj is Mobile && ((Mobile)obj).Player )
else if ( obj is Mobile master && master.Player )
{
Mobile master = (Mobile)obj;
ArrayList pets = new ArrayList();
foreach ( Mobile m in World.Mobiles.Values )
{
if ( m is BaseCreature )
if ( m is BaseCreature bc )
{
BaseCreature bc = (BaseCreature)m;
if ( (bc.Controlled && bc.ControlMaster == master) || (bc.Summoned && bc.SummonMaster == master) )
pets.Add( bc );
}
@ -314,8 +306,8 @@ namespace Server.Commands
{
Mobile pet = (Mobile)pets[i];
if ( pet is IMount )
((IMount)pet).Rider = null; // make sure it's dismounted
if ( pet is IMount mount )
mount.Rider = null; // make sure it's dismounted
pet.MoveToWorld( from.Location, from.Map );
}
@ -346,8 +338,8 @@ namespace Server.Commands
return;
}
if ( targeted is Mobile )
from.SendMenu( new EquipMenu( from, (Mobile)targeted, GetEquip( (Mobile)targeted ) ) );
if ( targeted is Mobile mobile )
from.SendMenu( new EquipMenu( from, mobile, GetEquip( mobile ) ) );
}
private static ItemListEntry[] GetEquip( Mobile m )
@ -472,17 +464,15 @@ namespace Server.Commands
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Mobile )
if ( targeted is Mobile m )
{
Mobile m = (Mobile)targeted;
BankBox box = ( m.Player ? m.BankBox : m.FindBankNoCreate() );
if ( box != null )
{
CommandLogging.WriteLine( from, "{0} {1} opening bank box of {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( targeted ) );
CommandLogging.WriteLine( from, "{0} {1} opening bank box of {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( m ) );
if ( from == targeted )
if ( from == m )
box.Open();
else
box.DisplayTo( from );
@ -522,19 +512,17 @@ namespace Server.Commands
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Mobile )
if ( targeted is Mobile targ )
{
CommandLogging.WriteLine( from, "{0} {1} dismounting {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( targeted ) );
Mobile targ = (Mobile)targeted;
CommandLogging.WriteLine( from, "{0} {1} dismounting {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( targ ) );
for ( int i = 0; i < targ.Items.Count; ++i )
{
Item item = targ.Items[i];
if ( item is IMountItem )
if ( item is IMountItem mountItem )
{
IMount mount = ((IMountItem)item).Mount;
IMount mount = mountItem.Mount;
if ( mount != null )
mount.Rider = null;
@ -566,15 +554,10 @@ namespace Server.Commands
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Mobile )
if ( targeted is Mobile targ && targ.NetState != null )
{
Mobile targ = (Mobile)targeted;
if ( targ.NetState != null )
{
CommandLogging.WriteLine( from, "{0} {1} opening client menu of {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( targeted ) );
from.SendGump( new ClientGump( from, targ.NetState ) );
}
CommandLogging.WriteLine( from, "{0} {1} opening client menu of {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( targ ) );
from.SendGump( new ClientGump( from, targ.NetState ) );
}
}
}
@ -610,14 +593,7 @@ namespace Server.Commands
private static bool FixMap( ref Map map, ref Point3D loc, Item item )
{
if ( map == null || map == Map.Internal )
{
Mobile m = item.RootParent as Mobile;
return ( m != null && FixMap( ref map, ref loc, m ) );
}
return true;
return map == null || map == Map.Internal && item.RootParent is Mobile m && FixMap( ref map, ref loc, m );
}
private static bool FixMap( ref Map map, ref Point3D loc, Mobile m )
@ -651,26 +627,24 @@ namespace Server.Commands
IEntity ent = World.FindEntity( ser );
if ( ent is Item )
if ( ent is Item item )
{
Item item = (Item)ent;
Map map = item.Map;
Point3D loc = item.GetWorldLocation();
Mobile owner = item.RootParent as Mobile;
if( owner != null && (owner.Map != null && owner.Map != Map.Internal) && !BaseCommand.IsAccessible( from, owner ) /* !from.CanSee( owner )*/ )
if ( owner != null && (owner.Map != null && owner.Map != Map.Internal) && !BaseCommand.IsAccessible( from, owner ) /* !from.CanSee( owner )*/ )
{
from.SendMessage( "You can not go to what you can not see." );
return;
}
else if ( owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= from.AccessLevel )
if ( owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= from.AccessLevel )
{
from.SendMessage( "You can not go to what you can not see." );
return;
}
else if ( !FixMap( ref map, ref loc, item ) )
if ( !FixMap( ref map, ref loc, item ) )
{
from.SendMessage( "That is an internal item and you cannot go to it." );
return;
@ -680,26 +654,24 @@ namespace Server.Commands
return;
}
else if ( ent is Mobile )
if ( ent is Mobile m )
{
Mobile m = (Mobile)ent;
Map map = m.Map;
Point3D loc = m.Location;
Mobile owner = m;
if ( owner != null && (owner.Map != null && owner.Map != Map.Internal) && !BaseCommand.IsAccessible( from, owner ) /* !from.CanSee( owner )*/ )
if ( (owner.Map != null && owner.Map != Map.Internal) && !BaseCommand.IsAccessible( from, owner ) /* !from.CanSee( owner )*/ )
{
from.SendMessage( "You can not go to what you can not see." );
return;
}
else if ( owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= from.AccessLevel )
if ( (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= from.AccessLevel )
{
from.SendMessage( "You can not go to what you can not see." );
return;
}
else if ( !FixMap( ref map, ref loc, m ) )
if ( !FixMap( ref map, ref loc, m ) )
{
from.SendMessage( "That is an internal mobile and you cannot go to it." );
return;
@ -743,16 +715,16 @@ namespace Server.Commands
for( int i = 0; i < Map.AllMaps.Count; ++i )
{
Map m = Map.AllMaps[i];
map = Map.AllMaps[i];
if( m.MapIndex == 0x7F || m.MapIndex == 0xFF || from.Map == m )
if ( map.MapIndex == 0x7F || map.MapIndex == 0xFF || from.Map == map )
continue;
foreach( Region r in m.Regions.Values )
foreach( Region r in map.Regions.Values )
{
if( Insensitive.Equals( r.Name, name ) )
if ( Insensitive.Equals( r.Name, name ) )
{
from.MoveToWorld( r.GoLocation, m );
from.MoveToWorld( r.GoLocation, map );
return;
}
}
@ -873,8 +845,8 @@ namespace Server.Commands
BroadcastMessage( AccessLevel.Player, 0x482, e.ArgString );
}
public static void BroadcastMessage ( AccessLevel ac, int hue, string message )
{
public static void BroadcastMessage ( AccessLevel ac, int hue, string message )
{
foreach ( NetState state in NetState.Instances )
{
Mobile m = state.Mobile;
@ -940,12 +912,12 @@ namespace Server.Commands
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Mobile )
if ( targeted is Mobile mobile )
{
if( ((Mobile)targeted).AccessLevel >= from.AccessLevel && targeted != from )
if ( mobile.AccessLevel >= from.AccessLevel && mobile != from )
from.SendMessage( "You can't do that to someone with higher Accesslevel than you!" );
else
from.SendGump( new StuckMenu( from, (Mobile) targeted, false ) );
from.SendGump( new StuckMenu( from, mobile, false ) );
}
}
}

View file

@ -34,14 +34,14 @@ namespace Server.Commands
[Description( "Gives information on a specified command, or when no argument specified, displays a gump containing all commands" )]
private static void HelpInfo_OnCommand( CommandEventArgs e )
{
if( e.Length > 0 )
if ( e.Length > 0 )
{
string arg = e.GetString( 0 ).ToLower();
if (m_HelpInfos.TryGetValue( arg, out CommandInfo c ))
{
Mobile m = e.Mobile;
if( m.AccessLevel >= c.AccessLevel )
if ( m.AccessLevel >= c.AccessLevel )
m.SendGump( new CommandInfoGump( c ) );
else
m.SendMessage( "You don't have access to that command." );
@ -73,19 +73,17 @@ namespace Server.Commands
object[] attrs = mi.GetCustomAttributes( typeof( UsageAttribute ), false );
if( attrs.Length == 0 )
if ( attrs.Length == 0 )
continue;
UsageAttribute usage = attrs[0] as UsageAttribute;
attrs = mi.GetCustomAttributes( typeof( DescriptionAttribute ), false );
if( attrs.Length == 0 )
if ( attrs.Length == 0 )
continue;
DescriptionAttribute desc = attrs[0] as DescriptionAttribute;
if( usage == null || desc == null )
if ( usage == null || !(attrs[0] is DescriptionAttribute desc) )
continue;
attrs = mi.GetCustomAttributes( typeof( AliasesAttribute ), false );
@ -94,7 +92,7 @@ namespace Server.Commands
string descString = desc.Description.Replace( "<", "(" ).Replace( ">", ")" );
if( aliases == null )
if ( aliases == null )
list.Add( new CommandInfo( e.AccessLevel, e.Command, null, usage.Usage, descString ) );
else
{
@ -121,7 +119,7 @@ namespace Server.Commands
string usage = command.Usage;
string desc = command.Description;
if( usage == null || desc == null )
if ( usage == null || desc == null )
continue;
string[] cmds = command.Commands;
@ -133,31 +131,31 @@ namespace Server.Commands
desc = desc.Replace( "<", "(" ).Replace( ">", ")" );
if( command.Supports != CommandSupport.Single )
if ( command.Supports != CommandSupport.Single )
{
StringBuilder sb = new StringBuilder( 50 + desc.Length );
sb.Append( "Modifiers: " );
if( (command.Supports & CommandSupport.Global) != 0 )
if ( (command.Supports & CommandSupport.Global) != 0 )
sb.Append( "<i>Global</i>, " );
if( (command.Supports & CommandSupport.Online) != 0 )
if ( (command.Supports & CommandSupport.Online) != 0 )
sb.Append( "<i>Online</i>, " );
if( (command.Supports & CommandSupport.Region) != 0 )
if ( (command.Supports & CommandSupport.Region) != 0 )
sb.Append( "<i>Region</i>, " );
if( (command.Supports & CommandSupport.Contained) != 0 )
if ( (command.Supports & CommandSupport.Contained) != 0 )
sb.Append( "<i>Contained</i>, " );
if( (command.Supports & CommandSupport.Multi) != 0 )
if ( (command.Supports & CommandSupport.Multi) != 0 )
sb.Append( "<i>Multi</i>, " );
if( (command.Supports & CommandSupport.Area) != 0 )
if ( (command.Supports & CommandSupport.Area) != 0 )
sb.Append( "<i>Area</i>, " );
if( (command.Supports & CommandSupport.Self) != 0 )
if ( (command.Supports & CommandSupport.Self) != 0 )
sb.Append( "<i>Self</i>, " );
sb.Remove( sb.Length - 2, 2 );
@ -190,7 +188,7 @@ namespace Server.Commands
string usage = command.Usage;
string desc = command.Description;
if( usage == null || desc == null )
if ( usage == null || desc == null )
continue;
string[] cmds = command.Accessors;
@ -222,7 +220,7 @@ namespace Server.Commands
foreach( CommandInfo c in m_SortedHelpInfo )
{
if( !m_HelpInfos.ContainsKey( c.Name.ToLower() ) )
if ( !m_HelpInfos.ContainsKey( c.Name.ToLower() ) )
m_HelpInfos.Add( c.Name.ToLower(), c );
}
}
@ -239,13 +237,13 @@ namespace Server.Commands
{
m_Page = page;
if( list == null )
if ( list == null )
{
m_List = new List<CommandInfo>();
foreach( CommandInfo c in m_SortedHelpInfo )
{
if( from.AccessLevel >= c.AccessLevel )
if ( from.AccessLevel >= c.AccessLevel )
m_List.Add( c );
}
}
@ -255,14 +253,14 @@ namespace Server.Commands
AddNewPage();
if( m_Page > 0 )
if ( m_Page > 0 )
AddEntryButton( 20, ArrowLeftID1, ArrowLeftID2, 1, ArrowLeftWidth, ArrowLeftHeight );
else
AddEntryHeader( 20 );
AddEntryHtml( 160, Center( String.Format( "Page {0} of {1}", m_Page+1, (m_List.Count + EntriesPerPage - 1) / EntriesPerPage ) ) );
if( (m_Page + 1) * EntriesPerPage < m_List.Count )
if ( (m_Page + 1) * EntriesPerPage < m_List.Count )
AddEntryButton( 20, ArrowRightID1, ArrowRightID2, 2, ArrowRightWidth, ArrowRightHeight );
else
AddEntryHeader( 20 );
@ -272,9 +270,9 @@ namespace Server.Commands
for( int i = m_Page * EntriesPerPage, line = 0; line < EntriesPerPage && i < m_List.Count; ++i, ++line )
{
CommandInfo c = m_List[i];
if( from.AccessLevel >= c.AccessLevel )
if ( from.AccessLevel >= c.AccessLevel )
{
if( (int)c.AccessLevel != last )
if ( (int)c.AccessLevel != last )
{
AddNewLine();
@ -308,14 +306,14 @@ namespace Server.Commands
}
case 1:
{
if( m_Page > 0 )
if ( m_Page > 0 )
m.SendGump( new CommandListGump( m_Page - 1, m, m_List ) );
break;
}
case 2:
{
if( (m_Page + 1) * EntriesPerPage < m_SortedHelpInfo.Count )
if ( (m_Page + 1) * EntriesPerPage < m_SortedHelpInfo.Count )
m.SendGump( new CommandListGump( m_Page + 1, m, m_List ) );
break;
@ -325,11 +323,11 @@ namespace Server.Commands
int v = info.ButtonID - 3;
if( v >= 0 && v < m_List.Count )
if ( v >= 0 && v < m_List.Count )
{
CommandInfo c = m_List[v];
if( m.AccessLevel >= c.AccessLevel )
if ( m.AccessLevel >= c.AccessLevel )
{
m.SendGump( new CommandInfoGump( c ) );
m.SendGump( new CommandListGump( m_Page, m, m_List ) );
@ -387,13 +385,13 @@ namespace Server.Commands
string[] aliases = info.Aliases;
if( aliases != null && aliases.Length != 0 )
if ( aliases != null && aliases.Length != 0 )
{
sb.Append( String.Format( "Alias{0}: ", aliases.Length == 1 ? "" : "es" ) );
for( int i = 0; i < aliases.Length; ++i )
{
if( i != 0 )
if ( i != 0 )
sb.Append( ", " );
sb.Append( aliases[i] );

View file

@ -43,19 +43,15 @@ namespace Server.Commands
public static object Format( object o )
{
if ( o is Mobile )
if ( o is Mobile m )
{
Mobile m = (Mobile)o;
if ( m.Account == null )
return String.Format( "{0} (no account)", m );
else
return String.Format( "{0} ('{1}')", m, m.Account.Username );
}
else if ( o is Item )
{
Item item = (Item)o;
return String.Format( "{0} ('{1}')", m, m.Account.Username );
}
if ( o is Item item )
{
return String.Format( "0x{0:X} ({1})", item.Serial.Value, item.GetType().Name );
}
@ -81,9 +77,7 @@ namespace Server.Commands
string path = Core.BaseDirectory;
Account acct = from.Account as Account;
string name = ( acct == null ? from.Name : acct.Username );
string name = ( !(from.Account is Account acct) ? from.Name : acct.Username );
AppendPath( ref path, "Logs" );
AppendPath( ref path, "Commands" );
@ -144,4 +138,4 @@ namespace Server.Commands
WriteLine( from, "{0} {1} set property '{2}' of {3} to '{4}'", from.AccessLevel, Format( from ), name, Format( o ), value );
}
}
}
}

View file

@ -109,13 +109,11 @@ namespace Server.Commands
private int GetCount( object obj )
{
if ( obj is int )
return (int) obj;
if ( obj is int intObj )
return intObj;
if ( obj is int[] )
if ( obj is int[] list )
{
int[] list = (int[]) obj;
int total = 0;
for ( int i = 0; i < list.Length; ++i )
@ -207,9 +205,7 @@ namespace Server.Commands
do
{
int[] countTable = typeTable[itemType] as int[];
if ( countTable == null )
if ( !(typeTable[itemType] is int[] countTable) )
typeTable[itemType] = countTable = new int[9];
if ( ( flags & ExpandFlag.Name ) != 0 )
@ -401,4 +397,4 @@ namespace Server.Commands
}
}
}
}
}

View file

@ -263,7 +263,7 @@ namespace Server.Commands
{
object obj = realProps[i].GetValue( realObjs[i], null );
if( !( obj is IConvertible ) )
if ( !( obj is IConvertible ) )
return "Property is not IConvertable.";
try
@ -509,9 +509,8 @@ namespace Server.Commands
{
try
{
if ( toSet is AccessLevel )
if ( toSet is AccessLevel newLevel )
{
AccessLevel newLevel = (AccessLevel) toSet;
AccessLevel reqLevel = AccessLevel.Administrator;
if ( newLevel == AccessLevel.Administrator )
@ -843,4 +842,4 @@ namespace Server
return prop;
}
}
}
}

View file

@ -25,7 +25,7 @@ namespace Server.Commands
else
{
SkillName skill;
if( Enum.TryParse( arg.GetString( 0 ), true, out skill ) )
if ( Enum.TryParse( arg.GetString( 0 ), true, out skill ) )
{
arg.Mobile.Target = new SkillTarget( skill, arg.GetDouble( 1 ) );
}
@ -61,7 +61,7 @@ namespace Server.Commands
else
{
SkillName skill;
if( Enum.TryParse( arg.GetString( 0 ), true, out skill ) )
if ( Enum.TryParse( arg.GetString( 0 ), true, out skill ) )
{
arg.Mobile.Target = new SkillTarget( skill );
}
@ -83,9 +83,8 @@ namespace Server.Commands
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Mobile )
if ( targeted is Mobile targ )
{
Mobile targ = (Mobile)targeted;
Server.Skills skills = targ.Skills;
for ( int i = 0; i < skills.Length; ++i )
@ -121,9 +120,8 @@ namespace Server.Commands
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Mobile )
if ( targeted is Mobile targ )
{
Mobile targ = (Mobile)targeted;
Skill skill = targ.Skills[m_Skill];
if ( skill == null )
@ -144,4 +142,4 @@ namespace Server.Commands
}
}
}
}
}

View file

@ -25,8 +25,8 @@ namespace Server.Commands
protected override void OnTarget( Mobile from, object o )
{
if ( o is Mobile )
from.SendGump( new SkillsGump( from, (Mobile)o ) );
if ( o is Mobile mobile )
from.SendGump( new SkillsGump( from, mobile ) );
}
}
@ -37,4 +37,4 @@ namespace Server.Commands
e.Mobile.Target = new SkillsTarget();
}
}
}
}

View file

@ -21,10 +21,8 @@ namespace Server.Commands
public static void OnLogin( LoginEventArgs e )
{
if ( e.Mobile is PlayerMobile )
if ( e.Mobile is PlayerMobile pm )
{
PlayerMobile pm = (PlayerMobile)e.Mobile;
pm.VisibilityList.Clear();
}
}
@ -44,9 +42,8 @@ namespace Server.Commands
[Description( "Shows the names of everyone in your visibility list." )]
public static void VisList_OnCommand( CommandEventArgs e )
{
if ( e.Mobile is PlayerMobile )
if ( e.Mobile is PlayerMobile pm )
{
PlayerMobile pm = (PlayerMobile)e.Mobile;
List<Mobile> list = pm.VisibilityList;
if ( list.Count > 0 )
@ -67,11 +64,10 @@ namespace Server.Commands
[Description( "Removes everyone from your visibility list." )]
public static void VisClear_OnCommand( CommandEventArgs e )
{
if ( e.Mobile is PlayerMobile )
if ( e.Mobile is PlayerMobile pm )
{
PlayerMobile pm = (PlayerMobile)e.Mobile;
List<Mobile> list = new List<Mobile>( pm.VisibilityList );
pm.VisibilityList.Clear();
pm.SendMessage( "Your visibility list has been cleared." );
@ -93,24 +89,21 @@ namespace Server.Commands
protected override void OnTarget( Mobile from, object targeted )
{
if ( from is PlayerMobile && targeted is Mobile )
if ( from is PlayerMobile pm && targeted is Mobile targ )
{
PlayerMobile pm = (PlayerMobile)from;
Mobile targ = (Mobile)targeted;
if ( targ.AccessLevel <= from.AccessLevel )
if ( targ.AccessLevel <= pm.AccessLevel )
{
List<Mobile> list = pm.VisibilityList;
if ( list.Contains( targ ) )
{
list.Remove( targ );
from.SendMessage( "{0} has been removed from your visibility list.", targ.Name );
pm.SendMessage( "{0} has been removed from your visibility list.", targ.Name );
}
else
{
list.Add( targ );
from.SendMessage( "{0} has been added to your visibility list.", targ.Name );
pm.SendMessage( "{0} has been added to your visibility list.", targ.Name );
}
if ( Utility.InUpdateRange( targ, from ) )
@ -118,28 +111,28 @@ namespace Server.Commands
NetState ns = targ.NetState;
if ( ns != null ) {
if ( targ.CanSee( from ) )
if ( targ.CanSee( pm ) )
{
ns.Send(MobileIncoming.Create(ns, targ, from));
ns.Send(MobileIncoming.Create(ns, targ, pm));
if ( ObjectPropertyList.Enabled )
{
ns.Send( from.OPLPacket );
ns.Send( pm.OPLPacket );
foreach ( Item item in from.Items )
foreach ( Item item in pm.Items )
ns.Send( item.OPLPacket );
}
}
else
{
ns.Send( from.RemovePacket );
ns.Send( pm.RemovePacket );
}
}
}
}
else
{
from.SendMessage( "They can already see you!" );
pm.SendMessage( "They can already see you!" );
}
}
else

View file

@ -89,8 +89,8 @@ namespace Server.Commands
toDelete.Add( obj );
else if ( multis && (obj is BaseMulti) )
toDelete.Add( obj );
else if ( mobiles && (obj is Mobile) && !((Mobile)obj).Player )
toDelete.Add( obj );
else if ( mobiles && (obj is Mobile mobile) && !mobile.Player )
toDelete.Add( mobile );
}
eable.Free();

View file

@ -13,8 +13,8 @@ namespace Server.ContextMenus
public override void OnClick()
{
if ( Owner.From.CheckAlive() && Owner.Target is SpellScroll )
Owner.From.Target = new InternalTarget( (SpellScroll)Owner.Target );
if ( Owner.From.CheckAlive() && Owner.Target is SpellScroll scroll )
Owner.From.Target = new InternalTarget( scroll );
}
private class InternalTarget : Target
@ -28,12 +28,10 @@ namespace Server.ContextMenus
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Spellbook )
if ( targeted is Spellbook book )
{
if ( from.CheckAlive() && !m_Scroll.Deleted && m_Scroll.Movable && m_Scroll.Amount >= 1 && m_Scroll.CheckItemUse( from ) )
{
Spellbook book = (Spellbook)targeted;
SpellbookType type = Spellbook.GetTypeForSpell( m_Scroll.SpellID );
if ( type != book.SpellbookType )
@ -61,4 +59,4 @@ namespace Server.ContextMenus
}
}
}
}
}

View file

@ -22,9 +22,9 @@ namespace Server.Engines.BulkOrders
{
Item item = null;
if ( obj is BOBLargeEntry )
item = ((BOBLargeEntry)obj).Reconstruct();
else if ( obj is BOBSmallEntry )
if ( obj is BOBLargeEntry entry )
item = entry.Reconstruct();
else
item = ((BOBSmallEntry)obj).Reconstruct();
return item;
@ -32,17 +32,13 @@ namespace Server.Engines.BulkOrders
public bool CheckFilter( object obj )
{
if ( obj is BOBLargeEntry )
if ( obj is BOBLargeEntry entry )
{
BOBLargeEntry e = (BOBLargeEntry)obj;
return CheckFilter( e.Material, e.AmountMax, true, e.RequireExceptional, e.DeedType, ( e.Entries.Length > 0 ? e.Entries[0].ItemType : null ) );
return CheckFilter( entry.Material, entry.AmountMax, true, entry.RequireExceptional, entry.DeedType, ( entry.Entries.Length > 0 ? entry.Entries[0].ItemType : null ) );
}
else if ( obj is BOBSmallEntry )
if ( obj is BOBSmallEntry smallEntry )
{
BOBSmallEntry e = (BOBSmallEntry)obj;
return CheckFilter( e.Material, e.AmountMax, false, e.RequireExceptional, e.DeedType, e.ItemType );
return CheckFilter( smallEntry.Material, smallEntry.AmountMax, false, smallEntry.RequireExceptional, smallEntry.DeedType, smallEntry.ItemType );
}
return false;
@ -57,25 +53,25 @@ namespace Server.Engines.BulkOrders
if ( f.Quality == 1 && reqExc )
return false;
else if ( f.Quality == 2 && !reqExc )
if ( f.Quality == 2 && !reqExc )
return false;
if ( f.Quantity == 1 && amountMax != 10 )
return false;
else if ( f.Quantity == 2 && amountMax != 15 )
if ( f.Quantity == 2 && amountMax != 15 )
return false;
else if ( f.Quantity == 3 && amountMax != 20 )
if ( f.Quantity == 3 && amountMax != 20 )
return false;
if ( f.Type == 1 && isLarge )
return false;
else if ( f.Type == 2 && !isLarge )
if ( f.Type == 2 && !isLarge )
return false;
switch ( f.Material )
{
default:
case 0: return true;
return true;
case 1: return ( deedType == BODType.Smith );
case 2: return ( deedType == BODType.Tailor );
@ -122,8 +118,8 @@ namespace Server.Engines.BulkOrders
{
int add;
if ( obj is BOBLargeEntry )
add = ((BOBLargeEntry)obj).Entries.Length;
if ( obj is BOBLargeEntry entry )
add = entry.Entries.Length;
else
add = 1;
@ -156,8 +152,8 @@ namespace Server.Engines.BulkOrders
obj = list[i];
if (CheckFilter(obj))
{
if (obj is BOBLargeEntry)
add = ((BOBLargeEntry)obj).Entries.Length;
if (obj is BOBLargeEntry entry)
add = entry.Entries.Length;
else
add = 1;
count += add;
@ -185,8 +181,8 @@ namespace Server.Engines.BulkOrders
obj = list[i];
if (CheckFilter(obj))
{
if (obj is BOBLargeEntry)
count += ((BOBLargeEntry)obj).Entries.Length;
if (obj is BOBLargeEntry entry)
count += entry.Entries.Length;
else
count += 1;
}
@ -327,8 +323,8 @@ namespace Server.Engines.BulkOrders
if (m_Book.IsChildOf(m_From.Backpack))
{
int sizeOfDroppedBod;
if (obj is BOBLargeEntry)
sizeOfDroppedBod = ((BOBLargeEntry)obj).Entries.Length;
if (obj is BOBLargeEntry entry)
sizeOfDroppedBod = entry.Entries.Length;
else
sizeOfDroppedBod = 1;
@ -336,13 +332,13 @@ namespace Server.Engines.BulkOrders
m_From.SendLocalizedMessage(1045152); // The bulk order deed has been placed in your backpack.
m_Book.Entries.Remove(obj);
m_Book.InvalidateProperties();
if ( m_Book.Entries.Count / 5 < m_Book.ItemCount )
{
m_Book.ItemCount--;
m_Book.InvalidateItems();
}
if (m_Book.Entries.Count > 0)
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
@ -366,19 +362,18 @@ namespace Server.Engines.BulkOrders
m_From.Prompt = new SetPricePrompt( m_Book, obj, m_Page, m_List );
m_From.SendLocalizedMessage( 1062383 ); // Type in a price for the deed:
}
else if ( m_Book.RootParent is PlayerVendor )
else if ( m_Book.RootParent is PlayerVendor pv )
{
PlayerVendor pv = (PlayerVendor)m_Book.RootParent;
VendorItem vi = pv.GetVendorItem( m_Book );
if (vi != null && !vi.IsForSale)
{
int sizeOfDroppedBod;
int price = 0;
if (obj is BOBLargeEntry)
if (obj is BOBLargeEntry entry)
{
price = ((BOBLargeEntry)obj).Price;
sizeOfDroppedBod = ((BOBLargeEntry)obj).Entries.Length;
price = entry.Price;
sizeOfDroppedBod = entry.Entries.Length;
}
else
{
@ -443,34 +438,34 @@ namespace Server.Engines.BulkOrders
if ( !m_Book.Entries.Contains( obj ) )
continue;
if ( obj is BOBLargeEntry )
((BOBLargeEntry)obj).Price = price;
else if ( obj is BOBSmallEntry )
if ( obj is BOBLargeEntry entry )
entry.Price = price;
else
((BOBSmallEntry)obj).Price = price;
}
from.SendMessage( "Deed prices set." );
if ( from is PlayerMobile )
from.SendGump( new BOBGump( (PlayerMobile)from, m_Book, m_Page, m_List ) );
if ( from is PlayerMobile mobile )
mobile.SendGump( new BOBGump( mobile, m_Book, m_Page, m_List ) );
}
else if ( m_Object is BOBLargeEntry )
else if ( m_Object is BOBLargeEntry entry )
{
((BOBLargeEntry)m_Object).Price = price;
entry.Price = price;
from.SendLocalizedMessage( 1062384 ); // Deed price set.
if ( from is PlayerMobile )
from.SendGump( new BOBGump( (PlayerMobile)from, m_Book, m_Page, m_List ) );
if ( from is PlayerMobile mobile )
mobile.SendGump( new BOBGump( mobile, m_Book, m_Page, m_List ) );
}
else if ( m_Object is BOBSmallEntry )
else
{
((BOBSmallEntry)m_Object).Price = price;
from.SendLocalizedMessage( 1062384 ); // Deed price set.
if ( from is PlayerMobile )
from.SendGump( new BOBGump( (PlayerMobile)from, m_Book, m_Page, m_List ) );
if ( from is PlayerMobile mobile )
mobile.SendGump( new BOBGump( mobile, m_Book, m_Page, m_List ) );
}
}
}
@ -553,9 +548,9 @@ namespace Server.Engines.BulkOrders
AddImageTiled( 24, 94 + (tableIndex * 32), canPrice ? 573 : 489, 2, 2624 );
if ( obj is BOBLargeEntry )
tableIndex += ((BOBLargeEntry)obj).Entries.Length;
else if ( obj is BOBSmallEntry )
if ( obj is BOBLargeEntry entry )
tableIndex += entry.Entries.Length;
else
++tableIndex;
}
@ -628,81 +623,79 @@ namespace Server.Engines.BulkOrders
if ( !CheckFilter( obj ) )
continue;
if ( obj is BOBLargeEntry )
if ( obj is BOBLargeEntry entry )
{
BOBLargeEntry e = (BOBLargeEntry)obj;
int y = 96 + (tableIndex * 32);
if ( canDrop )
AddButton( 35, y + 2, 5602, 5606, 5 + (i * 2), GumpButtonType.Reply, 0 );
if ( canDrop || (canBuy && e.Price > 0) )
if ( canDrop || (canBuy && entry.Price > 0) )
{
AddButton( 579, y + 2, 2117, 2118, 6 + (i * 2), GumpButtonType.Reply, 0 );
AddLabel( 495, y, 1152, e.Price.ToString() );
AddLabel( 495, y, 1152, entry.Price.ToString() );
}
AddHtmlLocalized( 61, y, 50, 32, 1062225, LabelColor, false, false ); // Large
for ( int j = 0; j < e.Entries.Length; ++j )
for ( int j = 0; j < entry.Entries.Length; ++j )
{
BOBLargeSubEntry sub = e.Entries[j];
BOBLargeSubEntry sub = entry.Entries[j];
AddHtmlLocalized( 103, y, 130, 32, sub.Number, LabelColor, false, false );
if ( e.RequireExceptional )
if ( entry.RequireExceptional )
AddHtmlLocalized( 235, y, 80, 20, 1060636, LabelColor, false, false ); // exceptional
else
AddHtmlLocalized( 235, y, 80, 20, 1011542, LabelColor, false, false ); // normal
object name = GetMaterialName( e.Material, e.DeedType, sub.ItemType );
object name = GetMaterialName( entry.Material, entry.DeedType, sub.ItemType );
if ( name is int )
AddHtmlLocalized( 316, y, 100, 20, (int)name, LabelColor, false, false );
else if ( name is string )
AddLabel( 316, y, 1152, (string)name );
if ( name is int intName )
AddHtmlLocalized( 316, y, 100, 20, intName, LabelColor, false, false );
else
AddLabel( 316, y, 1152, name.ToString() );
AddLabel( 421, y, 1152, String.Format( "{0} / {1}", sub.AmountCur, e.AmountMax ) );
AddLabel( 421, y, 1152, String.Format( "{0} / {1}", sub.AmountCur, entry.AmountMax ) );
++tableIndex;
y += 32;
}
}
else if ( obj is BOBSmallEntry )
else
{
BOBSmallEntry e = (BOBSmallEntry)obj;
BOBSmallEntry smallEntry = (BOBSmallEntry)obj;
int y = 96 + (tableIndex++ * 32);
if ( canDrop )
AddButton( 35, y + 2, 5602, 5606, 5 + (i * 2), GumpButtonType.Reply, 0 );
if ( canDrop || (canBuy && e.Price > 0) )
if ( canDrop || (canBuy && smallEntry.Price > 0) )
{
AddButton( 579, y + 2, 2117, 2118, 6 + (i * 2), GumpButtonType.Reply, 0 );
AddLabel( 495, y, 1152, e.Price.ToString() );
AddLabel( 495, y, 1152, smallEntry.Price.ToString() );
}
AddHtmlLocalized( 61, y, 50, 32, 1062224, LabelColor, false, false ); // Small
AddHtmlLocalized( 103, y, 130, 32, e.Number, LabelColor, false, false );
AddHtmlLocalized( 103, y, 130, 32, smallEntry.Number, LabelColor, false, false );
if ( e.RequireExceptional )
if ( smallEntry.RequireExceptional )
AddHtmlLocalized( 235, y, 80, 20, 1060636, LabelColor, false, false ); // exceptional
else
AddHtmlLocalized( 235, y, 80, 20, 1011542, LabelColor, false, false ); // normal
object name = GetMaterialName( e.Material, e.DeedType, e.ItemType );
object name = GetMaterialName( smallEntry.Material, smallEntry.DeedType, smallEntry.ItemType );
if ( name is int )
AddHtmlLocalized( 316, y, 100, 20, (int)name, LabelColor, false, false );
else if ( name is string )
AddLabel( 316, y, 1152, (string)name );
if ( name is int intName )
AddHtmlLocalized( 316, y, 100, 20, intName, LabelColor, false, false );
else
AddLabel( 316, y, 1152, name.ToString() );
AddLabel( 421, y, 1152, String.Format( "{0} / {1}", e.AmountCur, e.AmountMax ) );
AddLabel( 421, y, 1152, String.Format( "{0} / {1}", smallEntry.AmountCur, smallEntry.AmountMax ) );
}
}
}
}
}
}

View file

@ -28,9 +28,9 @@ namespace Server.Engines.BulkOrders
if ( vi != null && !vi.IsForSale )
{
if ( m_Object is BOBLargeEntry )
price = ((BOBLargeEntry)m_Object).Price;
else if ( m_Object is BOBSmallEntry )
if ( m_Object is BOBLargeEntry entry )
price = entry.Price;
else
price = ((BOBSmallEntry)m_Object).Price;
}
@ -46,9 +46,9 @@ namespace Server.Engines.BulkOrders
{
Item item = null;
if ( m_Object is BOBLargeEntry )
item = ((BOBLargeEntry)m_Object).Reconstruct();
else if ( m_Object is BOBSmallEntry )
if ( m_Object is BOBLargeEntry entry )
item = entry.Reconstruct();
else
item = ((BOBSmallEntry)m_Object).Reconstruct();
if ( item == null )
@ -75,7 +75,7 @@ namespace Server.Engines.BulkOrders
pv.HoldGold += price;
m_From.AddToBackpack( item );
m_From.SendLocalizedMessage( 1045152 ); // The bulk order deed has been placed in your backpack.
if ( m_Book.Entries.Count / 5 < m_Book.ItemCount )
{
m_Book.ItemCount--;

View file

@ -42,7 +42,7 @@ namespace Server.Engines.BulkOrders
{
get{ return m_Filter; }
}
public int ItemCount
{
get{ return m_ItemCount; }
@ -67,8 +67,8 @@ namespace Server.Engines.BulkOrders
from.LocalOverheadMessage( Network.MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
else if ( m_Entries.Count == 0 )
from.SendLocalizedMessage( 1062381 ); // The book is empty.
else if ( from is PlayerMobile )
from.SendGump( new BOBGump( (PlayerMobile)from, this ) );
else if ( from is PlayerMobile mobile )
mobile.SendGump( new BOBGump( mobile, this ) );
}
public override void OnDoubleClickSecureTrade( Mobile from )
@ -108,17 +108,17 @@ namespace Server.Engines.BulkOrders
from.SendLocalizedMessage( 1062385 ); // You must have the book in your backpack to add deeds to it.
return false;
}
else if ( !from.Backpack.CheckHold( from, dropped, true, true ) )
if ( !from.Backpack.CheckHold( from, dropped, true, true ) )
return false;
else if ( m_Entries.Count < 500 )
if ( m_Entries.Count < 500 )
{
if ( dropped is LargeBOD )
m_Entries.Add( new BOBLargeEntry( (LargeBOD)dropped ) );
else if ( dropped is SmallBOD ) // Sanity
if ( dropped is LargeBOD bod )
m_Entries.Add( new BOBLargeEntry( bod ) );
else
m_Entries.Add( new BOBSmallEntry( (SmallBOD)dropped ) );
InvalidateProperties();
if ( m_Entries.Count / 5 > m_ItemCount )
{
m_ItemCount++;
@ -128,51 +128,45 @@ namespace Server.Engines.BulkOrders
from.SendSound(0x42, GetWorldLocation());
from.SendLocalizedMessage( 1062386 ); // Deed added to book.
if ( from is PlayerMobile )
from.SendGump( new BOBGump( (PlayerMobile)from, this ) );
if ( from is PlayerMobile pm )
pm.SendGump( new BOBGump( pm, this ) );
dropped.Delete();
return true;
}
else
{
from.SendLocalizedMessage( 1062387 ); // The book is full of deeds.
return false;
}
from.SendLocalizedMessage( 1062387 ); // The book is full of deeds.
return false;
}
from.SendLocalizedMessage( 1062388 ); // That is not a bulk order deed.
return false;
}
public override int GetTotal( TotalType type )
{
int total = base.GetTotal( type );
if ( type == TotalType.Items )
total = m_ItemCount;
return total;
}
public void InvalidateItems()
{
if ( RootParent is Mobile )
if ( RootParent is Mobile m )
{
Mobile m = (Mobile) RootParent;
m.UpdateTotals();
InvalidateContainers( Parent );
}
}
public void InvalidateContainers( object parent )
{
if ( parent != null && parent is Container )
if ( parent is Container c )
{
Container c = (Container)parent;
c.InvalidateProperties();
InvalidateContainers( c.Parent );
}
@ -187,7 +181,7 @@ namespace Server.Engines.BulkOrders
base.Serialize( writer );
writer.Write( (int) 2 ); // version
writer.Write( (int) m_ItemCount );
writer.Write( (int) m_Level );
@ -202,19 +196,15 @@ namespace Server.Engines.BulkOrders
{
object obj = m_Entries[i];
if ( obj is BOBLargeEntry )
if ( obj is BOBLargeEntry entry )
{
writer.WriteEncodedInt( 0 );
((BOBLargeEntry)obj).Serialize( writer );
}
else if ( obj is BOBSmallEntry )
{
writer.WriteEncodedInt( 1 );
((BOBSmallEntry)obj).Serialize( writer );
entry.Serialize( writer );
}
else
{
writer.WriteEncodedInt( -1 );
writer.WriteEncodedInt( 1 );
((BOBSmallEntry)obj).Serialize( writer );
}
}
}
@ -341,4 +331,4 @@ namespace Server.Engines.BulkOrders
}
}
}
}
}

View file

@ -146,12 +146,10 @@ namespace Server.Engines.BulkOrders
public void EndCombine( Mobile from, object o )
{
if ( o is Item && ((Item)o).IsChildOf( from.Backpack ) )
if ( o is Item item && item.IsChildOf( from.Backpack ) )
{
if ( o is SmallBOD )
if ( item is SmallBOD small )
{
SmallBOD small = (SmallBOD)o;
LargeBulkEntry entry = null;
for ( int i = 0; entry == null && i < m_Entries.Length; ++i )

View file

@ -38,7 +38,7 @@ namespace Server.Engines.BulkOrders
{
LargeBulkEntry[] entries;
bool useMaterials = true;
int rand = Utility.Random( 8 );
switch ( rand )
@ -53,8 +53,8 @@ namespace Server.Engines.BulkOrders
case 6: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.LargePolearms ); break;
case 7: entries = LargeBulkEntry.ConvertEntries( this, LargeBulkEntry.LargeSwords ); break;
}
if( rand > 2 && rand < 8 )
if ( rand > 2 && rand < 8 )
useMaterials = false;
int hue = 0x44E;
@ -137,4 +137,4 @@ namespace Server.Engines.BulkOrders
int version = reader.ReadInt();
}
}
}
}

View file

@ -167,26 +167,24 @@ namespace Server.Engines.BulkOrders
public void EndCombine( Mobile from, object o )
{
if ( o is Item && ((Item)o).IsChildOf( from.Backpack ) )
if ( o is Item item && item.IsChildOf( from.Backpack ) )
{
Type objectType = o.GetType();
Type objectType = item.GetType();
if ( m_AmountCur >= m_AmountMax )
{
from.SendLocalizedMessage( 1045166 ); // The maximum amount of requested items have already been combined to this deed.
}
else if ( m_Type == null || (objectType != m_Type && !objectType.IsSubclassOf( m_Type )) || (!(o is BaseWeapon) && !(o is BaseArmor) && !(o is BaseClothing)) )
else if ( m_Type == null || (objectType != m_Type && !objectType.IsSubclassOf( m_Type )) || (!(item is BaseWeapon) && !(item is BaseArmor) && !(item is BaseClothing)) )
{
from.SendLocalizedMessage( 1045169 ); // The item is not in the request.
}
else
{
BulkMaterialType material = BulkMaterialType.None;
BaseArmor armor = item as BaseArmor;
BaseClothing clothing = item as BaseClothing;
if ( o is BaseArmor )
material = GetMaterial( ((BaseArmor)o).Resource );
else if ( o is BaseClothing )
material = GetMaterial( ((BaseClothing)o).Resource );
BulkMaterialType material = GetMaterial( armor?.Resource ?? clothing?.Resource ?? CraftResource.None );
if ( m_Material >= BulkMaterialType.DullCopper && m_Material <= BulkMaterialType.Valorite && material != m_Material )
{
@ -198,14 +196,14 @@ namespace Server.Engines.BulkOrders
}
else
{
bool isExceptional = false;
bool isExceptional;
if ( o is BaseWeapon )
isExceptional = ( ((BaseWeapon)o).Quality == WeaponQuality.Exceptional );
else if ( o is BaseArmor )
isExceptional = ( ((BaseArmor)o).Quality == ArmorQuality.Exceptional );
else if ( o is BaseClothing )
isExceptional = ( ((BaseClothing)o).Quality == ClothingQuality.Exceptional );
if ( item is BaseWeapon weapon )
isExceptional = weapon.Quality == WeaponQuality.Exceptional;
else if ( armor != null )
isExceptional = armor.Quality == ArmorQuality.Exceptional;
else
isExceptional = clothing.Quality == ClothingQuality.Exceptional;
if ( m_RequireExceptional && !isExceptional )
{
@ -213,7 +211,7 @@ namespace Server.Engines.BulkOrders
}
else
{
((Item)o).Delete();
item.Delete();
++AmountCur;
from.SendLocalizedMessage( 1045170 ); // The item has been combined with the deed.

View file

@ -60,7 +60,7 @@ namespace Server.Items
}
}
if( version == 0 )
if ( version == 0 )
{
if ( LootType != LootType.Cursed )
LootType = LootType.Cursed;

View file

@ -99,17 +99,17 @@ namespace Server.Engines.CannedEvil
public void UpdateRegion()
{
if( m_Region != null )
if ( m_Region != null )
m_Region.Unregister();
if( !Deleted && this.Map != Map.Internal )
if ( !Deleted && this.Map != Map.Internal )
{
m_Region = new ChampionSpawnRegion( this );
m_Region.Register();
}
/*
if( m_Region == null )
if ( m_Region == null )
{
m_Region = new ChampionSpawnRegion( this );
}
@ -229,7 +229,7 @@ namespace Server.Engines.CannedEvil
}
set
{
if( value )
if ( value )
Start();
else
Stop();
@ -322,24 +322,24 @@ namespace Server.Engines.CannedEvil
public void Start()
{
if( m_Active || Deleted )
if ( m_Active || Deleted )
return;
m_Active = true;
m_HasBeenAdvanced = false;
if( m_Timer != null )
if ( m_Timer != null )
m_Timer.Stop();
m_Timer = new SliceTimer( this );
m_Timer.Start();
if( m_RestartTimer != null )
if ( m_RestartTimer != null )
m_RestartTimer.Stop();
m_RestartTimer = null;
if( m_Altar != null )
if ( m_Altar != null )
{
if ( m_Champion != null )
m_Altar.Hue = 0x26;
@ -353,23 +353,23 @@ namespace Server.Engines.CannedEvil
public void Stop()
{
if( !m_Active || Deleted )
if ( !m_Active || Deleted )
return;
m_Active = false;
m_HasBeenAdvanced = false;
if( m_Timer != null )
if ( m_Timer != null )
m_Timer.Stop();
m_Timer = null;
if( m_RestartTimer != null )
if ( m_RestartTimer != null )
m_RestartTimer.Stop();
m_RestartTimer = null;
if( m_Altar != null )
if ( m_Altar != null )
m_Altar.Hue = 0;
if ( m_Platform != null )
@ -378,7 +378,7 @@ namespace Server.Engines.CannedEvil
public void BeginRestart( TimeSpan ts )
{
if( m_RestartTimer != null )
if ( m_RestartTimer != null )
m_RestartTimer.Stop();
m_RestartTime = DateTime.UtcNow + ts;
@ -389,7 +389,7 @@ namespace Server.Engines.CannedEvil
public void EndRestart()
{
if( RandomizeType )
if ( RandomizeType )
{
switch( Utility.Random( 5 ) )
{
@ -420,7 +420,7 @@ namespace Server.Engines.CannedEvil
public static void GiveScrollTo( Mobile killer, SpecialScroll scroll )
{
if( scroll == null || killer == null ) //sanity
if ( scroll == null || killer == null ) //sanity
return;
if ( scroll is ScrollofTranscendence )
@ -432,7 +432,7 @@ namespace Server.Engines.CannedEvil
killer.AddToBackpack( scroll );
else
{
if( killer.Corpse != null && !killer.Corpse.Deleted )
if ( killer.Corpse != null && !killer.Corpse.Deleted )
killer.Corpse.DropItem( scroll );
else
killer.AddToBackpack( scroll );
@ -462,9 +462,7 @@ namespace Server.Engines.CannedEvil
{
prot.SendLocalizedMessage( 1049368 ); // You have been rewarded for your dedication to Justice!
SpecialScroll scrollDupe = Activator.CreateInstance( scroll.GetType() ) as SpecialScroll;
if ( scrollDupe != null )
if ( Activator.CreateInstance( scroll.GetType() ) is SpecialScroll scrollDupe )
{
scrollDupe.Skill = scroll.Skill;
scrollDupe.Value = scroll.Value;
@ -478,28 +476,28 @@ namespace Server.Engines.CannedEvil
public void OnSlice()
{
if( !m_Active || Deleted )
if ( !m_Active || Deleted )
return;
if( m_Champion != null )
if ( m_Champion != null )
{
if( m_Champion.Deleted )
if ( m_Champion.Deleted )
{
RegisterDamageTo( m_Champion );
if( m_Champion is BaseChampion )
AwardArtifact( ((BaseChampion)m_Champion).GetArtifact() );
if ( m_Champion is BaseChampion champion )
AwardArtifact( champion.GetArtifact() );
m_DamageEntries.Clear();
if( m_Platform != null )
if ( m_Platform != null )
m_Platform.Hue = 0x497;
if( m_Altar != null )
if ( m_Altar != null )
{
m_Altar.Hue = 0;
if( !Core.ML || Map == Map.Felucca )
if ( !Core.ML || Map == Map.Felucca )
{
new StarRoomGate( true, m_Altar.Location, m_Altar.Map );
}
@ -521,7 +519,7 @@ namespace Server.Engines.CannedEvil
if ( m.Deleted )
{
if( m.Corpse != null && !m.Corpse.Deleted )
if ( m.Corpse != null && !m.Corpse.Deleted )
{
((Corpse)m.Corpse).BeginDecay( TimeSpan.FromMinutes( 1 ));
}
@ -533,10 +531,10 @@ namespace Server.Engines.CannedEvil
RegisterDamageTo( m );
if( killer is BaseCreature )
killer = ((BaseCreature)killer).GetMaster();
if ( killer is BaseCreature bc )
killer = bc.GetMaster();
if( killer is PlayerMobile )
if ( killer is PlayerMobile pm )
{
#region Scroll of Transcendence
if ( Core.ML )
@ -545,7 +543,6 @@ namespace Server.Engines.CannedEvil
{
if ( Utility.RandomDouble() < 0.001 )
{
PlayerMobile pm = (PlayerMobile)killer;
double random = Utility.Random ( 49 );
if ( random <= 24 )
@ -565,9 +562,9 @@ namespace Server.Engines.CannedEvil
{
if ( Utility.RandomDouble() < 0.0015 )
{
killer.SendLocalizedMessage( 1094936 ); // You have received a Scroll of Transcendence!
pm.SendLocalizedMessage( 1094936 ); // You have received a Scroll of Transcendence!
ScrollofTranscendence SoTT = CreateRandomSoT( false );
killer.AddToBackpack( SoTT );
pm.AddToBackpack( SoTT );
}
}
}
@ -575,15 +572,15 @@ namespace Server.Engines.CannedEvil
int mobSubLevel = GetSubLevelFor( m ) + 1;
if( mobSubLevel >= 0 )
if ( mobSubLevel >= 0 )
{
bool gainedPath = false;
int pointsToGain = mobSubLevel * 40;
if( VirtueHelper.Award( killer, VirtueName.Valor, pointsToGain, ref gainedPath ) )
if ( VirtueHelper.Award( pm, VirtueName.Valor, pointsToGain, ref gainedPath ) )
{
if( gainedPath )
if ( gainedPath )
m.SendLocalizedMessage( 1054032 ); // You have gained a path in Valor!
else
m.SendLocalizedMessage( 1054030 ); // You have gained in Valor!
@ -591,7 +588,7 @@ namespace Server.Engines.CannedEvil
//No delay on Valor gains
}
PlayerMobile.ChampionTitleInfo info = ((PlayerMobile)killer).ChampionTitles;
PlayerMobile.ChampionTitleInfo info = pm.ChampionTitles;
info.Award( m_Type, mobSubLevel );
}
@ -606,12 +603,12 @@ namespace Server.Engines.CannedEvil
double n = m_Kills / (double)MaxKills;
int p = (int)(n * 100);
if( p >= 90 )
if ( p >= 90 )
AdvanceLevel();
else if( p > 0 )
else if ( p > 0 )
SetWhiteSkullCount( p / 20 );
if( DateTime.UtcNow >= m_ExpireTime )
if ( DateTime.UtcNow >= m_ExpireTime )
Expire();
Respawn();
@ -622,14 +619,14 @@ namespace Server.Engines.CannedEvil
{
m_ExpireTime = DateTime.UtcNow + m_ExpireDelay;
if( Level < 16 )
if ( Level < 16 )
{
m_Kills = 0;
++Level;
InvalidateProperties();
SetWhiteSkullCount( 0 );
if( m_Altar != null )
if ( m_Altar != null )
{
Effects.PlaySound( m_Altar.Location, m_Altar.Map, 0x29 );
Effects.SendLocationEffect( new Point3D( m_Altar.X + 1, m_Altar.Y + 1, m_Altar.Z ), m_Altar.Map, 0x3728, 10 );
@ -643,7 +640,7 @@ namespace Server.Engines.CannedEvil
public void SpawnChampion()
{
if( m_Altar != null )
if ( m_Altar != null )
m_Altar.Hue = 0x26;
if ( m_Platform != null )
@ -660,20 +657,20 @@ namespace Server.Engines.CannedEvil
}
catch { }
if( m_Champion != null )
if ( m_Champion != null )
m_Champion.MoveToWorld( new Point3D( X, Y, Z - 15 ), Map );
}
public void Respawn()
{
if( !m_Active || Deleted || m_Champion != null )
if ( !m_Active || Deleted || m_Champion != null )
return;
while( m_Creatures.Count < ( ( m_SPawnSzMod * ( 200 / 12 ) ) ) - ( GetSubLevel() * ( m_SPawnSzMod * ( 40 / 12 ) ) ) )
{
Mobile m = Spawn();
if( m == null )
if ( m == null )
return;
Point3D loc = GetSpawnLocation();
@ -684,12 +681,11 @@ namespace Server.Engines.CannedEvil
m_Creatures.Add( m );
m.MoveToWorld( loc, Map );
if( m is BaseCreature )
if ( m is BaseCreature bc )
{
BaseCreature bc = m as BaseCreature;
bc.Tamable = false;
if( !m_ConfinedRoaming )
if ( !m_ConfinedRoaming )
{
bc.Home = this.Location;
bc.RangeHome = (int)(Math.Sqrt( m_SpawnArea.Width * m_SpawnArea.Width + m_SpawnArea.Height * m_SpawnArea.Height )/2);
@ -716,7 +712,7 @@ namespace Server.Engines.CannedEvil
{
Map map = Map;
if( map == null )
if ( map == null )
return Location;
// Try 20 times to find a spawnable location.
@ -732,11 +728,11 @@ namespace Server.Engines.CannedEvil
int z = Map.GetAverageZ( x, y );
if( Map.CanSpawnMobile( new Point2D( x, y ), z ) )
if ( Map.CanSpawnMobile( new Point2D( x, y ), z ) )
return new Point3D( x, y, z );
/* try @ platform Z if map z fails */
else if( Map.CanSpawnMobile( new Point2D( x, y ), m_Platform.Location.Z ) )
else if ( Map.CanSpawnMobile( new Point2D( x, y ), m_Platform.Location.Z ) )
return new Point3D( x, y, m_Platform.Location.Z );
}
@ -751,11 +747,11 @@ namespace Server.Engines.CannedEvil
{
int level = this.Level;
if( level <= Level1 )
if ( level <= Level1 )
return 0;
else if( level <= Level2 )
else if ( level <= Level2 )
return 1;
else if( level <= Level3 )
else if ( level <= Level3 )
return 2;
return 3;
@ -772,7 +768,7 @@ namespace Server.Engines.CannedEvil
for( int j = 0; j < individualTypes.Length; j++ )
{
if( t == individualTypes[j] )
if ( t == individualTypes[j] )
return i;
}
}
@ -786,7 +782,7 @@ namespace Server.Engines.CannedEvil
int v = GetSubLevel();
if( v >= 0 && v < types.Length )
if ( v >= 0 && v < types.Length )
return Spawn( types[v] );
return null;
@ -808,11 +804,11 @@ namespace Server.Engines.CannedEvil
{
m_Kills = 0;
if( m_WhiteSkulls.Count == 0 )
if ( m_WhiteSkulls.Count == 0 )
{
// They didn't even get 20%, go back a level
if( Level > 0 )
if ( Level > 0 )
--Level;
InvalidateProperties();
@ -829,17 +825,17 @@ namespace Server.Engines.CannedEvil
{
int x, y;
if( index < 5 )
if ( index < 5 )
{
x = index - 2;
y = -2;
}
else if( index < 9 )
else if ( index < 9 )
{
x = 2;
y = index - 6;
}
else if( index < 13 )
else if ( index < 13 )
{
x = 10 - index;
y = 2;
@ -878,7 +874,7 @@ namespace Server.Engines.CannedEvil
{
base.GetProperties( list );
if( m_Active )
if ( m_Active )
{
list.Add( 1060742 ); // active
list.Add( 1060658, "Type\t{0}", m_Type ); // ~1_val~: ~2_val~
@ -894,7 +890,7 @@ namespace Server.Engines.CannedEvil
public override void OnSingleClick( Mobile from )
{
if( m_Active )
if ( m_Active )
LabelTo( from, "{0} (Active; Level: {1}; Kills: {2}/{3})", m_Type, Level, m_Kills, MaxKills );
else
LabelTo( from, "{0} (Inactive)", m_Type );
@ -907,25 +903,25 @@ namespace Server.Engines.CannedEvil
public override void OnLocationChange( Point3D oldLoc )
{
if( Deleted )
if ( Deleted )
return;
if( m_Platform != null )
if ( m_Platform != null )
m_Platform.Location = new Point3D( X, Y, Z - 20 );
if( m_Altar != null )
if ( m_Altar != null )
m_Altar.Location = new Point3D( X, Y, Z - 15 );
if( m_Idol != null )
if ( m_Idol != null )
m_Idol.Location = new Point3D( X, Y, Z - 15 );
if( m_RedSkulls != null )
if ( m_RedSkulls != null )
{
for( int i = 0; i < m_RedSkulls.Count; ++i )
m_RedSkulls[i].Location = GetRedSkullLocation( i );
}
if( m_WhiteSkulls != null )
if ( m_WhiteSkulls != null )
{
for( int i = 0; i < m_WhiteSkulls.Count; ++i )
m_WhiteSkulls[i].Location = GetWhiteSkullLocation( i );
@ -939,25 +935,25 @@ namespace Server.Engines.CannedEvil
public override void OnMapChange()
{
if( Deleted )
if ( Deleted )
return;
if( m_Platform != null )
if ( m_Platform != null )
m_Platform.Map = Map;
if( m_Altar != null )
if ( m_Altar != null )
m_Altar.Map = Map;
if( m_Idol != null )
if ( m_Idol != null )
m_Idol.Map = Map;
if( m_RedSkulls != null )
if ( m_RedSkulls != null )
{
for( int i = 0; i < m_RedSkulls.Count; ++i )
m_RedSkulls[i].Map = Map;
}
if( m_WhiteSkulls != null )
if ( m_WhiteSkulls != null )
{
for( int i = 0; i < m_WhiteSkulls.Count; ++i )
m_WhiteSkulls[i].Map = Map;
@ -970,16 +966,16 @@ namespace Server.Engines.CannedEvil
{
base.OnAfterDelete();
if( m_Platform != null )
if ( m_Platform != null )
m_Platform.Delete();
if( m_Altar != null )
if ( m_Altar != null )
m_Altar.Delete();
if( m_Idol != null )
if ( m_Idol != null )
m_Idol.Delete();
if( m_RedSkulls != null )
if ( m_RedSkulls != null )
{
for( int i = 0; i < m_RedSkulls.Count; ++i )
m_RedSkulls[i].Delete();
@ -987,7 +983,7 @@ namespace Server.Engines.CannedEvil
m_RedSkulls.Clear();
}
if( m_WhiteSkulls != null )
if ( m_WhiteSkulls != null )
{
for( int i = 0; i < m_WhiteSkulls.Count; ++i )
m_WhiteSkulls[i].Delete();
@ -995,20 +991,20 @@ namespace Server.Engines.CannedEvil
m_WhiteSkulls.Clear();
}
if( m_Creatures != null )
if ( m_Creatures != null )
{
for( int i = 0; i < m_Creatures.Count; ++i )
{
Mobile mob = m_Creatures[i];
if( !mob.Player )
if ( !mob.Player )
mob.Delete();
}
m_Creatures.Clear();
}
if( m_Champion != null && !m_Champion.Player )
if ( m_Champion != null && !m_Champion.Player )
m_Champion.Delete();
Stop();
@ -1022,19 +1018,19 @@ namespace Server.Engines.CannedEvil
public virtual void RegisterDamageTo( Mobile m )
{
if( m == null )
if ( m == null )
return;
foreach( DamageEntry de in m.DamageEntries )
{
if( de.HasExpired )
if ( de.HasExpired )
continue;
Mobile damager = de.Damager;
Mobile master = damager.GetDamageMaster( m );
if( master != null )
if ( master != null )
damager = master;
RegisterDamage( damager, de.DamageGiven );
@ -1043,10 +1039,10 @@ namespace Server.Engines.CannedEvil
public void RegisterDamage( Mobile from, int amount )
{
if( from == null || !from.Player )
if ( from == null || !from.Player )
return;
if( m_DamageEntries.ContainsKey( from ) )
if ( m_DamageEntries.ContainsKey( from ) )
m_DamageEntries[from] += amount;
else
m_DamageEntries.Add( from, amount );
@ -1063,7 +1059,7 @@ namespace Server.Engines.CannedEvil
foreach (KeyValuePair<Mobile, int> kvp in m_DamageEntries)
{
if( IsEligible( kvp.Key, artifact ) )
if ( IsEligible( kvp.Key, artifact ) )
{
validEntries.Add( kvp.Key, kvp.Value );
totalDamage += kvp.Value;
@ -1078,7 +1074,7 @@ namespace Server.Engines.CannedEvil
{
totalDamage += kvp.Value;
if( totalDamage >= randomDamage )
if ( totalDamage >= randomDamage )
{
GiveArtifact( kvp.Key, artifact );
return;
@ -1144,7 +1140,7 @@ namespace Server.Engines.CannedEvil
writer.Write( m_RestartTimer != null );
if( m_RestartTimer != null )
if ( m_RestartTimer != null )
writer.WriteDeltaTime( m_RestartTime );
}
@ -1203,7 +1199,7 @@ namespace Server.Engines.CannedEvil
}
case 1:
{
if( version < 3 )
if ( version < 3 )
{
int oldRange = reader.ReadInt();
@ -1216,7 +1212,7 @@ namespace Server.Engines.CannedEvil
}
case 0:
{
if( version < 1 )
if ( version < 1 )
m_SpawnArea = new Rectangle2D( new Point2D( X - 24, Y - 24 ), new Point2D( X + 24, Y + 24 ) ); //Default was 24
bool active = reader.ReadBool();
@ -1231,21 +1227,21 @@ namespace Server.Engines.CannedEvil
m_Champion = reader.ReadMobile();
m_RestartDelay = reader.ReadTimeSpan();
if( reader.ReadBool() )
if ( reader.ReadBool() )
{
m_RestartTime = reader.ReadDeltaTime();
BeginRestart( m_RestartTime - DateTime.UtcNow );
}
if( version < 4 )
if ( version < 4 )
{
m_Idol = new IdolOfTheChampion( this );
m_Idol.MoveToWorld( new Point3D( X, Y, Z - 15 ), Map );
}
if( m_Platform == null || m_Altar == null || m_Idol == null )
if ( m_Platform == null || m_Altar == null || m_Idol == null )
Delete();
else if( active )
else if ( active )
Start();
break;

View file

@ -113,7 +113,7 @@ namespace Server.Engines.CannedEvil
{
int v = (int)type;
if( v < 0 || v >= m_Table.Length )
if ( v < 0 || v >= m_Table.Length )
v = 0;
return m_Table[v];

View file

@ -48,18 +48,14 @@ namespace Server.Engines.Chat
{
get
{
Account acct = m_Mobile.Account as Account;
if ( acct != null )
if ( m_Mobile.Account is Account acct )
return acct.GetTag( "ChatName" );
return null;
}
set
{
Account acct = m_Mobile.Account as Account;
if ( acct != null )
if ( m_Mobile.Account is Account acct )
acct.SetTag( "ChatName", value );
}
}

View file

@ -197,9 +197,7 @@ namespace Server.Engines.ConPVP
if ( info.IsSwitched( 1 ) )
{
PlayerMobile pm = m_Challenged as PlayerMobile;
if ( pm == null )
if ( !(m_Challenged is PlayerMobile pm) )
return;
if ( pm.DuelContext != null )
@ -254,25 +252,15 @@ namespace Server.Engines.ConPVP
{
foreach ( Gump g in ns.Gumps )
{
if ( g is ParticipantGump )
if ( g is ParticipantGump pg && pg.Participant == m_Participant )
{
ParticipantGump pg = (ParticipantGump)g;
if ( pg.Participant == m_Participant )
{
m_Challenger.SendGump( new ParticipantGump( m_Challenger, m_Context, m_Participant ) );
break;
}
m_Challenger.SendGump( new ParticipantGump( m_Challenger, m_Context, m_Participant ) );
break;
}
else if ( g is DuelContextGump )
if ( g is DuelContextGump dcg && dcg.Context == m_Context )
{
DuelContextGump dcg = (DuelContextGump)g;
if ( dcg.Context == m_Context )
{
m_Challenger.SendGump( new DuelContextGump( m_Challenger, m_Context ) );
break;
}
m_Challenger.SendGump( new DuelContextGump( m_Challenger, m_Context ) );
break;
}
}
}
@ -294,4 +282,4 @@ namespace Server.Engines.ConPVP
}
}
}
}
}

View file

@ -615,12 +615,8 @@ namespace Server.Engines.ConPVP
List<Mobile> pets = new List<Mobile>();
foreach ( Mobile mob in facet.GetMobilesInBounds( m_Bounds ) ) {
BaseCreature pet = mob as BaseCreature;
if ( pet != null && pet.Controlled && pet.ControlMaster != null ) {
if ( m_Players.Contains( pet.ControlMaster ) ) {
pets.Add( pet );
}
if ( mob is BaseCreature pet && pet.Controlled && pet.ControlMaster != null && m_Players.Contains( pet.ControlMaster ) ) {
pets.Add( pet );
}
}
@ -826,4 +822,4 @@ namespace Server.Engines.ConPVP
return a.CompareTo( b );
}
}
}
}

View file

@ -55,15 +55,13 @@ namespace Server.Engines.ConPVP
{
if ( m_EventGame != null )
return m_EventGame.CantDoAnything( mob );
else
return false;
}
public static bool IsFreeConsume( Mobile mob )
{
PlayerMobile pm = mob as PlayerMobile;
if ( pm == null || pm.DuelContext == null || pm.DuelContext.m_EventGame == null )
if ( !(mob is PlayerMobile pm) || pm.DuelContext?.m_EventGame == null )
return false;
return pm.DuelContext.m_EventGame.FreeConsume;
@ -76,14 +74,13 @@ namespace Server.Engines.ConPVP
public static bool AllowSpecialMove( Mobile from, string name, SpecialMove move )
{
PlayerMobile pm = from as PlayerMobile;
if( pm == null )
if ( !(from is PlayerMobile pm) )
return true;
DuelContext dc = pm.DuelContext;
return (dc == null || dc.InstAllowSpecialMove( from, name, move ));
// No DuelContext, or InstaAllowSpecialMove
return dc?.InstAllowSpecialMove( from, name, move ) != false;
}
public bool InstAllowSpecialMove( Mobile from, string name, SpecialMove move )
@ -102,9 +99,9 @@ namespace Server.Engines.ConPVP
string title = null;
if( move is NinjaMove )
if ( move is NinjaMove )
title = "Bushido";
else if( move is SamuraiMove )
else if ( move is SamuraiMove )
title = "Ninjitsu";
@ -133,7 +130,7 @@ namespace Server.Engines.ConPVP
string title = null, option = null;
if( spell is ArcanistSpell )
if ( spell is ArcanistSpell )
{
title = "Spellweaving";
option = spell.Name;
@ -158,9 +155,9 @@ namespace Server.Engines.ConPVP
title = "Bushido";
option = spell.Name;
}
else if( spell is MagerySpell )
else if ( spell is MagerySpell magerySpell )
{
switch( ((MagerySpell)spell).Circle )
switch( magerySpell.Circle )
{
case SpellCircle.First: title = "1st Circle"; break;
case SpellCircle.Second: title = "2nd Circle"; break;
@ -172,7 +169,7 @@ namespace Server.Engines.ConPVP
case SpellCircle.Eighth: title = "8th Circle"; break;
}
option = spell.Name;
option = magerySpell.Name;
}
else
{
@ -206,14 +203,13 @@ namespace Server.Engines.ConPVP
public static bool AllowSpecialAbility( Mobile from, string name, bool message )
{
PlayerMobile pm = from as PlayerMobile;
if ( pm == null )
if ( !(from is PlayerMobile pm) )
return true;
DuelContext dc = pm.DuelContext;
return ( dc == null || dc.InstAllowSpecialAbility( from, name, message ) );
// No DuelContext or InstAllowSpecialAbility
return dc?.InstAllowSpecialAbility( from, name, message ) != false;
}
public bool InstAllowSpecialAbility( Mobile from, string name, bool message )
@ -223,7 +219,7 @@ namespace Server.Engines.ConPVP
DuelPlayer pl = Find( from );
if ( pl == null || pl.Eliminated )
if ( pl?.Eliminated != false )
return true;
if ( CantDoAnything( from ) )
@ -245,10 +241,8 @@ namespace Server.Engines.ConPVP
if ( !m_Ruleset.GetOption( "Weapons", "Wrestling" ) )
return false;
}
else if ( item is BaseArmor )
else if ( item is BaseArmor armor )
{
BaseArmor armor = (BaseArmor)item;
if ( armor.ProtectionLevel > ArmorProtectionLevel.Regular && !m_Ruleset.GetOption( "Armor", "Magical" ) )
return false;
@ -258,10 +252,8 @@ namespace Server.Engines.ConPVP
if ( armor is BaseShield && !m_Ruleset.GetOption( "Armor", "Shields" ) )
return false;
}
else if ( item is BaseWeapon )
else if ( item is BaseWeapon weapon )
{
BaseWeapon weapon = (BaseWeapon)item;
if ( (weapon.DamageLevel > WeaponDamageLevel.Regular || weapon.AccuracyLevel > WeaponAccuracyLevel.Regular) && !m_Ruleset.GetOption( "Weapons", "Magical" ) )
return false;
@ -353,9 +345,9 @@ namespace Server.Engines.ConPVP
title = "Items";
option = "Bandages";
}
else if ( item is TrappableContainer )
else if ( item is TrappableContainer container )
{
if ( ((TrappableContainer)item).TrapType != TrapType.None )
if ( container.TrapType != TrapType.None )
{
title = "Items";
option = "Trapped Containers";
@ -402,12 +394,12 @@ namespace Server.Engines.ConPVP
from.SendMessage( "You may not use this item before the duel begins." );
return false;
}
else if ( item is BasePotion && !(item is BaseExplosionPotion) && !(item is BaseRefreshPotion) && IsSuddenDeath )
if ( item is BasePotion && !(item is BaseExplosionPotion) && !(item is BaseRefreshPotion) && IsSuddenDeath )
{
from.SendMessage( 0x22, "You may not drink potions in sudden death." );
return false;
}
else if ( item is Bandage && IsSuddenDeath )
if ( item is Bandage && IsSuddenDeath )
{
from.SendMessage( 0x22, "You may not use bandages in sudden death." );
return false;
@ -529,14 +521,11 @@ namespace Server.Engines.ConPVP
public void Requip( Mobile from, Container cont )
{
Corpse corpse = cont as Corpse;
if ( corpse == null )
if ( !(cont is Corpse corpse) )
return;
List<Item> items = new List<Item>( corpse.Items );
bool gathered = false;
bool didntFit = false;
Container pack = from.Backpack;
@ -544,20 +533,14 @@ namespace Server.Engines.ConPVP
for ( int i = 0; !didntFit && i < items.Count; ++i )
{
Item item = items[i];
Point3D loc = item.Location;
if ( (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair) || !item.Movable )
continue;
if ( pack != null )
{
pack.DropItem( item );
gathered = true;
}
else
{
didntFit = true;
}
}
corpse.Carved = true;
@ -578,10 +561,11 @@ namespace Server.Engines.ConPVP
from.PlaySound( 0x3E3 );
if ( gathered && !didntFit )
from.SendLocalizedMessage( 1062471 ); // You quickly gather all of your belongings.
else if ( gathered && didntFit )
from.SendLocalizedMessage( 1062472 ); // You gather some of your belongings. The rest remain on the corpse.
if (didntFit)
from.SendLocalizedMessage(1062472); // You gather some of your belongings. The rest remain on the corpse.
else
from.SendLocalizedMessage(1062471); // You quickly gather all of your belongings.
}
public void Refresh( Mobile mob, Container cont )
@ -590,15 +574,11 @@ namespace Server.Engines.ConPVP
{
mob.Resurrect();
DeathRobe robe = mob.FindItemOnLayer( Layer.OuterTorso ) as DeathRobe;
if ( robe != null )
if ( mob.FindItemOnLayer( Layer.OuterTorso ) is DeathRobe robe )
robe.Delete();
if ( cont is Corpse )
if ( cont is Corpse corpse )
{
Corpse corpse = (Corpse) cont;
for ( int i = 0; i < corpse.EquipItems.Count; ++i )
{
Item item = corpse.EquipItems[i];
@ -774,13 +754,13 @@ namespace Server.Engines.ConPVP
for ( int j = 0; j < p.Players.Length; ++j )
{
DuelPlayer pl = (DuelPlayer)p.Players[j];
DuelPlayer pl = p.Players[j];
if ( pl == null )
continue;
if ( pl.Mobile is PlayerMobile )
((PlayerMobile)pl.Mobile).DuelPlayer = null;
if ( pl.Mobile is PlayerMobile mobile )
mobile.DuelPlayer = null;
for ( int k = 0; k < types.Length; ++k )
pl.Mobile.CloseGump( types[k] );
@ -822,10 +802,8 @@ namespace Server.Engines.ConPVP
public DuelPlayer Find( Mobile mob )
{
if ( mob is PlayerMobile )
if ( mob is PlayerMobile pm )
{
PlayerMobile pm = (PlayerMobile)mob;
if ( pm.DuelContext == this )
return pm.DuelPlayer;
@ -985,15 +963,7 @@ namespace Server.Engines.ConPVP
public static bool CheckSuddenDeath( Mobile mob )
{
if ( mob is PlayerMobile )
{
PlayerMobile pm = (PlayerMobile)mob;
if ( pm.DuelPlayer != null && !pm.DuelPlayer.Eliminated && pm.DuelContext != null && pm.DuelContext.IsSuddenDeath )
return true;
}
return false;
return mob is PlayerMobile pm && pm.DuelPlayer?.Eliminated == false && pm.DuelContext?.IsSuddenDeath == true;
}
public void ActivateSuddenDeath()
@ -1134,10 +1104,8 @@ namespace Server.Engines.ConPVP
private static void vli_ot( Mobile from, object obj )
{
if ( obj is PlayerMobile )
if ( obj is PlayerMobile pm )
{
PlayerMobile pm = (PlayerMobile)obj;
Ladder ladder = Ladder.Instance;
if ( ladder == null )
@ -1176,9 +1144,7 @@ namespace Server.Engines.ConPVP
private static void EventSink_Login( LoginEventArgs e )
{
PlayerMobile pm = e.Mobile as PlayerMobile;
if ( pm == null )
if ( !(e.Mobile is PlayerMobile pm) )
return;
DuelContext dc = pm.DuelContext;
@ -1202,9 +1168,8 @@ namespace Server.Engines.ConPVP
private static void ViewLadder_OnTarget( Mobile from, object obj, object state )
{
if ( obj is PlayerMobile )
if ( obj is PlayerMobile pm )
{
PlayerMobile pm = (PlayerMobile)obj;
Ladder ladder = (Ladder)state;
LadderEntry entry = ladder.Find( pm );
@ -1216,10 +1181,8 @@ namespace Server.Engines.ConPVP
pm.PrivateOverheadMessage( MessageType.Regular, pm.SpeechHue, true, String.Format( text, from==pm?"You":"They" ), from.NetState );
}
else if ( obj is Mobile )
else if ( obj is Mobile mob )
{
Mobile mob = (Mobile)obj;
if ( mob.Body.IsHuman )
mob.PrivateOverheadMessage( MessageType.Regular, mob.SpeechHue, false, "I'm not a duelist, and quite frankly, I resent the implication.", from.NetState );
else
@ -1236,9 +1199,7 @@ namespace Server.Engines.ConPVP
if ( e.Handled )
return;
PlayerMobile pm = e.Mobile as PlayerMobile;
if ( pm == null )
if ( !(e.Mobile is PlayerMobile pm) )
return;
if ( Insensitive.Contains( e.Speech, "i wish to duel" ) )
@ -1388,25 +1349,15 @@ namespace Server.Engines.ConPVP
{
foreach ( Gump g in ns.Gumps )
{
if ( g is ParticipantGump )
if (g is ParticipantGump pg && pg.Participant == p)
{
ParticipantGump pg = (ParticipantGump)g;
if ( pg.Participant == p )
{
init.SendGump( new ParticipantGump( init, dc, p ) );
break;
}
init.SendGump( new ParticipantGump( init, dc, p ) );
break;
}
else if ( g is DuelContextGump )
if ( g is DuelContextGump dcg && dcg.Context == dc )
{
DuelContextGump dcg = (DuelContextGump)g;
if ( dcg.Context == dc )
{
init.SendGump( new DuelContextGump( init, dc ) );
break;
}
init.SendGump( new DuelContextGump( init, dc ) );
break;
}
}
}
@ -1433,31 +1384,22 @@ namespace Server.Engines.ConPVP
if ( ns != null )
{
bool send=true;
bool send = true;
foreach ( Gump g in ns.Gumps )
{
if ( g is ParticipantGump )
if ( g is ParticipantGump pg && pg.Participant == p )
{
ParticipantGump pg = (ParticipantGump)g;
if ( pg.Participant == p )
{
init.SendGump( new ParticipantGump( init, dc, p ) );
send=false;
break;
}
init.SendGump( new ParticipantGump( init, dc, p ) );
send=false;
break;
}
else if ( g is DuelContextGump )
{
DuelContextGump dcg = (DuelContextGump)g;
if ( dcg.Context == dc )
{
init.SendGump( new DuelContextGump( init, dc ) );
send=false;
break;
}
if ( g is DuelContextGump dcg && dcg.Context == dc )
{
init.SendGump( new DuelContextGump( init, dc ) );
send=false;
break;
}
}
@ -1468,9 +1410,8 @@ namespace Server.Engines.ConPVP
}
else
{
if ( pm.DuelContext.m_Countdown != null )
pm.DuelContext.m_Countdown.Stop();
pm.DuelContext.m_Countdown= null;
pm.DuelContext.m_Countdown?.Stop();
pm.DuelContext.m_Countdown = null;
pm.DuelContext.m_StartedReadyCountdown=false;
p.Broadcast( 0x22, null, "{0} has yielded.", "You have yielded." );
@ -1492,31 +1433,21 @@ namespace Server.Engines.ConPVP
if ( ns != null )
{
bool send=true;
bool send = true;
foreach ( Gump g in ns.Gumps )
{
if ( g is ParticipantGump )
if ( g is ParticipantGump pg && pg.Participant == p )
{
ParticipantGump pg = (ParticipantGump)g;
if ( pg.Participant == p )
{
init.SendGump( new ParticipantGump( init, dc, p ) );
send=false;
break;
}
init.SendGump( new ParticipantGump( init, dc, p ) );
send=false;
break;
}
else if ( g is DuelContextGump )
if ( g is DuelContextGump dcg && dcg.Context == dc )
{
DuelContextGump dcg = (DuelContextGump)g;
if ( dcg.Context == dc )
{
init.SendGump( new DuelContextGump( init, dc ) );
send=false;
break;
}
init.SendGump( new DuelContextGump( init, dc ) );
send=false;
break;
}
}
@ -1705,10 +1636,10 @@ namespace Server.Engines.ConPVP
TransformationSpellHelper.RemoveContext( mob, true );
AnimalForm.RemoveContext( mob, true );
if( DisguiseTimers.IsDisguised( mob ) )
if ( DisguiseTimers.IsDisguised( mob ) )
DisguiseTimers.StopTimer( mob );
if( !mob.CanBeginAction( typeof( PolymorphSpell ) ) )
if ( !mob.CanBeginAction( typeof( PolymorphSpell ) ) )
{
mob.BodyMod = 0;
mob.HueMod = -1;
@ -1727,8 +1658,8 @@ namespace Server.Engines.ConPVP
public static void CancelSpell( Mobile mob )
{
if ( mob.Spell is Spells.Spell )
((Spells.Spell)mob.Spell).Disturb( Spells.DisturbType.Kill );
if ( mob.Spell is Spell spell )
spell.Disturb( DisturbType.Kill );
Targeting.Target.Cancel( mob );
}
@ -2529,9 +2460,7 @@ namespace Server.Engines.ConPVP
m_GateFacet = m_Initiator.Map;
}
ExitTeleporter tp = arena.Teleporter as ExitTeleporter;
if ( tp == null )
if ( !(arena.Teleporter is ExitTeleporter tp) )
{
arena.Teleporter = tp = new ExitTeleporter();
tp.MoveToWorld( arena.GateOut == Point3D.Zero ? arena.Outside : arena.GateOut, arena.Facet );

View file

@ -24,11 +24,11 @@ namespace Server.Engines.ConPVP
private Mobile FindOwner( object parent )
{
if ( parent is Item )
return ( (Item) parent ).RootParent as Mobile;
if ( parent is Item item )
return item.RootParent as Mobile;
if ( parent is Mobile )
return (Mobile) parent;
if ( parent is Mobile mobile )
return mobile;
return null;
}
@ -282,8 +282,8 @@ namespace Server.Engines.ConPVP
if ( obj is Mobile )
pt.Z += 10;
else if ( obj is Item )
pt.Z += ((Item)obj).ItemData.CalcHeight + 1;
else if ( obj is Item item )
pt.Z += item.ItemData.CalcHeight + 1;
m_Flying = true;
this.Visible = false;
@ -317,12 +317,12 @@ namespace Server.Engines.ConPVP
if ( zdiff < 0 )
return false;
else if ( zdiff < 12 )
if ( zdiff < 12 )
return true;
else if ( zdiff < 16 )
if ( zdiff < 16 )
return Utility.RandomBool(); // 50% chance
else
return false;
return false;
}
private void DoAnim( Point3D start, Point3D end, Map map )
@ -604,10 +604,10 @@ namespace Server.Engines.ConPVP
continue;
area.Free();
if ( i is BRGoal )
if ( i is BRGoal goal )
{
Point3D oldLoc = new Point3D( this.GetWorldLocation() );
if ( CheckScore( (BRGoal)i, m_Thrower, 3 ) )
if ( CheckScore( goal, m_Thrower, 3 ) )
DoAnim( oldLoc, point, this.Map );
else
HitObject( point, loc.Z, height );
@ -939,9 +939,7 @@ namespace Server.Engines.ConPVP
else
this.Hue = 0x84C;
BRBomb b = m.Backpack.FindItemByType( typeof( BRBomb ), true ) as BRBomb;
if ( b != null )
if ( m.Backpack.FindItemByType( typeof( BRBomb ), true ) is BRBomb b )
b.CheckScore( this, m, 7 );
return true;
@ -1321,9 +1319,7 @@ namespace Server.Engines.ConPVP
if ( mob == null )
return null;
BRPlayerInfo val = m_Players[mob] as BRPlayerInfo;
if ( val == null )
if ( !(m_Players[mob] is BRPlayerInfo val) )
m_Players[mob] = val = new BRPlayerInfo( this, mob );
return val;
@ -1623,15 +1619,8 @@ namespace Server.Engines.ConPVP
public int GetTeamID( Mobile mob )
{
PlayerMobile pm = mob as PlayerMobile;
if ( pm == null )
{
if ( mob is BaseCreature )
return ((BaseCreature)mob).Team - 1;
else
return -1;
}
if ( !(mob is PlayerMobile pm) )
return mob is BaseCreature creature ? creature.Team - 1 : -1;
if ( pm.DuelContext == null || pm.DuelContext != m_Context )
return -1;
@ -1644,12 +1633,7 @@ namespace Server.Engines.ConPVP
public int GetColor( Mobile mob )
{
BRTeamInfo teamInfo = GetTeamInfo( mob );
if ( teamInfo != null )
return teamInfo.Color;
return -1;
return GetTeamInfo( mob )?.Color ?? -1;
}
private void ApplyHues( Participant p, int hueOverride )
@ -1674,8 +1658,8 @@ namespace Server.Engines.ConPVP
DuelPlayer dp = null;
if ( mob is PlayerMobile )
dp = ( mob as PlayerMobile ).DuelPlayer;
if ( mob is PlayerMobile mobile )
dp = mobile.DuelPlayer;
m_Context.RemoveAggressions( mob );
@ -1896,9 +1880,7 @@ namespace Server.Engines.ConPVP
for ( int i = 0; i < m_Context.Participants.Count; ++i )
{
Participant p = m_Context.Participants[i] as Participant;
if ( p == null || p.Players == null )
if ( !(m_Context.Participants[i] is Participant p) || p.Players == null )
continue;
for ( int j = 0; j < p.Players.Length; ++j )
@ -1915,7 +1897,7 @@ namespace Server.Engines.ConPVP
if ( i == winner.TeamID )
continue;
if ( p != null && p.Players != null )
if ( p.Players != null )
{
for ( int j = 0; j < p.Players.Length; ++j )
{
@ -1942,15 +1924,12 @@ namespace Server.Engines.ConPVP
ReturnBomb();
if( m_Bomb != null )
m_Bomb.Delete();
m_Bomb?.Delete();
for ( int i = 0; i < m_Context.Participants.Count; ++i )
ApplyHues( m_Context.Participants[i] as Participant, -1 );
if ( m_FinishTimer != null )
m_FinishTimer.Stop();
m_FinishTimer?.Stop();
m_FinishTimer = null;
}
}

View file

@ -448,10 +448,8 @@ namespace Server.Engines.ConPVP
from.LocalOverheadMessage( MessageType.Regular, 0x26, false, "Those are not my cookies." );
}
}
else if ( obj is Mobile )
else if ( obj is Mobile passTo )
{
Mobile passTo = obj as Mobile;
CTFTeamInfo passTeam = m_TeamInfo.Game.GetTeamInfo( passTo );
if ( passTo == from )
@ -481,11 +479,11 @@ namespace Server.Engines.ConPVP
private Mobile FindOwner( object parent )
{
if ( parent is Item )
return ( (Item) parent ).RootParent as Mobile;
if ( parent is Item item )
return item.RootParent as Mobile;
if ( parent is Mobile )
return (Mobile) parent;
if ( parent is Mobile mobile )
return mobile;
return null;
}
@ -969,9 +967,7 @@ namespace Server.Engines.ConPVP
public int GetTeamID( Mobile mob )
{
PlayerMobile pm = mob as PlayerMobile;
if ( pm == null )
if ( !(mob is PlayerMobile pm) )
return -1;
if ( pm.DuelContext == null || pm.DuelContext != m_Context )
@ -1015,8 +1011,8 @@ namespace Server.Engines.ConPVP
DuelPlayer dp = null;
if ( mob is PlayerMobile )
dp = ( mob as PlayerMobile ).DuelPlayer;
if ( mob is PlayerMobile mobile )
dp = mobile.DuelPlayer;
m_Context.RemoveAggressions( mob );
@ -1088,9 +1084,7 @@ namespace Server.Engines.ConPVP
{
for ( int j = 0; j < ourFlagCarrier.Aggressors.Count; ++j )
{
AggressorInfo aggr = ourFlagCarrier.Aggressors[j] as AggressorInfo;
if ( aggr == null || aggr.Defender != ourFlagCarrier || aggr.Attacker != mob )
if ( !(ourFlagCarrier.Aggressors[j] is AggressorInfo aggr) || aggr.Defender != ourFlagCarrier || aggr.Attacker != mob )
continue;
playerInfo.Score += 2; // helped defend guy capturing enemy flag

View file

@ -604,9 +604,7 @@ namespace Server.Engines.ConPVP
public int GetTeamID( Mobile mob )
{
PlayerMobile pm = mob as PlayerMobile;
if ( pm == null )
if ( !(mob is PlayerMobile pm) )
return -1;
if ( pm.DuelContext == null || pm.DuelContext != m_Context )
@ -620,12 +618,7 @@ namespace Server.Engines.ConPVP
public int GetColor( Mobile mob )
{
DDTeamInfo teamInfo = GetTeamInfo( mob );
if ( teamInfo != null )
return teamInfo.Color;
return -1;
return GetTeamInfo( mob )?.Color ?? -1;
}
private void ApplyHues( Participant p, int hueOverride )
@ -650,8 +643,8 @@ namespace Server.Engines.ConPVP
DuelPlayer dp = null;
if ( mob is PlayerMobile )
dp = ( mob as PlayerMobile ).DuelPlayer;
if ( mob is PlayerMobile mobile )
dp = mobile.DuelPlayer;
m_Context.RemoveAggressions( mob );
@ -748,9 +741,7 @@ namespace Server.Engines.ConPVP
for ( int i = 0; i < m_Context.Participants.Count; ++i )
ApplyHues( m_Context.Participants[i] as Participant, m_Controller.TeamInfo[i % m_Controller.TeamInfo.Length].Color );
if ( m_FinishTimer != null )
m_FinishTimer.Stop();
m_FinishTimer?.Stop();
m_FinishTimer = Timer.DelayCall( m_Controller.Duration, new TimerCallback( Finish_Callback ) );
}
@ -766,10 +757,7 @@ namespace Server.Engines.ConPVP
teams.Add( teamInfo );
}
teams.Sort( delegate( DDTeamInfo a, DDTeamInfo b )
{
return b.Score - a.Score;
} );
teams.Sort((a, b) => b.Score - a.Score);
Tournament tourny = m_Context.m_Tournament;
@ -897,7 +885,7 @@ namespace Server.Engines.ConPVP
{
DuelPlayer dp = p.Players[j];
if ( dp != null && dp.Mobile != null )
if ( dp?.Mobile != null )
{
dp.Mobile.CloseGump( typeof( DDBoardGump ) );
dp.Mobile.SendGump( new DDBoardGump( dp.Mobile, this ) );
@ -952,9 +940,7 @@ namespace Server.Engines.ConPVP
for ( int i = 0; i < m_Context.Participants.Count; ++i )
ApplyHues( m_Context.Participants[i] as Participant, -1 );
if ( m_FinishTimer != null )
m_FinishTimer.Stop();
m_FinishTimer?.Stop();
m_FinishTimer = null;
}
@ -981,14 +967,9 @@ namespace Server.Engines.ConPVP
{
Alert( "Domination averted!" );
if ( m_Controller.PointA != null )
m_Controller.PointA.SetNonCaptureHue();
if ( m_Controller.PointB != null )
m_Controller.PointB.SetNonCaptureHue();
if ( m_CaptureTimer != null )
m_CaptureTimer.Stop();
m_Controller.PointA?.SetNonCaptureHue();
m_Controller.PointB?.SetNonCaptureHue();
m_CaptureTimer?.Stop();
m_CaptureTimer = null;
}
@ -1012,8 +993,7 @@ namespace Server.Engines.ConPVP
if ( team == null )
{
m_Capturable = true;
if ( m_CaptureTimer != null )
m_CaptureTimer.Stop();
m_CaptureTimer?.Stop();
m_CaptureTimer = null;
return;
}
@ -1022,11 +1002,8 @@ namespace Server.Engines.ConPVP
{
Alert( "{0} is dominating... {1}", team.Name, 10 - m_CapStage );
if ( m_Controller.PointA != null )
m_Controller.PointA.SetCaptureHue( m_CapStage );
if ( m_Controller.PointB != null )
m_Controller.PointB.SetCaptureHue( m_CapStage );
m_Controller.PointA?.SetCaptureHue( m_CapStage );
m_Controller.PointB?.SetCaptureHue( m_CapStage );
}
else
{

View file

@ -673,9 +673,7 @@ namespace Server.Engines.ConPVP
if (mob == null)
return null;
KHPlayerInfo val = m_Players[mob] as KHPlayerInfo;
if (val == null)
if (!(m_Players[mob] is KHPlayerInfo val))
m_Players[mob] = val = new KHPlayerInfo(this, mob);
return val;
@ -978,15 +976,8 @@ namespace Server.Engines.ConPVP
public int GetTeamID(Mobile mob)
{
PlayerMobile pm = mob as PlayerMobile;
if (pm == null)
{
if (mob is BaseCreature)
return ((BaseCreature)mob).Team - 1;
else
return -1;
}
if (!(mob is PlayerMobile pm))
return mob is BaseCreature creature ? creature.Team - 1 : -1;
if (pm.DuelContext == null || pm.DuelContext != m_Context)
return -1;
@ -999,12 +990,7 @@ namespace Server.Engines.ConPVP
public int GetColor(Mobile mob)
{
KHTeamInfo teamInfo = GetTeamInfo(mob);
if (teamInfo != null)
return teamInfo.Color;
return -1;
return GetTeamInfo(mob)?.Color ?? -1;
}
private void ApplyHues(Participant p, int hueOverride)
@ -1029,8 +1015,8 @@ namespace Server.Engines.ConPVP
DuelPlayer dp = null;
if (mob is PlayerMobile)
dp = (mob as PlayerMobile).DuelPlayer;
if (mob is PlayerMobile mobile)
dp = mobile.DuelPlayer;
m_Context.RemoveAggressions(mob);
@ -1252,16 +1238,14 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < m_Context.Participants.Count; ++i)
{
Participant p = m_Context.Participants[i] as Participant;
if (p == null || p.Players == null)
if (!(m_Context.Participants[i] is Participant p) || p.Players == null)
continue;
for (int j = 0; j < p.Players.Length; ++j)
{
DuelPlayer dp = p.Players[j];
if (dp != null && dp.Mobile != null)
if (dp?.Mobile != null)
{
dp.Mobile.CloseGump(typeof(KHBoardGump));
dp.Mobile.SendGump(new KHBoardGump(dp.Mobile, this));
@ -1271,7 +1255,7 @@ namespace Server.Engines.ConPVP
if (i == winner.TeamID)
continue;
if (p != null && p.Players != null)
if (p?.Players != null)
{
for (int j = 0; j < p.Players.Length; ++j)
{
@ -1304,9 +1288,8 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < m_Context.Participants.Count; ++i)
ApplyHues(m_Context.Participants[i] as Participant, -1);
if (m_FinishTimer != null)
m_FinishTimer.Stop();
m_FinishTimer = null;
m_FinishTimer?.Stop();
m_FinishTimer = null;
}
}
}

View file

@ -19,10 +19,8 @@ namespace Server.Engines.ConPVP
public DuelPlayer Find( Mobile mob )
{
if ( mob is PlayerMobile )
if ( mob is PlayerMobile pm )
{
PlayerMobile pm = (PlayerMobile)mob;
if ( pm.DuelContext == m_Context && pm.DuelPlayer.Participant == this )
return pm.DuelPlayer;
@ -229,8 +227,8 @@ namespace Server.Engines.ConPVP
m_Mobile = mob;
m_Participant = p;
if ( mob is PlayerMobile )
((PlayerMobile)mob).DuelPlayer = this;
if ( mob is PlayerMobile mobile )
mobile.DuelPlayer = this;
}
}
}
}

View file

@ -15,7 +15,7 @@ namespace Server.Engines.ConPVP
private DuelContext m_Context;
private Participant m_Participant;
public Mobile From{ get{ return m_From; } }
public Mobile From{ get{ return m_From; } }
public DuelContext Context{ get{ return m_Context; } }
public Participant Participant{ get{ return m_Participant; } }
@ -52,7 +52,7 @@ namespace Server.Engines.ConPVP
count = 4;
AddPage( 0 );
int height = 35 + 10 + 22 + 22 + 30 + 22 + 2 + (count * 22) + 2 + 30;
AddBackground( 0, 0, 300, height, 9250 );
@ -203,9 +203,7 @@ namespace Server.Engines.ConPVP
if ( index < 0 || index >= m_Participant.Players.Length )
return;
Mobile mob = targeted as Mobile;
if ( mob == null )
if ( !(targeted is Mobile mob) )
{
from.SendMessage( "That is not a player." );
}
@ -222,9 +220,7 @@ namespace Server.Engines.ConPVP
}
else
{
PlayerMobile pm = mob as PlayerMobile;
if ( pm == null )
if ( !(mob is PlayerMobile pm) )
return;
if ( pm.DuelContext != null )
@ -247,4 +243,4 @@ namespace Server.Engines.ConPVP
}
}
}
}
}

View file

@ -209,9 +209,7 @@ namespace Server.Engines.ConPVP
{
case 1: // okay
{
PlayerMobile pm = m_From as PlayerMobile;
if ( pm == null )
if ( !(m_From is PlayerMobile pm) )
break;
pm.DuelPlayer.Ready = true;
@ -232,4 +230,4 @@ namespace Server.Engines.ConPVP
}
}
}
}
}

View file

@ -136,7 +136,7 @@ namespace Server.Engines.ConPVP
"Suprise Attack"
} ) );
if( Core.ML )
if ( Core.ML )
{
entries.Add( new RulesetLayout( "Spellweaving", new string[]
{
@ -280,7 +280,7 @@ namespace Server.Engines.ConPVP
} ) );
}
if( Core.SE )
if ( Core.SE )
{
entries.Add( new RulesetLayout( "Items", new RulesetLayout[]
{
@ -342,7 +342,7 @@ namespace Server.Engines.ConPVP
// Set up default rulesets
if( !Core.AOS )
if ( !Core.AOS )
{
#region Mage 5x
Ruleset m5x = new Ruleset( m_Root );
@ -785,4 +785,4 @@ namespace Server.Engines.ConPVP
children[i].m_Parent = this;
}
}
}
}

View file

@ -39,15 +39,10 @@ namespace Server.Engines.ConPVP
PlayerMobile pm = m as PlayerMobile;
if ( pm == null && m is BaseCreature )
{
BaseCreature bc = (BaseCreature)m;
if ( pm == null && m is BaseCreature bc && bc.Summoned )
pm = bc.SummonMaster as PlayerMobile;
if ( bc.Summoned )
pm = bc.SummonMaster as PlayerMobile;
}
if ( pm != null && pm.DuelContext != null && pm.DuelContext.StartedBeginCountdown )
if ( pm?.DuelContext != null && pm.DuelContext.StartedBeginCountdown )
return true;
if ( DuelContext.CheckCombat( m ) )

View file

@ -163,9 +163,9 @@ namespace Server.Engines.ConPVP
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that
}
else if ( m_Tournament != null )
else
{
Tournament tourny = m_Tournament.Tournament;
Tournament tourny = m_Tournament?.Tournament;
if ( tourny != null )
{
@ -194,60 +194,46 @@ namespace Server.Engines.ConPVP
}
case TournamentStage.Inactive:
{
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState );
break;
}
case TournamentStage.Signup:
{
Ladder ladder = Ladder.Instance;
LadderEntry entry = ladder?.Find( from );
if ( ladder != null )
if ( entry != null && Ladder.GetLevel( entry.Experience ) < tourny.LevelRequirement )
{
LadderEntry entry = ladder.Find( from );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState );
if ( entry != null && Ladder.GetLevel( entry.Experience ) < tourny.LevelRequirement )
{
if ( m_Registrar != null )
{
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState );
}
break;
}
break;
}
if ( tourny.IsFactionRestricted && Faction.Find( from ) == null )
{
if ( m_Registrar != null )
{
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.", from.NetState );
}
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.", from.NetState );
break;
}
if ( from.HasGump( typeof( AcceptTeamGump ) ) )
{
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "You must first respond to the offer I've given you.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "You must first respond to the offer I've given you.", from.NetState );
}
else if ( from.HasGump( typeof( AcceptDuelGump ) ) )
{
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "You must first cancel your duel offer.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "You must first cancel your duel offer.", from.NetState );
}
else if ( from is PlayerMobile && ((PlayerMobile)from).DuelContext != null )
else if ( from is PlayerMobile mobile && mobile.DuelContext != null )
{
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "You are already participating in a duel.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "You are already participating in a duel.", mobile.NetState );
}
else if ( !tourny.HasParticipant( from ) )
{
@ -256,9 +242,9 @@ namespace Server.Engines.ConPVP
from.CloseGump( typeof( ConfirmSignupGump ) );
from.SendGump( new ConfirmSignupGump( from, m_Registrar, tourny, players ) );
}
else if ( m_Registrar != null )
else
{
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "You have already entered this tournament.", from.NetState );
}
@ -642,7 +628,7 @@ namespace Server.Engines.ConPVP
{
Mobile mob = (Mobile)m_Players[i];
LadderEntry entry = ( ladder == null ? null : ladder.Find( mob ) );
LadderEntry entry = ladder?.Find( mob );
if ( entry != null && Ladder.GetLevel( entry.Experience ) < tourny.LevelRequirement )
{
@ -663,18 +649,15 @@ namespace Server.Engines.ConPVP
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
return;
}
else if ( tourny.IsFactionRestricted && Faction.Find( mob ) == null )
if ( tourny.IsFactionRestricted && Faction.Find( mob ) == null )
{
if ( m_Registrar != null )
{
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.", from.NetState );
}
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "Only those who have declared their faction allegiance may participate.", from.NetState );
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
return;
}
else if ( tourny.HasParticipant( mob ) )
if ( tourny.HasParticipant( mob ) )
{
if ( m_Registrar != null )
{
@ -693,20 +676,17 @@ namespace Server.Engines.ConPVP
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
return;
}
else if ( mob is PlayerMobile && ((PlayerMobile)mob).DuelContext != null )
if ( mob is PlayerMobile mobile && mobile.DuelContext != null )
{
if ( m_Registrar != null )
if ( mob == from )
{
if ( mob == from )
{
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "You are already assigned to a duel. You must yield it before joining this tournament.", from.NetState );
}
else
{
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x35, false, String.Format( "{0} is already assigned to a duel. They must yield it before joining this tournament.", mob.Name ), from.NetState );
}
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "You are already assigned to a duel. You must yield it before joining this tournament.", from.NetState );
}
else
{
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x35, false, String.Format( "{0} is already assigned to a duel. They must yield it before joining this tournament.", mobile.Name ), from.NetState );
}
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
@ -766,15 +746,12 @@ namespace Server.Engines.ConPVP
private void AddPlayer_OnTarget( Mobile from, object obj )
{
Mobile mob = obj as Mobile;
if ( mob == null || mob == from )
if ( !(obj is Mobile mob) || mob == from )
{
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "Excuse me?", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "Excuse me?", from.NetState );
}
else if ( !mob.Player )
{
@ -789,73 +766,63 @@ namespace Server.Engines.ConPVP
{
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They ignore your invitation.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They ignore your invitation.", from.NetState );
}
else
{
PlayerMobile pm = mob as PlayerMobile;
if ( pm == null )
if ( !(mob is PlayerMobile pm) )
return;
if ( pm.DuelContext != null )
{
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They are already assigned to another duel.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They are already assigned to another duel.", from.NetState );
}
else if ( mob.HasGump( typeof( AcceptTeamGump ) ) )
{
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They have already been offered a partnership.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They have already been offered a partnership.", from.NetState );
}
else if ( mob.HasGump( typeof( ConfirmSignupGump ) ) )
{
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They are already trying to join this tournament.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They are already trying to join this tournament.", from.NetState );
}
else if ( m_Players.Contains( mob ) )
{
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "You have already named them as a team member.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "You have already named them as a team member.", from.NetState );
}
else if ( m_Tournament.HasParticipant( mob ) )
{
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They have already entered this tournament.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They have already entered this tournament.", from.NetState );
}
else if ( m_Players.Count >= m_Tournament.PlayersPerParticipant )
{
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "Your team is full.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "Your team is full.", from.NetState );
}
else
{
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
mob.SendGump( new AcceptTeamGump( from, mob, m_Tournament, m_Registrar, m_Players ) );
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x59, false, String.Format( "As you command m'{0}. I've given your offer to {1}.", from.Female ? "Lady" : "Lord", mob.Name ), from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x59, false, String.Format( "As you command m'{0}. I've given your offer to {1}.", from.Female ? "Lady" : "Lord", mob.Name ), from.NetState );
}
}
}
@ -1144,50 +1111,43 @@ namespace Server.Engines.ConPVP
if ( info.IsSwitched( 1 ) )
{
PlayerMobile pm = mob as PlayerMobile;
if ( pm == null )
if ( !(mob is PlayerMobile pm) )
return;
if ( AcceptDuelGump.IsIgnored( mob, from ) || mob.Blessed )
{
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They ignore your invitation.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They ignore your invitation.", from.NetState );
}
else if ( pm.DuelContext != null )
{
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They are already assigned to another duel.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They are already assigned to another duel.", from.NetState );
}
else if ( m_Players.Contains( mob ) )
{
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "You have already named them as a team member.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "You have already named them as a team member.", from.NetState );
}
else if ( m_Tournament.HasParticipant( mob ) )
{
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They have already entered this tournament.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "They have already entered this tournament.", from.NetState );
}
else if ( m_Players.Count >= m_Tournament.PlayersPerParticipant )
{
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "Your team is full.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x22, false, "Your team is full.", from.NetState );
}
else
{
@ -3094,9 +3054,7 @@ namespace Server.Engines.ConPVP
if ( m_Tournament.TournyType != TournyType.Standard && part.Players.Count == 1 )
{
PlayerMobile pm = part.Players[0] as PlayerMobile;
if ( pm != null && pm.DuelPlayer != null )
if ( part.Players[0] is PlayerMobile pm && pm.DuelPlayer != null )
name = Color( name, pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666 );
}
@ -3107,9 +3065,7 @@ namespace Server.Engines.ConPVP
}
case TournyBracketGumpType.Participant_Info:
{
TournyParticipant part = obj as TournyParticipant;
if ( part == null )
if ( !(obj is TournyParticipant part) )
break;
AddPage( 0 );
@ -3130,9 +3086,7 @@ namespace Server.Engines.ConPVP
if ( m_Tournament.TournyType != TournyType.Standard )
{
PlayerMobile pm = mob as PlayerMobile;
if ( pm != null && pm.DuelPlayer != null )
if ( mob is PlayerMobile pm && pm.DuelPlayer != null )
name = Color( name, pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666 );
}
@ -3171,13 +3125,11 @@ namespace Server.Engines.ConPVP
AddLeftArrow( 25, 11, ToButtonID( 0, 3 ) );
AddHtml( 25, 35, 250, 20, Center( "Participants" ), false, false );
Mobile mob = obj as Mobile;
if ( mob == null )
if ( !(obj is Mobile mob) )
break;
Ladder ladder = Ladder.Instance;
LadderEntry entry = ( ladder == null ? null : ladder.Find( mob ) );
LadderEntry entry = ladder?.Find( mob );
AddHtml( 25, 53, 250, 20, String.Format( "Name: {0}", mob.Name ), false, false );
AddHtml( 25, 73, 250, 20, String.Format( "Guild: {0}", mob.Guild == null ? "None" : mob.Guild.Name + " [" + mob.Guild.Abbreviation + "]" ), false, false );
@ -3204,7 +3156,7 @@ namespace Server.Engines.ConPVP
for ( int i = 0; i < count; ++i, y += 18 )
{
PyramidLevel level = (PyramidLevel)m_List[index + i];
// PyramidLevel level = (PyramidLevel)m_List[index + i];
AddRightArrow( 25, y, ToButtonID( 3, index + i ), "Round #" + (index + i + 1) );
}
@ -3219,9 +3171,7 @@ namespace Server.Engines.ConPVP
AddLeftArrow( 25, 11, ToButtonID( 0, 2 ) );
AddHtml( 25, 35, 250, 20, Center( "Rounds" ), false, false );
PyramidLevel level = m_Object as PyramidLevel;
if ( level == null )
if ( !(m_Object is PyramidLevel level) )
break;
if ( m_List == null )
@ -3343,9 +3293,7 @@ namespace Server.Engines.ConPVP
}
case TournyBracketGumpType.Match_Info:
{
TournyMatch match = obj as TournyMatch;
if ( match == null )
if ( !(obj is TournyMatch match) )
break;
int ct = ( m_Tournament.TournyType == TournyType.FreeForAll ? 2 : match.Participants.Count );
@ -3358,7 +3306,7 @@ namespace Server.Engines.ConPVP
AddHtml( 25, 53, 250, 20, String.Format( "Winner: {0}", match.Winner == null ? "N/A" : match.Winner.NameList ), false, false );
AddHtml( 25, 73, 250, 20, String.Format( "State: {0}", match.InProgress ? "In progress" : match.Context != null ? "Complete" : "Waiting" ), false, false );
AddHtml( 25, 93, 250, 20, String.Format( "Participants:" ), false, false );
AddHtml( 25, 93, 250, 20, "Participants:", false, false );
if ( m_Tournament.TournyType == TournyType.Standard )
{
@ -3465,9 +3413,7 @@ namespace Server.Engines.ConPVP
}
case 5:
{
TournyMatch match = m_Object as TournyMatch;
if ( match == null )
if ( !(m_Object is TournyMatch match) )
break;
for ( int i = 0; i < m_Tournament.Pyramid.Levels.Count; ++i )
@ -3531,9 +3477,7 @@ namespace Server.Engines.ConPVP
if ( m_Type != TournyBracketGumpType.Participant_Info )
break;
TournyParticipant part = m_Object as TournyParticipant;
if ( part != null && index >= 0 && index < part.Players.Count )
if ( m_Object is TournyParticipant part && index >= 0 && index < part.Players.Count )
m_From.SendGump( new TournamentBracketGump( m_From, m_Tournament, TournyBracketGumpType.Player_Info, null, 0, part.Players[index] ) );
break;
@ -3543,9 +3487,7 @@ namespace Server.Engines.ConPVP
if ( m_Type != TournyBracketGumpType.Round_Info )
break;
PyramidLevel level = m_Object as PyramidLevel;
if ( level == null )
if ( !(m_Object is PyramidLevel level) )
break;
if ( index == 0 )
@ -3567,9 +3509,7 @@ namespace Server.Engines.ConPVP
if ( m_Type != TournyBracketGumpType.Match_Info )
break;
TournyMatch match = m_Object as TournyMatch;
if ( match != null && index >= 0 && index < match.Participants.Count )
if ( m_Object is TournyMatch match && index >= 0 && index < match.Participants.Count )
m_From.SendGump( new TournamentBracketGump( m_From, m_Tournament, TournyBracketGumpType.Participant_Info, null, 0, match.Participants[index] ) );
break;
@ -3602,9 +3542,9 @@ namespace Server.Engines.ConPVP
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that
}
else if ( m_Tournament != null )
else
{
Tournament tourny = m_Tournament.Tournament;
Tournament tourny = m_Tournament?.Tournament;
if ( tourny != null )
{
@ -3648,4 +3588,4 @@ namespace Server.Engines.ConPVP
}
}
}
}
}

View file

@ -104,8 +104,8 @@ namespace Server.Engines.Craft
}
// ****************************************
if ( notice is int && (int)notice > 0 )
AddHtmlLocalized( 170, 295, 350, 40, (int)notice, LabelColor, false, false );
if ( notice is int noticeInt && noticeInt > 0 )
AddHtmlLocalized( 170, 295, 350, 40, noticeInt, LabelColor, false, false );
else if ( notice is string )
AddHtml( 170, 295, 350, 40, String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice ), false, false );
@ -115,7 +115,7 @@ namespace Server.Engines.Craft
string nameString = craftSystem.CraftSubRes.NameString;
int nameNumber = craftSystem.CraftSubRes.NameNumber;
int resIndex = ( context == null ? -1 : context.LastResourceIndex );
int resIndex = context?.LastResourceIndex ?? -1;
Type resourceType = craftSystem.CraftSubRes.ResType;
@ -616,4 +616,4 @@ namespace Server.Engines.Craft
}
}
}
}
}

View file

@ -62,9 +62,9 @@ namespace Server.Engines.Craft
AddButton( 15, 387, 4014, 4016, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 50, 390, 150, 18, 1044150, LabelColor, false, false ); // BACK
bool needsRecipe = ( craftItem.Recipe != null && from is PlayerMobile && !((PlayerMobile)from).HasRecipe( craftItem.Recipe ) );
bool needsRecipe = ( craftItem.Recipe != null && from is PlayerMobile mobile && !mobile.HasRecipe( craftItem.Recipe ) );
if( needsRecipe )
if ( needsRecipe )
{
AddButton( 270, 387, 4005, 4007, 0, GumpButtonType.Page, 0 );
AddHtmlLocalized( 305, 390, 150, 18, 1044151, GreyLabelColor, false, false ); // MAKE NOW
@ -88,17 +88,17 @@ namespace Server.Engines.Craft
DrawResource();
/*
if( craftItem.RequiresSE )
if ( craftItem.RequiresSE )
AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 310, 18, 1063363, LabelColor, false, false ); //* Requires the "Samurai Empire" expansion
* */
if( craftItem.RequiredExpansion != Expansion.None )
if ( craftItem.RequiredExpansion != Expansion.None )
{
bool supportsEx = (from.NetState != null && from.NetState.SupportsExpansion( craftItem.RequiredExpansion ));
TextDefinition.AddHtmlText( this, 170, 302 + (m_OtherCount++ * 20), 310, 18, RequiredExpansionMessage( craftItem.RequiredExpansion ), false, false, supportsEx ? LabelColor : RedLabelColor, supportsEx ? LabelHue : RedLabelHue );
}
if( needsRecipe )
if ( needsRecipe )
AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 310, 18, 1073620, RedLabelColor, false, false ); // You have not learned this recipe.
}
@ -167,9 +167,9 @@ namespace Server.Engines.Craft
if ( m_ShowExceptionalChance )
{
if( excepChance < 0.0 )
if ( excepChance < 0.0 )
excepChance = 0.0;
else if( excepChance > 1.0 )
else if ( excepChance > 1.0 )
excepChance = 1.0;
AddHtmlLocalized( 170, 100, 250, 18, 1044058, 32767, false, false ); // Exceptional Chance:
@ -207,7 +207,7 @@ namespace Server.Engines.Craft
type = craftResource.ItemType;
nameString = craftResource.NameString;
nameNumber = craftResource.NameNumber;
// Resource Mutation
if ( type == res.ResType && resIndex > -1 )
{
@ -284,4 +284,4 @@ namespace Server.Engines.Craft
}
}
}
}
}

View file

@ -72,7 +72,7 @@ namespace Server.Engines.Craft
public void AddRecipe( int id, CraftSystem system )
{
if( m_Recipe != null )
if ( m_Recipe != null )
{
Console.WriteLine( "Warning: Attempted add of recipe #{0} to the crafting of {1} in CraftSystem {2}.", id, this.m_Type.Name, system );
return;
@ -395,7 +395,7 @@ namespace Server.Engines.Craft
public bool IsMarkable( Type type )
{
if( m_ForceNonExceptional ) //Don't even display the stuff for marking if it can't ever be exceptional.
if ( m_ForceNonExceptional ) //Don't even display the stuff for marking if it can't ever be exceptional.
return false;
for ( int i = 0; i < m_MarkableTable.Length; ++i )
@ -526,15 +526,13 @@ namespace Server.Engines.Craft
for ( int j = 0; j < items[i].Length; ++j )
{
IHasQuantity hq = items[i][j] as IHasQuantity;
if ( hq == null )
if ( !(items[i][j] is IHasQuantity hq) )
{
totals[i] += items[i][j].Amount;
}
else
{
if ( hq is BaseBeverage && ((BaseBeverage)hq).Content != m_RequiredBeverage )
if ( hq is BaseBeverage beverage && beverage.Content != m_RequiredBeverage )
continue;
totals[i] += hq.Quantity;
@ -552,9 +550,8 @@ namespace Server.Engines.Craft
for ( int j = 0; j < items[i].Length; ++j )
{
Item item = items[i][j];
IHasQuantity hq = item as IHasQuantity;
if ( hq == null )
if ( !(item is IHasQuantity hq) )
{
int theirAmount = item.Amount;
@ -571,7 +568,7 @@ namespace Server.Engines.Craft
}
else
{
if ( hq is BaseBeverage && ((BaseBeverage)hq).Content != m_RequiredBeverage )
if ( hq is BaseBeverage beverage && beverage.Content != m_RequiredBeverage )
continue;
int theirAmount = hq.Quantity;
@ -601,15 +598,13 @@ namespace Server.Engines.Craft
for ( int i = 0; i < items.Length; ++i )
{
IHasQuantity hq = items[i] as IHasQuantity;
if ( hq == null )
if ( !(items[i] is IHasQuantity hq) )
{
amount += items[i].Amount;
}
else
{
if ( hq is BaseBeverage && ((BaseBeverage)hq).Content != m_RequiredBeverage )
if ( hq is BaseBeverage beverage && beverage.Content != m_RequiredBeverage )
continue;
amount += hq.Quantity;
@ -862,26 +857,20 @@ namespace Server.Engines.Craft
public double GetExceptionalChance( CraftSystem system, double chance, Mobile from )
{
if( m_ForceNonExceptional )
if ( m_ForceNonExceptional )
return 0.0;
double bonus = 0.0;
if ( from.Talisman is BaseTalisman )
if ( from.Talisman is BaseTalisman talisman && talisman.Skill == system.MainSkill )
{
BaseTalisman talisman = (BaseTalisman) from.Talisman;
if ( talisman.Skill == system.MainSkill )
{
chance -= talisman.SuccessBonus / 100.0;
bonus = talisman.ExceptionalBonus / 100.0;
}
chance -= talisman.SuccessBonus / 100.0;
bonus = talisman.ExceptionalBonus / 100.0;
}
switch ( system.ECA )
{
default:
case CraftECA.ChanceMinusSixty: chance -= 0.6; break;
default: chance -= 0.6; break;
case CraftECA.FiftyPercentChanceMinusTenPercent: chance = chance * 0.5 - 0.1; break;
case CraftECA.ChanceMinusSixtyToFourtyFive:
{
@ -955,13 +944,8 @@ namespace Server.Engines.Craft
else
chance = 0.0;
if ( allRequiredSkills && from.Talisman is BaseTalisman )
{
BaseTalisman talisman = (BaseTalisman) from.Talisman;
if ( talisman.Skill == craftSystem.MainSkill )
chance += talisman.SuccessBonus / 100.0;
}
if ( allRequiredSkills && from.Talisman is BaseTalisman talisman && talisman.Skill == craftSystem.MainSkill )
chance += talisman.SuccessBonus / 100.0;
if ( allRequiredSkills && valMainSkill == maxMainSkill )
chance = 1.0;
@ -973,32 +957,32 @@ namespace Server.Engines.Craft
{
if ( from.BeginAction( typeof( CraftSystem ) ) )
{
if( RequiredExpansion == Expansion.None || ( from.NetState != null && from.NetState.SupportsExpansion( RequiredExpansion ) ) )
if ( RequiredExpansion == Expansion.None || ( from.NetState != null && from.NetState.SupportsExpansion( RequiredExpansion ) ) )
{
bool allRequiredSkills = true;
double chance = GetSuccessChance( from, typeRes, craftSystem, false, ref allRequiredSkills );
if ( allRequiredSkills && chance >= 0.0 )
{
if( this.Recipe == null || !(from is PlayerMobile) || ((PlayerMobile)from).HasRecipe( this.Recipe ) )
if ( this.Recipe == null || !(from is PlayerMobile) || ((PlayerMobile)from).HasRecipe( this.Recipe ) )
{
int badCraft = craftSystem.CanCraft( from, tool, m_Type );
if( badCraft <= 0 )
if ( badCraft <= 0 )
{
int resHue = 0;
int maxAmount = 0;
object message = null;
if( ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref message ) )
if ( ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref message ) )
{
message = null;
if( ConsumeAttributes( from, ref message, false ) )
if ( ConsumeAttributes( from, ref message, false ) )
{
CraftContext context = craftSystem.GetContext( from );
if( context != null )
if ( context != null )
context.OnMade( this );
int iMin = craftSystem.MinCraftEffect;
@ -1080,25 +1064,15 @@ namespace Server.Engines.Craft
object checkMessage = null;
// Not enough resource to craft it
if ( !ConsumeRes( from, typeRes, craftSystem, ref checkResHue, ref checkMaxAmount, ConsumeType.None, ref checkMessage ) )
if ( !(ConsumeRes( from, typeRes, craftSystem, ref checkResHue, ref checkMaxAmount, ConsumeType.None, ref checkMessage )
&& ConsumeAttributes( from, ref checkMessage, false )))
{
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, checkMessage ) );
else if ( checkMessage is int && (int)checkMessage > 0 )
from.SendLocalizedMessage( (int)checkMessage );
else if ( checkMessage is string )
from.SendMessage( (string)checkMessage );
return;
}
else if ( !ConsumeAttributes( from, ref checkMessage, false ) )
{
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, checkMessage ) );
else if ( checkMessage is int && (int)checkMessage > 0 )
from.SendLocalizedMessage( (int)checkMessage );
else if ( checkMessage is string )
from.SendMessage( (string)checkMessage );
else if ( checkMessage is int messageInt && messageInt > 0 )
from.SendLocalizedMessage( messageInt );
else
from.SendMessage( checkMessage.ToString() );
return;
}
@ -1119,25 +1093,15 @@ namespace Server.Engines.Craft
object message = null;
// Not enough resource to craft it
if ( !ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message ) )
if ( !(ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message )
&& ConsumeAttributes( from, ref message, true )))
{
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
else if ( message is int && (int)message > 0 )
from.SendLocalizedMessage( (int)message );
else if ( message is string )
from.SendMessage( (string)message );
return;
}
else if ( !ConsumeAttributes( from, ref message, true ) )
{
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
else if ( message is int && (int)message > 0 )
from.SendLocalizedMessage( (int)message );
else if ( message is string )
from.SendMessage( (string)message );
else if ( message is int messageIn && messageIn > 0 )
from.SendLocalizedMessage( messageIn );
else
from.SendMessage( message.ToString() );
return;
}
@ -1146,8 +1110,7 @@ namespace Server.Engines.Craft
if ( craftSystem is DefBlacksmithy )
{
AncientSmithyHammer hammer = from.FindItemOnLayer( Layer.OneHanded ) as AncientSmithyHammer;
if ( hammer != null && hammer != tool )
if ( from.FindItemOnLayer( Layer.OneHanded ) is AncientSmithyHammer hammer && hammer != tool )
{
hammer.UsesRemaining--;
if ( hammer.UsesRemaining < 1 )
@ -1180,22 +1143,22 @@ namespace Server.Engines.Craft
if ( item != null )
{
if( item is ICraftable )
endquality = ((ICraftable)item).OnCraft( quality, makersMark, from, craftSystem, typeRes, tool, this, resHue );
if ( item is ICraftable craftable )
endquality = craftable.OnCraft( quality, makersMark, from, craftSystem, typeRes, tool, this, resHue );
else if ( item.Hue == 0 )
item.Hue = resHue;
if ( maxAmount > 0 )
{
if ( !item.Stackable && item is IUsesRemaining )
((IUsesRemaining)item).UsesRemaining *= maxAmount;
if ( !item.Stackable && item is IUsesRemaining remaining )
remaining.UsesRemaining *= maxAmount;
else
item.Amount = maxAmount;
}
from.AddToBackpack( item );
if( from.AccessLevel > AccessLevel.Player )
if ( from.AccessLevel > AccessLevel.Player )
CommandLogging.WriteLine( from, "Crafting {0} with craft system {1}", CommandLogging.Format( item ), craftSystem.GetType().Name );
//from.PlaySound( 0x57 );
@ -1266,10 +1229,10 @@ namespace Server.Engines.Craft
{
if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
else if ( message is int && (int)message > 0 )
from.SendLocalizedMessage( (int)message );
else if ( message is string )
from.SendMessage( (string)message );
else if ( message is int messageInt && messageInt > 0 )
from.SendLocalizedMessage( messageInt );
else
from.SendMessage( message.ToString() );
return;
}

View file

@ -32,18 +32,14 @@ namespace Server.Engines.Craft
if ( !(item is BaseArmor) && !(item is BaseWeapon) )
return EnhanceResult.BadItem;
if ( item is IArcaneEquip )
{
IArcaneEquip eq = (IArcaneEquip)item;
if ( eq.IsArcane )
return EnhanceResult.BadItem;
}
if ( item is IArcaneEquip eq && eq.IsArcane )
return EnhanceResult.BadItem;
if ( CraftResources.IsStandard( resource ) )
return EnhanceResult.BadResource;
int num = craftSystem.CanCraft( from, tool, item.GetType() );
if ( num > 0 )
{
resMessage = num;
@ -56,7 +52,7 @@ namespace Server.Engines.Craft
return EnhanceResult.BadItem;
bool allRequiredSkills = false;
if( craftItem.GetSuccessChance( from, resType, craftSystem, false, ref allRequiredSkills ) <= 0.0 )
if ( craftItem.GetSuccessChance( from, resType, craftSystem, false, ref allRequiredSkills ) <= 0.0 )
return EnhanceResult.NoSkill;
CraftResourceInfo info = CraftResources.GetInfo( resource );
@ -76,8 +72,7 @@ namespace Server.Engines.Craft
if ( craftSystem is DefBlacksmithy )
{
AncientSmithyHammer hammer = from.FindItemOnLayer( Layer.OneHanded ) as AncientSmithyHammer;
if ( hammer != null )
if ( from.FindItemOnLayer( Layer.OneHanded ) is AncientSmithyHammer hammer )
{
hammer.UsesRemaining--;
if ( hammer.UsesRemaining < 1 )
@ -99,10 +94,8 @@ namespace Server.Engines.Craft
bool lreqBonus = false;
bool dincBonus = false;
if ( item is BaseWeapon )
if ( item is BaseWeapon weapon )
{
BaseWeapon weapon = (BaseWeapon)item;
if ( !CraftResources.IsStandard( weapon.Resource ) )
return EnhanceResult.AlreadyEnhanced;
@ -203,17 +196,15 @@ namespace Server.Engines.Craft
if ( !craftItem.ConsumeRes( from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref resMessage ) )
return EnhanceResult.NoResources;
if( item is BaseWeapon )
if ( item is BaseWeapon w )
{
BaseWeapon w = (BaseWeapon)item;
w.Resource = resource;
int hue = w.GetElementalDamageHue();
if( hue > 0 )
if ( hue > 0 )
w.Hue = hue;
}
else if( item is BaseArmor ) //Sanity
else
{
((BaseArmor)item).Resource = resource;
}
@ -302,10 +293,10 @@ namespace Server.Engines.Craft
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Item )
if ( targeted is Item item )
{
object message = null;
EnhanceResult res = Enhance.Invoke( from, m_CraftSystem, m_Tool, (Item)targeted, m_Resource, m_ResourceType, ref message );
EnhanceResult res = Enhance.Invoke( from, m_CraftSystem, m_Tool, item, m_Resource, m_ResourceType, ref message );
switch ( res )
{
@ -324,4 +315,4 @@ namespace Server.Engines.Craft
}
}
}
}
}

View file

@ -24,10 +24,10 @@ namespace Server.Engines.Craft
m.BeginTarget( -1, false, Server.Targeting.TargetFlags.None, new TargetCallback(
delegate( Mobile from, object targeted )
{
if( targeted is PlayerMobile )
if ( targeted is PlayerMobile mobile )
{
foreach( KeyValuePair<int, Recipe> kvp in m_Recipes )
((PlayerMobile)targeted).AcquireRecipe( kvp.Key );
mobile.AcquireRecipe( kvp.Key );
m.SendMessage( "You teach them all of the recipies." );
}
@ -49,9 +49,9 @@ namespace Server.Engines.Craft
m.BeginTarget( -1, false, Server.Targeting.TargetFlags.None, new TargetCallback(
delegate( Mobile from, object targeted )
{
if( targeted is PlayerMobile )
if ( targeted is PlayerMobile mobile )
{
((PlayerMobile)targeted).ResetRecipes();
mobile.ResetRecipes();
m.SendMessage( "They forget all their recipies." );
}
@ -99,7 +99,7 @@ namespace Server.Engines.Craft
{
get
{
if( m_TD == null )
if ( m_TD == null )
m_TD = new TextDefinition( m_CraftItem.NameNumber, m_CraftItem.NameString );
return m_TD;
@ -112,7 +112,7 @@ namespace Server.Engines.Craft
m_System = system;
m_CraftItem = item;
if( m_Recipes.ContainsKey( id ) )
if ( m_Recipes.ContainsKey( id ) )
throw new Exception( "Attempting to create recipe with preexisting ID." );
m_Recipes.Add( id, this );

View file

@ -68,15 +68,15 @@ namespace Server.Engines.Craft
double difficulty = GetRepairDifficulty( curHits, maxHits ) * 0.1;
if( m_Deed != null )
if ( m_Deed != null )
{
double value = m_Deed.SkillLevel;
double minSkill = difficulty - 25.0;
double maxSkill = difficulty + 25;
if( value < minSkill )
if ( value < minSkill )
return false; // Too difficult
else if( value >= maxSkill )
else if ( value >= maxSkill )
return true; // No challenge
double chance = (value - minSkill) / (maxSkill - minSkill);
@ -91,7 +91,7 @@ namespace Server.Engines.Craft
private bool CheckDeed( Mobile from )
{
if( m_Deed != null )
if ( m_Deed != null )
{
return m_Deed.Check( from );
}
@ -211,7 +211,7 @@ namespace Server.Engines.Craft
{
int number;
if( !CheckDeed( from ) )
if ( !CheckDeed( from ) )
return;
bool usingDeed = (m_Deed != null);
@ -223,9 +223,8 @@ namespace Server.Engines.Craft
{
number = 1044282; // You must be near a forge and and anvil to repair items. * Yes, there are two and's *
}
else if ( m_CraftSystem is DefTinkering && targeted is Golem )
else if ( m_CraftSystem is DefTinkering && targeted is Golem g )
{
Golem g = (Golem)targeted;
int damage = g.HitsMax - g.Hits;
if ( g.IsDeadBondedPet )
@ -286,9 +285,8 @@ namespace Server.Engines.Craft
}
}
}
else if ( targeted is BaseWeapon )
else if ( targeted is BaseWeapon weapon )
{
BaseWeapon weapon = (BaseWeapon)targeted;
SkillName skill = m_CraftSystem.MainSkill;
int toWeaken = 0;
@ -351,9 +349,8 @@ namespace Server.Engines.Craft
toDelete = true;
}
}
else if ( targeted is BaseArmor )
else if ( targeted is BaseArmor armor )
{
BaseArmor armor = (BaseArmor)targeted;
SkillName skill = m_CraftSystem.MainSkill;
int toWeaken = 0;
@ -412,9 +409,8 @@ namespace Server.Engines.Craft
toDelete = true;
}
}
else if ( targeted is BaseClothing )
else if ( targeted is BaseClothing clothing )
{
BaseClothing clothing = (BaseClothing)targeted;
SkillName skill = m_CraftSystem.MainSkill;
int toWeaken = 0;
@ -434,7 +430,7 @@ namespace Server.Engines.Craft
toWeaken = 3;
}
if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !IsSpecialClothing(clothing) && !((targeted is TribalMask) || (targeted is HornedTribalMask)) )
if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !IsSpecialClothing(clothing) && !((clothing is TribalMask) || (clothing is HornedTribalMask)) )
{
number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
}
@ -473,13 +469,13 @@ namespace Server.Engines.Craft
toDelete = true;
}
}
else if( !usingDeed && targeted is BlankScroll )
else if ( !usingDeed && targeted is BlankScroll scroll )
{
SkillName skill = m_CraftSystem.MainSkill;
if( from.Skills[skill].Value >= 50.0 )
if ( from.Skills[skill].Value >= 50.0 )
{
((BlankScroll)targeted).Consume( 1 );
scroll.Consume( 1 );
RepairDeed deed = new RepairDeed( RepairDeed.GetTypeFor( m_CraftSystem ), from.Skills[skill].Value, from );
from.AddToBackpack( deed );
@ -497,7 +493,7 @@ namespace Server.Engines.Craft
number = 500426; // You can't repair that.
}
if( !usingDeed )
if ( !usingDeed )
{
CraftContext context = m_CraftSystem.GetContext( from );
from.SendGump( new CraftGump( from, m_CraftSystem, m_Tool, number ) );
@ -506,10 +502,10 @@ namespace Server.Engines.Craft
{
from.SendLocalizedMessage( number );
if( toDelete )
if ( toDelete )
m_Deed.Delete();
}
}
}
}
}
}

View file

@ -90,7 +90,7 @@ namespace Server.Engines.Craft
Type resourceType = info.ResourceTypes[0];
Item ingot = (Item)Activator.CreateInstance( resourceType );
if ( item is DragonBardingDeed || (item is BaseArmor && ((BaseArmor)item).PlayerConstructed) || (item is BaseWeapon && ((BaseWeapon)item).PlayerConstructed) || (item is BaseClothing && ((BaseClothing)item).PlayerConstructed) )
if ( item is DragonBardingDeed || (item is BaseArmor armor && armor.PlayerConstructed) || (item is BaseWeapon weapon && weapon.PlayerConstructed) || (item is BaseClothing clothing && clothing.PlayerConstructed) )
ingot.Amount = craftResource.Amount / 2;
else
ingot.Amount = 1;
@ -118,7 +118,7 @@ namespace Server.Engines.Craft
if ( num == 1044267 )
{
bool anvil, forge;
DefBlacksmithy.CheckAnvilAndForge( from, 2, out anvil, out forge );
if ( !anvil )
@ -135,19 +135,19 @@ namespace Server.Engines.Craft
bool isStoreBought = false;
int message;
if ( targeted is BaseArmor )
if ( targeted is BaseArmor armor )
{
result = Resmelt( from, (BaseArmor)targeted, ((BaseArmor)targeted).Resource );
isStoreBought = !((BaseArmor)targeted).PlayerConstructed;
result = Resmelt( from, armor, armor.Resource );
isStoreBought = !armor.PlayerConstructed;
}
else if ( targeted is BaseWeapon )
else if ( targeted is BaseWeapon weapon )
{
result = Resmelt( from, (BaseWeapon)targeted, ((BaseWeapon)targeted).Resource );
isStoreBought = !((BaseWeapon)targeted).PlayerConstructed;
result = Resmelt( from, weapon, weapon.Resource );
isStoreBought = !weapon.PlayerConstructed;
}
else if ( targeted is DragonBardingDeed )
else if ( targeted is DragonBardingDeed deed )
{
result = Resmelt( from, (DragonBardingDeed)targeted, ((DragonBardingDeed)targeted).Resource );
result = Resmelt( from, deed, deed.Resource );
isStoreBought = false;
}
@ -164,4 +164,4 @@ namespace Server.Engines.Craft
}
}
}
}
}

View file

@ -39,7 +39,7 @@ namespace Server.Engines.Craft
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
@ -154,7 +154,7 @@ namespace Server.Engines.Craft
index = AddCraft( typeof( GreaterExplosionPotion ), 1044537, 1044557, 65.0, 115.0, typeof( SulfurousAsh ), 1044359, 10, 1044367 );
AddRes( index, typeof ( Bottle ), 1044529, 1, 500315 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( SmokeBomb ), 1044537, 1030248, 90.0, 120.0, typeof( Eggs ), 1044477, 1, 1044253 );
AddRes( index, typeof ( Ginseng ), 1044356, 3, 1044364 );
@ -177,4 +177,4 @@ namespace Server.Engines.Craft
}
}
}
}
}

View file

@ -229,7 +229,7 @@ namespace Server.Engines.Craft
if ( Core.AOS ) // exact pre-aos functionality unknown
AddCraft( typeof( DragonBardingDeed ), 1011078, 1053012, 72.5, 122.5, typeof( IronIngot ), 1044036, 750, 1044037 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( PlateMempo ), 1011078, 1030180, 80.0, 130.0, typeof( IronIngot ), 1044036, 18, 1044037 );
SetNeededExpansion( index, Expansion.SE );
@ -256,7 +256,7 @@ namespace Server.Engines.Craft
AddCraft( typeof( NorseHelm ), 1011079, 1025134, 37.9, 87.9, typeof( IronIngot ), 1044036, 15, 1044037 );
AddCraft( typeof( PlateHelm ), 1011079, 1025138, 62.6, 112.6, typeof( IronIngot ), 1044036, 15, 1044037 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( ChainHatsuburi ), 1011079, 1030175, 30.0, 80.0, typeof( IronIngot ), 1044036, 20, 1044037 );
SetNeededExpansion( index, Expansion.SE );
@ -282,7 +282,7 @@ namespace Server.Engines.Craft
index = AddCraft( typeof( StandardPlateKabuto ), 1011079, 1030196, 90.0, 140.0, typeof( IronIngot ), 1044036, 25, 1044037 );
SetNeededExpansion( index, Expansion.SE );
if( Core.ML )
if ( Core.ML )
{
index = AddCraft( typeof( Circlet ), 1011079, 1032645, 62.1, 112.1, typeof( IronIngot ), 1044036, 6, 1044037 );
SetNeededExpansion( index, Expansion.ML );
@ -332,7 +332,7 @@ namespace Server.Engines.Craft
AddCraft( typeof( Scimitar ), 1011081, 1025046, 31.7, 81.7, typeof( IronIngot ), 1044036, 10, 1044037 );
AddCraft( typeof( VikingSword ), 1011081, 1025049, 24.3, 74.3, typeof( IronIngot ), 1044036, 14, 1044037 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( NoDachi ), 1011081, 1030221, 75.0, 125.0, typeof( IronIngot ), 1044036, 18, 1044037 );
SetNeededExpansion( index, Expansion.SE );
@ -351,7 +351,7 @@ namespace Server.Engines.Craft
index = AddCraft( typeof( Sai ), 1011081, 1030234, 50.0, 100.0, typeof( IronIngot ), 1044036, 12, 1044037 );
SetNeededExpansion( index, Expansion.SE );
if( Core.ML )
if ( Core.ML )
{
index = AddCraft( typeof( RadiantScimitar ), 1011081, 1031571, 75.0, 125.0, typeof( IronIngot ), 1044036, 15, 1044037 );
SetNeededExpansion( index, Expansion.ML );
@ -565,7 +565,7 @@ namespace Server.Engines.Craft
AddCraft( typeof( TwoHandedAxe ), 1011082, 1025187, 33.0, 83.0, typeof( IronIngot ), 1044036, 16, 1044037 );
AddCraft( typeof( WarAxe ), 1011082, 1025040, 39.1, 89.1, typeof( IronIngot ), 1044036, 16, 1044037 );
if( Core.ML )
if ( Core.ML )
{
index = AddCraft( typeof( OrnateAxe ), 1011082, 1031572, 70.0, 120.0, typeof( IronIngot ), 1044036, 18, 1044037 );
SetNeededExpansion( index, Expansion.ML );
@ -634,7 +634,7 @@ namespace Server.Engines.Craft
AddCraft( typeof( WarMace ), 1011084, 1025127, 28.0, 78.0, typeof( IronIngot ), 1044036, 14, 1044037 );
AddCraft( typeof( WarHammer ), 1011084, 1025177, 34.2, 84.2, typeof( IronIngot ), 1044036, 16, 1044037 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( Tessen ), 1011084, 1030222, 85.0, 135.0, typeof( IronIngot ), 1044036, 16, 1044037 );
AddSkill( index, SkillName.Tailoring, 50.0, 55.0 );
@ -642,7 +642,7 @@ namespace Server.Engines.Craft
SetNeededExpansion( index, Expansion.SE );
}
if( Core.ML )
if ( Core.ML )
{
index = AddCraft( typeof( DiamondMace ), 1011084, 1031556, 70.0, 120.0, typeof( IronIngot ), 1044036, 20, 1044037 );
SetNeededExpansion( index, Expansion.ML );

View file

@ -39,7 +39,7 @@ namespace Server.Engines.Craft
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
@ -102,7 +102,7 @@ namespace Server.Engines.Craft
AddRes( index, typeof( Feather ), 1044562, 1, 1044563 );
SetUseAllRes( index, true );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( FukiyaDarts ), 1044565, 1030246, 50.0, 90.0, typeof( Log ), 1044041, 1, 1044351 );
SetUseAllRes( index, true );
@ -120,7 +120,7 @@ namespace Server.Engines.Craft
AddCraft( typeof( RepeatingCrossbow ), 1044566, 1029923, 90.0, 130.0, typeof( Log ), 1044041, 10, 1044351 );
}
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( Yumi ), 1044566, 1030224, 90.0, 130.0, typeof( Log ), 1044041, 10, 1044351 );
SetNeededExpansion( index, Expansion.SE );

View file

@ -39,7 +39,7 @@ namespace Server.Engines.Craft
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
@ -98,7 +98,7 @@ namespace Server.Engines.Craft
AddCraft( typeof( TallMusicStand ), 1044294, 1044315, 81.5, 106.5, typeof( Log ), 1044041, 20, 1044351 );
AddCraft( typeof( Easle ), 1044294, 1044317, 86.8, 111.8, typeof( Log ), 1044041, 20, 1044351 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( RedHangingLantern ), 1044294, 1029412, 65.0, 90.0, typeof( Log ), 1044041, 5, 1044351 );
AddRes( index, typeof( BlankScroll ), 1044377, 10, 1044378 );
@ -119,7 +119,7 @@ namespace Server.Engines.Craft
SetNeededExpansion( index, Expansion.SE );
}
if( Core.AOS ) //Duplicate Entries to preserve ordering depending on era
if ( Core.AOS ) //Duplicate Entries to preserve ordering depending on era
{
index = AddCraft( typeof( FishingPole ), 1044294, 1023519, 68.4, 93.4, typeof( Log ), 1044041, 5, 1044351 ); //This is in the categor of Other during AoS
AddSkill( index, SkillName.Tailoring, 40.0, 45.0 );
@ -177,7 +177,7 @@ namespace Server.Engines.Craft
AddCraft( typeof( YewWoodTable ), 1044291, 1044307, 63.1, 88.1, typeof( Log ), 1044041, 23, 1044351 );
AddCraft( typeof( LargeTable ), 1044291, 1044308, 84.2, 109.2, typeof( Log ), 1044041, 27, 1044351 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( ElegantLowTable ), 1044291, 1030265, 80.0, 105.0, typeof( Log ), 1044041, 35, 1044351 );
SetNeededExpansion( index, Expansion.SE );
@ -203,7 +203,7 @@ namespace Server.Engines.Craft
AddCraft( typeof( FancyArmoire ), 1044292, 1044312, 84.2, 109.2, typeof( Log ), 1044041, 35, 1044351 );
AddCraft( typeof( Armoire ), 1044292, 1022643, 84.2, 109.2, typeof( Log ), 1044041, 35, 1044351 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( PlainWoodenChest ), 1044292, 1030251, 90.0, 115.0, typeof( Log ), 1044041, 30, 1044351 );
SetNeededExpansion( index, Expansion.SE );
@ -291,14 +291,14 @@ namespace Server.Engines.Craft
AddCraft( typeof( GnarledStaff ), Core.ML ? 1044566 : 1044295, 1025112, 78.9, 103.9, typeof( Log ), 1044041, 7, 1044351 );
AddCraft( typeof( WoodenShield ), Core.ML ? 1062760 : 1044295, 1027034, 52.6, 77.6, typeof( Log ), 1044041, 9, 1044351 );
if( !Core.AOS ) //Duplicate Entries to preserve ordering depending on era
if ( !Core.AOS ) //Duplicate Entries to preserve ordering depending on era
{
index = AddCraft( typeof( FishingPole ), Core.ML ? 1044294 : 1044295, 1023519, 68.4, 93.4, typeof( Log ), 1044041, 5, 1044351 ); //This is in the categor of Other during AoS
AddSkill( index, SkillName.Tailoring, 40.0, 45.0 );
AddRes( index, typeof( Cloth ), 1044286, 5, 1044287 );
}
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( Bokuto ), Core.ML ? 1044566 : 1044295, 1030227, 70.0, 95.0, typeof( Log ), 1044041, 6, 1044351 );
SetNeededExpansion( index, Expansion.SE );
@ -386,7 +386,7 @@ namespace Server.Engines.Craft
AddSkill( index, SkillName.Musicianship, 45.0, 50.0 );
AddRes( index, typeof( Cloth ), 1044286, 15, 1044287 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( BambooFlute ), 1044293, 1030247, 80.0, 105.0, typeof( Log ), 1044041, 15, 1044351 );
AddSkill( index, SkillName.Musicianship, 45.0, 50.0 );
@ -519,4 +519,4 @@ namespace Server.Engines.Craft
AddSubRes( typeof( FrostwoodLog ), 1072649, 100.0, 1044041, 1072652 );
}
}
}
}

View file

@ -39,7 +39,7 @@ namespace Server.Engines.Craft
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
@ -72,7 +72,7 @@ namespace Server.Engines.Craft
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
else
return 1044154; // You create the item.
}
}
@ -85,4 +85,4 @@ namespace Server.Engines.Craft
AddCraft( typeof( WorldMap ), 1044448, 1015233, 39.5, 99.5, typeof( BlankMap ), 1044449, 1, 1044450 );
}
}
}
}

View file

@ -41,7 +41,7 @@ namespace Server.Engines.Craft
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.

View file

@ -31,7 +31,7 @@ namespace Server.Engines.Craft
public override double GetChanceAtMin( CraftItem item )
{
if( item.ItemType == typeof( HollowPrism ) )
if ( item.ItemType == typeof( HollowPrism ) )
return 0.5; // 50%
return 0.0; // 0%
@ -43,13 +43,13 @@ namespace Server.Engines.Craft
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckTool( tool, from ) )
if ( !BaseTool.CheckTool( tool, from ) )
return 1048146; // If you have a tool equipped, you must use that tool.
else if ( !(from is PlayerMobile && ((PlayerMobile)from).Glassblowing && from.Skills[SkillName.Alchemy].Base >= 100.0) )
if ( !(from is PlayerMobile mobile && mobile.Glassblowing && mobile.Skills[SkillName.Alchemy].Base >= 100.0) )
return 1044634; // You havent learned glassblowing.
else if ( !BaseTool.CheckAccessible( tool, from ) )
if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
bool anvil, forge;
@ -139,4 +139,4 @@ namespace Server.Engines.Craft
}
}
}
}
}

View file

@ -43,16 +43,15 @@ namespace Server.Engines.Craft
{
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
if ( !BaseTool.CheckAccessible( tool, @from ) )
if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
if ( typeItem != null )
{
var o = Activator.CreateInstance( typeItem );
if ( o is SpellScroll )
if ( o is SpellScroll scroll )
{
var scroll = (SpellScroll) o;
var book = Spellbook.Find( from, scroll.SpellID );
var hasSpell = ( book != null && book.HasSpell( scroll.SpellID ) );
@ -61,9 +60,10 @@ namespace Server.Engines.Craft
return ( hasSpell ? 0 : 1042404 ); // null : You don't have that spell!
}
else if ( o is Item )
if ( o is Item item )
{
( (Item) o ).Delete();
item.Delete();
}
}
@ -404,4 +404,4 @@ namespace Server.Engines.Craft
MarkOption = true;
}
}
}
}

View file

@ -1,42 +1,42 @@
using System;
using Server.Items;
using Server.Mobiles;
using System;
using Server.Items;
using Server.Mobiles;
namespace Server.Engines.Craft
{
public class DefMasonry : CraftSystem
{
public override SkillName MainSkill
{
get{ return SkillName.Carpentry; }
}
namespace Server.Engines.Craft
{
public class DefMasonry : CraftSystem
{
public override SkillName MainSkill
{
get{ return SkillName.Carpentry; }
}
public override int GumpTitleNumber
{
get{ return 1044500; } // <CENTER>MASONRY MENU</CENTER>
}
public override int GumpTitleNumber
{
get{ return 1044500; } // <CENTER>MASONRY MENU</CENTER>
}
private static CraftSystem m_CraftSystem;
private static CraftSystem m_CraftSystem;
public static CraftSystem CraftSystem
{
get
{
if ( m_CraftSystem == null )
m_CraftSystem = new DefMasonry();
public static CraftSystem CraftSystem
{
get
{
if ( m_CraftSystem == null )
m_CraftSystem = new DefMasonry();
return m_CraftSystem;
}
}
return m_CraftSystem;
}
}
public override double GetChanceAtMin( CraftItem item )
{
return 0.0; // 0%
}
public override double GetChanceAtMin( CraftItem item )
{
return 0.0; // 0%
}
private DefMasonry() : base( 1, 1, 1.25 )// base( 1, 2, 1.7 )
{
}
private DefMasonry() : base( 1, 1, 1.25 )// base( 1, 2, 1.7 )
{
}
public override bool RetainsColorFrom( CraftItem item, Type type )
{
@ -45,74 +45,74 @@ namespace Server.Engines.Craft
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckTool( tool, from ) )
if ( !BaseTool.CheckTool( tool, from ) )
return 1048146; // If you have a tool equipped, you must use that tool.
else if ( !(from is PlayerMobile && ((PlayerMobile)from).Masonry && from.Skills[SkillName.Carpentry].Base >= 100.0) )
if ( !(from is PlayerMobile mobile && mobile.Masonry && mobile.Skills[SkillName.Carpentry].Base >= 100.0) )
return 1044633; // You havent learned stonecraft.
else if ( !BaseTool.CheckAccessible( tool, from ) )
if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
return 0;
}
}
public override void PlayCraftEffect( Mobile from )
{
public override void PlayCraftEffect( Mobile from )
{
// no effects
//if ( from.Body.Type == BodyType.Human && !from.Mounted )
// from.Animate( 9, 5, 1, true, false, 0 );
//new InternalTimer( from ).Start();
}
//if ( from.Body.Type == BodyType.Human && !from.Mounted )
// from.Animate( 9, 5, 1, true, false, 0 );
//new InternalTimer( from ).Start();
}
// Delay to synchronize the sound with the hit on the anvil
private class InternalTimer : Timer
{
private Mobile m_From;
// Delay to synchronize the sound with the hit on the anvil
private class InternalTimer : Timer
{
private Mobile m_From;
public InternalTimer( Mobile from ) : base( TimeSpan.FromSeconds( 0.7 ) )
{
m_From = from;
}
public InternalTimer( Mobile from ) : base( TimeSpan.FromSeconds( 0.7 ) )
{
m_From = from;
}
protected override void OnTick()
{
m_From.PlaySound( 0x23D );
}
}
protected override void OnTick()
{
m_From.PlaySound( 0x23D );
}
}
public override int PlayEndingEffect( Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, bool makersMark, CraftItem item )
{
if ( toolBroken )
from.SendLocalizedMessage( 1044038 ); // You have worn out your tool
public override int PlayEndingEffect( Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, bool makersMark, CraftItem item )
{
if ( toolBroken )
from.SendLocalizedMessage( 1044038 ); // You have worn out your tool
if ( failed )
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
}
}
if ( failed )
{
if ( lostMaterial )
return 1044043; // You failed to create the item, and some of your materials are lost.
else
return 1044157; // You failed to create the item, but no materials were lost.
}
else
{
if ( quality == 0 )
return 502785; // You were barely able to make this item. It's quality is below average.
else if ( makersMark && quality == 2 )
return 1044156; // You create an exceptional quality item and affix your maker's mark.
else if ( quality == 2 )
return 1044155; // You create an exceptional quality item.
else
return 1044154; // You create the item.
}
}
public override void InitCraftList()
{
public override void InitCraftList()
{
// Decorations
AddCraft( typeof( Vase ), 1044501, 1022888, 52.5, 102.5, typeof( Granite ), 1044514, 1, 1044513 );
AddCraft( typeof( LargeVase ), 1044501, 1022887, 52.5, 102.5, typeof( Granite ), 1044514, 3, 1044513 );
if( Core.SE )
if ( Core.SE )
{
int index = AddCraft( typeof( SmallUrn ), 1044501, 1029244, 82.0, 132.0, typeof( Granite ), 1044514, 3, 1044513 );
SetNeededExpansion( index, Expansion.SE );
@ -147,4 +147,4 @@ namespace Server.Engines.Craft
AddSubRes( typeof( ValoriteGranite ), 1044030, 99.0, 1044514, 1044527 );
}
}
}
}

View file

@ -41,7 +41,7 @@ namespace Server.Engines.Craft
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
@ -123,7 +123,7 @@ namespace Server.Engines.Craft
if ( Core.AOS )
AddCraft( typeof( FlowerGarland ), 1011375, 1028965, 10.0, 35.0, typeof( Cloth ), 1044286, 5, 1044287 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( ClothNinjaHood ), 1011375, 1030202, 80.0, 105.0, typeof( Cloth ), 1044286, 13, 1044287 );
SetNeededExpansion( index, Expansion.SE );
@ -152,7 +152,7 @@ namespace Server.Engines.Craft
AddCraft( typeof( FormalShirt ), 1015269, 1028975, 26.0, 51.0, typeof( Cloth ), 1044286, 16, 1044287 );
}
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( ClothNinjaJacket ), 1015269, 1030207, 75.0, 100.0, typeof( Cloth ), 1044286, 12, 1044287 );
SetNeededExpansion( index, Expansion.SE );
@ -179,7 +179,7 @@ namespace Server.Engines.Craft
if ( Core.AOS )
AddCraft( typeof( FurSarong ), 1015279, 1028971, 35.0, 60.0, typeof( Cloth ), 1044286, 12, 1044287 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( Hakama ), 1015279, 1030213, 50.0, 75.0, typeof( Cloth ), 1044286, 16, 1044287 );
SetNeededExpansion( index, Expansion.SE );
@ -194,13 +194,13 @@ namespace Server.Engines.Craft
AddCraft( typeof( HalfApron ), 1015283, 1025435, 20.7, 45.7, typeof( Cloth ), 1044286, 6, 1044287 );
AddCraft( typeof( FullApron ), 1015283, 1025437, 29.0, 54.0, typeof( Cloth ), 1044286, 10, 1044287 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( Obi ), 1015283, 1030219, 20.0, 45.0, typeof( Cloth ), 1044286, 6, 1044287 );
SetNeededExpansion( index, Expansion.SE );
}
if( Core.ML )
if ( Core.ML )
{
index = AddCraft( typeof( ElvenQuiver ), 1015283, 1032657, 65.0, 115.0, typeof( Leather ), 1044462, 28, 1044463 );
AddRecipe( index, 501 );
@ -229,7 +229,7 @@ namespace Server.Engines.Craft
AddCraft( typeof( OilCloth ), 1015283, 1041498, 74.6, 99.6, typeof( Cloth ), 1044286, 1, 1044287 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( GozaMatEastDeed ), 1015283, 1030404, 55.0, 80.0, typeof( Cloth ), 1044286, 25, 1044287 );
SetNeededExpansion( index, Expansion.SE );
@ -255,7 +255,7 @@ namespace Server.Engines.Craft
if ( Core.AOS )
AddCraft( typeof( FurBoots ), 1015288, 1028967, 50.0, 75.0, typeof( Cloth ), 1044286, 12, 1044287 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( NinjaTabi ), 1015288, 1030210, 70.0, 95.0, typeof( Cloth ), 1044286, 10, 1044287 );
SetNeededExpansion( index, Expansion.SE );
@ -305,7 +305,7 @@ namespace Server.Engines.Craft
AddCraft( typeof( LeatherLegs ), 1015293, 1025067, 66.3, 91.3, typeof( Leather ), 1044462, 10, 1044463 );
AddCraft( typeof( LeatherChest ), 1015293, 1025068, 70.5, 95.5, typeof( Leather ), 1044462, 12, 1044463 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( LeatherJingasa ), 1015293, 1030177, 45.0, 70.0, typeof( Leather ), 1044462, 4, 1044463 );
SetNeededExpansion( index, Expansion.SE );
@ -340,7 +340,7 @@ namespace Server.Engines.Craft
AddCraft( typeof( StuddedLegs ), 1015300, 1025082, 91.2, 116.2, typeof( Leather ), 1044462, 12, 1044463 );
AddCraft( typeof( StuddedChest ), 1015300, 1025083, 94.0, 119.0, typeof( Leather ), 1044462, 14, 1044463 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( StuddedMempo ), 1015300, 1030216, 80.0, 105.0, typeof( Leather ), 1044462, 8, 1044463 );
SetNeededExpansion( index, Expansion.SE );

View file

@ -45,7 +45,7 @@ namespace Server.Engines.Craft
public override int CanCraft( Mobile from, BaseTool tool, Type itemType )
{
if( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
if ( tool == null || tool.Deleted || tool.UsesRemaining < 0 )
return 1044038; // You have worn out your tool!
else if ( !BaseTool.CheckAccessible( tool, from ) )
return 1044263; // The tool must be on your person to use.
@ -158,7 +158,7 @@ namespace Server.Engines.Craft
AddCraft( typeof( Axle ), 1044042, 1024187, -25.0, 25.0, typeof( Log ), 1044041, 2, 1044351 );
AddCraft( typeof( RollingPin ), 1044042, 1024163, 0.0, 50.0, typeof( Log ), 1044041, 5, 1044351 );
if( Core.SE )
if ( Core.SE )
{
index = AddCraft( typeof( Nunchaku ), 1044042, 1030158, 70.0, 120.0, typeof( IronIngot ), 1044036, 3, 1044037 );
AddRes( index, typeof( Log ), 1044041, 8, 1044351 );

View file

@ -334,17 +334,10 @@ namespace Server.Engines.Doom
object obj = Activator.CreateInstance( type );
if ( obj == null )
return;
if ( obj is Item )
if ( obj is Item item )
item.Delete();
else if ( obj is Mobile mob )
{
((Item)obj).Delete();
}
else if ( obj is Mobile )
{
Mobile mob = (Mobile)obj;
mob.MoveToWorld( GetWorldLocation(), this.Map );
m_Creatures.Add( mob );
@ -414,7 +407,7 @@ namespace Server.Engines.Doom
public GauntletSpawner( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
@ -704,4 +697,4 @@ namespace Server.Engines.Doom
{
}
}
}
}

View file

@ -9,7 +9,7 @@ using System.Collections.Generic;
/*
this is From me to you, Under no terms, Conditions... K? to apply you
just simply Unpatch/delete, Stick these in, Same location.. Restart
*/
*/
namespace Server.Engines.Doom
{
@ -75,7 +75,7 @@ namespace Server.Engines.Doom
{
for (int i=0; i<5; i++)
{
if( GetOccupant( i ) == null)
if ( GetOccupant( i ) == null)
{
return false;
}
@ -107,7 +107,7 @@ namespace Server.Engines.Doom
for (; i<19; i++)
m_Statues.Add( AddLeverPuzzlePart( TA[i], new LeverPuzzleStatue( TA[++i], this )));
if(!installed)
if (!installed)
Delete();
else
Enabled=true;
@ -119,7 +119,7 @@ namespace Server.Engines.Doom
public static Item AddLeverPuzzlePart( int[] Loc, Item newitem )
{
if( newitem == null || newitem.Deleted )
if ( newitem == null || newitem.Deleted )
{
installed=false;
}
@ -141,7 +141,7 @@ namespace Server.Engines.Doom
NukeItemList( m_Statues );
NukeItemList( m_Levers );
if( m_LampRoom != null )
if ( m_LampRoom != null )
{
m_LampRoom.Unregister();
}
@ -152,7 +152,7 @@ namespace Server.Engines.Doom
region.Unregister();
}
}
if( m_Box != null && !m_Box.Deleted )
if ( m_Box != null && !m_Box.Deleted )
{
m_Box.Delete();
}
@ -164,7 +164,7 @@ namespace Server.Engines.Doom
{
foreach ( Item item in list )
{
if( item != null && !item.Deleted )
if ( item != null && !item.Deleted )
{
item.Delete();
}
@ -178,7 +178,7 @@ namespace Server.Engines.Doom
if ( region != null )
{
if( region.Occupant != null && region.Occupant.Alive )
if ( region.Occupant != null && region.Occupant.Alive )
{
return (PlayerMobile)region.Occupant;
}
@ -190,7 +190,7 @@ namespace Server.Engines.Doom
{
LeverPuzzleStatue statue = (LeverPuzzleStatue)m_Statues[index];
if( statue != null && !statue.Deleted )
if ( statue != null && !statue.Deleted )
{
return statue;
}
@ -201,7 +201,7 @@ namespace Server.Engines.Doom
{
LeverPuzzleLever lever = (LeverPuzzleLever)m_Levers[index];
if( lever != null && !lever.Deleted )
if ( lever != null && !lever.Deleted )
{
return lever;
}
@ -213,7 +213,7 @@ namespace Server.Engines.Doom
for( int i=0; i<2; i++)
{
Item s;
if(( s = GetStatue( i )) != null )
if (( s = GetStatue( i )) != null )
{
s.PublicOverheadMessage( MessageType.Regular, 0x3B2, message, fstring );
}
@ -231,7 +231,7 @@ namespace Server.Engines.Doom
for(int i=0;i<4; i++)
{
Item l;
if(( l = GetLever( i )) != null )
if (( l = GetLever( i )) != null )
{
l.ItemID=0x108E;
Effects.PlaySound( l.Location, Map, 0x3E8 );
@ -266,24 +266,24 @@ namespace Server.Engines.Doom
/* if one bit in each of the four nibbles is set, this is false */
if( (TheirKey=(ushort)(code|(TheirKey<<=4))) < 0x0FFF )
if ( (TheirKey=(ushort)(code|(TheirKey<<=4))) < 0x0FFF )
{
l_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 30.0 ), new TimerCallback( ResetPuzzle ));
return;
}
if( !CircleComplete )
if ( !CircleComplete )
{
PuzzleStatus( 1050004, null ); // The circle is the key...
}
else
{
if( TheirKey == MyKey )
if ( TheirKey == MyKey )
{
GenKey();
if (( m_Successful = ( m_Player=GetOccupant( 0 ))) != null )
{
SendLocationEffect( lp_Center, 0x1153, 0, 60, 1 );
SendLocationEffect( lp_Center, 0x1153, 0, 60, 1 );
PlaySounds( lp_Center, cs1 );
Effects.SendBoltEffect( m_Player, true );
@ -298,7 +298,7 @@ namespace Server.Engines.Doom
{
for(int i=0; i<16; i++) /* Count matching SET bits, ie correct codes */
{
if( (((MyKey>>i)&1)==1)&&(((TheirKey>>i)&1)==1) )
if ( (((MyKey>>i)&1)==1)&&(((TheirKey>>i)&1)==1) )
{
Correct++;
}
@ -308,7 +308,7 @@ namespace Server.Engines.Doom
for (int i=0; i<5; i++)
{
if(( m_Player=GetOccupant( i )) != null )
if (( m_Player=GetOccupant( i )) != null )
{
Timer smash = new RockTimer( m_Player, this );
smash.Start();
@ -324,7 +324,7 @@ namespace Server.Engines.Doom
UInt16 tmp; int n, i; ushort[] CA = { 1,2,4,8 };
for (i=0; i<4; i++)
{
n=(((n = Utility.Random(0,3))==i) ? n&~i : n ); /* if(i==n) { return pointless; } */
n=(((n = Utility.Random(0,3))==i) ? n&~i : n ); /* if (i==n) { return pointless; } */
tmp = CA[i];
CA[i]=CA[n];
CA[n]=tmp;
@ -338,7 +338,7 @@ namespace Server.Engines.Doom
private Mobile m_Player;
private LeverPuzzleController m_Controller;
public RockTimer( Mobile player, LeverPuzzleController Controller )
public RockTimer( Mobile player, LeverPuzzleController Controller )
: base( TimeSpan.Zero, TimeSpan.FromSeconds( .25 ) )
{
Count = 0;
@ -353,7 +353,7 @@ namespace Server.Engines.Doom
protected override void OnTick()
{
if( m_Player == null || !(m_Player.Map == Map.Malas) )
if ( m_Player == null || !(m_Player.Map == Map.Malas) )
{
Stop();
}
@ -361,7 +361,7 @@ namespace Server.Engines.Doom
{
Count++;
if ( Count == 1 ) /* TODO consolidate */
{
{
m_Player.Paralyze( TimeSpan.FromSeconds(2) );
Effects.SendTargetEffect( m_Player, 0x11B7, 20, 10 );
PlayerSendASCII( m_Player, 0 ); // You are pinned down ...
@ -376,7 +376,7 @@ namespace Server.Engines.Doom
PlaySounds( m_Player.Location, exp );
PlayerSendASCII( m_Player, 1 ); // A speeding rock ...
if( AniSafe( m_Player ))
if ( AniSafe( m_Player ))
{
m_Player.Animate( 21, 10, 1, true, true, 0 );
}
@ -401,12 +401,12 @@ namespace Server.Engines.Doom
}
for( int k=0; k<mobiles.Count; k++ )
{
if( IsValidDamagable( mobiles[k] ) && mobiles[k] != m_Player )
if ( IsValidDamagable( mobiles[k] ) && mobiles[k] != m_Player )
{
PlayEffect( m_Player, mobiles[k], Rock(), 8, true );
DoDamage( mobiles[k], 25, 30, false );
if( mobiles[k].Player )
if ( mobiles[k].Player )
{
POHMessage( mobiles[k], 2 ); // OUCH!
}
@ -423,7 +423,7 @@ namespace Server.Engines.Doom
{
private Mobile m;
public LampRoomKickTimer( Mobile player )
public LampRoomKickTimer( Mobile player )
: base( TimeSpan.FromSeconds( .25 ) )
{
m = player;
@ -440,7 +440,7 @@ namespace Server.Engines.Doom
public int ticks;
public int level;
public LampRoomTimer( LeverPuzzleController controller )
public LampRoomTimer( LeverPuzzleController controller )
: base( TimeSpan.FromSeconds( 5.0 ), TimeSpan.FromSeconds( 5.0 ) )
{
level=0;
@ -457,7 +457,7 @@ namespace Server.Engines.Doom
{
foreach ( Mobile mobile in mobiles )
{
if( mobile != null && !mobile.Deleted && !mobile.IsDeadBondedPet )
if ( mobile != null && !mobile.Deleted && !mobile.IsDeadBondedPet )
{
mobile.Kill();
}
@ -480,7 +480,7 @@ namespace Server.Engines.Doom
if ( mobile.Player )
{
mobile.Say( 1062092 );
if( AniSafe( mobile ))
if ( AniSafe( mobile ))
{
mobile.Animate( 32, 5, 1, true, false, 0 );
}
@ -509,19 +509,10 @@ namespace Server.Engines.Doom
{
if ( m != null && !m.Deleted )
{
if( m.Player && m.Alive )
{
if ( m.Player && m.Alive )
return true;
}
if( m is BaseCreature )
{
BaseCreature bc=(BaseCreature)m;
if ( ( bc.Controlled || bc.Summoned ) && !bc.IsDeadBondedPet )
{
return true;
}
}
return m is BaseCreature bc && (bc.Controlled || bc.Summoned) && !bc.IsDeadBondedPet;
}
return false;
}
@ -530,9 +521,9 @@ namespace Server.Engines.Doom
{
if ( m != null )
{
if( m is PlayerMobile && !m.Alive )
if ( m is PlayerMobile && !m.Alive )
{
if( m.Corpse != null && !m.Corpse.Deleted )
if ( m.Corpse != null && !m.Corpse.Deleted )
{
m.Corpse.MoveToWorld( lr_Exit, Map.Malas );
}
@ -597,7 +588,7 @@ namespace Server.Engines.Doom
}
/* I cant find any better way to send "speech" using fonts other than default */
public static void POHMessage( Mobile from, int index )
public static void POHMessage( Mobile from, int index )
{
Packet p = new AsciiMessage( from.Serial, from.Body, MessageType.Regular, MsgParams[index][0], MsgParams[index][1], from.Name, Msgs[index] );
p.Acquire();
@ -607,7 +598,7 @@ namespace Server.Engines.Doom
Packet.Release( p );
}
public static string[] Msgs =
public static string[] Msgs =
{
"You are pinned down by the weight of the boulder!!!", // 0
"A speeding rock hits you in the head!", // 1
@ -615,7 +606,7 @@ namespace Server.Engines.Doom
};
/* font&hue for above msgs. index matches */
public static int[][] MsgParams =
public static int[][] MsgParams =
{
new int[]{ 0x66d, 3 },
new int[]{ 0x66d, 3 },
@ -623,26 +614,26 @@ namespace Server.Engines.Doom
};
/* World data for items */
public static int[][] TA =
{
public static int[][] TA =
{
new int[]{316, 64, 5}, /* 3D Coords for levers */
new int[]{323, 58, 5},
new int[]{332, 63, 5},
new int[]{323, 58, 5},
new int[]{332, 63, 5},
new int[]{323, 71, 5},
new int[]{324, 64}, /* 2D Coords for standing regions */
new int[]{316, 65},
new int[]{324, 58},
new int[]{332, 64},
new int[]{316, 65},
new int[]{324, 58},
new int[]{332, 64},
new int[]{323, 72},
new int[]{468, 92, -1}, new int[]{0x181D, 0x482}, /* 3D coord, itemid+hue for L.R. teles */
new int[]{469, 92, -1}, new int[]{0x1821, 0x3fd},
new int[]{470, 92, -1}, new int[]{0x1825, 0x66d},
new int[]{469, 92, -1}, new int[]{0x1821, 0x3fd},
new int[]{470, 92, -1}, new int[]{0x1825, 0x66d},
new int[]{319, 70, 18}, new int[]{0x12d8}, /* 3D coord, itemid for statues */
new int[]{329, 60, 18}, new int[]{0x12d9},
new int[]{329, 60, 18}, new int[]{0x12d9},
new int[]{469, 96, 6} /* 3D Coords for Fake Box */
};
@ -666,8 +657,8 @@ namespace Server.Engines.Doom
/* Lamp Room area Poison message data */
public static int[][] PA =
{
public static int[][] PA =
{
new int[]{ 0, 0, 0xA6 },
new int[]{ 1050001, 0x485, 0xAA },
new int[]{ 1050003, 0x485, 0xAC },
@ -675,14 +666,14 @@ namespace Server.Engines.Doom
new int[]{ 1050057, 0x485, 0xA4 },
new int[]{ 1062091, 0x23F3, 0xAC }
};
public static Poison[] PA2 =
public static Poison[] PA2 =
{
Poison.Lesser,
Poison.Regular,
Poison.Greater,
Poison.Deadly,
Poison.Lethal,
Poison.Lethal
Poison.Lesser,
Poison.Regular,
Poison.Greater,
Poison.Deadly,
Poison.Lethal,
Poison.Lethal
};
/* SOUNDS */

View file

@ -41,7 +41,7 @@ namespace Server.Engines.Doom
}
public override void OnAfterDelete()
{
if( m_Controller!=null && !m_Controller.Deleted )
if ( m_Controller!=null && !m_Controller.Deleted )
m_Controller.Delete();
}
public LampRoomBox( Serial serial ) : base( serial )
@ -75,7 +75,7 @@ namespace Server.Engines.Doom
}
public override void OnAfterDelete()
{
if( m_Controller!=null && !m_Controller.Deleted )
if ( m_Controller!=null && !m_Controller.Deleted )
m_Controller.Delete();
}
public LeverPuzzleStatue( Serial serial ) : base( serial )
@ -130,7 +130,7 @@ namespace Server.Engines.Doom
public override void OnAfterDelete()
{
if( m_Controller != null && !m_Controller.Deleted )
if ( m_Controller != null && !m_Controller.Deleted )
m_Controller.Delete();
}
@ -166,7 +166,7 @@ namespace Server.Engines.Doom
public override bool HandlesOnMovement => true;
public override bool OnMoveOver( Mobile m )
{
if( m != null && m is PlayerMobile )
if ( m != null && m is PlayerMobile )
{
if ( SpellHelper.CheckCombat( m ) )
{

View file

@ -49,14 +49,9 @@ namespace Server.Engines.Doom
return;
}
}
else if ( m is BaseCreature )
{
BaseCreature bc = (BaseCreature)m;
if(( bc.Controlled && bc.ControlMaster == Controller.Successful ) || bc.Summoned )
{
return;
}
}
else if (m is BaseCreature bc && ((bc.Controlled && bc.ControlMaster == Controller.Successful) ||
bc.Summoned))
return;
}
Timer kick = new LeverPuzzleController.LampRoomKickTimer( m );
kick.Start();
@ -64,16 +59,16 @@ namespace Server.Engines.Doom
public override void OnExit( Mobile m )
{
if( m != null && m == Controller.Successful )
if ( m != null && m == Controller.Successful )
Controller.RemoveSuccessful();
}
public override void OnDeath( Mobile m )
{
if( m != null && !m.Deleted && !(m is WandererOfTheVoid) )
if ( m != null && !m.Deleted && !(m is WandererOfTheVoid) )
{
Timer kick = new LeverPuzzleController.LampRoomKickTimer( m );
kick.Start();;
kick.Start();
}
}
@ -103,7 +98,7 @@ namespace Server.Engines.Doom
}
}
public LeverPuzzleRegion ( LeverPuzzleController controller, int[] loc )
public LeverPuzzleRegion ( LeverPuzzleController controller, int[] loc )
: base( null, Map.Malas, Region.Find( LeverPuzzleController.lr_Enter, Map.Malas ), new Rectangle2D(loc[0],loc[1],1,1) )
{
Controller = controller;
@ -112,13 +107,13 @@ namespace Server.Engines.Doom
public override void OnEnter( Mobile m )
{
if( m != null && m_Occupant == null && m is PlayerMobile && m.Alive )
if ( m != null && m_Occupant == null && m is PlayerMobile && m.Alive )
m_Occupant = m;
}
public override void OnExit( Mobile m )
{
if( m != null && m == m_Occupant )
if ( m != null && m == m_Occupant )
m_Occupant = null;
}
}

View file

@ -84,7 +84,7 @@ namespace Server.Ethics
public static void Initialize()
{
if( Enabled )
if ( Enabled )
EventSink.Speech += new SpeechEventHandler( EventSink_Speech );
}
@ -134,7 +134,7 @@ namespace Server.Ethics
}
else
{
if ( e.Mobile is PlayerMobile && ( e.Mobile as PlayerMobile ).DuelContext != null )
if ( e.Mobile is PlayerMobile mobile && mobile.DuelContext != null )
return;
Ethic ethic = pl.Ethic;
@ -188,15 +188,13 @@ namespace Server.Ethics
if ( pl != null )
return pl.Ethic;
if ( inherit && mob is BaseCreature )
if ( inherit && mob is BaseCreature bc )
{
BaseCreature bc = (BaseCreature) mob;
if ( bc.Controlled )
return Find( bc.ControlMaster, false );
else if ( bc.Summoned )
if ( bc.Summoned )
return Find( bc.SummonMaster, false );
else if ( allegiance )
if ( allegiance )
return bc.EthicAllegiance;
}
@ -252,4 +250,4 @@ namespace Server.Ethics
Evil
};
}
}
}

View file

@ -23,13 +23,11 @@ namespace Server.Ethics
if ( pm == null )
{
if ( inherit && mob is BaseCreature )
if ( inherit && mob is BaseCreature bc )
{
BaseCreature bc = mob as BaseCreature;
if ( bc != null && bc.Controlled )
if ( bc.Controlled )
pm = bc.ControlMaster as PlayerMobile;
else if ( bc != null && bc.Summoned )
else if ( bc.Summoned )
pm = bc.SummonMaster as PlayerMobile;
}
@ -114,16 +112,16 @@ namespace Server.Ethics
public void Attach()
{
if ( m_Mobile is PlayerMobile )
( m_Mobile as PlayerMobile ).EthicPlayer = this;
if ( m_Mobile is PlayerMobile mobile )
mobile.EthicPlayer = this;
m_Ethic.Players.Add( this );
}
public void Detach()
{
if ( m_Mobile is PlayerMobile )
( m_Mobile as PlayerMobile ).EthicPlayer = null;
if ( m_Mobile is PlayerMobile mobile )
mobile.EthicPlayer = null;
m_Ethic.Players.Remove( this );
}

View file

@ -27,9 +27,7 @@ namespace Server.Ethics.Evil
{
Player from = state as Player;
IPoint3D p = obj as IPoint3D;
if ( p == null )
if ( !(obj is IPoint3D p) )
return;
if ( !CheckInvoke( from ) )

View file

@ -25,11 +25,10 @@ namespace Server.Ethics.Evil
private void Power_OnTarget( Mobile fromMobile, object obj, object state )
{
Player from = state as Player;
if (!(state is Player from))
return;
Item item = obj as Item;
if ( item == null )
if ( !(obj is Item item) )
{
from.Mobile.LocalOverheadMessage( Server.Network.MessageType.Regular, 0x3B2, false, "You may not imbue that." );
return;

View file

@ -25,11 +25,10 @@ namespace Server.Ethics.Hero
private void Power_OnTarget( Mobile fromMobile, object obj, object state )
{
Player from = state as Player;
if (!(state is Player from))
return;
IPoint3D p = obj as IPoint3D;
if ( p == null )
if ( !(obj is IPoint3D p) )
return;
if ( !CheckInvoke( from ) )

View file

@ -25,11 +25,10 @@ namespace Server.Ethics.Hero
private void Power_OnTarget( Mobile fromMobile, object obj, object state )
{
Player from = state as Player;
if (!(state is Player from))
return;
Item item = obj as Item;
if ( item == null )
if ( !(obj is Item item) )
{
from.Mobile.LocalOverheadMessage( Server.Network.MessageType.Regular, 0x3B2, false, "You may not imbue that." );
return;

View file

@ -409,8 +409,8 @@ namespace Server.Factions
{
TimeSpan gameTime = TimeSpan.Zero;
if ( m_From is PlayerMobile )
gameTime = ((PlayerMobile)m_From).GameTime;
if ( m_From is PlayerMobile mobile )
gameTime = mobile.GameTime;
int kp = 0;

View file

@ -198,10 +198,8 @@ namespace Server.Factions
public void HonorLeadership_OnTarget( Mobile from, object obj )
{
if ( obj is Mobile )
if ( obj is Mobile recv )
{
Mobile recv = (Mobile) obj;
PlayerState giveState = PlayerState.Find( from );
PlayerState recvState = PlayerState.Find( recv );
@ -353,7 +351,7 @@ namespace Server.Factions
int killPoints = pl.KillPoints;
if( mob.Backpack != null )
if ( mob.Backpack != null )
{
//Ordinarily, through normal faction removal, this will never find any sigils.
//Only with a leave delay less than the ReturnPeriod or a Faction Kick/Ban, will this ever do anything
@ -377,8 +375,8 @@ namespace Server.Factions
Members.Remove( pl );
if ( mob is PlayerMobile )
((PlayerMobile)mob).FactionPlayerState = null;
if ( mob is PlayerMobile mobile )
mobile.FactionPlayerState = null;
mob.InvalidateProperties();
mob.Delta( MobileDelta.Noto );
@ -397,8 +395,8 @@ namespace Server.Factions
if ( Commander == mob )
Commander = null;
if ( mob is PlayerMobile )
((PlayerMobile)mob).ValidateEquipment();
if ( mob is PlayerMobile playerMobile )
playerMobile.ValidateEquipment();
if ( killPoints > 0 )
DistributePoints( killPoints );
@ -436,9 +434,7 @@ namespace Server.Factions
private bool AlreadyHasCharInFaction( Mobile mob )
{
Account acct = mob.Account as Account;
if ( acct != null )
if ( mob.Account is Account acct )
{
for ( int i = 0; i < acct.Length; ++i )
{
@ -454,9 +450,7 @@ namespace Server.Factions
public static bool IsFactionBanned( Mobile mob )
{
Account acct = mob.Account as Account;
if ( acct == null )
if ( !(mob.Account is Account acct) )
return false;
return ( acct.GetTag( "FactionBanned" ) != null );
@ -464,9 +458,7 @@ namespace Server.Factions
public void OnJoinAccepted( Mobile mob )
{
PlayerMobile pm = mob as PlayerMobile;
if ( pm == null )
if ( !(mob is PlayerMobile pm) )
return; // sanity
PlayerState pl = PlayerState.Find( pm );
@ -483,7 +475,7 @@ namespace Server.Factions
{
Guild guild = pm.Guild as Guild;
if ( guild.Leader != pm )
if ( guild?.Leader != pm )
pm.SendLocalizedMessage( 1005057 ); // You cannot join a faction because you are in a guild and not the guildmaster
else if ( guild.Type != GuildType.Regular )
pm.SendLocalizedMessage( 1042161 ); // You cannot join a faction because your guild is an Order or Chaos type.
@ -499,9 +491,7 @@ namespace Server.Factions
for ( int i = 0; i < members.Count; ++i )
{
PlayerMobile member = members[i] as PlayerMobile;
if ( member == null )
if ( !(members[i] is PlayerMobile member) )
continue;
JoinGuilded( member, guild );
@ -745,9 +735,9 @@ namespace Server.Factions
public static void FactionCommander_OnTarget( Mobile from, object obj )
{
if ( obj is PlayerMobile )
if ( obj is PlayerMobile mobile )
{
Mobile targ = (Mobile)obj;
Mobile targ = mobile;
PlayerState pl = PlayerState.Find( targ );
if ( pl != null )
@ -774,9 +764,9 @@ namespace Server.Factions
public static void FactionElection_OnTarget( Mobile from, object obj )
{
if ( obj is FactionStone )
if ( obj is FactionStone stone )
{
Faction faction = ((FactionStone)obj).Faction;
Faction faction = stone.Faction;
if ( faction != null )
from.SendGump( new ElectionManagementGump( faction.Election ) );
@ -798,10 +788,9 @@ namespace Server.Factions
public static void FactionKick_OnTarget( Mobile from, object obj )
{
if ( obj is Mobile )
if ( obj is Mobile mob )
{
Mobile mob = (Mobile) obj;
PlayerState pl = PlayerState.Find( (Mobile) mob );
PlayerState pl = PlayerState.Find( mob );
if ( pl != null )
{
@ -1004,7 +993,7 @@ namespace Server.Factions
public bool CanHandleInflux( int influx )
{
if( !StabilityActive())
if ( !StabilityActive())
return true;
Faction smallest = FindSmallestFaction();
@ -1063,9 +1052,8 @@ namespace Server.Factions
if ( killerState == null )
return;
if ( victim is BaseCreature )
if ( victim is BaseCreature bc )
{
BaseCreature bc = (BaseCreature)victim;
Faction victimFaction = bc.FactionAllegiance;
if ( bc.Map == Faction.Facet && victimFaction != null && killerState.Faction != victimFaction )
@ -1261,17 +1249,15 @@ namespace Server.Factions
if ( pl != null )
return pl.Faction;
if ( inherit && mob is BaseCreature )
if ( inherit && mob is BaseCreature bc )
{
BaseCreature bc = (BaseCreature)mob;
if ( bc.Controlled )
return Find( bc.ControlMaster, false );
else if ( bc.Summoned )
if ( bc.Summoned )
return Find( bc.SummonMaster, false );
else if ( creatureAllegiances && mob is BaseFactionGuard )
return ((BaseFactionGuard)mob).Faction;
else if ( creatureAllegiances )
if ( creatureAllegiances && bc is BaseFactionGuard guard )
return guard.Faction;
if ( creatureAllegiances )
return bc.FactionAllegiance;
}
@ -1364,9 +1350,7 @@ namespace Server.Factions
}
case FactionKickType.Ban:
{
Account acct = mob.Account as Account;
if ( acct != null )
if ( mob.Account is Account acct )
{
if ( acct.GetTag( "FactionBanned" ) == null )
{
@ -1404,9 +1388,7 @@ namespace Server.Factions
}
case FactionKickType.Unban:
{
Account acct = mob.Account as Account;
if ( acct != null )
if ( mob.Account is Account acct )
{
if ( acct.GetTag( "FactionBanned" ) == null )
{

View file

@ -45,17 +45,16 @@ namespace Server.Factions
public void Attach()
{
if ( m_Item is IFactionItem )
((IFactionItem)m_Item).FactionItemState = this;
if ( m_Item is IFactionItem item )
item.FactionItemState = this;
if ( m_Faction != null )
m_Faction.State.FactionItems.Add( this );
m_Faction?.State.FactionItems.Add( this );
}
public void Detach()
{
if ( m_Item is IFactionItem )
((IFactionItem)m_Item).FactionItemState = null;
if ( m_Item is IFactionItem item )
item.FactionItemState = null;
if ( m_Faction != null && m_Faction.State.FactionItems.Contains( this ) )
m_Faction.State.FactionItems.Remove( this );
@ -107,11 +106,11 @@ namespace Server.Factions
public static FactionItem Find( Item item )
{
if ( item is IFactionItem )
if ( item is IFactionItem factionItem )
{
FactionItem state = ((IFactionItem)item).FactionItemState;
FactionItem state = factionItem.FactionItemState;
if ( state != null && state.HasExpired )
if ( state?.HasExpired == true )
{
state.Detach();
state = null;
@ -143,4 +142,4 @@ namespace Server.Factions
return item;
}
}
}
}

View file

@ -51,7 +51,7 @@ namespace Server.Factions
for ( int i = 0; i < members.Count; ++i )
{
PlayerState ps = members[i];
if ( ps.IsActive )
{
ps.IsActive = false;
@ -219,7 +219,7 @@ namespace Server.Factions
}
m_Faction.State = this;
m_Faction.ZeroRankOffset = m_Members.Count;
m_Members.Sort();
@ -254,9 +254,7 @@ namespace Server.Factions
for ( int i = 0; i < factionTrapCount; ++i )
{
BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap;
if ( trap != null && !trap.CheckDecay() )
if ( reader.ReadItem() is BaseFactionTrap trap && !trap.CheckDecay() )
m_FactionTraps.Add( trap );
}
}
@ -309,4 +307,4 @@ namespace Server.Factions
writer.Write( (Item) m_FactionTraps[i] );
}
}
}
}

View file

@ -40,8 +40,8 @@ namespace Server.Factions
if ( FactionGump.Exists( from ) )
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
else if ( town.Owner != null && from is PlayerMobile )
from.SendGump( new FinanceGump( (PlayerMobile)from, town.Owner, town ) );
else if ( town.Owner != null && from is PlayerMobile mobile )
mobile.SendGump( new FinanceGump( mobile, town.Owner, town ) );
break;
}
@ -75,7 +75,7 @@ namespace Server.Factions
{
PlayerState pl = PlayerState.Find( from );
if ( pl != null && pl.Finance != null )
if ( pl?.Finance != null )
{
pl.Finance.Finance = null;
from.SendLocalizedMessage( 1005081 ); // You have been fired as Finance Minister
@ -87,7 +87,7 @@ namespace Server.Factions
{
PlayerState pl = PlayerState.Find( from );
if ( pl != null && pl.Sheriff != null )
if ( pl?.Sheriff != null )
{
pl.Sheriff.Sheriff = null;
from.SendLocalizedMessage( 1010270 ); // You have been fired as Sheriff
@ -99,16 +99,16 @@ namespace Server.Factions
{
PlayerState pl = PlayerState.Find( from );
if ( pl != null && pl.IsLeaving )
if ( pl?.IsLeaving == true )
{
if ( Faction.CheckLeaveTimer( from ) )
break;
TimeSpan remaining = ( pl.Leaving + Faction.LeavePeriod ) - DateTime.UtcNow;
if( remaining.TotalDays >= 1 )
if ( remaining.TotalDays >= 1 )
from.SendLocalizedMessage( 1042743, remaining.TotalDays.ToString( "N0" ) ) ;// Your term of service will come to an end in ~1_DAYS~ days.
else if( remaining.TotalHours >= 1 )
else if ( remaining.TotalHours >= 1 )
from.SendLocalizedMessage( 1042741, remaining.TotalHours.ToString( "N0" ) ); // Your term of service will come to an end in ~1_HOURS~ hours.
else
from.SendLocalizedMessage( 1042742 ); // Your term of service will come to an end in less than one hour.
@ -156,4 +156,4 @@ namespace Server.Factions
}
}
}
}
}

View file

@ -169,9 +169,8 @@ namespace Server.Factions
public void Invalidate()
{
if ( m_Mobile is PlayerMobile )
if ( m_Mobile is PlayerMobile pm )
{
PlayerMobile pm = (PlayerMobile)m_Mobile;
pm.InvalidateProperties();
pm.InvalidateMyRunUO();
}
@ -179,8 +178,8 @@ namespace Server.Factions
public void Attach()
{
if ( m_Mobile is PlayerMobile )
((PlayerMobile)m_Mobile).FactionPlayerState = this;
if ( m_Mobile is PlayerMobile mobile )
mobile.FactionPlayerState = this;
}
public PlayerState( Mobile mob, Faction faction, List<PlayerState> owner )
@ -241,10 +240,7 @@ namespace Server.Factions
public static PlayerState Find( Mobile mob )
{
if ( mob is PlayerMobile )
return ((PlayerMobile)mob).FactionPlayerState;
return null;
return mob is PlayerMobile mobile ? mobile.FactionPlayerState : null;
}
public int CompareTo( object obj )

View file

@ -59,20 +59,16 @@ namespace Server.Factions
if ( type.IsSubclassOf( typeof( Faction ) ) )
{
Faction faction = Construct( type ) as Faction;
if ( faction != null )
if ( Construct( type ) is Faction faction )
Faction.Factions.Add( faction );
}
else if ( type.IsSubclassOf( typeof( Town ) ) )
{
Town town = Construct( type ) as Town;
if ( town != null )
if ( Construct( type ) is Town town )
Town.Towns.Add( town );
}
}
}
}
}
}
}

View file

@ -30,14 +30,10 @@ namespace Server.Factions
if ( m.AccessLevel >= AccessLevel.Counselor || Contains( oldLocation ) )
return true;
if ( m is PlayerMobile ) {
PlayerMobile pm = (PlayerMobile)m;
if ( pm.DuelContext != null ) {
m.SendMessage( "You may not enter this area while participating in a duel or a tournament." );
return false;
}
if ( m is PlayerMobile pm && pm.DuelContext != null) {
pm.SendMessage( "You may not enter this area while participating in a duel or a tournament." );
return false;
}
return ( Faction.Find( m, true, true ) != null );
@ -48,4 +44,4 @@ namespace Server.Factions
return false;
}
}
}
}

View file

@ -134,13 +134,8 @@ namespace Server.Factions
foreach ( BaseMonolith monolith in monoliths )
{
if ( monolith is TownMonolith )
{
TownMonolith townMonolith = (TownMonolith)monolith;
if ( townMonolith.Town == this )
return townMonolith;
}
if ( monolith is TownMonolith townMonolith && townMonolith.Town == this )
return townMonolith;
}
return null;
@ -184,20 +179,10 @@ namespace Server.Factions
else if ( isSheriff )
type = "guard";
if ( obj is BaseFactionVendor )
{
BaseFactionVendor vendor = (BaseFactionVendor)obj;
if ( vendor.Town == this && isFinance )
vendor.Delete();
}
else if ( obj is BaseFactionGuard )
{
BaseFactionGuard guard = (BaseFactionGuard)obj;
if ( guard.Town == this && isSheriff )
guard.Delete();
}
if ( obj is BaseFactionVendor vendor && vendor.Town == this && isFinance )
vendor.Delete();
else if ( obj is BaseFactionGuard guard && guard.Town == this && isSheriff )
guard.Delete();
else
{
from.SendMessage( "That is not a {0}!", type );
@ -208,16 +193,14 @@ namespace Server.Factions
public void StartIncomeTimer()
{
if ( m_IncomeTimer != null )
m_IncomeTimer.Stop();
m_IncomeTimer?.Stop();
m_IncomeTimer = Timer.DelayCall( TimeSpan.FromMinutes( 1.0 ), TimeSpan.FromMinutes( 1.0 ), new TimerCallback( CheckIncome ) );
}
public void StopIncomeTimer()
{
if ( m_IncomeTimer != null )
m_IncomeTimer.Stop();
m_IncomeTimer?.Stop();
m_IncomeTimer = null;
}

View file

@ -28,9 +28,9 @@ namespace Server.Factions
public static FactionItemDefinition Identify( Item item )
{
if ( item is BaseArmor )
if ( item is BaseArmor armor )
{
if ( CraftResources.GetType( ((BaseArmor)item).Resource ) == CraftResourceType.Leather )
if ( CraftResources.GetType( armor.Resource ) == CraftResourceType.Leather )
return m_LeatherArmor;
return m_MetalArmor;
@ -38,14 +38,14 @@ namespace Server.Factions
if ( item is BaseRanged )
return m_RangedWeapon;
else if ( item is BaseWeapon )
if ( item is BaseWeapon )
return m_Weapon;
else if ( item is BaseClothing )
if ( item is BaseClothing )
return m_Clothing;
else if ( item is SpellScroll )
if ( item is SpellScroll )
return m_Scroll;
return null;
}
}
}
}

View file

@ -154,9 +154,9 @@ namespace Server.Factions
{
object obj = fields[j];
if ( obj is Mobile )
if ( obj is Mobile mobile )
{
AddHtml( x + 2, 140 + (idx * 20), 150, 20, Color( ((Mobile)obj).Name, LabelColor ), false, false );
AddHtml( x + 2, 140 + (idx * 20), 150, 20, Color( mobile.Name, LabelColor ), false, false );
x += 150;
}
else if ( obj is System.Net.IPAddress )
@ -164,14 +164,14 @@ namespace Server.Factions
AddHtml( x, 140 + (idx * 20), 100, 20, Color( Center( obj.ToString() ), LabelColor ), false, false );
x += 100;
}
else if ( obj is DateTime )
else if ( obj is DateTime time )
{
AddHtml( x, 140 + (idx * 20), 80, 20, Color( Center( FormatTimeSpan( ((DateTime)obj) - election.LastStateTime ) ), LabelColor ), false, false );
AddHtml( x, 140 + (idx * 20), 80, 20, Color( Center( FormatTimeSpan( time - election.LastStateTime ) ), LabelColor ), false, false );
x += 80;
}
else if ( obj is int )
else if ( obj is int i1 )
{
AddHtml( x, 140 + (idx * 20), 60, 20, Color( Center( (int)obj + "%" ), LabelColor ), false, false );
AddHtml( x, 140 + (idx * 20), 60, 20, Color( Center( i1 + "%" ), LabelColor ), false, false );
x += 60;
}
}
@ -215,4 +215,4 @@ namespace Server.Factions
}
}
}
}
}

View file

@ -20,8 +20,8 @@ namespace Server.Factions
private FactionItemDefinition m_Definition;
public FactionImbueGump( int quality, Item item, Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, int availableSilver, Faction faction, FactionItemDefinition def ) : base( 100, 200 )
{
public FactionImbueGump( int quality, Item item, Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, int availableSilver, Faction faction, FactionItemDefinition def ) : base( 100, 200 )
{
m_Item = item;
m_Mobile = from;
m_Faction = faction;
@ -39,13 +39,13 @@ namespace Server.Factions
AddHtmlLocalized( 20, 20, 210, 25, 1011569, false, false ); // Imbue with Faction properties?
AddHtmlLocalized( 20, 60, 170, 25, 1018302, false, false ); // Item quality:
AddHtmlLocalized( 20, 60, 170, 25, 1018302, false, false ); // Item quality:
AddHtmlLocalized( 175, 60, 100, 25, 1018305 - m_Quality, false, false ); // Exceptional, Average, Low
AddHtmlLocalized( 20, 80, 170, 25, 1011572, false, false ); // Item Cost :
AddHtmlLocalized( 20, 80, 170, 25, 1011572, false, false ); // Item Cost :
AddLabel( 175, 80, 0x34, def.SilverCost.ToString( "N0" ) ); // NOTE: Added 'N0'
AddHtmlLocalized( 20, 100, 170, 25, 1011573, false, false ); // Your Silver :
AddHtmlLocalized( 20, 100, 170, 25, 1011573, false, false ); // Your Silver :
AddLabel( 175, 100, 0x34, availableSilver.ToString( "N0" ) ); // NOTE: Added 'N0'
@ -95,10 +95,10 @@ namespace Server.Factions
if ( m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 0 )
m_Mobile.SendGump( new CraftGump( m_Mobile, m_CraftSystem, m_Tool, m_Notice ) );
else if ( m_Notice is string )
m_Mobile.SendMessage( (string) m_Notice );
else if ( m_Notice is int && ((int)m_Notice) > 0 )
m_Mobile.SendLocalizedMessage( (int) m_Notice );
else if ( m_Notice is string s )
m_Mobile.SendMessage( s );
else if ( m_Notice is int i && i > 0 )
m_Mobile.SendLocalizedMessage( i );
}
}
}
}

View file

@ -20,7 +20,7 @@ namespace Server.Factions
AddBackground( 0, 0, 270, 120, 5054 );
AddBackground( 10, 10, 250, 100, 3000 );
if ( from.Guild is Guild && ((Guild)from.Guild).Leader == from )
if ( from.Guild is Guild guild && guild.Leader == from )
AddHtmlLocalized( 20, 15, 230, 60, 1018057, true, true ); // Are you sure you want your entire guild to leave this faction?
else
AddHtmlLocalized( 20, 15, 230, 60, 1018063, true, true ); // Are you sure you want to leave this faction?
@ -38,9 +38,7 @@ namespace Server.Factions
{
case 1: // continue
{
Guild guild = m_From.Guild as Guild;
if ( guild == null )
if ( !(m_From.Guild is Guild guild) )
{
PlayerState pl = PlayerState.Find( m_From );
@ -89,4 +87,4 @@ namespace Server.Factions
}
}
}
}
}

View file

@ -124,9 +124,8 @@ namespace Server.Factions
{
from.SendLocalizedMessage( 1010342 ); // You must fire your Sheriff before you can elect a new one
}
else if ( obj is Mobile )
else if ( obj is Mobile targ )
{
Mobile targ = (Mobile)obj;
PlayerState pl = PlayerState.Find( targ );
if ( pl == null )
@ -163,15 +162,13 @@ namespace Server.Factions
if ( m_Town.Owner != m_Faction || !m_Faction.IsCommander( from ) )
{
from.SendLocalizedMessage( 1010339 ); // You no longer control this city
return;
}
else if ( m_Town.Finance != null )
{
from.SendLocalizedMessage( 1010342 ); // You must fire your Sheriff before you can elect a new one
}
else if ( obj is Mobile )
else if ( obj is Mobile targ )
{
Mobile targ = (Mobile)obj;
PlayerState pl = PlayerState.Find( targ );
if ( pl == null )
@ -203,4 +200,4 @@ namespace Server.Factions
}
}
}
}
}

View file

@ -48,27 +48,27 @@ namespace Server.Factions
{
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
}
else if ( from is PlayerMobile )
else if ( from is PlayerMobile mobile )
{
Faction existingFaction = Faction.Find( from );
Faction existingFaction = Faction.Find( mobile );
if ( existingFaction == m_Faction || from.AccessLevel >= AccessLevel.GameMaster )
if ( existingFaction == m_Faction || mobile.AccessLevel >= AccessLevel.GameMaster )
{
PlayerState pl = PlayerState.Find( from );
PlayerState pl = PlayerState.Find( mobile );
if ( pl != null && pl.IsLeaving )
from.SendLocalizedMessage( 1005051 ); // You cannot use the faction stone until you have finished quitting your current faction
mobile.SendLocalizedMessage( 1005051 ); // You cannot use the faction stone until you have finished quitting your current faction
else
from.SendGump( new FactionStoneGump( (PlayerMobile) from, m_Faction ) );
mobile.SendGump( new FactionStoneGump( mobile, m_Faction ) );
}
else if ( existingFaction != null )
{
// TODO: Validate
from.SendLocalizedMessage( 1005053 ); // This is not your faction stone!
mobile.SendLocalizedMessage( 1005053 ); // This is not your faction stone!
}
else
{
from.SendGump( new JoinStoneGump( (PlayerMobile) from, m_Faction ) );
mobile.SendGump( new JoinStoneGump( mobile, m_Faction ) );
}
}
}

Some files were not shown because too many files have changed in this diff Show more