Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -1,86 +1,88 @@
|
|||
namespace Server.Engines.Mahjong
|
||||
{
|
||||
public class MahjongTile
|
||||
{
|
||||
public static MahjongPieceDim GetDimensions( Point2D position, MahjongPieceDirection direction )
|
||||
{
|
||||
if ( direction == MahjongPieceDirection.Up || direction == MahjongPieceDirection.Down )
|
||||
return new MahjongPieceDim( position, 20, 30 );
|
||||
return new MahjongPieceDim( position, 30, 20 );
|
||||
}
|
||||
public class MahjongTile
|
||||
{
|
||||
protected Point2D m_Position;
|
||||
|
||||
protected Point2D m_Position;
|
||||
public MahjongTile(MahjongGame game, int number, MahjongTileType value, Point2D position, int stackLevel,
|
||||
MahjongPieceDirection direction, bool flipped)
|
||||
{
|
||||
Game = game;
|
||||
Number = number;
|
||||
Value = value;
|
||||
m_Position = position;
|
||||
StackLevel = stackLevel;
|
||||
Direction = direction;
|
||||
Flipped = flipped;
|
||||
}
|
||||
|
||||
public MahjongGame Game { get; }
|
||||
public MahjongTile(MahjongGame game, GenericReader reader)
|
||||
{
|
||||
Game = game;
|
||||
|
||||
public int Number { get; }
|
||||
int version = reader.ReadInt();
|
||||
|
||||
public MahjongTileType Value { get; }
|
||||
Number = reader.ReadInt();
|
||||
Value = (MahjongTileType)reader.ReadInt();
|
||||
m_Position = reader.ReadPoint2D();
|
||||
StackLevel = reader.ReadInt();
|
||||
Direction = (MahjongPieceDirection)reader.ReadInt();
|
||||
Flipped = reader.ReadBool();
|
||||
}
|
||||
|
||||
public Point2D Position => m_Position;
|
||||
public int StackLevel { get; private set; }
|
||||
public MahjongGame Game{ get; }
|
||||
|
||||
public MahjongPieceDirection Direction { get; private set; }
|
||||
public int Number{ get; }
|
||||
|
||||
public bool Flipped { get; private set; }
|
||||
public MahjongTileType Value{ get; }
|
||||
|
||||
public MahjongTile( MahjongGame game, int number, MahjongTileType value, Point2D position, int stackLevel, MahjongPieceDirection direction, bool flipped )
|
||||
{
|
||||
Game = game;
|
||||
Number = number;
|
||||
Value = value;
|
||||
m_Position = position;
|
||||
StackLevel = stackLevel;
|
||||
Direction = direction;
|
||||
Flipped = flipped;
|
||||
}
|
||||
public Point2D Position => m_Position;
|
||||
public int StackLevel{ get; private set; }
|
||||
|
||||
public MahjongPieceDim Dimensions => GetDimensions( m_Position, Direction );
|
||||
public MahjongPieceDirection Direction{ get; private set; }
|
||||
|
||||
public bool IsMovable => Game.GetStackLevel( Dimensions ) <= StackLevel;
|
||||
public bool Flipped{ get; private set; }
|
||||
|
||||
public void Move( Point2D position, MahjongPieceDirection direction, bool flip, int validHandArea )
|
||||
{
|
||||
MahjongPieceDim dim = GetDimensions( position, direction );
|
||||
int curHandArea = Dimensions.GetHandArea();
|
||||
int newHandArea = dim.GetHandArea();
|
||||
public MahjongPieceDim Dimensions => GetDimensions(m_Position, Direction);
|
||||
|
||||
if ( !IsMovable || !dim.IsValid() || ( validHandArea >= 0 && ((curHandArea >= 0 && curHandArea != validHandArea) || (newHandArea >= 0 && newHandArea != validHandArea)) ) )
|
||||
return;
|
||||
public bool IsMovable => Game.GetStackLevel(Dimensions) <= StackLevel;
|
||||
|
||||
m_Position = position;
|
||||
Direction = direction;
|
||||
StackLevel = -1; // Avoid self interference
|
||||
StackLevel = Game.GetStackLevel( dim ) + 1;
|
||||
Flipped = flip;
|
||||
public static MahjongPieceDim GetDimensions(Point2D position, MahjongPieceDirection direction)
|
||||
{
|
||||
if (direction == MahjongPieceDirection.Up || direction == MahjongPieceDirection.Down)
|
||||
return new MahjongPieceDim(position, 20, 30);
|
||||
return new MahjongPieceDim(position, 30, 20);
|
||||
}
|
||||
|
||||
Game.Players.SendTilePacket( this, true, true );
|
||||
}
|
||||
public void Move(Point2D position, MahjongPieceDirection direction, bool flip, int validHandArea)
|
||||
{
|
||||
MahjongPieceDim dim = GetDimensions(position, direction);
|
||||
int curHandArea = Dimensions.GetHandArea();
|
||||
int newHandArea = dim.GetHandArea();
|
||||
|
||||
public void Save( GenericWriter writer )
|
||||
{
|
||||
writer.Write( (int) 0 ); // version
|
||||
if (!IsMovable || !dim.IsValid() || validHandArea >= 0 &&
|
||||
(curHandArea >= 0 && curHandArea != validHandArea || newHandArea >= 0 && newHandArea != validHandArea))
|
||||
return;
|
||||
|
||||
writer.Write( Number );
|
||||
writer.Write( (int) Value );
|
||||
writer.Write( m_Position );
|
||||
writer.Write( StackLevel );
|
||||
writer.Write( (int) Direction );
|
||||
writer.Write( Flipped );
|
||||
}
|
||||
m_Position = position;
|
||||
Direction = direction;
|
||||
StackLevel = -1; // Avoid self interference
|
||||
StackLevel = Game.GetStackLevel(dim) + 1;
|
||||
Flipped = flip;
|
||||
|
||||
public MahjongTile( MahjongGame game, GenericReader reader )
|
||||
{
|
||||
Game = game;
|
||||
Game.Players.SendTilePacket(this, true, true);
|
||||
}
|
||||
|
||||
int version = reader.ReadInt();
|
||||
public void Save(GenericWriter writer)
|
||||
{
|
||||
writer.Write(0); // version
|
||||
|
||||
Number = reader.ReadInt();
|
||||
Value = (MahjongTileType) reader.ReadInt();
|
||||
m_Position = reader.ReadPoint2D();
|
||||
StackLevel = reader.ReadInt();
|
||||
Direction = (MahjongPieceDirection) reader.ReadInt();
|
||||
Flipped = reader.ReadBool();
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.Write(Number);
|
||||
writer.Write((int)Value);
|
||||
writer.Write(m_Position);
|
||||
writer.Write(StackLevel);
|
||||
writer.Write((int)Direction);
|
||||
writer.Write(Flipped);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue