Changes properties to use automatic property initializers
This commit is contained in:
parent
f0a48ad431
commit
06fa31a7bf
623 changed files with 13072 additions and 19304 deletions
|
|
@ -9,14 +9,8 @@ namespace Server.Items
|
|||
{
|
||||
public abstract class BaseBoard : Container, ISecurable
|
||||
{
|
||||
private SecureLevel m_Level;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public SecureLevel Level
|
||||
{
|
||||
get => m_Level;
|
||||
set => m_Level = value;
|
||||
}
|
||||
public SecureLevel Level { get; set; }
|
||||
|
||||
public BaseBoard( int itemID ) : base( itemID )
|
||||
{
|
||||
|
|
@ -57,7 +51,7 @@ namespace Server.Items
|
|||
base.Serialize( writer );
|
||||
writer.Write( (int) 1 ); // version
|
||||
|
||||
writer.Write( (int)m_Level );
|
||||
writer.Write( (int)Level );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
|
|
@ -66,7 +60,7 @@ namespace Server.Items
|
|||
int version = reader.ReadInt();
|
||||
|
||||
if ( version == 1 )
|
||||
m_Level = (SecureLevel)reader.ReadInt();
|
||||
Level = (SecureLevel)reader.ReadInt();
|
||||
|
||||
if ( Weight == 1.0 )
|
||||
Weight = 5.0;
|
||||
|
|
|
|||
|
|
@ -2,19 +2,13 @@ namespace Server.Items
|
|||
{
|
||||
public class BasePiece : Item
|
||||
{
|
||||
private BaseBoard m_Board;
|
||||
|
||||
public BaseBoard Board
|
||||
{
|
||||
get => m_Board;
|
||||
set => m_Board = value;
|
||||
}
|
||||
public BaseBoard Board { get; set; }
|
||||
|
||||
public override bool IsVirtualItem => true;
|
||||
|
||||
public BasePiece( int itemID, BaseBoard board ) : base( itemID )
|
||||
{
|
||||
m_Board = board;
|
||||
Board = board;
|
||||
}
|
||||
|
||||
public BasePiece( Serial serial ) : base( serial )
|
||||
|
|
@ -26,7 +20,7 @@ namespace Server.Items
|
|||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 );
|
||||
writer.Write( m_Board );
|
||||
writer.Write( Board );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
|
|
@ -39,9 +33,9 @@ namespace Server.Items
|
|||
{
|
||||
case 0:
|
||||
{
|
||||
m_Board = (BaseBoard)reader.ReadItem();
|
||||
Board = (BaseBoard)reader.ReadItem();
|
||||
|
||||
if ( m_Board == null || Parent == null )
|
||||
if ( Board == null || Parent == null )
|
||||
Delete();
|
||||
|
||||
break;
|
||||
|
|
@ -51,25 +45,25 @@ namespace Server.Items
|
|||
|
||||
public override void OnSingleClick( Mobile from )
|
||||
{
|
||||
if ( m_Board == null || m_Board.Deleted )
|
||||
if ( Board == null || Board.Deleted )
|
||||
Delete();
|
||||
else if ( !IsChildOf( m_Board ) )
|
||||
m_Board.DropItem( this );
|
||||
else if ( !IsChildOf( Board ) )
|
||||
Board.DropItem( this );
|
||||
else
|
||||
base.OnSingleClick( from );
|
||||
}
|
||||
|
||||
public override bool OnDragLift( Mobile from )
|
||||
{
|
||||
if ( m_Board == null || m_Board.Deleted )
|
||||
if ( Board == null || Board.Deleted )
|
||||
{
|
||||
Delete();
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !IsChildOf( m_Board ) )
|
||||
if ( !IsChildOf( Board ) )
|
||||
{
|
||||
m_Board.DropItem( this );
|
||||
Board.DropItem( this );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -84,7 +78,7 @@ namespace Server.Items
|
|||
|
||||
public override bool DropToItem( Mobile from, Item target, Point3D p )
|
||||
{
|
||||
return ( target == m_Board && p.X != -1 && p.Y != -1 && base.DropToItem( from, target, p ) );
|
||||
return ( target == Board && p.X != -1 && p.Y != -1 && base.DropToItem( from, target, p ) );
|
||||
}
|
||||
|
||||
public override bool DropToWorld( Mobile from, Point3D p )
|
||||
|
|
|
|||
|
|
@ -9,25 +9,23 @@ namespace Server.Engines.Mahjong
|
|||
return new MahjongPieceDim( position, 20, 40 );
|
||||
}
|
||||
|
||||
private MahjongGame m_Game;
|
||||
private Point2D m_Position;
|
||||
private MahjongPieceDirection m_Direction;
|
||||
private MahjongWind m_Wind;
|
||||
public MahjongGame Game { get; }
|
||||
|
||||
public MahjongGame Game => m_Game;
|
||||
public Point2D Position => m_Position;
|
||||
public MahjongPieceDirection Direction => m_Direction;
|
||||
public MahjongWind Wind => m_Wind;
|
||||
public Point2D Position { get; private set; }
|
||||
|
||||
public MahjongPieceDirection Direction { get; private set; }
|
||||
|
||||
public MahjongWind Wind { get; private set; }
|
||||
|
||||
public MahjongDealerIndicator( MahjongGame game, Point2D position, MahjongPieceDirection direction, MahjongWind wind )
|
||||
{
|
||||
m_Game = game;
|
||||
m_Position = position;
|
||||
m_Direction = direction;
|
||||
m_Wind = wind;
|
||||
Game = game;
|
||||
Position = position;
|
||||
Direction = direction;
|
||||
Wind = wind;
|
||||
}
|
||||
|
||||
public MahjongPieceDim Dimensions => GetDimensions( m_Position, m_Direction );
|
||||
public MahjongPieceDim Dimensions => GetDimensions( Position, Direction );
|
||||
|
||||
public void Move( Point2D position, MahjongPieceDirection direction, MahjongWind wind )
|
||||
{
|
||||
|
|
@ -36,31 +34,31 @@ namespace Server.Engines.Mahjong
|
|||
if ( !dim.IsValid() )
|
||||
return;
|
||||
|
||||
m_Position = position;
|
||||
m_Direction = direction;
|
||||
m_Wind = wind;
|
||||
Position = position;
|
||||
Direction = direction;
|
||||
Wind = wind;
|
||||
|
||||
m_Game.Players.SendGeneralPacket( true, true );
|
||||
Game.Players.SendGeneralPacket( true, true );
|
||||
}
|
||||
|
||||
public void Save( GenericWriter writer )
|
||||
{
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
writer.Write( m_Position );
|
||||
writer.Write( (int) m_Direction );
|
||||
writer.Write( (int) m_Wind );
|
||||
writer.Write( Position );
|
||||
writer.Write( (int) Direction );
|
||||
writer.Write( (int) Wind );
|
||||
}
|
||||
|
||||
public MahjongDealerIndicator( MahjongGame game, GenericReader reader )
|
||||
{
|
||||
m_Game = game;
|
||||
Game = game;
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_Position = reader.ReadPoint2D();
|
||||
m_Direction = (MahjongPieceDirection) reader.ReadInt();
|
||||
m_Wind = (MahjongWind) reader.ReadInt();
|
||||
Position = reader.ReadPoint2D();
|
||||
Direction = (MahjongPieceDirection) reader.ReadInt();
|
||||
Wind = (MahjongWind) reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,48 +2,46 @@ namespace Server.Engines.Mahjong
|
|||
{
|
||||
public class MahjongDices
|
||||
{
|
||||
private MahjongGame m_Game;
|
||||
private int m_First;
|
||||
private int m_Second;
|
||||
public MahjongGame Game { get; }
|
||||
|
||||
public MahjongGame Game => m_Game;
|
||||
public int First => m_First;
|
||||
public int Second => m_Second;
|
||||
public int First { get; private set; }
|
||||
|
||||
public int Second { get; private set; }
|
||||
|
||||
public MahjongDices( MahjongGame game )
|
||||
{
|
||||
m_Game = game;
|
||||
m_First = Utility.Random( 1, 6 );
|
||||
m_Second = Utility.Random( 1, 6 );
|
||||
Game = game;
|
||||
First = Utility.Random( 1, 6 );
|
||||
Second = Utility.Random( 1, 6 );
|
||||
}
|
||||
|
||||
public void RollDices( Mobile from )
|
||||
{
|
||||
m_First = Utility.Random( 1, 6 );
|
||||
m_Second = Utility.Random( 1, 6 );
|
||||
First = Utility.Random( 1, 6 );
|
||||
Second = Utility.Random( 1, 6 );
|
||||
|
||||
m_Game.Players.SendGeneralPacket( true, true );
|
||||
Game.Players.SendGeneralPacket( true, true );
|
||||
|
||||
if ( from != null )
|
||||
m_Game.Players.SendLocalizedMessage( 1062695, $"{from.Name}\t{m_First}\t{m_Second}"); // ~1_name~ rolls the dice and gets a ~2_number~ and a ~3_number~!
|
||||
Game.Players.SendLocalizedMessage( 1062695, $"{from.Name}\t{First}\t{Second}"); // ~1_name~ rolls the dice and gets a ~2_number~ and a ~3_number~!
|
||||
}
|
||||
|
||||
public void Save( GenericWriter writer )
|
||||
{
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
writer.Write( m_First );
|
||||
writer.Write( m_Second );
|
||||
writer.Write( First );
|
||||
writer.Write( Second );
|
||||
}
|
||||
|
||||
public MahjongDices( MahjongGame game, GenericReader reader )
|
||||
{
|
||||
m_Game = game;
|
||||
Game = game;
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_First = reader.ReadInt();
|
||||
m_Second = reader.ReadInt();
|
||||
First = reader.ReadInt();
|
||||
Second = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,29 +11,22 @@ namespace Server.Engines.Mahjong
|
|||
public const int MaxPlayers = 4;
|
||||
public const int BaseScore = 30000;
|
||||
|
||||
private MahjongTile[] m_Tiles;
|
||||
private MahjongDealerIndicator m_DealerIndicator;
|
||||
private MahjongWallBreakIndicator m_WallBreakIndicator;
|
||||
private MahjongDices m_Dices;
|
||||
private MahjongPlayers m_Players;
|
||||
private bool m_ShowScores;
|
||||
private bool m_SpectatorVision;
|
||||
private DateTime m_LastReset;
|
||||
|
||||
public MahjongTile[] Tiles => m_Tiles;
|
||||
public MahjongDealerIndicator DealerIndicator => m_DealerIndicator;
|
||||
public MahjongWallBreakIndicator WallBreakIndicator => m_WallBreakIndicator;
|
||||
public MahjongDices Dices => m_Dices;
|
||||
public MahjongPlayers Players => m_Players;
|
||||
public MahjongTile[] Tiles { get; private set; }
|
||||
|
||||
private SecureLevel m_Level;
|
||||
public MahjongDealerIndicator DealerIndicator { get; private set; }
|
||||
|
||||
public MahjongWallBreakIndicator WallBreakIndicator { get; private set; }
|
||||
|
||||
public MahjongDices Dices { get; private set; }
|
||||
|
||||
public MahjongPlayers Players { get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public SecureLevel Level
|
||||
{
|
||||
get => m_Level;
|
||||
set => m_Level = value;
|
||||
}
|
||||
public SecureLevel Level { get; set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool ShowScores
|
||||
|
|
@ -47,11 +40,11 @@ namespace Server.Engines.Mahjong
|
|||
m_ShowScores = value;
|
||||
|
||||
if ( value )
|
||||
m_Players.SendPlayersPacket( true, true );
|
||||
Players.SendPlayersPacket( true, true );
|
||||
|
||||
m_Players.SendGeneralPacket( true, true );
|
||||
Players.SendGeneralPacket( true, true );
|
||||
|
||||
m_Players.SendLocalizedMessage( value ? 1062777 : 1062778 ); // The dealer has enabled/disabled score display.
|
||||
Players.SendLocalizedMessage( value ? 1062777 : 1062778 ); // The dealer has enabled/disabled score display.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -66,12 +59,12 @@ namespace Server.Engines.Mahjong
|
|||
|
||||
m_SpectatorVision = value;
|
||||
|
||||
if ( m_Players.IsInGamePlayer( m_Players.DealerPosition ) )
|
||||
m_Players.Dealer.Send( new MahjongGeneralInfo( this ) );
|
||||
if ( Players.IsInGamePlayer( Players.DealerPosition ) )
|
||||
Players.Dealer.Send( new MahjongGeneralInfo( this ) );
|
||||
|
||||
m_Players.SendTilesPacket( false, true );
|
||||
Players.SendTilesPacket( false, true );
|
||||
|
||||
m_Players.SendLocalizedMessage( value ? 1062715 : 1062716 ); // The dealer has enabled/disabled Spectator Vision.
|
||||
Players.SendLocalizedMessage( value ? 1062715 : 1062716 ); // The dealer has enabled/disabled Spectator Vision.
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
|
@ -83,12 +76,12 @@ namespace Server.Engines.Mahjong
|
|||
Weight = 5.0;
|
||||
|
||||
BuildWalls();
|
||||
m_DealerIndicator = new MahjongDealerIndicator( this, new Point2D( 300, 300 ), MahjongPieceDirection.Up, MahjongWind.North );
|
||||
m_WallBreakIndicator = new MahjongWallBreakIndicator( this, new Point2D( 335, 335 ) );
|
||||
m_Dices = new MahjongDices( this );
|
||||
m_Players = new MahjongPlayers( this, MaxPlayers, BaseScore );
|
||||
DealerIndicator = new MahjongDealerIndicator( this, new Point2D( 300, 300 ), MahjongPieceDirection.Up, MahjongWind.North );
|
||||
WallBreakIndicator = new MahjongWallBreakIndicator( this, new Point2D( 335, 335 ) );
|
||||
Dices = new MahjongDices( this );
|
||||
Players = new MahjongPlayers( this, MaxPlayers, BaseScore );
|
||||
m_LastReset = DateTime.UtcNow;
|
||||
m_Level = SecureLevel.CoOwners;
|
||||
Level = SecureLevel.CoOwners;
|
||||
}
|
||||
|
||||
public MahjongGame( Serial serial ) : base( serial )
|
||||
|
|
@ -100,7 +93,7 @@ namespace Server.Engines.Mahjong
|
|||
for ( int i = 0; i < 17; i++ )
|
||||
{
|
||||
Point2D position = new Point2D( x + i*20, y );
|
||||
m_Tiles[index + i] = new MahjongTile( this, index + i, typeGenerator.Next(), position, stackLevel, direction, false );
|
||||
Tiles[index + i] = new MahjongTile( this, index + i, typeGenerator.Next(), position, stackLevel, direction, false );
|
||||
}
|
||||
|
||||
index += 17;
|
||||
|
|
@ -111,7 +104,7 @@ namespace Server.Engines.Mahjong
|
|||
for ( int i = 0; i < 17; i++ )
|
||||
{
|
||||
Point2D position = new Point2D( x, y + i*20 );
|
||||
m_Tiles[index + i] = new MahjongTile( this, index + i, typeGenerator.Next(), position, stackLevel, direction, false );
|
||||
Tiles[index + i] = new MahjongTile( this, index + i, typeGenerator.Next(), position, stackLevel, direction, false );
|
||||
}
|
||||
|
||||
index += 17;
|
||||
|
|
@ -119,7 +112,7 @@ namespace Server.Engines.Mahjong
|
|||
|
||||
private void BuildWalls()
|
||||
{
|
||||
m_Tiles = new MahjongTile[17 * 8];
|
||||
Tiles = new MahjongTile[17 * 8];
|
||||
|
||||
MahjongTileTypeGenerator typeGenerator = new MahjongTileTypeGenerator( 4 );
|
||||
|
||||
|
|
@ -152,9 +145,9 @@ namespace Server.Engines.Mahjong
|
|||
{
|
||||
base.GetContextMenuEntries( from, list );
|
||||
|
||||
m_Players.CheckPlayers();
|
||||
Players.CheckPlayers();
|
||||
|
||||
if ( from.Alive && IsAccessibleTo( from ) && m_Players.GetInGameMobiles( true, false ).Count == 0 )
|
||||
if ( from.Alive && IsAccessibleTo( from ) && Players.GetInGameMobiles( true, false ).Count == 0 )
|
||||
list.Add( new ResetGameEntry( this ) );
|
||||
|
||||
SetSecureLevelEntry.AddTo( from, this, list );
|
||||
|
|
@ -180,9 +173,9 @@ namespace Server.Engines.Mahjong
|
|||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
m_Players.CheckPlayers();
|
||||
Players.CheckPlayers();
|
||||
|
||||
m_Players.Join( from );
|
||||
Players.Join( from );
|
||||
}
|
||||
|
||||
public void ResetGame( Mobile from )
|
||||
|
|
@ -193,14 +186,14 @@ namespace Server.Engines.Mahjong
|
|||
m_LastReset = DateTime.UtcNow;
|
||||
|
||||
if ( from != null )
|
||||
m_Players.SendLocalizedMessage( 1062771, from.Name ); // ~1_name~ has reset the game.
|
||||
Players.SendLocalizedMessage( 1062771, from.Name ); // ~1_name~ has reset the game.
|
||||
|
||||
m_Players.SendRelievePacket( true, true );
|
||||
Players.SendRelievePacket( true, true );
|
||||
|
||||
BuildWalls();
|
||||
m_DealerIndicator = new MahjongDealerIndicator( this, new Point2D( 300, 300 ), MahjongPieceDirection.Up, MahjongWind.North );
|
||||
m_WallBreakIndicator = new MahjongWallBreakIndicator( this, new Point2D( 335, 335 ) );
|
||||
m_Players = new MahjongPlayers( this, MaxPlayers, BaseScore );
|
||||
DealerIndicator = new MahjongDealerIndicator( this, new Point2D( 300, 300 ), MahjongPieceDirection.Up, MahjongWind.North );
|
||||
WallBreakIndicator = new MahjongWallBreakIndicator( this, new Point2D( 335, 335 ) );
|
||||
Players = new MahjongPlayers( this, MaxPlayers, BaseScore );
|
||||
}
|
||||
|
||||
public void ResetWalls( Mobile from )
|
||||
|
|
@ -212,16 +205,16 @@ namespace Server.Engines.Mahjong
|
|||
|
||||
BuildWalls();
|
||||
|
||||
m_Players.SendTilesPacket( true, true );
|
||||
Players.SendTilesPacket( true, true );
|
||||
|
||||
if ( from != null )
|
||||
m_Players.SendLocalizedMessage( 1062696 ); // The dealer rebuilds the wall.
|
||||
Players.SendLocalizedMessage( 1062696 ); // The dealer rebuilds the wall.
|
||||
}
|
||||
|
||||
public int GetStackLevel( MahjongPieceDim dim )
|
||||
{
|
||||
int level = -1;
|
||||
foreach ( MahjongTile tile in m_Tiles )
|
||||
foreach ( MahjongTile tile in Tiles )
|
||||
{
|
||||
if ( tile.StackLevel > level && dim.IsOverlapping( tile.Dimensions ) )
|
||||
level = tile.StackLevel;
|
||||
|
|
@ -235,20 +228,20 @@ namespace Server.Engines.Mahjong
|
|||
|
||||
writer.Write( (int) 1 ); // version
|
||||
|
||||
writer.Write( (int) m_Level );
|
||||
writer.Write( (int) Level );
|
||||
|
||||
writer.Write( m_Tiles.Length );
|
||||
writer.Write( Tiles.Length );
|
||||
|
||||
for ( int i = 0; i < m_Tiles.Length; i++ )
|
||||
m_Tiles[i].Save( writer );
|
||||
for ( int i = 0; i < Tiles.Length; i++ )
|
||||
Tiles[i].Save( writer );
|
||||
|
||||
m_DealerIndicator.Save( writer );
|
||||
DealerIndicator.Save( writer );
|
||||
|
||||
m_WallBreakIndicator.Save( writer );
|
||||
WallBreakIndicator.Save( writer );
|
||||
|
||||
m_Dices.Save( writer );
|
||||
Dices.Save( writer );
|
||||
|
||||
m_Players.Save( writer );
|
||||
Players.Save( writer );
|
||||
|
||||
writer.Write( m_ShowScores );
|
||||
writer.Write( m_SpectatorVision );
|
||||
|
|
@ -264,28 +257,28 @@ namespace Server.Engines.Mahjong
|
|||
{
|
||||
case 1:
|
||||
{
|
||||
m_Level = (SecureLevel)reader.ReadInt();
|
||||
Level = (SecureLevel)reader.ReadInt();
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
if ( version < 1 )
|
||||
m_Level = SecureLevel.CoOwners;
|
||||
Level = SecureLevel.CoOwners;
|
||||
|
||||
int length = reader.ReadInt();
|
||||
m_Tiles = new MahjongTile[length];
|
||||
Tiles = new MahjongTile[length];
|
||||
|
||||
for ( int i = 0; i < length; i++ )
|
||||
m_Tiles[i] = new MahjongTile( this, reader );
|
||||
Tiles[i] = new MahjongTile( this, reader );
|
||||
|
||||
m_DealerIndicator = new MahjongDealerIndicator( this, reader );
|
||||
DealerIndicator = new MahjongDealerIndicator( this, reader );
|
||||
|
||||
m_WallBreakIndicator = new MahjongWallBreakIndicator( this, reader );
|
||||
WallBreakIndicator = new MahjongWallBreakIndicator( this, reader );
|
||||
|
||||
m_Dices = new MahjongDices( this, reader );
|
||||
Dices = new MahjongDices( this, reader );
|
||||
|
||||
m_Players = new MahjongPlayers( this, reader );
|
||||
Players = new MahjongPlayers( this, reader );
|
||||
|
||||
m_ShowScores = reader.ReadBool();
|
||||
m_SpectatorVision = reader.ReadBool();
|
||||
|
|
|
|||
|
|
@ -2,43 +2,41 @@ namespace Server.Engines.Mahjong
|
|||
{
|
||||
public struct MahjongPieceDim
|
||||
{
|
||||
private Point2D m_Position;
|
||||
private int m_Width;
|
||||
private int m_Height;
|
||||
public Point2D Position { get; }
|
||||
|
||||
public Point2D Position => m_Position;
|
||||
public int Width => m_Width;
|
||||
public int Height => m_Height;
|
||||
public int Width { get; }
|
||||
|
||||
public int Height { get; }
|
||||
|
||||
public MahjongPieceDim( Point2D position, int width, int height )
|
||||
{
|
||||
m_Position = position;
|
||||
m_Width = width;
|
||||
m_Height = height;
|
||||
Position = position;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
public bool IsValid()
|
||||
{
|
||||
return m_Position.X >= 0 && m_Position.Y >= 0 && m_Position.X + m_Width <= 670 && m_Position.Y + m_Height <= 670;
|
||||
return Position.X >= 0 && Position.Y >= 0 && Position.X + Width <= 670 && Position.Y + Height <= 670;
|
||||
}
|
||||
|
||||
public bool IsOverlapping( MahjongPieceDim dim )
|
||||
{
|
||||
return m_Position.X < dim.m_Position.X + dim.m_Width && m_Position.Y < dim.m_Position.Y + dim.m_Height && m_Position.X + m_Width > dim.m_Position.X && m_Position.Y + m_Height > dim.m_Position.Y;
|
||||
return Position.X < dim.Position.X + dim.Width && Position.Y < dim.Position.Y + dim.Height && Position.X + Width > dim.Position.X && Position.Y + Height > dim.Position.Y;
|
||||
}
|
||||
|
||||
public int GetHandArea()
|
||||
{
|
||||
if ( m_Position.X + m_Width > 150 && m_Position.X < 520 && m_Position.Y < 35 )
|
||||
if ( Position.X + Width > 150 && Position.X < 520 && Position.Y < 35 )
|
||||
return 0;
|
||||
|
||||
if ( m_Position.X + m_Width > 635 && m_Position.Y + m_Height > 150 && m_Position.Y < 520 )
|
||||
if ( Position.X + Width > 635 && Position.Y + Height > 150 && Position.Y < 520 )
|
||||
return 1;
|
||||
|
||||
if ( m_Position.X + m_Width > 150 && m_Position.X < 520 && m_Position.Y + m_Height > 635 )
|
||||
if ( Position.X + Width > 150 && Position.X < 520 && Position.Y + Height > 635 )
|
||||
return 2;
|
||||
|
||||
if ( m_Position.X < 35 && m_Position.Y + m_Height > 150 && m_Position.Y < 520 )
|
||||
if ( Position.X < 35 && Position.Y + Height > 150 && Position.Y < 520 )
|
||||
return 3;
|
||||
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -4,22 +4,21 @@ namespace Server.Engines.Mahjong
|
|||
{
|
||||
public class MahjongPlayers
|
||||
{
|
||||
private MahjongGame m_Game;
|
||||
private Mobile[] m_Players;
|
||||
private bool[] m_InGame;
|
||||
private bool[] m_PublicHand;
|
||||
private int[] m_Scores;
|
||||
private int m_DealerPosition;
|
||||
private ArrayList m_Spectators;
|
||||
|
||||
public MahjongGame Game => m_Game;
|
||||
public MahjongGame Game { get; }
|
||||
|
||||
public int Seats => m_Players.Length;
|
||||
public Mobile Dealer => m_Players[m_DealerPosition];
|
||||
public int DealerPosition => m_DealerPosition;
|
||||
public Mobile Dealer => m_Players[DealerPosition];
|
||||
public int DealerPosition { get; private set; }
|
||||
|
||||
public MahjongPlayers( MahjongGame game, int maxPlayers, int baseScore )
|
||||
{
|
||||
m_Game = game;
|
||||
Game = game;
|
||||
m_Spectators = new ArrayList();
|
||||
|
||||
m_Players = new Mobile[maxPlayers];
|
||||
|
|
@ -52,7 +51,7 @@ namespace Server.Engines.Mahjong
|
|||
{
|
||||
if ( Dealer != mobile )
|
||||
return false;
|
||||
return m_InGame[m_DealerPosition];
|
||||
return m_InGame[DealerPosition];
|
||||
}
|
||||
|
||||
public bool IsInGamePlayer( int index )
|
||||
|
|
@ -95,7 +94,7 @@ namespace Server.Engines.Mahjong
|
|||
|
||||
m_PublicHand[index] = value;
|
||||
|
||||
SendTilesPacket( true, !m_Game.SpectatorVision );
|
||||
SendTilesPacket( true, !Game.SpectatorVision );
|
||||
|
||||
if ( IsInGamePlayer( index ) )
|
||||
m_Players[index].SendLocalizedMessage( value ? 1062775 : 1062776 ); // Your hand is [not] publicly viewable.
|
||||
|
|
@ -152,11 +151,11 @@ namespace Server.Engines.Mahjong
|
|||
|
||||
removed = true;
|
||||
}
|
||||
else if ( !m_Game.IsAccessibleTo( player ) || player.Map != m_Game.Map || !player.InRange( m_Game.GetWorldLocation(), 5 ) )
|
||||
else if ( !Game.IsAccessibleTo( player ) || player.Map != Game.Map || !player.InRange( Game.GetWorldLocation(), 5 ) )
|
||||
{
|
||||
m_InGame[i] = false;
|
||||
|
||||
player.Send( new MahjongRelieve( m_Game ) );
|
||||
player.Send( new MahjongRelieve( Game ) );
|
||||
|
||||
SendPlayerExitMessage( player );
|
||||
UpdateDealer( true );
|
||||
|
|
@ -175,11 +174,11 @@ namespace Server.Engines.Mahjong
|
|||
{
|
||||
m_Spectators.RemoveAt( i );
|
||||
}
|
||||
else if ( !m_Game.IsAccessibleTo( mobile ) || mobile.Map != m_Game.Map || !mobile.InRange( m_Game.GetWorldLocation(), 5 ) )
|
||||
else if ( !Game.IsAccessibleTo( mobile ) || mobile.Map != Game.Map || !mobile.InRange( Game.GetWorldLocation(), 5 ) )
|
||||
{
|
||||
m_Spectators.RemoveAt( i );
|
||||
|
||||
mobile.Send( new MahjongRelieve( m_Game ) );
|
||||
mobile.Send( new MahjongRelieve( Game ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -193,14 +192,14 @@ namespace Server.Engines.Mahjong
|
|||
|
||||
private void UpdateDealer( bool message )
|
||||
{
|
||||
if ( IsInGamePlayer( m_DealerPosition ) )
|
||||
if ( IsInGamePlayer( DealerPosition ) )
|
||||
return;
|
||||
|
||||
for ( int i = m_DealerPosition + 1; i < m_Players.Length; i++ )
|
||||
for ( int i = DealerPosition + 1; i < m_Players.Length; i++ )
|
||||
{
|
||||
if ( IsInGamePlayer( i ) )
|
||||
{
|
||||
m_DealerPosition = i;
|
||||
DealerPosition = i;
|
||||
|
||||
if ( message )
|
||||
SendDealerChangedMessage();
|
||||
|
|
@ -209,11 +208,11 @@ namespace Server.Engines.Mahjong
|
|||
}
|
||||
}
|
||||
|
||||
for ( int i = 0; i < m_DealerPosition; i++ )
|
||||
for ( int i = 0; i < DealerPosition; i++ )
|
||||
{
|
||||
if ( IsInGamePlayer( i ) )
|
||||
{
|
||||
m_DealerPosition = i;
|
||||
DealerPosition = i;
|
||||
|
||||
if ( message )
|
||||
SendDealerChangedMessage();
|
||||
|
|
@ -225,13 +224,13 @@ namespace Server.Engines.Mahjong
|
|||
|
||||
private int GetNextSeat()
|
||||
{
|
||||
for ( int i = m_DealerPosition; i < m_Players.Length; i++ )
|
||||
for ( int i = DealerPosition; i < m_Players.Length; i++ )
|
||||
{
|
||||
if ( m_Players[i] == null )
|
||||
return i;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < m_DealerPosition; i++ )
|
||||
for ( int i = 0; i < DealerPosition; i++ )
|
||||
{
|
||||
if ( m_Players[i] == null )
|
||||
return i;
|
||||
|
|
@ -271,14 +270,14 @@ namespace Server.Engines.Mahjong
|
|||
UpdateDealer( false );
|
||||
|
||||
if ( sendJoinGame )
|
||||
player.Send( new MahjongJoinGame( m_Game ) );
|
||||
player.Send( new MahjongJoinGame( Game ) );
|
||||
|
||||
SendPlayersPacket( true, true );
|
||||
|
||||
player.Send( new MahjongGeneralInfo( m_Game ) );
|
||||
player.Send( new MahjongTilesInfo( m_Game, player ) );
|
||||
player.Send( new MahjongGeneralInfo( Game ) );
|
||||
player.Send( new MahjongTilesInfo( Game, player ) );
|
||||
|
||||
if ( m_DealerPosition == index )
|
||||
if ( DealerPosition == index )
|
||||
SendLocalizedMessage( 1062773, player.Name ); // ~1_name~ has entered the game as the dealer.
|
||||
else
|
||||
SendLocalizedMessage( 1062772, player.Name ); // ~1_name~ has entered the game as a player.
|
||||
|
|
@ -291,10 +290,10 @@ namespace Server.Engines.Mahjong
|
|||
m_Spectators.Add( mobile );
|
||||
}
|
||||
|
||||
mobile.Send( new MahjongJoinGame( m_Game ) );
|
||||
mobile.Send( new MahjongPlayersInfo( m_Game, mobile ) );
|
||||
mobile.Send( new MahjongGeneralInfo( m_Game ) );
|
||||
mobile.Send( new MahjongTilesInfo( m_Game, mobile ) );
|
||||
mobile.Send( new MahjongJoinGame( Game ) );
|
||||
mobile.Send( new MahjongPlayersInfo( Game, mobile ) );
|
||||
mobile.Send( new MahjongGeneralInfo( Game ) );
|
||||
mobile.Send( new MahjongTilesInfo( Game, mobile ) );
|
||||
}
|
||||
|
||||
public void Join( Mobile mobile )
|
||||
|
|
@ -345,7 +344,7 @@ namespace Server.Engines.Mahjong
|
|||
m_Scores[i] = value;
|
||||
}
|
||||
|
||||
SendPlayersPacket( true, m_Game.ShowScores );
|
||||
SendPlayersPacket( true, Game.ShowScores );
|
||||
|
||||
SendLocalizedMessage( 1062697 ); // The dealer redistributes the score sticks evenly.
|
||||
}
|
||||
|
|
@ -361,14 +360,14 @@ namespace Server.Engines.Mahjong
|
|||
m_Scores[fromPosition] -= amount;
|
||||
m_Scores[toPosition] += amount;
|
||||
|
||||
if ( m_Game.ShowScores )
|
||||
if ( Game.ShowScores )
|
||||
{
|
||||
SendPlayersPacket( true, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.Send( new MahjongPlayersInfo( m_Game, from ) );
|
||||
to.Send( new MahjongPlayersInfo( m_Game, to ) );
|
||||
from.Send( new MahjongPlayersInfo( Game, from ) );
|
||||
to.Send( new MahjongPlayersInfo( Game, to ) );
|
||||
}
|
||||
|
||||
SendLocalizedMessage( 1062774, $"{from.Name}\t{to.Name}\t{amount}"); // ~1_giver~ gives ~2_receiver~ ~3_number~ points.
|
||||
|
|
@ -381,7 +380,7 @@ namespace Server.Engines.Mahjong
|
|||
return;
|
||||
|
||||
if ( m_InGame[index] )
|
||||
player.Send( new MahjongRelieve( m_Game ) );
|
||||
player.Send( new MahjongRelieve( Game ) );
|
||||
|
||||
m_Players[index] = null;
|
||||
|
||||
|
|
@ -400,14 +399,14 @@ namespace Server.Engines.Mahjong
|
|||
if ( to == null || !m_InGame[index] )
|
||||
return;
|
||||
|
||||
int oldDealer = m_DealerPosition;
|
||||
int oldDealer = DealerPosition;
|
||||
|
||||
m_DealerPosition = index;
|
||||
DealerPosition = index;
|
||||
|
||||
if ( IsInGamePlayer( oldDealer ) )
|
||||
m_Players[oldDealer].Send( new MahjongPlayersInfo( m_Game, m_Players[oldDealer] ) );
|
||||
m_Players[oldDealer].Send( new MahjongPlayersInfo( Game, m_Players[oldDealer] ) );
|
||||
|
||||
to.Send( new MahjongPlayersInfo( m_Game, to ) );
|
||||
to.Send( new MahjongPlayersInfo( Game, to ) );
|
||||
|
||||
SendDealerChangedMessage();
|
||||
}
|
||||
|
|
@ -427,7 +426,7 @@ namespace Server.Engines.Mahjong
|
|||
{
|
||||
foreach ( Mobile mobile in GetInGameMobiles( players, spectators ) )
|
||||
{
|
||||
mobile.Send( new MahjongPlayersInfo( m_Game, mobile ) );
|
||||
mobile.Send( new MahjongPlayersInfo( Game, mobile ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -438,7 +437,7 @@ namespace Server.Engines.Mahjong
|
|||
if ( mobiles.Count == 0 )
|
||||
return;
|
||||
|
||||
MahjongGeneralInfo generalInfo = new MahjongGeneralInfo( m_Game );
|
||||
MahjongGeneralInfo generalInfo = new MahjongGeneralInfo( Game );
|
||||
|
||||
generalInfo.Acquire();
|
||||
|
||||
|
|
@ -454,7 +453,7 @@ namespace Server.Engines.Mahjong
|
|||
{
|
||||
foreach ( Mobile mobile in GetInGameMobiles( players, spectators ) )
|
||||
{
|
||||
mobile.Send( new MahjongTilesInfo( m_Game, mobile ) );
|
||||
mobile.Send( new MahjongTilesInfo( Game, mobile ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -473,7 +472,7 @@ namespace Server.Engines.Mahjong
|
|||
if ( mobiles.Count == 0 )
|
||||
return;
|
||||
|
||||
MahjongRelieve relieve = new MahjongRelieve( m_Game );
|
||||
MahjongRelieve relieve = new MahjongRelieve( Game );
|
||||
|
||||
relieve.Acquire();
|
||||
|
||||
|
|
@ -514,12 +513,12 @@ namespace Server.Engines.Mahjong
|
|||
writer.Write( m_Scores[i] );
|
||||
}
|
||||
|
||||
writer.Write( m_DealerPosition );
|
||||
writer.Write( DealerPosition );
|
||||
}
|
||||
|
||||
public MahjongPlayers( MahjongGame game, GenericReader reader )
|
||||
{
|
||||
m_Game = game;
|
||||
Game = game;
|
||||
m_Spectators = new ArrayList();
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
|
@ -537,7 +536,7 @@ namespace Server.Engines.Mahjong
|
|||
m_Scores[i] = reader.ReadInt();
|
||||
}
|
||||
|
||||
m_DealerPosition = reader.ReadInt();
|
||||
DealerPosition = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,36 +9,35 @@ namespace Server.Engines.Mahjong
|
|||
return new MahjongPieceDim( position, 30, 20 );
|
||||
}
|
||||
|
||||
private MahjongGame m_Game;
|
||||
private int m_Number;
|
||||
private MahjongTileType m_Value;
|
||||
protected Point2D m_Position;
|
||||
private int m_StackLevel;
|
||||
private MahjongPieceDirection m_Direction;
|
||||
private bool m_Flipped;
|
||||
|
||||
public MahjongGame Game => m_Game;
|
||||
public int Number => m_Number;
|
||||
public MahjongTileType Value => m_Value;
|
||||
public MahjongGame Game { get; }
|
||||
|
||||
public int Number { get; }
|
||||
|
||||
public MahjongTileType Value { get; }
|
||||
|
||||
public Point2D Position => m_Position;
|
||||
public int StackLevel => m_StackLevel;
|
||||
public MahjongPieceDirection Direction => m_Direction;
|
||||
public bool Flipped => m_Flipped;
|
||||
public int StackLevel { get; private set; }
|
||||
|
||||
public MahjongPieceDirection Direction { get; private set; }
|
||||
|
||||
public bool Flipped { get; private set; }
|
||||
|
||||
public MahjongTile( MahjongGame game, int number, MahjongTileType value, Point2D position, int stackLevel, MahjongPieceDirection direction, bool flipped )
|
||||
{
|
||||
m_Game = game;
|
||||
m_Number = number;
|
||||
m_Value = value;
|
||||
Game = game;
|
||||
Number = number;
|
||||
Value = value;
|
||||
m_Position = position;
|
||||
m_StackLevel = stackLevel;
|
||||
m_Direction = direction;
|
||||
m_Flipped = flipped;
|
||||
StackLevel = stackLevel;
|
||||
Direction = direction;
|
||||
Flipped = flipped;
|
||||
}
|
||||
|
||||
public MahjongPieceDim Dimensions => GetDimensions( m_Position, m_Direction );
|
||||
public MahjongPieceDim Dimensions => GetDimensions( m_Position, Direction );
|
||||
|
||||
public bool IsMovable => m_Game.GetStackLevel( Dimensions ) <= m_StackLevel;
|
||||
public bool IsMovable => Game.GetStackLevel( Dimensions ) <= StackLevel;
|
||||
|
||||
public void Move( Point2D position, MahjongPieceDirection direction, bool flip, int validHandArea )
|
||||
{
|
||||
|
|
@ -50,38 +49,38 @@ namespace Server.Engines.Mahjong
|
|||
return;
|
||||
|
||||
m_Position = position;
|
||||
m_Direction = direction;
|
||||
m_StackLevel = -1; // Avoid self interference
|
||||
m_StackLevel = m_Game.GetStackLevel( dim ) + 1;
|
||||
m_Flipped = flip;
|
||||
Direction = direction;
|
||||
StackLevel = -1; // Avoid self interference
|
||||
StackLevel = Game.GetStackLevel( dim ) + 1;
|
||||
Flipped = flip;
|
||||
|
||||
m_Game.Players.SendTilePacket( this, true, true );
|
||||
Game.Players.SendTilePacket( this, true, true );
|
||||
}
|
||||
|
||||
public void Save( GenericWriter writer )
|
||||
{
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
writer.Write( m_Number );
|
||||
writer.Write( (int) m_Value );
|
||||
writer.Write( Number );
|
||||
writer.Write( (int) Value );
|
||||
writer.Write( m_Position );
|
||||
writer.Write( m_StackLevel );
|
||||
writer.Write( (int) m_Direction );
|
||||
writer.Write( m_Flipped );
|
||||
writer.Write( StackLevel );
|
||||
writer.Write( (int) Direction );
|
||||
writer.Write( Flipped );
|
||||
}
|
||||
|
||||
public MahjongTile( MahjongGame game, GenericReader reader )
|
||||
{
|
||||
m_Game = game;
|
||||
Game = game;
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_Number = reader.ReadInt();
|
||||
m_Value = (MahjongTileType) reader.ReadInt();
|
||||
Number = reader.ReadInt();
|
||||
Value = (MahjongTileType) reader.ReadInt();
|
||||
m_Position = reader.ReadPoint2D();
|
||||
m_StackLevel = reader.ReadInt();
|
||||
m_Direction = (MahjongPieceDirection) reader.ReadInt();
|
||||
m_Flipped = reader.ReadBool();
|
||||
StackLevel = reader.ReadInt();
|
||||
Direction = (MahjongPieceDirection) reader.ReadInt();
|
||||
Flipped = reader.ReadBool();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,28 +4,26 @@ namespace Server.Engines.Mahjong
|
|||
{
|
||||
public class MahjongTileTypeGenerator
|
||||
{
|
||||
private ArrayList m_LeftTileTypes;
|
||||
|
||||
public ArrayList LeftTileTypes => m_LeftTileTypes;
|
||||
public ArrayList LeftTileTypes { get; }
|
||||
|
||||
public MahjongTileTypeGenerator( int count )
|
||||
{
|
||||
m_LeftTileTypes = new ArrayList( 34 * count );
|
||||
LeftTileTypes = new ArrayList( 34 * count );
|
||||
|
||||
for ( int i = 1; i <= 34; i++ )
|
||||
{
|
||||
for ( int j = 0; j < count; j++ )
|
||||
{
|
||||
m_LeftTileTypes.Add( (MahjongTileType)i );
|
||||
LeftTileTypes.Add( (MahjongTileType)i );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MahjongTileType Next()
|
||||
{
|
||||
int random = Utility.Random( m_LeftTileTypes.Count );
|
||||
MahjongTileType next = (MahjongTileType)m_LeftTileTypes[random];
|
||||
m_LeftTileTypes.RemoveAt( random );
|
||||
int random = Utility.Random( LeftTileTypes.Count );
|
||||
MahjongTileType next = (MahjongTileType)LeftTileTypes[random];
|
||||
LeftTileTypes.RemoveAt( random );
|
||||
|
||||
return next;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,19 +7,17 @@ namespace Server.Engines.Mahjong
|
|||
return new MahjongPieceDim( position, 20, 20 );
|
||||
}
|
||||
|
||||
private MahjongGame m_Game;
|
||||
private Point2D m_Position;
|
||||
public MahjongGame Game { get; }
|
||||
|
||||
public MahjongGame Game => m_Game;
|
||||
public Point2D Position => m_Position;
|
||||
public Point2D Position { get; private set; }
|
||||
|
||||
public MahjongWallBreakIndicator( MahjongGame game, Point2D position )
|
||||
{
|
||||
m_Game = game;
|
||||
m_Position = position;
|
||||
Game = game;
|
||||
Position = position;
|
||||
}
|
||||
|
||||
public MahjongPieceDim Dimensions => GetDimensions( m_Position );
|
||||
public MahjongPieceDim Dimensions => GetDimensions( Position );
|
||||
|
||||
public void Move( Point2D position )
|
||||
{
|
||||
|
|
@ -28,25 +26,25 @@ namespace Server.Engines.Mahjong
|
|||
if ( !dim.IsValid() )
|
||||
return;
|
||||
|
||||
m_Position = position;
|
||||
Position = position;
|
||||
|
||||
m_Game.Players.SendGeneralPacket( true, true );
|
||||
Game.Players.SendGeneralPacket( true, true );
|
||||
}
|
||||
|
||||
public void Save( GenericWriter writer )
|
||||
{
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
writer.Write( m_Position );
|
||||
writer.Write( Position );
|
||||
}
|
||||
|
||||
public MahjongWallBreakIndicator( MahjongGame game, GenericReader reader )
|
||||
{
|
||||
m_Game = game;
|
||||
Game = game;
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_Position = reader.ReadPoint2D();
|
||||
Position = reader.ReadPoint2D();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue