Changes properties to use automatic property initializers

This commit is contained in:
Kamron Batman 2018-09-14 15:23:29 -07:00
parent f0a48ad431
commit 06fa31a7bf
623 changed files with 13072 additions and 19304 deletions

View file

@ -15,7 +15,6 @@ namespace Server.Engines.ConPVP
public override string DefaultName => "da bomb";
private BRGame m_Game;
private Mobile m_Thrower;
private EffectTimer m_Timer;
private bool m_Flying;
@ -287,7 +286,7 @@ namespace Server.Engines.ConPVP
m_Flying = true;
Visible = false;
m_Thrower = from;
Thrower = from;
MoveToWorld( GetWorldLocation(), from.Map );
BeginFlight( pt );
@ -348,7 +347,7 @@ namespace Server.Engines.ConPVP
string verb = "caught";
if ( m_Thrower != null && m_Game.GetTeamInfo( m_Thrower ) != useTeam )
if ( Thrower != null && m_Game.GetTeamInfo( Thrower ) != useTeam )
verb = "intercepted";
if ( !TakeBomb( m, useTeam, verb ) )
@ -607,7 +606,7 @@ namespace Server.Engines.ConPVP
if ( i is BRGoal goal )
{
Point3D oldLoc = new Point3D( GetWorldLocation() );
if ( CheckScore( goal, m_Thrower, 3 ) )
if ( CheckScore( goal, Thrower, 3 ) )
DoAnim( oldLoc, point, Map );
else
HitObject( point, loc.Z, height );
@ -626,7 +625,7 @@ namespace Server.Engines.ConPVP
{
Mobile m = ns.Mobile;
if ( m == null || m == m_Thrower )
if ( m == null || m == Thrower )
continue;
Point3D point;
@ -705,7 +704,7 @@ namespace Server.Engines.ConPVP
}
}
public Mobile Thrower => m_Thrower;
public Mobile Thrower { get; private set; }
public bool CheckScore( BRGoal goal, Mobile m, int points )
{
@ -1165,14 +1164,12 @@ namespace Server.Engines.ConPVP
{
private BRTeamInfo m_TeamInfo;
private Mobile m_Player;
private int m_Kills;
private int m_Captures;
private int m_Score;
public Mobile Player => m_Player;
public Mobile Player { get; }
public int CompareTo( object obj )
{
@ -1188,7 +1185,7 @@ namespace Server.Engines.ConPVP
return res;
}
public string Name => m_Player.Name;
public string Name => Player.Name;
public int Kills
{
@ -1226,29 +1223,15 @@ namespace Server.Engines.ConPVP
public BRPlayerInfo( BRTeamInfo teamInfo, Mobile player )
{
m_TeamInfo = teamInfo;
m_Player = player;
Player = player;
}
}
[PropertyObject]
public sealed class BRTeamInfo : IRankedCTF, IComparable
{
private BRGame m_Game;
private int m_TeamID;
private int m_Color;
private string m_Name;
private BRBoard m_Board;
private BRGoal m_Goal;
private int m_Kills;
private int m_Captures;
private int m_Score;
private Hashtable m_Players;
public int CompareTo( object obj )
{
BRTeamInfo ti = (BRTeamInfo)obj;
@ -1263,40 +1246,24 @@ namespace Server.Engines.ConPVP
return res;
}
public string Name => $"{m_Name} Team";
public string Name => $"{TeamName} Team";
public BRGame Game { get => m_Game;
set => m_Game = value;
}
public int TeamID => m_TeamID;
public BRGame Game { get; set; }
public int Kills { get => m_Kills;
set => m_Kills = value;
}
public int Captures { get => m_Captures;
set => m_Captures = value;
}
public int TeamID { get; }
public int Score { get => m_Score;
set => m_Score = value;
}
public int Kills { get; set; }
private BRPlayerInfo m_Leader;
public int Captures { get; set; }
public BRPlayerInfo Leader
{
get => m_Leader;
set => m_Leader = value;
}
public int Score { get; set; }
public BRPlayerInfo Leader { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public BRBoard Board
{
get => m_Board;
set => m_Board = value;
}
public BRBoard Board { get; set; }
public Hashtable Players => m_Players;
public Hashtable Players { get; }
public BRPlayerInfo this[Mobile mob]
{
@ -1305,26 +1272,18 @@ namespace Server.Engines.ConPVP
if ( mob == null )
return null;
if ( !(m_Players[mob] is BRPlayerInfo val) )
m_Players[mob] = val = new BRPlayerInfo( this, mob );
if ( !(Players[mob] is BRPlayerInfo val) )
Players[mob] = val = new BRPlayerInfo( this, mob );
return val;
}
}
[CommandProperty( AccessLevel.GameMaster )]
public int Color
{
get => m_Color;
set => m_Color = value;
}
public int Color { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public string TeamName
{
get => m_Name;
set => m_Name = value;
}
public string TeamName { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public BRGoal Goal
@ -1340,30 +1299,30 @@ namespace Server.Engines.ConPVP
public BRTeamInfo( int teamID )
{
m_TeamID = teamID;
m_Players = new Hashtable();
TeamID = teamID;
Players = new Hashtable();
}
public void Reset()
{
m_Kills = 0;
m_Captures = 0;
m_Score = 0;
Kills = 0;
Captures = 0;
Score = 0;
m_Leader = null;
Leader = null;
m_Players.Clear();
Players.Clear();
if ( m_Board != null )
m_Board.m_TeamInfo = this;
if ( Board != null )
Board.m_TeamInfo = this;
if ( m_Goal != null )
m_Goal.Team = this;
}
public BRTeamInfo( int teamID, GenericReader ip )
{
m_TeamID = teamID;
m_Players = new Hashtable();
TeamID = teamID;
Players = new Hashtable();
int version = ip.ReadEncodedInt();
@ -1371,9 +1330,9 @@ namespace Server.Engines.ConPVP
{
case 0:
{
m_Board = ip.ReadItem() as BRBoard;
m_Name = ip.ReadString();
m_Color = ip.ReadEncodedInt();
Board = ip.ReadItem() as BRBoard;
TeamName = ip.ReadString();
Color = ip.ReadEncodedInt();
m_Goal = ip.ReadItem() as BRGoal;
break;
}
@ -1384,18 +1343,18 @@ namespace Server.Engines.ConPVP
{
op.WriteEncodedInt( 0 ); // version
op.Write( m_Board );
op.Write( Board );
op.Write( m_Name );
op.Write( TeamName );
op.WriteEncodedInt( m_Color );
op.WriteEncodedInt( Color );
op.Write( m_Goal );
}
public override string ToString()
{
if ( m_Name != null )
if ( TeamName != null )
return $"({Name}) ...";
return "...";
}
@ -1403,48 +1362,36 @@ namespace Server.Engines.ConPVP
public sealed class BRController : EventController
{
private BRTeamInfo[] m_TeamInfo;
private TimeSpan m_Duration;
private Point3D m_BombHome;
public BRTeamInfo[] TeamInfo => m_TeamInfo;
public BRTeamInfo[] TeamInfo { get; private set; }
[CommandProperty( AccessLevel.GameMaster )]
public BRTeamInfo Team1 { get => m_TeamInfo[0];
public BRTeamInfo Team1 { get => TeamInfo[0];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public BRTeamInfo Team2 { get => m_TeamInfo[1];
public BRTeamInfo Team2 { get => TeamInfo[1];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public BRTeamInfo Team3 { get => m_TeamInfo[2];
public BRTeamInfo Team3 { get => TeamInfo[2];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public BRTeamInfo Team4 { get => m_TeamInfo[3];
public BRTeamInfo Team4 { get => TeamInfo[3];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public TimeSpan Duration
{
get => m_Duration;
set => m_Duration = value;
}
public TimeSpan Duration { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public Point3D BombHome
{
get => m_BombHome;
set => m_BombHome = value;
}
public Point3D BombHome { get; set; }
public override string Title => "Bombing Run";
public override string DefaultName => "Bombing Run Controller";
public override string GetTeamName( int teamID )
{
return m_TeamInfo[teamID % m_TeamInfo.Length].Name;
return TeamInfo[teamID % TeamInfo.Length].Name;
}
public override EventGame Construct( DuelContext context )
@ -1458,14 +1405,14 @@ namespace Server.Engines.ConPVP
Visible = false;
Movable = false;
m_Duration = TimeSpan.FromMinutes( 30.0 );
Duration = TimeSpan.FromMinutes( 30.0 );
m_BombHome = Point3D.Zero;
BombHome = Point3D.Zero;
m_TeamInfo = new BRTeamInfo[4];
TeamInfo = new BRTeamInfo[4];
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i] = new BRTeamInfo( i );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i] = new BRTeamInfo( i );
}
public BRController( Serial serial )
@ -1479,14 +1426,14 @@ namespace Server.Engines.ConPVP
writer.Write( (int) 0 );
writer.Write( m_BombHome );
writer.Write( BombHome );
writer.Write( m_Duration );
writer.Write( Duration );
writer.WriteEncodedInt( m_TeamInfo.Length );
writer.WriteEncodedInt( TeamInfo.Length );
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i].Serialize( writer );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i].Serialize( writer );
}
public override void Deserialize( GenericReader reader )
@ -1499,14 +1446,14 @@ namespace Server.Engines.ConPVP
{
case 0:
{
m_BombHome = reader.ReadPoint3D();
BombHome = reader.ReadPoint3D();
m_Duration = reader.ReadTimeSpan();
Duration = reader.ReadTimeSpan();
m_TeamInfo = new BRTeamInfo[reader.ReadEncodedInt()];
TeamInfo = new BRTeamInfo[reader.ReadEncodedInt()];
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i] = new BRTeamInfo( i, reader );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i] = new BRTeamInfo( i, reader );
break;
}
@ -1535,12 +1482,12 @@ namespace Server.Engines.ConPVP
public void ReturnBomb()
{
if ( m_Bomb != null && m_Controller != null )
if ( m_Bomb != null && Controller != null )
{
if ( m_UnhideCallback == null )
m_UnhideCallback = UnhideBomb;
m_Bomb.Visible = false;
m_Bomb.MoveToWorld( m_Controller.BombHome, m_Controller.Map );
m_Bomb.MoveToWorld( Controller.BombHome, Controller.Map );
Timer.DelayCall( TimeSpan.FromSeconds( Utility.RandomMinMax( 5, 15 ) ), m_UnhideCallback );
}
}
@ -1554,9 +1501,7 @@ namespace Server.Engines.ConPVP
}
}
private BRController m_Controller;
public BRController Controller => m_Controller;
public BRController Controller { get; }
public void Alert( string text )
{
@ -1581,7 +1526,7 @@ namespace Server.Engines.ConPVP
public BRGame( BRController controller, DuelContext context ) : base( context )
{
m_Controller = controller;
Controller = controller;
}
public Map Facet
@ -1591,7 +1536,7 @@ namespace Server.Engines.ConPVP
if ( m_Context.Arena != null )
return m_Context.Arena.Facet;
return m_Controller.Map;
return Controller.Map;
}
}
@ -1600,7 +1545,7 @@ namespace Server.Engines.ConPVP
int teamID = GetTeamID( mob );
if ( teamID >= 0 )
return m_Controller.TeamInfo[teamID % m_Controller.TeamInfo.Length];
return Controller.TeamInfo[teamID % Controller.TeamInfo.Length];
return null;
}
@ -1718,23 +1663,23 @@ namespace Server.Engines.ConPVP
public override void OnStart()
{
for ( int i = 0; i < m_Controller.TeamInfo.Length; ++i )
for ( int i = 0; i < Controller.TeamInfo.Length; ++i )
{
BRTeamInfo teamInfo = m_Controller.TeamInfo[i];
BRTeamInfo teamInfo = Controller.TeamInfo[i];
teamInfo.Game = this;
teamInfo.Reset();
}
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 );
ApplyHues( m_Context.Participants[i] as Participant, Controller.TeamInfo[i % Controller.TeamInfo.Length].Color );
m_FinishTimer?.Stop();
m_Bomb = new BRBomb( this );
ReturnBomb();
m_FinishTimer = Timer.DelayCall( m_Controller.Duration, Finish_Callback );
m_FinishTimer = Timer.DelayCall( Controller.Duration, Finish_Callback );
}
private void Finish_Callback()
@ -1743,7 +1688,7 @@ namespace Server.Engines.ConPVP
for ( int i = 0; i < m_Context.Participants.Count; ++i )
{
BRTeamInfo teamInfo = m_Controller.TeamInfo[i % m_Controller.TeamInfo.Length];
BRTeamInfo teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length];
if ( teamInfo == null )
continue;
@ -1787,8 +1732,8 @@ namespace Server.Engines.ConPVP
}
}
if ( m_Controller != null )
sb.Append( ' ' ).Append( m_Controller.Title );
if ( Controller != null )
sb.Append( ' ' ).Append( Controller.Title );
string title = sb.ToString();
@ -1899,9 +1844,9 @@ namespace Server.Engines.ConPVP
public override void OnStop()
{
for ( int i = 0; i < m_Controller.TeamInfo.Length; ++i )
for ( int i = 0; i < Controller.TeamInfo.Length; ++i )
{
BRTeamInfo teamInfo = m_Controller.TeamInfo[i];
BRTeamInfo teamInfo = Controller.TeamInfo[i];
if ( teamInfo.Board != null )
teamInfo.Board.m_TeamInfo = null;

View file

@ -528,16 +528,14 @@ namespace Server.Engines.ConPVP
{
private CTFTeamInfo m_TeamInfo;
private Mobile m_Player;
private int m_Kills;
private int m_Captures;
private int m_Score;
public Mobile Player => m_Player;
public Mobile Player { get; }
string IRankedCTF.Name => m_Player.Name;
string IRankedCTF.Name => Player.Name;
public int Kills
{
@ -575,65 +573,31 @@ namespace Server.Engines.ConPVP
public CTFPlayerInfo( CTFTeamInfo teamInfo, Mobile player )
{
m_TeamInfo = teamInfo;
m_Player = player;
Player = player;
}
}
[PropertyObject]
public sealed class CTFTeamInfo : IRankedCTF
{
private CTFGame m_Game;
private int m_TeamID;
string IRankedCTF.Name => $"{Name} Team";
private int m_Color;
private string m_Name;
public CTFGame Game { get; set; }
private CTFBoard m_Board;
public int TeamID { get; }
private CTFFlag m_Flag;
private Point3D m_Origin;
public int Kills { get; set; }
private int m_Kills;
private int m_Captures;
public int Captures { get; set; }
private int m_Score;
public int Score { get; set; }
private Dictionary<Mobile, CTFPlayerInfo> m_Players;
string IRankedCTF.Name => $"{m_Name} Team";
public CTFGame Game { get => m_Game;
set => m_Game = value;
}
public int TeamID => m_TeamID;
public int Kills { get => m_Kills;
set => m_Kills = value;
}
public int Captures { get => m_Captures;
set => m_Captures = value;
}
public int Score { get => m_Score;
set => m_Score = value;
}
private CTFPlayerInfo m_Leader;
public CTFPlayerInfo Leader
{
get => m_Leader;
set => m_Leader = value;
}
public CTFPlayerInfo Leader { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public CTFBoard Board
{
get => m_Board;
set => m_Board = value;
}
public CTFBoard Board { get; set; }
public Dictionary<Mobile, CTFPlayerInfo> Players => m_Players;
public Dictionary<Mobile, CTFPlayerInfo> Players { get; }
public CTFPlayerInfo this[Mobile mob]
{
@ -642,73 +606,57 @@ namespace Server.Engines.ConPVP
if ( mob == null )
return null;
if (!m_Players.TryGetValue( mob, out CTFPlayerInfo val ))
m_Players[mob] = val = new CTFPlayerInfo( this, mob );
if (!Players.TryGetValue( mob, out CTFPlayerInfo val ))
Players[mob] = val = new CTFPlayerInfo( this, mob );
return val;
}
}
[CommandProperty( AccessLevel.GameMaster )]
public int Color
{
get => m_Color;
set => m_Color = value;
}
public int Color { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public string Name
{
get => m_Name;
set => m_Name = value;
}
public string Name { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public CTFFlag Flag
{
get => m_Flag;
set => m_Flag = value;
}
public CTFFlag Flag { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public Point3D Origin
{
get => m_Origin;
set => m_Origin = value;
}
public Point3D Origin { get; set; }
public CTFTeamInfo( int teamID )
{
m_TeamID = teamID;
m_Players = new Dictionary<Mobile, CTFPlayerInfo>();
TeamID = teamID;
Players = new Dictionary<Mobile, CTFPlayerInfo>();
}
public void Reset()
{
m_Kills = 0;
m_Captures = 0;
Kills = 0;
Captures = 0;
m_Score = 0;
Score = 0;
m_Leader = null;
Leader = null;
m_Players.Clear();
Players.Clear();
if ( m_Flag != null )
if ( Flag != null )
{
m_Flag.m_TeamInfo = this;
m_Flag.Hue = m_Color;
m_Flag.SendHome();
Flag.m_TeamInfo = this;
Flag.Hue = Color;
Flag.SendHome();
}
if ( m_Board != null )
m_Board.m_TeamInfo = this;
if ( Board != null )
Board.m_TeamInfo = this;
}
public CTFTeamInfo( int teamID, GenericReader ip )
{
m_TeamID = teamID;
m_Players = new Dictionary<Mobile, CTFPlayerInfo>();
TeamID = teamID;
Players = new Dictionary<Mobile, CTFPlayerInfo>();
int version = ip.ReadEncodedInt();
@ -716,22 +664,22 @@ namespace Server.Engines.ConPVP
{
case 2:
{
m_Board = ip.ReadItem() as CTFBoard;
Board = ip.ReadItem() as CTFBoard;
goto case 1;
}
case 1:
{
m_Name = ip.ReadString();
Name = ip.ReadString();
goto case 0;
}
case 0:
{
m_Color = ip.ReadEncodedInt();
Color = ip.ReadEncodedInt();
m_Flag = ip.ReadItem() as CTFFlag;
m_Origin = ip.ReadPoint3D();
Flag = ip.ReadItem() as CTFFlag;
Origin = ip.ReadPoint3D();
break;
}
}
@ -741,14 +689,14 @@ namespace Server.Engines.ConPVP
{
op.WriteEncodedInt( 2 ); // version
op.Write( m_Board );
op.Write( Board );
op.Write( m_Name );
op.Write( Name );
op.WriteEncodedInt( m_Color );
op.WriteEncodedInt( Color );
op.Write( m_Flag );
op.Write( m_Origin );
op.Write( Flag );
op.Write( Origin );
}
public override string ToString()
@ -759,56 +707,48 @@ namespace Server.Engines.ConPVP
public sealed class CTFController : EventController
{
private CTFTeamInfo[] m_TeamInfo;
private TimeSpan m_Duration;
public CTFTeamInfo[] TeamInfo => m_TeamInfo;
public CTFTeamInfo[] TeamInfo { get; private set; }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team1 { get => m_TeamInfo[0];
public CTFTeamInfo Team1 { get => TeamInfo[0];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team2 { get => m_TeamInfo[1];
public CTFTeamInfo Team2 { get => TeamInfo[1];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team3 { get => m_TeamInfo[2];
public CTFTeamInfo Team3 { get => TeamInfo[2];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team4 { get => m_TeamInfo[3];
public CTFTeamInfo Team4 { get => TeamInfo[3];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team5 { get => m_TeamInfo[4];
public CTFTeamInfo Team5 { get => TeamInfo[4];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team6 { get => m_TeamInfo[5];
public CTFTeamInfo Team6 { get => TeamInfo[5];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team7 { get => m_TeamInfo[6];
public CTFTeamInfo Team7 { get => TeamInfo[6];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team8 { get => m_TeamInfo[7];
public CTFTeamInfo Team8 { get => TeamInfo[7];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public TimeSpan Duration
{
get => m_Duration;
set => m_Duration = value;
}
public TimeSpan Duration { get; set; }
public override string Title => "CTF";
public override string GetTeamName( int teamID )
{
return m_TeamInfo[teamID % m_TeamInfo.Length].Name;
return TeamInfo[teamID % TeamInfo.Length].Name;
}
public override EventGame Construct( DuelContext context )
@ -822,12 +762,12 @@ namespace Server.Engines.ConPVP
Visible = false;
Movable = false;
m_Duration = TimeSpan.FromMinutes( 30.0 );
Duration = TimeSpan.FromMinutes( 30.0 );
m_TeamInfo = new CTFTeamInfo[8];
TeamInfo = new CTFTeamInfo[8];
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i] = new CTFTeamInfo( i );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i] = new CTFTeamInfo( i );
}
public CTFController( Serial serial )
@ -841,12 +781,12 @@ namespace Server.Engines.ConPVP
writer.Write( (int) 2 );
writer.Write( m_Duration );
writer.Write( Duration );
writer.WriteEncodedInt( m_TeamInfo.Length );
writer.WriteEncodedInt( TeamInfo.Length );
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i].Serialize( writer );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i].Serialize( writer );
}
public override void Deserialize( GenericReader reader )
@ -859,32 +799,32 @@ namespace Server.Engines.ConPVP
{
case 2:
{
m_Duration = reader.ReadTimeSpan();
Duration = reader.ReadTimeSpan();
goto case 1;
}
case 1:
{
m_TeamInfo = new CTFTeamInfo[reader.ReadEncodedInt()];
TeamInfo = new CTFTeamInfo[reader.ReadEncodedInt()];
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i] = new CTFTeamInfo( i, reader );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i] = new CTFTeamInfo( i, reader );
break;
}
case 0:
{
m_TeamInfo = new CTFTeamInfo[8];
TeamInfo = new CTFTeamInfo[8];
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i] = new CTFTeamInfo( i );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i] = new CTFTeamInfo( i );
break;
}
}
if ( version < 2 )
m_Duration = TimeSpan.FromMinutes( 30.0 );
Duration = TimeSpan.FromMinutes( 30.0 );
}
}
@ -896,9 +836,7 @@ namespace Server.Engines.ConPVP
TileData.ItemTable[i].Flags |= TileFlag.NoShoot;
}
private CTFController m_Controller;
public CTFController Controller => m_Controller;
public CTFController Controller { get; }
public void Alert( string text )
{
@ -923,7 +861,7 @@ namespace Server.Engines.ConPVP
public CTFGame( CTFController controller, DuelContext context ) : base( context )
{
m_Controller = controller;
Controller = controller;
}
public Map Facet
@ -933,7 +871,7 @@ namespace Server.Engines.ConPVP
if ( m_Context.Arena != null )
return m_Context.Arena.Facet;
return m_Controller.Map;
return Controller.Map;
}
}
@ -942,7 +880,7 @@ namespace Server.Engines.ConPVP
int teamID = GetTeamID( mob );
if ( teamID >= 0 )
return m_Controller.TeamInfo[teamID % m_Controller.TeamInfo.Length];
return Controller.TeamInfo[teamID % Controller.TeamInfo.Length];
return null;
}
@ -1052,15 +990,15 @@ namespace Server.Engines.ConPVP
if ( mob.InRange( teamInfo.Origin, 24 ) && mob.Map == Facet )
playerInfo.Score += 1; // fragged in base -- guarding
for ( int i = 0; i < m_Controller.TeamInfo.Length; ++i )
for ( int i = 0; i < Controller.TeamInfo.Length; ++i )
{
if ( m_Controller.TeamInfo[i] == teamInfo )
if ( Controller.TeamInfo[i] == teamInfo )
continue;
Mobile ourFlagCarrier = null;
if ( m_Controller.TeamInfo[i].Flag != null )
ourFlagCarrier = m_Controller.TeamInfo[i].Flag.RootParent as Mobile;
if ( Controller.TeamInfo[i].Flag != null )
ourFlagCarrier = Controller.TeamInfo[i].Flag.RootParent as Mobile;
if ( ourFlagCarrier != null && GetTeamInfo( ourFlagCarrier ) == teamInfo )
{
@ -1094,20 +1032,20 @@ namespace Server.Engines.ConPVP
public override void OnStart()
{
for ( int i = 0; i < m_Controller.TeamInfo.Length; ++i )
for ( int i = 0; i < Controller.TeamInfo.Length; ++i )
{
CTFTeamInfo teamInfo = m_Controller.TeamInfo[i];
CTFTeamInfo teamInfo = Controller.TeamInfo[i];
teamInfo.Game = this;
teamInfo.Reset();
}
for ( int i = 0; i < m_Context.Participants.Count; ++i )
ApplyHues( m_Context.Participants[i] as Participant, m_Controller.TeamInfo[i % 8].Color );
ApplyHues( m_Context.Participants[i] as Participant, Controller.TeamInfo[i % 8].Color );
m_FinishTimer?.Stop();
m_FinishTimer = Timer.DelayCall( m_Controller.Duration, Finish_Callback );
m_FinishTimer = Timer.DelayCall( Controller.Duration, Finish_Callback );
}
private void Finish_Callback()
@ -1116,7 +1054,7 @@ namespace Server.Engines.ConPVP
for ( int i = 0; i < m_Context.Participants.Count; ++i )
{
CTFTeamInfo teamInfo = m_Controller.TeamInfo[i % 8];
CTFTeamInfo teamInfo = Controller.TeamInfo[i % 8];
if ( teamInfo?.Flag == null )
continue;
@ -1163,8 +1101,8 @@ namespace Server.Engines.ConPVP
}
}
if ( m_Controller != null )
sb.Append( ' ' ).Append( m_Controller.Title );
if ( Controller != null )
sb.Append( ' ' ).Append( Controller.Title );
string title = sb.ToString();
@ -1277,9 +1215,9 @@ namespace Server.Engines.ConPVP
public override void OnStop()
{
for ( int i = 0; i < m_Controller.TeamInfo.Length; ++i )
for ( int i = 0; i < Controller.TeamInfo.Length; ++i )
{
CTFTeamInfo teamInfo = m_Controller.TeamInfo[i];
CTFTeamInfo teamInfo = Controller.TeamInfo[i];
if ( teamInfo.Flag != null )
{

View file

@ -223,16 +223,14 @@ namespace Server.Engines.ConPVP
{
private DDTeamInfo m_TeamInfo;
private Mobile m_Player;
private int m_Kills;
private int m_Captures;
private int m_Score;
public Mobile Player => m_Player;
public Mobile Player { get; }
public string Name => m_Player.Name;
public string Name => Player.Name;
public int Kills
{
@ -270,64 +268,31 @@ namespace Server.Engines.ConPVP
public DDPlayerInfo( DDTeamInfo teamInfo, Mobile player )
{
m_TeamInfo = teamInfo;
m_Player = player;
Player = player;
}
}
[PropertyObject]
public sealed class DDTeamInfo : IRankedCTF
{
private DDGame m_Game;
private int m_TeamID;
public string Name => $"{TeamName} Team";
private int m_Color;
private string m_Name;
public DDGame Game { get; set; }
private DDBoard m_Board;
public int TeamID { get; }
private Point3D m_Origin;
public int Kills { get; set; }
private int m_Kills;
private int m_Captures;
public int Captures { get; set; }
private int m_Score;
public int Score { get; set; }
private Dictionary<Mobile, DDPlayerInfo> m_Players;
public string Name => $"{m_Name} Team";
public DDGame Game { get => m_Game;
set => m_Game = value;
}
public int TeamID => m_TeamID;
public int Kills { get => m_Kills;
set => m_Kills = value;
}
public int Captures { get => m_Captures;
set => m_Captures = value;
}
public int Score { get => m_Score;
set => m_Score = value;
}
private DDPlayerInfo m_Leader;
public DDPlayerInfo Leader
{
get => m_Leader;
set => m_Leader = value;
}
public DDPlayerInfo Leader { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public DDBoard Board
{
get => m_Board;
set => m_Board = value;
}
public DDBoard Board { get; set; }
public Dictionary<Mobile, DDPlayerInfo> Players => m_Players;
public Dictionary<Mobile, DDPlayerInfo> Players { get; }
public DDPlayerInfo this[Mobile mob]
{
@ -336,59 +301,47 @@ namespace Server.Engines.ConPVP
if ( mob == null )
return null;
if (!m_Players.TryGetValue( mob, out DDPlayerInfo val ))
m_Players[mob] = val = new DDPlayerInfo( this, mob );
if (!Players.TryGetValue( mob, out DDPlayerInfo val ))
Players[mob] = val = new DDPlayerInfo( this, mob );
return val;
}
}
[CommandProperty( AccessLevel.GameMaster )]
public int Color
{
get => m_Color;
set => m_Color = value;
}
public int Color { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public string TeamName
{
get => m_Name;
set => m_Name = value;
}
public string TeamName { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public Point3D Origin
{
get => m_Origin;
set => m_Origin = value;
}
public Point3D Origin { get; set; }
public DDTeamInfo( int teamID )
{
m_TeamID = teamID;
m_Players = new Dictionary<Mobile, DDPlayerInfo>();
TeamID = teamID;
Players = new Dictionary<Mobile, DDPlayerInfo>();
}
public void Reset()
{
m_Kills = 0;
m_Captures = 0;
Kills = 0;
Captures = 0;
m_Score = 0;
Score = 0;
m_Leader = null;
Leader = null;
m_Players.Clear();
Players.Clear();
if ( m_Board != null )
m_Board.m_TeamInfo = this;
if ( Board != null )
Board.m_TeamInfo = this;
}
public DDTeamInfo( int teamID, GenericReader ip )
{
m_TeamID = teamID;
m_Players = new Dictionary<Mobile, DDPlayerInfo>();
TeamID = teamID;
Players = new Dictionary<Mobile, DDPlayerInfo>();
int version = ip.ReadEncodedInt();
@ -396,10 +349,10 @@ namespace Server.Engines.ConPVP
{
case 0:
{
m_Board = ip.ReadItem() as DDBoard;
m_Name = ip.ReadString();
m_Color = ip.ReadEncodedInt();
m_Origin = ip.ReadPoint3D();
Board = ip.ReadItem() as DDBoard;
TeamName = ip.ReadString();
Color = ip.ReadEncodedInt();
Origin = ip.ReadPoint3D();
break;
}
}
@ -409,10 +362,10 @@ namespace Server.Engines.ConPVP
{
op.WriteEncodedInt( 0 ); // version
op.Write( m_Board );
op.Write( m_Name );
op.WriteEncodedInt( m_Color );
op.Write( m_Origin );
op.Write( Board );
op.Write( TeamName );
op.WriteEncodedInt( Color );
op.Write( Origin );
}
public override string ToString()
@ -423,44 +376,30 @@ namespace Server.Engines.ConPVP
public sealed class DDController : EventController
{
private DDTeamInfo[] m_TeamInfo;
private TimeSpan m_Duration;
public DDTeamInfo[] TeamInfo => m_TeamInfo;
public DDTeamInfo[] TeamInfo { get; private set; }
[CommandProperty( AccessLevel.GameMaster )]
public DDTeamInfo Team1 { get => m_TeamInfo[0];
public DDTeamInfo Team1 { get => TeamInfo[0];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public DDTeamInfo Team2 { get => m_TeamInfo[1];
public DDTeamInfo Team2 { get => TeamInfo[1];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public DDWayPoint PointA { get => m_PointA;
set => m_PointA = value;
}
public DDWayPoint PointA { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public DDWayPoint PointB { get => m_PointB;
set => m_PointB = value;
}
private DDWayPoint m_PointA, m_PointB;
public DDWayPoint PointB { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public TimeSpan Duration
{
get => m_Duration;
set => m_Duration = value;
}
public TimeSpan Duration { get; set; }
public override string Title => "DoubleDom";
public override string GetTeamName( int teamID )
{
return m_TeamInfo[teamID % m_TeamInfo.Length].Name;
return TeamInfo[teamID % TeamInfo.Length].Name;
}
public override EventGame Construct( DuelContext context )
@ -476,12 +415,12 @@ namespace Server.Engines.ConPVP
Visible = false;
Movable = false;
m_Duration = TimeSpan.FromMinutes( 30.0 );
Duration = TimeSpan.FromMinutes( 30.0 );
m_TeamInfo = new DDTeamInfo[2];
TeamInfo = new DDTeamInfo[2];
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i] = new DDTeamInfo( i );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i] = new DDTeamInfo( i );
}
public DDController( Serial serial )
@ -495,15 +434,15 @@ namespace Server.Engines.ConPVP
writer.Write( (int)0 );
writer.Write( m_Duration );
writer.Write( Duration );
writer.WriteEncodedInt( m_TeamInfo.Length );
writer.WriteEncodedInt( TeamInfo.Length );
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i].Serialize( writer );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i].Serialize( writer );
writer.Write( m_PointA );
writer.Write( m_PointB );
writer.Write( PointA );
writer.Write( PointB );
}
public override void Deserialize( GenericReader reader )
@ -516,14 +455,14 @@ namespace Server.Engines.ConPVP
{
case 0:
{
m_Duration = reader.ReadTimeSpan();
m_TeamInfo = new DDTeamInfo[reader.ReadEncodedInt()];
Duration = reader.ReadTimeSpan();
TeamInfo = new DDTeamInfo[reader.ReadEncodedInt()];
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i] = new DDTeamInfo( i, reader );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i] = new DDTeamInfo( i, reader );
m_PointA = reader.ReadItem() as DDWayPoint;
m_PointB = reader.ReadItem() as DDWayPoint;
PointA = reader.ReadItem() as DDWayPoint;
PointB = reader.ReadItem() as DDWayPoint;
break;
}
@ -533,9 +472,7 @@ namespace Server.Engines.ConPVP
public sealed class DDGame : EventGame
{
private DDController m_Controller;
public DDController Controller => m_Controller;
public DDController Controller { get; }
public void Alert( string text )
{
@ -560,7 +497,7 @@ namespace Server.Engines.ConPVP
public DDGame( DDController controller, DuelContext context ) : base( context )
{
m_Controller = controller;
Controller = controller;
}
public Map Facet
@ -570,7 +507,7 @@ namespace Server.Engines.ConPVP
if ( m_Context.Arena != null )
return m_Context.Arena.Facet;
return m_Controller.Map;
return Controller.Map;
}
}
@ -579,7 +516,7 @@ namespace Server.Engines.ConPVP
int teamID = GetTeamID( mob );
if ( teamID >= 0 )
return m_Controller.TeamInfo[teamID % m_Controller.TeamInfo.Length];
return Controller.TeamInfo[teamID % Controller.TeamInfo.Length];
return null;
}
@ -706,25 +643,25 @@ namespace Server.Engines.ConPVP
m_UncaptureTimer = null;
}
for ( int i = 0; i < m_Controller.TeamInfo.Length; ++i )
for ( int i = 0; i < Controller.TeamInfo.Length; ++i )
{
DDTeamInfo teamInfo = m_Controller.TeamInfo[i];
DDTeamInfo teamInfo = Controller.TeamInfo[i];
teamInfo.Game = this;
teamInfo.Reset();
}
if ( m_Controller.PointA != null )
m_Controller.PointA.Game = this;
if ( Controller.PointA != null )
Controller.PointA.Game = this;
if ( m_Controller.PointB != null )
m_Controller.PointB.Game = this;
if ( Controller.PointB != null )
Controller.PointB.Game = this;
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 );
ApplyHues( m_Context.Participants[i] as Participant, Controller.TeamInfo[i % Controller.TeamInfo.Length].Color );
m_FinishTimer?.Stop();
m_FinishTimer = Timer.DelayCall( m_Controller.Duration, Finish_Callback );
m_FinishTimer = Timer.DelayCall( Controller.Duration, Finish_Callback );
}
private void Finish_Callback()
@ -733,7 +670,7 @@ namespace Server.Engines.ConPVP
for ( int i = 0; i < m_Context.Participants.Count; ++i )
{
DDTeamInfo teamInfo = m_Controller.TeamInfo[i % m_Controller.TeamInfo.Length];
DDTeamInfo teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length];
if ( teamInfo != null )
teams.Add( teamInfo );
@ -775,8 +712,8 @@ namespace Server.Engines.ConPVP
}
}
if ( m_Controller != null )
sb.Append( ' ' ).Append( m_Controller.Title );
if ( Controller != null )
sb.Append( ' ' ).Append( Controller.Title );
string title = sb.ToString();
@ -889,9 +826,9 @@ namespace Server.Engines.ConPVP
public override void OnStop()
{
for ( int i = 0; i < m_Controller.TeamInfo.Length; ++i )
for ( int i = 0; i < Controller.TeamInfo.Length; ++i )
{
DDTeamInfo teamInfo = m_Controller.TeamInfo[i];
DDTeamInfo teamInfo = Controller.TeamInfo[i];
if ( teamInfo.Board != null )
teamInfo.Board.m_TeamInfo = null;
@ -899,11 +836,11 @@ namespace Server.Engines.ConPVP
teamInfo.Game = null;
}
if ( m_Controller.PointA != null )
m_Controller.PointA.Game = null;
if ( Controller.PointA != null )
Controller.PointA.Game = null;
if ( m_Controller.PointB != null )
m_Controller.PointB.Game = null;
if ( Controller.PointB != null )
Controller.PointB.Game = null;
m_Capturable = false;
@ -936,21 +873,21 @@ namespace Server.Engines.ConPVP
if ( point == null || from == null || team == null || !m_Capturable )
return;
bool wasDom = ( m_Controller.PointA != null && m_Controller.PointB != null &&
m_Controller.PointA.TeamOwner == m_Controller.PointB.TeamOwner && m_Controller.PointA.TeamOwner != null );
bool wasDom = ( Controller.PointA != null && Controller.PointB != null &&
Controller.PointA.TeamOwner == Controller.PointB.TeamOwner && Controller.PointA.TeamOwner != null );
point.TeamOwner = team;
Alert( "{0} has captured {1}!", team.Name, point.Name );
bool isDom = ( m_Controller.PointA != null && m_Controller.PointB != null &&
m_Controller.PointA.TeamOwner == m_Controller.PointB.TeamOwner && m_Controller.PointA.TeamOwner != null );
bool isDom = ( Controller.PointA != null && Controller.PointB != null &&
Controller.PointA.TeamOwner == Controller.PointB.TeamOwner && Controller.PointA.TeamOwner != null );
if ( wasDom && !isDom )
{
Alert( "Domination averted!" );
m_Controller.PointA?.SetNonCaptureHue();
m_Controller.PointB?.SetNonCaptureHue();
Controller.PointA?.SetNonCaptureHue();
Controller.PointB?.SetNonCaptureHue();
m_CaptureTimer?.Stop();
m_CaptureTimer = null;
}
@ -967,10 +904,10 @@ namespace Server.Engines.ConPVP
{
DDTeamInfo team = null;
if ( m_Controller.PointA?.TeamOwner != null )
team = m_Controller.PointA.TeamOwner;
else if ( m_Controller.PointB?.TeamOwner != null )
team = m_Controller.PointB.TeamOwner;
if ( Controller.PointA?.TeamOwner != null )
team = Controller.PointA.TeamOwner;
else if ( Controller.PointB?.TeamOwner != null )
team = Controller.PointB.TeamOwner;
if ( team == null )
{
@ -984,8 +921,8 @@ namespace Server.Engines.ConPVP
{
Alert( "{0} is dominating... {1}", team.Name, 10 - m_CapStage );
m_Controller.PointA?.SetCaptureHue( m_CapStage );
m_Controller.PointB?.SetCaptureHue( m_CapStage );
Controller.PointA?.SetCaptureHue( m_CapStage );
Controller.PointB?.SetCaptureHue( m_CapStage );
}
else
{
@ -999,16 +936,16 @@ namespace Server.Engines.ConPVP
m_CaptureTimer.Stop();
m_CaptureTimer = null;
if ( m_Controller.PointA != null )
if ( Controller.PointA != null )
{
m_Controller.PointA.TeamOwner = null;
m_Controller.PointA.SetUncapturableHue();
Controller.PointA.TeamOwner = null;
Controller.PointA.SetUncapturableHue();
}
if ( m_Controller.PointB != null )
if ( Controller.PointB != null )
{
m_Controller.PointB.TeamOwner = null;
m_Controller.PointB.SetUncapturableHue();
Controller.PointB.TeamOwner = null;
Controller.PointB.SetUncapturableHue();
}
m_UncaptureTimer = Timer.DelayCall( TimeSpan.FromSeconds( 30.0 ), UncaptureTick );
@ -1032,16 +969,16 @@ namespace Server.Engines.ConPVP
m_UncaptureTimer = null;
}
if ( m_Controller.PointA != null )
if ( Controller.PointA != null )
{
m_Controller.PointA.TeamOwner = null;
m_Controller.PointA.SetNonCaptureHue();
Controller.PointA.TeamOwner = null;
Controller.PointA.SetNonCaptureHue();
}
if ( m_Controller.PointB != null )
if ( Controller.PointB != null )
{
m_Controller.PointB.TeamOwner = null;
m_Controller.PointB.SetNonCaptureHue();
Controller.PointB.TeamOwner = null;
Controller.PointB.SetNonCaptureHue();
}
}
}

View file

@ -11,18 +11,16 @@ namespace Server.Engines.ConPVP
{
public class HillOfTheKing : Item
{
private int m_ScoreInterval;
private KHGame m_Game;
private Mobile m_King;
private KingTimer m_KingTimer;
private KHGame m_Game;
private KingTimer m_KingTimer;
[Constructible]
public HillOfTheKing()
: base(0x520)
{
m_ScoreInterval = 10;
ScoreInterval = 10;
m_Game = null;
m_King = null;
King = null;
Movable = false;
Name = "the hill";
@ -43,7 +41,7 @@ namespace Server.Engines.ConPVP
{
case 0:
{
m_ScoreInterval = reader.ReadEncodedInt();
ScoreInterval = reader.ReadEncodedInt();
break;
}
}
@ -55,10 +53,10 @@ namespace Server.Engines.ConPVP
writer.Write((int)0); // version
writer.WriteEncodedInt(m_ScoreInterval);
writer.WriteEncodedInt(ScoreInterval);
}
public Mobile King => m_King;
public Mobile King { get; private set; }
public KHGame Game
{
@ -69,17 +67,15 @@ namespace Server.Engines.ConPVP
{
m_KingTimer?.Stop();
m_Game = value;
m_King = null;
King = null;
}
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int ScoreInterval { get => m_ScoreInterval;
set => m_ScoreInterval = value;
}
public int ScoreInterval { get; set; }
public int CapturesSoFar
public int CapturesSoFar
{
get
{
@ -100,7 +96,7 @@ namespace Server.Engines.ConPVP
return false;
// Not current king (or they are the current king)
if (m_King != null && m_King != m)
if (King != null && King != m)
return false;
// They are on a team
@ -137,7 +133,7 @@ namespace Server.Engines.ConPVP
{
if (base.OnMoveOff(m))
{
if (m_King == m)
if (King == m)
DeKingify();
return true;
@ -169,7 +165,7 @@ namespace Server.Engines.ConPVP
m_KingTimer?.Stop();
m_King = null;
King = null;
}
private void ReKingify(Mobile m)
@ -182,30 +178,29 @@ namespace Server.Engines.ConPVP
if (ti == null)
return;
m_King = m;
King = m;
if (m_KingTimer == null)
m_KingTimer = new KingTimer(this);
m_KingTimer.Stop();
m_KingTimer.StartHillTicker();
if (m_King.Name != null)
PublicOverheadMessage(MessageType.Regular, 0x0481, false, $"Taken by {m_King.Name}!");
if (King.Name != null)
PublicOverheadMessage(MessageType.Regular, 0x0481, false, $"Taken by {King.Name}!");
}
private class KingTimer : Timer
{
private HillOfTheKing m_Hill;
private int m_Total;
private int m_Counter;
private int m_Counter;
public int Captures => m_Total;
public int Captures { get; private set; }
public KingTimer(HillOfTheKing hill)
public KingTimer(HillOfTheKing hill)
: base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
{
m_Hill = hill;
m_Total = 0;
Captures = 0;
m_Counter = 0;
Priority = TimerPriority.FiftyMS;
@ -213,7 +208,7 @@ namespace Server.Engines.ConPVP
public void StartHillTicker()
{
m_Total = 0;
Captures = 0;
m_Counter = 0;
Start();
@ -268,7 +263,7 @@ namespace Server.Engines.ConPVP
m_Hill.PublicOverheadMessage(MessageType.Regular, 0x0481, false, "Capture!");
pi.Captures++;
m_Total++;
Captures++;
pi.Score += m_Counter;
@ -512,21 +507,19 @@ namespace Server.Engines.ConPVP
{
private KHTeamInfo m_TeamInfo;
private Mobile m_Player;
private int m_Kills;
private int m_Kills;
private int m_Captures;
private int m_Score;
public KHPlayerInfo(KHTeamInfo teamInfo, Mobile player)
{
m_TeamInfo = teamInfo;
m_Player = player;
Player = player;
}
public Mobile Player => m_Player;
public Mobile Player { get; }
public int CompareTo(object obj)
public int CompareTo(object obj)
{
KHPlayerInfo pi = (KHPlayerInfo)obj;
int res = pi.Score.CompareTo(Score);
@ -544,9 +537,9 @@ namespace Server.Engines.ConPVP
{
get
{
if (m_Player?.Name == null)
if (Player?.Name == null)
return "";
return m_Player.Name;
return Player.Name;
}
}
@ -587,20 +580,7 @@ namespace Server.Engines.ConPVP
[PropertyObject]
public sealed class KHTeamInfo : IRankedCTF, IComparable
{
private KHGame m_Game;
private int m_TeamID;
private int m_Color;
private string m_Name;
private int m_Kills;
private int m_Captures;
private int m_Score;
private Hashtable m_Players;
public int CompareTo(object obj)
public int CompareTo(object obj)
{
KHTeamInfo ti = (KHTeamInfo)obj;
int res = ti.Score.CompareTo(Score);
@ -618,36 +598,25 @@ namespace Server.Engines.ConPVP
{
get
{
if (m_Name == null)
if (TeamName == null)
return "(null) Team";
return $"{m_Name} Team";
return $"{TeamName} Team";
}
}
public KHGame Game { get => m_Game;
set => m_Game = value;
}
public int TeamID => m_TeamID;
public KHGame Game { get; set; }
public int Kills { get => m_Kills;
set => m_Kills = value;
}
public int Captures { get => m_Captures;
set => m_Captures = value;
}
public int Score { get => m_Score;
set => m_Score = value;
}
public int TeamID { get; }
private KHPlayerInfo m_Leader;
public int Kills { get; set; }
public KHPlayerInfo Leader
{
get => m_Leader;
set => m_Leader = value;
}
public int Captures { get; set; }
public Hashtable Players => m_Players;
public int Score { get; set; }
public KHPlayerInfo Leader { get; set; }
public Hashtable Players { get; }
public KHPlayerInfo this[Mobile mob]
{
@ -656,48 +625,40 @@ namespace Server.Engines.ConPVP
if (mob == null)
return null;
if (!(m_Players[mob] is KHPlayerInfo val))
m_Players[mob] = val = new KHPlayerInfo(this, mob);
if (!(Players[mob] is KHPlayerInfo val))
Players[mob] = val = new KHPlayerInfo(this, mob);
return val;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int Color
{
get => m_Color;
set => m_Color = value;
}
public int Color { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public string TeamName
{
get => m_Name;
set => m_Name = value;
}
[CommandProperty(AccessLevel.GameMaster)]
public string TeamName { get; set; }
public KHTeamInfo(int teamID)
public KHTeamInfo(int teamID)
{
m_TeamID = teamID;
m_Players = new Hashtable();
TeamID = teamID;
Players = new Hashtable();
}
public void Reset()
{
m_Kills = 0;
m_Captures = 0;
m_Score = 0;
Kills = 0;
Captures = 0;
Score = 0;
m_Leader = null;
Leader = null;
m_Players.Clear();
Players.Clear();
}
public KHTeamInfo(int teamID, GenericReader ip)
{
m_TeamID = teamID;
m_Players = new Hashtable();
TeamID = teamID;
Players = new Hashtable();
int version = ip.ReadEncodedInt();
@ -705,8 +666,8 @@ namespace Server.Engines.ConPVP
{
case 0:
{
m_Name = ip.ReadString();
m_Color = ip.ReadEncodedInt();
TeamName = ip.ReadString();
Color = ip.ReadEncodedInt();
break;
}
}
@ -716,13 +677,13 @@ namespace Server.Engines.ConPVP
{
op.WriteEncodedInt(0); // version
op.Write(m_Name);
op.WriteEncodedInt(m_Color);
op.Write(TeamName);
op.WriteEncodedInt(Color);
}
public override string ToString()
{
if (m_Name != null)
if (TeamName != null)
return $"({Name}) ...";
return "...";
}
@ -730,82 +691,74 @@ namespace Server.Engines.ConPVP
public sealed class KHController : EventController
{
private KHTeamInfo[] m_TeamInfo;
private HillOfTheKing[] m_Hills;
private ArrayList m_Boards;
private TimeSpan m_Duration;
private int m_ScoreInterval;
private int m_ScoreInterval;
public KHTeamInfo[] TeamInfo => m_TeamInfo;
public KHTeamInfo[] TeamInfo { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team1_W { get => m_TeamInfo[0];
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team1_W { get => TeamInfo[0];
set { } }
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team2_E { get => m_TeamInfo[1];
public KHTeamInfo Team2_E { get => TeamInfo[1];
set { } }
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team3_N { get => m_TeamInfo[2];
public KHTeamInfo Team3_N { get => TeamInfo[2];
set { } }
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team4_S { get => m_TeamInfo[3];
public KHTeamInfo Team4_S { get => TeamInfo[3];
set { } }
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team5_NW { get => m_TeamInfo[4];
public KHTeamInfo Team5_NW { get => TeamInfo[4];
set { } }
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team6_SE { get => m_TeamInfo[5];
public KHTeamInfo Team6_SE { get => TeamInfo[5];
set { } }
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team7_SW { get => m_TeamInfo[6];
public KHTeamInfo Team7_SW { get => TeamInfo[6];
set { } }
[CommandProperty(AccessLevel.GameMaster)]
public KHTeamInfo Team8_NE { get => m_TeamInfo[7];
public KHTeamInfo Team8_NE { get => TeamInfo[7];
set { } }
public HillOfTheKing[] Hills => m_Hills;
public HillOfTheKing[] Hills { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public HillOfTheKing Hill1 { get => m_Hills[0];
set => m_Hills[0] = value;
[CommandProperty(AccessLevel.GameMaster)]
public HillOfTheKing Hill1 { get => Hills[0];
set => Hills[0] = value;
}
[CommandProperty(AccessLevel.GameMaster)]
public HillOfTheKing Hill2 { get => m_Hills[1];
set => m_Hills[1] = value;
public HillOfTheKing Hill2 { get => Hills[1];
set => Hills[1] = value;
}
[CommandProperty(AccessLevel.GameMaster)]
public HillOfTheKing Hill3 { get => m_Hills[2];
set => m_Hills[2] = value;
public HillOfTheKing Hill3 { get => Hills[2];
set => Hills[2] = value;
}
[CommandProperty(AccessLevel.GameMaster)]
public HillOfTheKing Hill4 { get => m_Hills[3];
set => m_Hills[3] = value;
public HillOfTheKing Hill4 { get => Hills[3];
set => Hills[3] = value;
}
public ArrayList Boards => m_Boards;
public ArrayList Boards { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan Duration
{
get => m_Duration;
set => m_Duration = value;
}
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan Duration { get; set; }
public override string Title => "King of the Hill";
public override string Title => "King of the Hill";
public override string GetTeamName(int teamID)
{
return m_TeamInfo[teamID % m_TeamInfo.Length].Name;
return TeamInfo[teamID % TeamInfo.Length].Name;
}
public override EventGame Construct(DuelContext context)
@ -817,7 +770,7 @@ namespace Server.Engines.ConPVP
{
if (b != null)
{
m_Boards.Remove(b);
Boards.Remove(b);
b.m_Game = null;
}
}
@ -825,7 +778,7 @@ namespace Server.Engines.ConPVP
public void AddBoard(KHBoard b)
{
if (b != null)
m_Boards.Add(b);
Boards.Add(b);
}
[Constructible]
@ -836,13 +789,13 @@ namespace Server.Engines.ConPVP
Name = "King of the Hill Controller";
m_Duration = TimeSpan.FromMinutes(30.0);
m_Boards = new ArrayList();
m_Hills = new HillOfTheKing[4];
m_TeamInfo = new KHTeamInfo[8];
Duration = TimeSpan.FromMinutes(30.0);
Boards = new ArrayList();
Hills = new HillOfTheKing[4];
TeamInfo = new KHTeamInfo[8];
for (int i = 0; i < m_TeamInfo.Length; ++i)
m_TeamInfo[i] = new KHTeamInfo(i);
for (int i = 0; i < TeamInfo.Length; ++i)
TeamInfo[i] = new KHTeamInfo(i);
}
public KHController(Serial serial)
@ -857,17 +810,17 @@ namespace Server.Engines.ConPVP
writer.Write((int)0);
writer.WriteEncodedInt(m_ScoreInterval);
writer.Write(m_Duration);
writer.Write(Duration);
writer.WriteItemList(m_Boards, true);
writer.WriteItemList(Boards, true);
writer.WriteEncodedInt(m_Hills.Length);
for (int i = 0; i < m_Hills.Length; ++i)
writer.Write(m_Hills[i]);
writer.WriteEncodedInt(Hills.Length);
for (int i = 0; i < Hills.Length; ++i)
writer.Write(Hills[i]);
writer.WriteEncodedInt(m_TeamInfo.Length);
for (int i = 0; i < m_TeamInfo.Length; ++i)
m_TeamInfo[i].Serialize(writer);
writer.WriteEncodedInt(TeamInfo.Length);
for (int i = 0; i < TeamInfo.Length; ++i)
TeamInfo[i].Serialize(writer);
}
public override void Deserialize(GenericReader reader)
@ -882,17 +835,17 @@ namespace Server.Engines.ConPVP
{
m_ScoreInterval = reader.ReadEncodedInt();
m_Duration = reader.ReadTimeSpan();
Duration = reader.ReadTimeSpan();
m_Boards = reader.ReadItemList();
Boards = reader.ReadItemList();
m_Hills = new HillOfTheKing[reader.ReadEncodedInt()];
for (int i = 0; i < m_Hills.Length; ++i)
m_Hills[i] = reader.ReadItem() as HillOfTheKing;
Hills = new HillOfTheKing[reader.ReadEncodedInt()];
for (int i = 0; i < Hills.Length; ++i)
Hills[i] = reader.ReadItem() as HillOfTheKing;
m_TeamInfo = new KHTeamInfo[reader.ReadEncodedInt()];
for (int i = 0; i < m_TeamInfo.Length; ++i)
m_TeamInfo[i] = new KHTeamInfo(i, reader);
TeamInfo = new KHTeamInfo[reader.ReadEncodedInt()];
for (int i = 0; i < TeamInfo.Length; ++i)
TeamInfo[i] = new KHTeamInfo(i, reader);
break;
}
@ -902,17 +855,15 @@ namespace Server.Engines.ConPVP
public sealed class KHGame : EventGame
{
private KHController m_Controller;
public KHController Controller { get; }
public KHController Controller => m_Controller;
public override bool CantDoAnything(Mobile mob)
public override bool CantDoAnything(Mobile mob)
{
if (mob != null && GetTeamInfo(mob) != null && m_Controller != null)
if (mob != null && GetTeamInfo(mob) != null && Controller != null)
{
for (int i = 0; i < m_Controller.Hills.Length; i++)
for (int i = 0; i < Controller.Hills.Length; i++)
{
if (m_Controller.Hills[i] != null && m_Controller.Hills[i].King == mob)
if (Controller.Hills[i] != null && Controller.Hills[i].King == mob)
return true;
}
}
@ -944,7 +895,7 @@ namespace Server.Engines.ConPVP
public KHGame(KHController controller, DuelContext context)
: base(context)
{
m_Controller = controller;
Controller = controller;
}
public Map Facet
@ -954,7 +905,7 @@ namespace Server.Engines.ConPVP
if (m_Context?.Arena != null)
return m_Context.Arena.Facet;
return m_Controller.Map;
return Controller.Map;
}
}
@ -963,7 +914,7 @@ namespace Server.Engines.ConPVP
int teamID = GetTeamID(mob);
if (teamID >= 0)
return m_Controller.TeamInfo[teamID % m_Controller.TeamInfo.Length];
return Controller.TeamInfo[teamID % Controller.TeamInfo.Length];
return null;
}
@ -1038,18 +989,18 @@ namespace Server.Engines.ConPVP
if (killer != null && killer.Player)
teamInfo = GetTeamInfo(killer);
for (int i = 0; i < m_Controller.Hills.Length; i++)
for (int i = 0; i < Controller.Hills.Length; i++)
{
if (m_Controller.Hills[i] == null)
if (Controller.Hills[i] == null)
continue;
if (m_Controller.Hills[i].King == mob)
if (Controller.Hills[i].King == mob)
{
bonus += m_Controller.Hills[i].CapturesSoFar;
m_Controller.Hills[i].OnKingDied(mob, victInfo, killer, teamInfo);
bonus += Controller.Hills[i].CapturesSoFar;
Controller.Hills[i].OnKingDied(mob, victInfo, killer, teamInfo);
}
if (m_Controller.Hills[i].King == killer)
if (Controller.Hills[i].King == killer)
bonus += 2;
}
@ -1077,32 +1028,32 @@ namespace Server.Engines.ConPVP
public override void OnStart()
{
for (int i = 0; i < m_Controller.TeamInfo.Length; ++i)
for (int i = 0; i < Controller.TeamInfo.Length; ++i)
{
KHTeamInfo teamInfo = m_Controller.TeamInfo[i];
KHTeamInfo teamInfo = Controller.TeamInfo[i];
teamInfo.Game = this;
teamInfo.Reset();
}
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);
ApplyHues(m_Context.Participants[i] as Participant, Controller.TeamInfo[i % Controller.TeamInfo.Length].Color);
m_FinishTimer?.Stop();
for (int i = 0; i < m_Controller.Hills.Length; i++)
for (int i = 0; i < Controller.Hills.Length; i++)
{
if (m_Controller.Hills[i] != null)
m_Controller.Hills[i].Game = this;
if (Controller.Hills[i] != null)
Controller.Hills[i].Game = this;
}
foreach (KHBoard board in m_Controller.Boards)
foreach (KHBoard board in Controller.Boards)
{
if (board != null && !board.Deleted)
board.m_Game = this;
}
m_FinishTimer = Timer.DelayCall(m_Controller.Duration, Finish_Callback);
m_FinishTimer = Timer.DelayCall(Controller.Duration, Finish_Callback);
}
private void Finish_Callback()
@ -1111,7 +1062,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < m_Context.Participants.Count; ++i)
{
KHTeamInfo teamInfo = m_Controller.TeamInfo[i % m_Controller.TeamInfo.Length];
KHTeamInfo teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length];
if (teamInfo == null)
continue;
@ -1150,8 +1101,8 @@ namespace Server.Engines.ConPVP
}
}
if (m_Controller != null)
sb.Append(' ').Append(m_Controller.Title);
if (Controller != null)
sb.Append(' ').Append(Controller.Title);
string title = sb.ToString();
@ -1263,16 +1214,16 @@ namespace Server.Engines.ConPVP
public override void OnStop()
{
for (int i = 0; i < m_Controller.TeamInfo.Length; ++i)
m_Controller.TeamInfo[i].Game = null;
for (int i = 0; i < Controller.TeamInfo.Length; ++i)
Controller.TeamInfo[i].Game = null;
for (int i = 0; i < m_Controller.Hills.Length; ++i)
for (int i = 0; i < Controller.Hills.Length; ++i)
{
if (m_Controller.Hills[i] != null)
m_Controller.Hills[i].Game = null;
if (Controller.Hills[i] != null)
Controller.Hills[i].Game = null;
}
foreach (KHBoard board in m_Controller.Boards)
foreach (KHBoard board in Controller.Boards)
{
if (board != null)
board.m_Game = null;