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,64 +1,64 @@
|
|||
namespace Server.Engines.Mahjong
|
||||
{
|
||||
public class MahjongDealerIndicator
|
||||
{
|
||||
public static MahjongPieceDim GetDimensions( Point2D position, MahjongPieceDirection direction )
|
||||
{
|
||||
if ( direction == MahjongPieceDirection.Up || direction == MahjongPieceDirection.Down )
|
||||
return new MahjongPieceDim( position, 40, 20 );
|
||||
return new MahjongPieceDim( position, 20, 40 );
|
||||
}
|
||||
public class MahjongDealerIndicator
|
||||
{
|
||||
public MahjongDealerIndicator(MahjongGame game, Point2D position, MahjongPieceDirection direction, MahjongWind wind)
|
||||
{
|
||||
Game = game;
|
||||
Position = position;
|
||||
Direction = direction;
|
||||
Wind = wind;
|
||||
}
|
||||
|
||||
public MahjongGame Game { get; }
|
||||
public MahjongDealerIndicator(MahjongGame game, GenericReader reader)
|
||||
{
|
||||
Game = game;
|
||||
|
||||
public Point2D Position { get; private set; }
|
||||
int version = reader.ReadInt();
|
||||
|
||||
public MahjongPieceDirection Direction { get; private set; }
|
||||
Position = reader.ReadPoint2D();
|
||||
Direction = (MahjongPieceDirection)reader.ReadInt();
|
||||
Wind = (MahjongWind)reader.ReadInt();
|
||||
}
|
||||
|
||||
public MahjongWind Wind { get; private set; }
|
||||
public MahjongGame Game{ get; }
|
||||
|
||||
public MahjongDealerIndicator( MahjongGame game, Point2D position, MahjongPieceDirection direction, MahjongWind wind )
|
||||
{
|
||||
Game = game;
|
||||
Position = position;
|
||||
Direction = direction;
|
||||
Wind = wind;
|
||||
}
|
||||
public Point2D Position{ get; private set; }
|
||||
|
||||
public MahjongPieceDim Dimensions => GetDimensions( Position, Direction );
|
||||
public MahjongPieceDirection Direction{ get; private set; }
|
||||
|
||||
public void Move( Point2D position, MahjongPieceDirection direction, MahjongWind wind )
|
||||
{
|
||||
MahjongPieceDim dim = GetDimensions( position, direction );
|
||||
public MahjongWind Wind{ get; private set; }
|
||||
|
||||
if ( !dim.IsValid() )
|
||||
return;
|
||||
public MahjongPieceDim Dimensions => GetDimensions(Position, Direction);
|
||||
|
||||
Position = position;
|
||||
Direction = direction;
|
||||
Wind = wind;
|
||||
public static MahjongPieceDim GetDimensions(Point2D position, MahjongPieceDirection direction)
|
||||
{
|
||||
if (direction == MahjongPieceDirection.Up || direction == MahjongPieceDirection.Down)
|
||||
return new MahjongPieceDim(position, 40, 20);
|
||||
return new MahjongPieceDim(position, 20, 40);
|
||||
}
|
||||
|
||||
Game.Players.SendGeneralPacket( true, true );
|
||||
}
|
||||
public void Move(Point2D position, MahjongPieceDirection direction, MahjongWind wind)
|
||||
{
|
||||
MahjongPieceDim dim = GetDimensions(position, direction);
|
||||
|
||||
public void Save( GenericWriter writer )
|
||||
{
|
||||
writer.Write( (int) 0 ); // version
|
||||
if (!dim.IsValid())
|
||||
return;
|
||||
|
||||
writer.Write( Position );
|
||||
writer.Write( (int) Direction );
|
||||
writer.Write( (int) Wind );
|
||||
}
|
||||
Position = position;
|
||||
Direction = direction;
|
||||
Wind = wind;
|
||||
|
||||
public MahjongDealerIndicator( MahjongGame game, GenericReader reader )
|
||||
{
|
||||
Game = game;
|
||||
Game.Players.SendGeneralPacket(true, true);
|
||||
}
|
||||
|
||||
int version = reader.ReadInt();
|
||||
public void Save(GenericWriter writer)
|
||||
{
|
||||
writer.Write(0); // version
|
||||
|
||||
Position = reader.ReadPoint2D();
|
||||
Direction = (MahjongPieceDirection) reader.ReadInt();
|
||||
Wind = (MahjongWind) reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.Write(Position);
|
||||
writer.Write((int)Direction);
|
||||
writer.Write((int)Wind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,47 +1,48 @@
|
|||
namespace Server.Engines.Mahjong
|
||||
{
|
||||
public class MahjongDices
|
||||
{
|
||||
public MahjongGame Game { get; }
|
||||
public class MahjongDices
|
||||
{
|
||||
public MahjongDices(MahjongGame game)
|
||||
{
|
||||
Game = game;
|
||||
First = Utility.Random(1, 6);
|
||||
Second = Utility.Random(1, 6);
|
||||
}
|
||||
|
||||
public int First { get; private set; }
|
||||
public MahjongDices(MahjongGame game, GenericReader reader)
|
||||
{
|
||||
Game = game;
|
||||
|
||||
public int Second { get; private set; }
|
||||
int version = reader.ReadInt();
|
||||
|
||||
public MahjongDices( MahjongGame game )
|
||||
{
|
||||
Game = game;
|
||||
First = Utility.Random( 1, 6 );
|
||||
Second = Utility.Random( 1, 6 );
|
||||
}
|
||||
First = reader.ReadInt();
|
||||
Second = reader.ReadInt();
|
||||
}
|
||||
|
||||
public void RollDices( Mobile from )
|
||||
{
|
||||
First = Utility.Random( 1, 6 );
|
||||
Second = Utility.Random( 1, 6 );
|
||||
public MahjongGame Game{ get; }
|
||||
|
||||
Game.Players.SendGeneralPacket( true, true );
|
||||
public int First{ get; private set; }
|
||||
|
||||
if ( from != null )
|
||||
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 int Second{ get; private set; }
|
||||
|
||||
public void Save( GenericWriter writer )
|
||||
{
|
||||
writer.Write( (int) 0 ); // version
|
||||
public void RollDices(Mobile from)
|
||||
{
|
||||
First = Utility.Random(1, 6);
|
||||
Second = Utility.Random(1, 6);
|
||||
|
||||
writer.Write( First );
|
||||
writer.Write( Second );
|
||||
}
|
||||
Game.Players.SendGeneralPacket(true, true);
|
||||
|
||||
public MahjongDices( MahjongGame game, GenericReader reader )
|
||||
{
|
||||
Game = game;
|
||||
if (from != null)
|
||||
Game.Players.SendLocalizedMessage(1062695,
|
||||
$"{from.Name}\t{First}\t{Second}"); // ~1_name~ rolls the dice and gets a ~2_number~ and a ~3_number~!
|
||||
}
|
||||
|
||||
int version = reader.ReadInt();
|
||||
public void Save(GenericWriter writer)
|
||||
{
|
||||
writer.Write(0); // version
|
||||
|
||||
First = reader.ReadInt();
|
||||
Second = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.Write(First);
|
||||
writer.Write(Second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +1,56 @@
|
|||
namespace Server.Engines.Mahjong
|
||||
{
|
||||
public enum MahjongPieceDirection
|
||||
{
|
||||
Up,
|
||||
Left,
|
||||
Down,
|
||||
Right
|
||||
}
|
||||
public enum MahjongPieceDirection
|
||||
{
|
||||
Up,
|
||||
Left,
|
||||
Down,
|
||||
Right
|
||||
}
|
||||
|
||||
public enum MahjongWind
|
||||
{
|
||||
North,
|
||||
East,
|
||||
South,
|
||||
West
|
||||
}
|
||||
public enum MahjongWind
|
||||
{
|
||||
North,
|
||||
East,
|
||||
South,
|
||||
West
|
||||
}
|
||||
|
||||
public enum MahjongTileType
|
||||
{
|
||||
Dagger1 = 1,
|
||||
Dagger2,
|
||||
Dagger3,
|
||||
Dagger4,
|
||||
Dagger5,
|
||||
Dagger6,
|
||||
Dagger7,
|
||||
Dagger8,
|
||||
Dagger9,
|
||||
Gem1,
|
||||
Gem2,
|
||||
Gem3,
|
||||
Gem4,
|
||||
Gem5,
|
||||
Gem6,
|
||||
Gem7,
|
||||
Gem8,
|
||||
Gem9,
|
||||
Number1,
|
||||
Number2,
|
||||
Number3,
|
||||
Number4,
|
||||
Number5,
|
||||
Number6,
|
||||
Number7,
|
||||
Number8,
|
||||
Number9,
|
||||
North,
|
||||
East,
|
||||
South,
|
||||
West,
|
||||
Green,
|
||||
Red,
|
||||
White
|
||||
}
|
||||
public enum MahjongTileType
|
||||
{
|
||||
Dagger1 = 1,
|
||||
Dagger2,
|
||||
Dagger3,
|
||||
Dagger4,
|
||||
Dagger5,
|
||||
Dagger6,
|
||||
Dagger7,
|
||||
Dagger8,
|
||||
Dagger9,
|
||||
Gem1,
|
||||
Gem2,
|
||||
Gem3,
|
||||
Gem4,
|
||||
Gem5,
|
||||
Gem6,
|
||||
Gem7,
|
||||
Gem8,
|
||||
Gem9,
|
||||
Number1,
|
||||
Number2,
|
||||
Number3,
|
||||
Number4,
|
||||
Number5,
|
||||
Number6,
|
||||
Number7,
|
||||
Number8,
|
||||
Number9,
|
||||
North,
|
||||
East,
|
||||
South,
|
||||
West,
|
||||
Green,
|
||||
Red,
|
||||
White
|
||||
}
|
||||
}
|
||||
|
|
@ -1,293 +1,298 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.ContextMenus;
|
||||
using Server.Gumps;
|
||||
using Server.Multis;
|
||||
using Server.ContextMenus;
|
||||
|
||||
namespace Server.Engines.Mahjong
|
||||
{
|
||||
public class MahjongGame : Item, ISecurable
|
||||
{
|
||||
public const int MaxPlayers = 4;
|
||||
public const int BaseScore = 30000;
|
||||
public class MahjongGame : Item, ISecurable
|
||||
{
|
||||
public const int MaxPlayers = 4;
|
||||
public const int BaseScore = 30000;
|
||||
private DateTime m_LastReset;
|
||||
|
||||
private bool m_ShowScores;
|
||||
private bool m_SpectatorVision;
|
||||
|
||||
[Constructible]
|
||||
public MahjongGame() : base(0xFAA)
|
||||
{
|
||||
Weight = 5.0;
|
||||
|
||||
BuildWalls();
|
||||
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;
|
||||
Level = SecureLevel.CoOwners;
|
||||
}
|
||||
|
||||
private bool m_ShowScores;
|
||||
private bool m_SpectatorVision;
|
||||
private DateTime m_LastReset;
|
||||
public MahjongGame(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public MahjongTile[] Tiles { get; private set; }
|
||||
public MahjongTile[] Tiles{ get; private set; }
|
||||
|
||||
public MahjongDealerIndicator DealerIndicator { get; private set; }
|
||||
public MahjongDealerIndicator DealerIndicator{ get; private set; }
|
||||
|
||||
public MahjongWallBreakIndicator WallBreakIndicator { get; private set; }
|
||||
public MahjongWallBreakIndicator WallBreakIndicator{ get; private set; }
|
||||
|
||||
public MahjongDices Dices { get; private set; }
|
||||
public MahjongDices Dices{ get; private set; }
|
||||
|
||||
public MahjongPlayers Players { get; private set; }
|
||||
public MahjongPlayers Players{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public SecureLevel Level { get; set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool ShowScores
|
||||
{
|
||||
get => m_ShowScores;
|
||||
set
|
||||
{
|
||||
if (m_ShowScores == value)
|
||||
return;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool ShowScores
|
||||
{
|
||||
get => m_ShowScores;
|
||||
set
|
||||
{
|
||||
if ( m_ShowScores == value )
|
||||
return;
|
||||
m_ShowScores = value;
|
||||
|
||||
m_ShowScores = value;
|
||||
if (value)
|
||||
Players.SendPlayersPacket(true, true);
|
||||
|
||||
if ( value )
|
||||
Players.SendPlayersPacket( true, true );
|
||||
Players.SendGeneralPacket(true, true);
|
||||
|
||||
Players.SendGeneralPacket( true, true );
|
||||
Players.SendLocalizedMessage(value ? 1062777 : 1062778); // The dealer has enabled/disabled score display.
|
||||
}
|
||||
}
|
||||
|
||||
Players.SendLocalizedMessage( value ? 1062777 : 1062778 ); // The dealer has enabled/disabled score display.
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool SpectatorVision
|
||||
{
|
||||
get => m_SpectatorVision;
|
||||
set
|
||||
{
|
||||
if (m_SpectatorVision == value)
|
||||
return;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool SpectatorVision
|
||||
{
|
||||
get => m_SpectatorVision;
|
||||
set
|
||||
{
|
||||
if ( m_SpectatorVision == value )
|
||||
return;
|
||||
m_SpectatorVision = value;
|
||||
|
||||
m_SpectatorVision = value;
|
||||
if (Players.IsInGamePlayer(Players.DealerPosition))
|
||||
Players.Dealer.Send(new MahjongGeneralInfo(this));
|
||||
|
||||
if ( Players.IsInGamePlayer( Players.DealerPosition ) )
|
||||
Players.Dealer.Send( new MahjongGeneralInfo( this ) );
|
||||
Players.SendTilesPacket(false, true);
|
||||
|
||||
Players.SendTilesPacket( false, true );
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public SecureLevel Level{ get; set; }
|
||||
|
||||
[Constructible]
|
||||
public MahjongGame() : base( 0xFAA )
|
||||
{
|
||||
Weight = 5.0;
|
||||
private void BuildHorizontalWall(ref int index, int x, int y, int stackLevel, MahjongPieceDirection direction,
|
||||
MahjongTileTypeGenerator typeGenerator)
|
||||
{
|
||||
for (int i = 0; i < 17; i++)
|
||||
{
|
||||
Point2D position = new Point2D(x + i * 20, y);
|
||||
Tiles[index + i] = new MahjongTile(this, index + i, typeGenerator.Next(), position, stackLevel, direction,
|
||||
false);
|
||||
}
|
||||
|
||||
BuildWalls();
|
||||
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;
|
||||
Level = SecureLevel.CoOwners;
|
||||
}
|
||||
index += 17;
|
||||
}
|
||||
|
||||
public MahjongGame( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
private void BuildVerticalWall(ref int index, int x, int y, int stackLevel, MahjongPieceDirection direction,
|
||||
MahjongTileTypeGenerator typeGenerator)
|
||||
{
|
||||
for (int i = 0; i < 17; i++)
|
||||
{
|
||||
Point2D position = new Point2D(x, y + i * 20);
|
||||
Tiles[index + i] = new MahjongTile(this, index + i, typeGenerator.Next(), position, stackLevel, direction,
|
||||
false);
|
||||
}
|
||||
|
||||
private void BuildHorizontalWall( ref int index, int x, int y, int stackLevel, MahjongPieceDirection direction, MahjongTileTypeGenerator typeGenerator )
|
||||
{
|
||||
for ( int i = 0; i < 17; i++ )
|
||||
{
|
||||
Point2D position = new Point2D( x + i*20, y );
|
||||
Tiles[index + i] = new MahjongTile( this, index + i, typeGenerator.Next(), position, stackLevel, direction, false );
|
||||
}
|
||||
index += 17;
|
||||
}
|
||||
|
||||
index += 17;
|
||||
}
|
||||
private void BuildWalls()
|
||||
{
|
||||
Tiles = new MahjongTile[17 * 8];
|
||||
|
||||
private void BuildVerticalWall( ref int index, int x, int y, int stackLevel, MahjongPieceDirection direction, MahjongTileTypeGenerator typeGenerator )
|
||||
{
|
||||
for ( int i = 0; i < 17; i++ )
|
||||
{
|
||||
Point2D position = new Point2D( x, y + i*20 );
|
||||
Tiles[index + i] = new MahjongTile( this, index + i, typeGenerator.Next(), position, stackLevel, direction, false );
|
||||
}
|
||||
MahjongTileTypeGenerator typeGenerator = new MahjongTileTypeGenerator(4);
|
||||
|
||||
index += 17;
|
||||
}
|
||||
int i = 0;
|
||||
|
||||
private void BuildWalls()
|
||||
{
|
||||
Tiles = new MahjongTile[17 * 8];
|
||||
BuildHorizontalWall(ref i, 165, 110, 0, MahjongPieceDirection.Up, typeGenerator);
|
||||
BuildHorizontalWall(ref i, 165, 115, 1, MahjongPieceDirection.Up, typeGenerator);
|
||||
|
||||
MahjongTileTypeGenerator typeGenerator = new MahjongTileTypeGenerator( 4 );
|
||||
BuildVerticalWall(ref i, 530, 165, 0, MahjongPieceDirection.Left, typeGenerator);
|
||||
BuildVerticalWall(ref i, 525, 165, 1, MahjongPieceDirection.Left, typeGenerator);
|
||||
|
||||
int i = 0;
|
||||
BuildHorizontalWall(ref i, 165, 530, 0, MahjongPieceDirection.Down, typeGenerator);
|
||||
BuildHorizontalWall(ref i, 165, 525, 1, MahjongPieceDirection.Down, typeGenerator);
|
||||
|
||||
BuildHorizontalWall( ref i, 165, 110, 0, MahjongPieceDirection.Up, typeGenerator );
|
||||
BuildHorizontalWall( ref i, 165, 115, 1, MahjongPieceDirection.Up, typeGenerator );
|
||||
BuildVerticalWall(ref i, 110, 165, 0, MahjongPieceDirection.Right, typeGenerator);
|
||||
BuildVerticalWall(ref i, 115, 165, 1, MahjongPieceDirection.Right, typeGenerator);
|
||||
}
|
||||
|
||||
BuildVerticalWall( ref i, 530, 165, 0, MahjongPieceDirection.Left, typeGenerator );
|
||||
BuildVerticalWall( ref i, 525, 165, 1, MahjongPieceDirection.Left, typeGenerator );
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
BuildHorizontalWall( ref i, 165, 530, 0, MahjongPieceDirection.Down, typeGenerator );
|
||||
BuildHorizontalWall( ref i, 165, 525, 1, MahjongPieceDirection.Down, typeGenerator );
|
||||
if (m_SpectatorVision)
|
||||
list.Add(1062717); // Spectator Vision Enabled
|
||||
else
|
||||
list.Add(1062718); // Spectator Vision Disabled
|
||||
}
|
||||
|
||||
BuildVerticalWall( ref i, 110, 165, 0, MahjongPieceDirection.Right, typeGenerator );
|
||||
BuildVerticalWall( ref i, 115, 165, 1, MahjongPieceDirection.Right, typeGenerator );
|
||||
}
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
Players.CheckPlayers();
|
||||
|
||||
if ( m_SpectatorVision )
|
||||
list.Add( 1062717 ); // Spectator Vision Enabled
|
||||
else
|
||||
list.Add( 1062718 ); // Spectator Vision Disabled
|
||||
}
|
||||
if (from.Alive && IsAccessibleTo(from) && Players.GetInGameMobiles(true, false).Count == 0)
|
||||
list.Add(new ResetGameEntry(this));
|
||||
|
||||
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
|
||||
{
|
||||
base.GetContextMenuEntries( from, list );
|
||||
SetSecureLevelEntry.AddTo(from, this, list);
|
||||
}
|
||||
|
||||
Players.CheckPlayers();
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
Players.CheckPlayers();
|
||||
|
||||
if ( from.Alive && IsAccessibleTo( from ) && Players.GetInGameMobiles( true, false ).Count == 0 )
|
||||
list.Add( new ResetGameEntry( this ) );
|
||||
Players.Join(from);
|
||||
}
|
||||
|
||||
SetSecureLevelEntry.AddTo( from, this, list );
|
||||
}
|
||||
public void ResetGame(Mobile from)
|
||||
{
|
||||
if (DateTime.UtcNow - m_LastReset < TimeSpan.FromSeconds(5.0))
|
||||
return;
|
||||
|
||||
private class ResetGameEntry : ContextMenuEntry
|
||||
{
|
||||
private MahjongGame m_Game;
|
||||
m_LastReset = DateTime.UtcNow;
|
||||
|
||||
public ResetGameEntry( MahjongGame game ) : base( 6162 )
|
||||
{
|
||||
m_Game = game;
|
||||
}
|
||||
if (from != null)
|
||||
Players.SendLocalizedMessage(1062771, from.Name); // ~1_name~ has reset the game.
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
Mobile from = Owner.From;
|
||||
Players.SendRelievePacket(true, true);
|
||||
|
||||
if ( from.CheckAlive() && !m_Game.Deleted && m_Game.IsAccessibleTo( from ) && m_Game.Players.GetInGameMobiles( true, false ).Count == 0 )
|
||||
m_Game.ResetGame( from );
|
||||
}
|
||||
}
|
||||
BuildWalls();
|
||||
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 override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
Players.CheckPlayers();
|
||||
public void ResetWalls(Mobile from)
|
||||
{
|
||||
if (DateTime.UtcNow - m_LastReset < TimeSpan.FromSeconds(5.0))
|
||||
return;
|
||||
|
||||
Players.Join( from );
|
||||
}
|
||||
m_LastReset = DateTime.UtcNow;
|
||||
|
||||
public void ResetGame( Mobile from )
|
||||
{
|
||||
if ( DateTime.UtcNow - m_LastReset < TimeSpan.FromSeconds( 5.0 ) )
|
||||
return;
|
||||
BuildWalls();
|
||||
|
||||
m_LastReset = DateTime.UtcNow;
|
||||
Players.SendTilesPacket(true, true);
|
||||
|
||||
if ( from != null )
|
||||
Players.SendLocalizedMessage( 1062771, from.Name ); // ~1_name~ has reset the game.
|
||||
if (from != null)
|
||||
Players.SendLocalizedMessage(1062696); // The dealer rebuilds the wall.
|
||||
}
|
||||
|
||||
Players.SendRelievePacket( true, true );
|
||||
public int GetStackLevel(MahjongPieceDim dim)
|
||||
{
|
||||
int level = -1;
|
||||
foreach (MahjongTile tile in Tiles)
|
||||
if (tile.StackLevel > level && dim.IsOverlapping(tile.Dimensions))
|
||||
level = tile.StackLevel;
|
||||
return level;
|
||||
}
|
||||
|
||||
BuildWalls();
|
||||
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 override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
public void ResetWalls( Mobile from )
|
||||
{
|
||||
if ( DateTime.UtcNow - m_LastReset < TimeSpan.FromSeconds( 5.0 ) )
|
||||
return;
|
||||
writer.Write(1); // version
|
||||
|
||||
m_LastReset = DateTime.UtcNow;
|
||||
writer.Write((int)Level);
|
||||
|
||||
BuildWalls();
|
||||
writer.Write(Tiles.Length);
|
||||
|
||||
Players.SendTilesPacket( true, true );
|
||||
for (int i = 0; i < Tiles.Length; i++)
|
||||
Tiles[i].Save(writer);
|
||||
|
||||
if ( from != null )
|
||||
Players.SendLocalizedMessage( 1062696 ); // The dealer rebuilds the wall.
|
||||
}
|
||||
DealerIndicator.Save(writer);
|
||||
|
||||
public int GetStackLevel( MahjongPieceDim dim )
|
||||
{
|
||||
int level = -1;
|
||||
foreach ( MahjongTile tile in Tiles )
|
||||
{
|
||||
if ( tile.StackLevel > level && dim.IsOverlapping( tile.Dimensions ) )
|
||||
level = tile.StackLevel;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
WallBreakIndicator.Save(writer);
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
Dices.Save(writer);
|
||||
|
||||
writer.Write( (int) 1 ); // version
|
||||
Players.Save(writer);
|
||||
|
||||
writer.Write( (int) Level );
|
||||
writer.Write(m_ShowScores);
|
||||
writer.Write(m_SpectatorVision);
|
||||
}
|
||||
|
||||
writer.Write( Tiles.Length );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
for ( int i = 0; i < Tiles.Length; i++ )
|
||||
Tiles[i].Save( writer );
|
||||
int version = reader.ReadInt();
|
||||
|
||||
DealerIndicator.Save( writer );
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
Level = (SecureLevel)reader.ReadInt();
|
||||
|
||||
WallBreakIndicator.Save( writer );
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
if (version < 1)
|
||||
Level = SecureLevel.CoOwners;
|
||||
|
||||
Dices.Save( writer );
|
||||
int length = reader.ReadInt();
|
||||
Tiles = new MahjongTile[length];
|
||||
|
||||
Players.Save( writer );
|
||||
for (int i = 0; i < length; i++)
|
||||
Tiles[i] = new MahjongTile(this, reader);
|
||||
|
||||
writer.Write( m_ShowScores );
|
||||
writer.Write( m_SpectatorVision );
|
||||
}
|
||||
DealerIndicator = new MahjongDealerIndicator(this, reader);
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
WallBreakIndicator = new MahjongWallBreakIndicator(this, reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
Dices = new MahjongDices(this, reader);
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
Level = (SecureLevel)reader.ReadInt();
|
||||
Players = new MahjongPlayers(this, reader);
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
if ( version < 1 )
|
||||
Level = SecureLevel.CoOwners;
|
||||
m_ShowScores = reader.ReadBool();
|
||||
m_SpectatorVision = reader.ReadBool();
|
||||
|
||||
int length = reader.ReadInt();
|
||||
Tiles = new MahjongTile[length];
|
||||
m_LastReset = DateTime.UtcNow;
|
||||
|
||||
for ( int i = 0; i < length; i++ )
|
||||
Tiles[i] = new MahjongTile( this, reader );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DealerIndicator = new MahjongDealerIndicator( this, reader );
|
||||
private class ResetGameEntry : ContextMenuEntry
|
||||
{
|
||||
private MahjongGame m_Game;
|
||||
|
||||
WallBreakIndicator = new MahjongWallBreakIndicator( this, reader );
|
||||
public ResetGameEntry(MahjongGame game) : base(6162)
|
||||
{
|
||||
m_Game = game;
|
||||
}
|
||||
|
||||
Dices = new MahjongDices( this, reader );
|
||||
public override void OnClick()
|
||||
{
|
||||
Mobile from = Owner.From;
|
||||
|
||||
Players = new MahjongPlayers( this, reader );
|
||||
|
||||
m_ShowScores = reader.ReadBool();
|
||||
m_SpectatorVision = reader.ReadBool();
|
||||
|
||||
m_LastReset = DateTime.UtcNow;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (from.CheckAlive() && !m_Game.Deleted && m_Game.IsAccessibleTo(from) &&
|
||||
m_Game.Players.GetInGameMobiles(true, false).Count == 0)
|
||||
m_Game.ResetGame(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,239 +2,232 @@ using Server.Network;
|
|||
|
||||
namespace Server.Engines.Mahjong
|
||||
{
|
||||
public delegate void OnMahjongPacketReceive( MahjongGame game, NetState state, PacketReader pvSrc );
|
||||
public delegate void OnMahjongPacketReceive(MahjongGame game, NetState state, PacketReader pvSrc);
|
||||
|
||||
public sealed class MahjongPacketHandlers
|
||||
{
|
||||
private static OnMahjongPacketReceive[] m_SubCommandDelegates = new OnMahjongPacketReceive[0x100];
|
||||
public sealed class MahjongPacketHandlers
|
||||
{
|
||||
private static OnMahjongPacketReceive[] m_SubCommandDelegates = new OnMahjongPacketReceive[0x100];
|
||||
|
||||
public static void RegisterSubCommand( int subCmd, OnMahjongPacketReceive onReceive )
|
||||
{
|
||||
m_SubCommandDelegates[subCmd] = onReceive;
|
||||
}
|
||||
public static void RegisterSubCommand(int subCmd, OnMahjongPacketReceive onReceive)
|
||||
{
|
||||
m_SubCommandDelegates[subCmd] = onReceive;
|
||||
}
|
||||
|
||||
public static OnMahjongPacketReceive GetSubCommandDelegate( int cmd )
|
||||
{
|
||||
if ( cmd >= 0 && cmd < 0x100 )
|
||||
{
|
||||
return m_SubCommandDelegates[cmd];
|
||||
}
|
||||
public static OnMahjongPacketReceive GetSubCommandDelegate(int cmd)
|
||||
{
|
||||
if (cmd >= 0 && cmd < 0x100) return m_SubCommandDelegates[cmd];
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
PacketHandlers.Register( 0xDA, 0, true, OnPacket );
|
||||
public static void Initialize()
|
||||
{
|
||||
PacketHandlers.Register(0xDA, 0, true, OnPacket);
|
||||
|
||||
RegisterSubCommand( 0x6, ExitGame );
|
||||
RegisterSubCommand( 0xA, GivePoints );
|
||||
RegisterSubCommand( 0xB, RollDice );
|
||||
RegisterSubCommand( 0xC, BuildWalls );
|
||||
RegisterSubCommand( 0xD, ResetScores );
|
||||
RegisterSubCommand( 0xF, AssignDealer );
|
||||
RegisterSubCommand( 0x10, OpenSeat );
|
||||
RegisterSubCommand( 0x11, ChangeOption );
|
||||
RegisterSubCommand( 0x15, MoveWallBreakIndicator );
|
||||
RegisterSubCommand( 0x16, TogglePublicHand );
|
||||
RegisterSubCommand( 0x17, MoveTile );
|
||||
RegisterSubCommand( 0x18, MoveDealerIndicator );
|
||||
}
|
||||
RegisterSubCommand(0x6, ExitGame);
|
||||
RegisterSubCommand(0xA, GivePoints);
|
||||
RegisterSubCommand(0xB, RollDice);
|
||||
RegisterSubCommand(0xC, BuildWalls);
|
||||
RegisterSubCommand(0xD, ResetScores);
|
||||
RegisterSubCommand(0xF, AssignDealer);
|
||||
RegisterSubCommand(0x10, OpenSeat);
|
||||
RegisterSubCommand(0x11, ChangeOption);
|
||||
RegisterSubCommand(0x15, MoveWallBreakIndicator);
|
||||
RegisterSubCommand(0x16, TogglePublicHand);
|
||||
RegisterSubCommand(0x17, MoveTile);
|
||||
RegisterSubCommand(0x18, MoveDealerIndicator);
|
||||
}
|
||||
|
||||
public static void OnPacket( NetState state, PacketReader pvSrc )
|
||||
{
|
||||
MahjongGame game = World.FindItem( pvSrc.ReadInt32() ) as MahjongGame;
|
||||
public static void OnPacket(NetState state, PacketReader pvSrc)
|
||||
{
|
||||
MahjongGame game = World.FindItem(pvSrc.ReadInt32()) as MahjongGame;
|
||||
|
||||
game?.Players.CheckPlayers();
|
||||
game?.Players.CheckPlayers();
|
||||
|
||||
pvSrc.ReadByte();
|
||||
pvSrc.ReadByte();
|
||||
|
||||
int cmd = pvSrc.ReadByte();
|
||||
int cmd = pvSrc.ReadByte();
|
||||
|
||||
OnMahjongPacketReceive onReceive = GetSubCommandDelegate( cmd );
|
||||
OnMahjongPacketReceive onReceive = GetSubCommandDelegate(cmd);
|
||||
|
||||
if ( onReceive != null )
|
||||
{
|
||||
onReceive( game, state, pvSrc );
|
||||
}
|
||||
else
|
||||
{
|
||||
pvSrc.Trace( state );
|
||||
}
|
||||
}
|
||||
if (onReceive != null)
|
||||
onReceive(game, state, pvSrc);
|
||||
else
|
||||
pvSrc.Trace(state);
|
||||
}
|
||||
|
||||
private static MahjongPieceDirection GetDirection( int value )
|
||||
{
|
||||
switch ( value )
|
||||
{
|
||||
case 0: return MahjongPieceDirection.Up;
|
||||
case 1: return MahjongPieceDirection.Left;
|
||||
case 2: return MahjongPieceDirection.Down;
|
||||
default: return MahjongPieceDirection.Right;
|
||||
}
|
||||
}
|
||||
private static MahjongPieceDirection GetDirection(int value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 0: return MahjongPieceDirection.Up;
|
||||
case 1: return MahjongPieceDirection.Left;
|
||||
case 2: return MahjongPieceDirection.Down;
|
||||
default: return MahjongPieceDirection.Right;
|
||||
}
|
||||
}
|
||||
|
||||
private static MahjongWind GetWind( int value )
|
||||
{
|
||||
switch ( value )
|
||||
{
|
||||
case 0: return MahjongWind.North;
|
||||
case 1: return MahjongWind.East;
|
||||
case 2: return MahjongWind.South;
|
||||
default: return MahjongWind.West;
|
||||
}
|
||||
}
|
||||
private static MahjongWind GetWind(int value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 0: return MahjongWind.North;
|
||||
case 1: return MahjongWind.East;
|
||||
case 2: return MahjongWind.South;
|
||||
default: return MahjongWind.West;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ExitGame( MahjongGame game, NetState state, PacketReader pvSrc )
|
||||
{
|
||||
if ( game == null )
|
||||
return;
|
||||
public static void ExitGame(MahjongGame game, NetState state, PacketReader pvSrc)
|
||||
{
|
||||
if (game == null)
|
||||
return;
|
||||
|
||||
Mobile from = state.Mobile;
|
||||
Mobile from = state.Mobile;
|
||||
|
||||
game.Players.LeaveGame( from );
|
||||
}
|
||||
game.Players.LeaveGame(from);
|
||||
}
|
||||
|
||||
public static void GivePoints( MahjongGame game, NetState state, PacketReader pvSrc )
|
||||
{
|
||||
if ( game == null || !game.Players.IsInGamePlayer( state.Mobile ) )
|
||||
return;
|
||||
public static void GivePoints(MahjongGame game, NetState state, PacketReader pvSrc)
|
||||
{
|
||||
if (game == null || !game.Players.IsInGamePlayer(state.Mobile))
|
||||
return;
|
||||
|
||||
int to = pvSrc.ReadByte();
|
||||
int amount = pvSrc.ReadInt32();
|
||||
int to = pvSrc.ReadByte();
|
||||
int amount = pvSrc.ReadInt32();
|
||||
|
||||
game.Players.TransferScore( state.Mobile, to, amount );
|
||||
}
|
||||
game.Players.TransferScore(state.Mobile, to, amount);
|
||||
}
|
||||
|
||||
public static void RollDice( MahjongGame game, NetState state, PacketReader pvSrc )
|
||||
{
|
||||
if ( game == null || !game.Players.IsInGamePlayer( state.Mobile ) )
|
||||
return;
|
||||
public static void RollDice(MahjongGame game, NetState state, PacketReader pvSrc)
|
||||
{
|
||||
if (game == null || !game.Players.IsInGamePlayer(state.Mobile))
|
||||
return;
|
||||
|
||||
game.Dices.RollDices( state.Mobile );
|
||||
}
|
||||
game.Dices.RollDices(state.Mobile);
|
||||
}
|
||||
|
||||
public static void BuildWalls( MahjongGame game, NetState state, PacketReader pvSrc )
|
||||
{
|
||||
if ( game == null || !game.Players.IsInGameDealer( state.Mobile ) )
|
||||
return;
|
||||
public static void BuildWalls(MahjongGame game, NetState state, PacketReader pvSrc)
|
||||
{
|
||||
if (game == null || !game.Players.IsInGameDealer(state.Mobile))
|
||||
return;
|
||||
|
||||
game.ResetWalls( state.Mobile );
|
||||
}
|
||||
game.ResetWalls(state.Mobile);
|
||||
}
|
||||
|
||||
public static void ResetScores( MahjongGame game, NetState state, PacketReader pvSrc )
|
||||
{
|
||||
if ( game == null || !game.Players.IsInGameDealer( state.Mobile ) )
|
||||
return;
|
||||
public static void ResetScores(MahjongGame game, NetState state, PacketReader pvSrc)
|
||||
{
|
||||
if (game == null || !game.Players.IsInGameDealer(state.Mobile))
|
||||
return;
|
||||
|
||||
game.Players.ResetScores( MahjongGame.BaseScore );
|
||||
}
|
||||
game.Players.ResetScores(MahjongGame.BaseScore);
|
||||
}
|
||||
|
||||
public static void AssignDealer( MahjongGame game, NetState state, PacketReader pvSrc )
|
||||
{
|
||||
if ( game == null || !game.Players.IsInGameDealer( state.Mobile ) )
|
||||
return;
|
||||
public static void AssignDealer(MahjongGame game, NetState state, PacketReader pvSrc)
|
||||
{
|
||||
if (game == null || !game.Players.IsInGameDealer(state.Mobile))
|
||||
return;
|
||||
|
||||
int position = pvSrc.ReadByte();
|
||||
int position = pvSrc.ReadByte();
|
||||
|
||||
game.Players.AssignDealer( position );
|
||||
}
|
||||
game.Players.AssignDealer(position);
|
||||
}
|
||||
|
||||
public static void OpenSeat( MahjongGame game, NetState state, PacketReader pvSrc )
|
||||
{
|
||||
if ( game == null || !game.Players.IsInGameDealer( state.Mobile ) )
|
||||
return;
|
||||
public static void OpenSeat(MahjongGame game, NetState state, PacketReader pvSrc)
|
||||
{
|
||||
if (game == null || !game.Players.IsInGameDealer(state.Mobile))
|
||||
return;
|
||||
|
||||
int position = pvSrc.ReadByte();
|
||||
int position = pvSrc.ReadByte();
|
||||
|
||||
if ( game.Players.GetPlayer( position ) == state.Mobile )
|
||||
return;
|
||||
if (game.Players.GetPlayer(position) == state.Mobile)
|
||||
return;
|
||||
|
||||
game.Players.OpenSeat( position );
|
||||
}
|
||||
game.Players.OpenSeat(position);
|
||||
}
|
||||
|
||||
public static void ChangeOption( MahjongGame game, NetState state, PacketReader pvSrc )
|
||||
{
|
||||
if ( game == null || !game.Players.IsInGameDealer( state.Mobile ) )
|
||||
return;
|
||||
public static void ChangeOption(MahjongGame game, NetState state, PacketReader pvSrc)
|
||||
{
|
||||
if (game == null || !game.Players.IsInGameDealer(state.Mobile))
|
||||
return;
|
||||
|
||||
pvSrc.ReadInt16();
|
||||
pvSrc.ReadByte();
|
||||
pvSrc.ReadInt16();
|
||||
pvSrc.ReadByte();
|
||||
|
||||
int options = pvSrc.ReadByte();
|
||||
int options = pvSrc.ReadByte();
|
||||
|
||||
game.ShowScores = (options & 0x1) != 0;
|
||||
game.SpectatorVision = (options & 0x2) != 0;
|
||||
}
|
||||
game.ShowScores = (options & 0x1) != 0;
|
||||
game.SpectatorVision = (options & 0x2) != 0;
|
||||
}
|
||||
|
||||
public static void MoveWallBreakIndicator( MahjongGame game, NetState state, PacketReader pvSrc )
|
||||
{
|
||||
if ( game == null || !game.Players.IsInGameDealer( state.Mobile ) )
|
||||
return;
|
||||
public static void MoveWallBreakIndicator(MahjongGame game, NetState state, PacketReader pvSrc)
|
||||
{
|
||||
if (game == null || !game.Players.IsInGameDealer(state.Mobile))
|
||||
return;
|
||||
|
||||
int y = pvSrc.ReadInt16();
|
||||
int x = pvSrc.ReadInt16();
|
||||
int y = pvSrc.ReadInt16();
|
||||
int x = pvSrc.ReadInt16();
|
||||
|
||||
game.WallBreakIndicator.Move( new Point2D( x, y ) );
|
||||
}
|
||||
game.WallBreakIndicator.Move(new Point2D(x, y));
|
||||
}
|
||||
|
||||
public static void TogglePublicHand( MahjongGame game, NetState state, PacketReader pvSrc )
|
||||
{
|
||||
if ( game == null || !game.Players.IsInGamePlayer( state.Mobile ) )
|
||||
return;
|
||||
public static void TogglePublicHand(MahjongGame game, NetState state, PacketReader pvSrc)
|
||||
{
|
||||
if (game == null || !game.Players.IsInGamePlayer(state.Mobile))
|
||||
return;
|
||||
|
||||
pvSrc.ReadInt16();
|
||||
pvSrc.ReadByte();
|
||||
pvSrc.ReadInt16();
|
||||
pvSrc.ReadByte();
|
||||
|
||||
bool publicHand = pvSrc.ReadBoolean();
|
||||
bool publicHand = pvSrc.ReadBoolean();
|
||||
|
||||
game.Players.SetPublic( game.Players.GetPlayerIndex( state.Mobile ), publicHand );
|
||||
}
|
||||
game.Players.SetPublic(game.Players.GetPlayerIndex(state.Mobile), publicHand);
|
||||
}
|
||||
|
||||
public static void MoveTile( MahjongGame game, NetState state, PacketReader pvSrc )
|
||||
{
|
||||
if ( game == null || !game.Players.IsInGamePlayer( state.Mobile ) )
|
||||
return;
|
||||
public static void MoveTile(MahjongGame game, NetState state, PacketReader pvSrc)
|
||||
{
|
||||
if (game == null || !game.Players.IsInGamePlayer(state.Mobile))
|
||||
return;
|
||||
|
||||
int number = pvSrc.ReadByte();
|
||||
int number = pvSrc.ReadByte();
|
||||
|
||||
if ( number < 0 || number >= game.Tiles.Length )
|
||||
return;
|
||||
if (number < 0 || number >= game.Tiles.Length)
|
||||
return;
|
||||
|
||||
pvSrc.ReadByte(); // Current direction
|
||||
pvSrc.ReadByte(); // Current direction
|
||||
|
||||
MahjongPieceDirection direction = GetDirection( pvSrc.ReadByte() );
|
||||
MahjongPieceDirection direction = GetDirection(pvSrc.ReadByte());
|
||||
|
||||
pvSrc.ReadByte();
|
||||
pvSrc.ReadByte();
|
||||
|
||||
bool flip = pvSrc.ReadBoolean();
|
||||
bool flip = pvSrc.ReadBoolean();
|
||||
|
||||
pvSrc.ReadInt16(); // Current Y
|
||||
pvSrc.ReadInt16(); // Current X
|
||||
pvSrc.ReadInt16(); // Current Y
|
||||
pvSrc.ReadInt16(); // Current X
|
||||
|
||||
pvSrc.ReadByte();
|
||||
pvSrc.ReadByte();
|
||||
|
||||
int y = pvSrc.ReadInt16();
|
||||
int x = pvSrc.ReadInt16();
|
||||
int y = pvSrc.ReadInt16();
|
||||
int x = pvSrc.ReadInt16();
|
||||
|
||||
pvSrc.ReadByte();
|
||||
pvSrc.ReadByte();
|
||||
|
||||
game.Tiles[number].Move( new Point2D( x, y ), direction, flip, game.Players.GetPlayerIndex( state.Mobile ) );
|
||||
}
|
||||
game.Tiles[number].Move(new Point2D(x, y), direction, flip, game.Players.GetPlayerIndex(state.Mobile));
|
||||
}
|
||||
|
||||
public static void MoveDealerIndicator( MahjongGame game, NetState state, PacketReader pvSrc )
|
||||
{
|
||||
if ( game == null || !game.Players.IsInGameDealer( state.Mobile ) )
|
||||
return;
|
||||
public static void MoveDealerIndicator(MahjongGame game, NetState state, PacketReader pvSrc)
|
||||
{
|
||||
if (game == null || !game.Players.IsInGameDealer(state.Mobile))
|
||||
return;
|
||||
|
||||
MahjongPieceDirection direction = GetDirection( pvSrc.ReadByte() );
|
||||
MahjongPieceDirection direction = GetDirection(pvSrc.ReadByte());
|
||||
|
||||
MahjongWind wind = GetWind( pvSrc.ReadByte() );
|
||||
MahjongWind wind = GetWind(pvSrc.ReadByte());
|
||||
|
||||
int y = pvSrc.ReadInt16();
|
||||
int x = pvSrc.ReadInt16();
|
||||
int y = pvSrc.ReadInt16();
|
||||
int x = pvSrc.ReadInt16();
|
||||
|
||||
game.DealerIndicator.Move( new Point2D( x, y ), direction, wind );
|
||||
}
|
||||
}
|
||||
game.DealerIndicator.Move(new Point2D(x, y), direction, wind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +1,46 @@
|
|||
namespace Server.Engines.Mahjong
|
||||
{
|
||||
public struct MahjongPieceDim
|
||||
{
|
||||
public Point2D Position { get; }
|
||||
public struct MahjongPieceDim
|
||||
{
|
||||
public Point2D Position{ get; }
|
||||
|
||||
public int Width { get; }
|
||||
public int Width{ get; }
|
||||
|
||||
public int Height { get; }
|
||||
public int Height{ get; }
|
||||
|
||||
public MahjongPieceDim( Point2D position, int width, int height )
|
||||
{
|
||||
Position = position;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
public MahjongPieceDim(Point2D position, int width, int height)
|
||||
{
|
||||
Position = position;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
public bool IsValid()
|
||||
{
|
||||
return Position.X >= 0 && Position.Y >= 0 && Position.X + Width <= 670 && Position.Y + Height <= 670;
|
||||
}
|
||||
public bool IsValid()
|
||||
{
|
||||
return Position.X >= 0 && Position.Y >= 0 && Position.X + Width <= 670 && Position.Y + Height <= 670;
|
||||
}
|
||||
|
||||
public bool IsOverlapping( MahjongPieceDim dim )
|
||||
{
|
||||
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 bool IsOverlapping(MahjongPieceDim dim)
|
||||
{
|
||||
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 ( Position.X + Width > 150 && Position.X < 520 && Position.Y < 35 )
|
||||
return 0;
|
||||
public int GetHandArea()
|
||||
{
|
||||
if (Position.X + Width > 150 && Position.X < 520 && Position.Y < 35)
|
||||
return 0;
|
||||
|
||||
if ( Position.X + Width > 635 && Position.Y + Height > 150 && Position.Y < 520 )
|
||||
return 1;
|
||||
if (Position.X + Width > 635 && Position.Y + Height > 150 && Position.Y < 520)
|
||||
return 1;
|
||||
|
||||
if ( Position.X + Width > 150 && Position.X < 520 && Position.Y + Height > 635 )
|
||||
return 2;
|
||||
if (Position.X + Width > 150 && Position.X < 520 && Position.Y + Height > 635)
|
||||
return 2;
|
||||
|
||||
if ( Position.X < 35 && Position.Y + Height > 150 && Position.Y < 520 )
|
||||
return 3;
|
||||
if (Position.X < 35 && Position.Y + Height > 150 && Position.Y < 520)
|
||||
return 3;
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,30 +2,26 @@ using System.Collections;
|
|||
|
||||
namespace Server.Engines.Mahjong
|
||||
{
|
||||
public class MahjongTileTypeGenerator
|
||||
{
|
||||
public ArrayList LeftTileTypes { get; }
|
||||
public class MahjongTileTypeGenerator
|
||||
{
|
||||
public MahjongTileTypeGenerator(int count)
|
||||
{
|
||||
LeftTileTypes = new ArrayList(34 * count);
|
||||
|
||||
public MahjongTileTypeGenerator( int count )
|
||||
{
|
||||
LeftTileTypes = new ArrayList( 34 * count );
|
||||
for (int i = 1; i <= 34; i++)
|
||||
for (int j = 0; j < count; j++)
|
||||
LeftTileTypes.Add((MahjongTileType)i);
|
||||
}
|
||||
|
||||
for ( int i = 1; i <= 34; i++ )
|
||||
{
|
||||
for ( int j = 0; j < count; j++ )
|
||||
{
|
||||
LeftTileTypes.Add( (MahjongTileType)i );
|
||||
}
|
||||
}
|
||||
}
|
||||
public ArrayList LeftTileTypes{ get; }
|
||||
|
||||
public MahjongTileType Next()
|
||||
{
|
||||
int random = Utility.Random( LeftTileTypes.Count );
|
||||
MahjongTileType next = (MahjongTileType)LeftTileTypes[random];
|
||||
LeftTileTypes.RemoveAt( random );
|
||||
public MahjongTileType Next()
|
||||
{
|
||||
int random = Utility.Random(LeftTileTypes.Count);
|
||||
MahjongTileType next = (MahjongTileType)LeftTileTypes[random];
|
||||
LeftTileTypes.RemoveAt(random);
|
||||
|
||||
return next;
|
||||
}
|
||||
}
|
||||
}
|
||||
return next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +1,50 @@
|
|||
namespace Server.Engines.Mahjong
|
||||
{
|
||||
public class MahjongWallBreakIndicator
|
||||
{
|
||||
public static MahjongPieceDim GetDimensions( Point2D position )
|
||||
{
|
||||
return new MahjongPieceDim( position, 20, 20 );
|
||||
}
|
||||
public class MahjongWallBreakIndicator
|
||||
{
|
||||
public MahjongWallBreakIndicator(MahjongGame game, Point2D position)
|
||||
{
|
||||
Game = game;
|
||||
Position = position;
|
||||
}
|
||||
|
||||
public MahjongGame Game { get; }
|
||||
public MahjongWallBreakIndicator(MahjongGame game, GenericReader reader)
|
||||
{
|
||||
Game = game;
|
||||
|
||||
public Point2D Position { get; private set; }
|
||||
int version = reader.ReadInt();
|
||||
|
||||
public MahjongWallBreakIndicator( MahjongGame game, Point2D position )
|
||||
{
|
||||
Game = game;
|
||||
Position = position;
|
||||
}
|
||||
Position = reader.ReadPoint2D();
|
||||
}
|
||||
|
||||
public MahjongPieceDim Dimensions => GetDimensions( Position );
|
||||
public MahjongGame Game{ get; }
|
||||
|
||||
public void Move( Point2D position )
|
||||
{
|
||||
MahjongPieceDim dim = GetDimensions( position );
|
||||
public Point2D Position{ get; private set; }
|
||||
|
||||
if ( !dim.IsValid() )
|
||||
return;
|
||||
public MahjongPieceDim Dimensions => GetDimensions(Position);
|
||||
|
||||
Position = position;
|
||||
public static MahjongPieceDim GetDimensions(Point2D position)
|
||||
{
|
||||
return new MahjongPieceDim(position, 20, 20);
|
||||
}
|
||||
|
||||
Game.Players.SendGeneralPacket( true, true );
|
||||
}
|
||||
public void Move(Point2D position)
|
||||
{
|
||||
MahjongPieceDim dim = GetDimensions(position);
|
||||
|
||||
public void Save( GenericWriter writer )
|
||||
{
|
||||
writer.Write( (int) 0 ); // version
|
||||
if (!dim.IsValid())
|
||||
return;
|
||||
|
||||
writer.Write( Position );
|
||||
}
|
||||
Position = position;
|
||||
|
||||
public MahjongWallBreakIndicator( MahjongGame game, GenericReader reader )
|
||||
{
|
||||
Game = game;
|
||||
Game.Players.SendGeneralPacket(true, true);
|
||||
}
|
||||
|
||||
int version = reader.ReadInt();
|
||||
public void Save(GenericWriter writer)
|
||||
{
|
||||
writer.Write(0); // version
|
||||
|
||||
Position = reader.ReadPoint2D();
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.Write(Position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,206 +1,209 @@
|
|||
using System.IO;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.Mahjong
|
||||
{
|
||||
public sealed class MahjongJoinGame : Packet
|
||||
{
|
||||
public MahjongJoinGame( MahjongGame game ) : base( 0xDA )
|
||||
{
|
||||
EnsureCapacity( 9 );
|
||||
public sealed class MahjongJoinGame : Packet
|
||||
{
|
||||
public MahjongJoinGame(MahjongGame game) : base(0xDA)
|
||||
{
|
||||
EnsureCapacity(9);
|
||||
|
||||
m_Stream.Write( (int) game.Serial );
|
||||
m_Stream.Write( (byte) 0 );
|
||||
m_Stream.Write( (byte) 0x19 );
|
||||
}
|
||||
}
|
||||
m_Stream.Write(game.Serial);
|
||||
m_Stream.Write((byte)0);
|
||||
m_Stream.Write((byte)0x19);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MahjongPlayersInfo : Packet
|
||||
{
|
||||
public MahjongPlayersInfo( MahjongGame game, Mobile to ) : base( 0xDA )
|
||||
{
|
||||
MahjongPlayers players = game.Players;
|
||||
public sealed class MahjongPlayersInfo : Packet
|
||||
{
|
||||
public MahjongPlayersInfo(MahjongGame game, Mobile to) : base(0xDA)
|
||||
{
|
||||
MahjongPlayers players = game.Players;
|
||||
|
||||
EnsureCapacity( 11 + 45 * players.Seats );
|
||||
EnsureCapacity(11 + 45 * players.Seats);
|
||||
|
||||
m_Stream.Write( (int) game.Serial );
|
||||
m_Stream.Write( (byte) 0 );
|
||||
m_Stream.Write( (byte) 0x2 );
|
||||
m_Stream.Write(game.Serial);
|
||||
m_Stream.Write((byte)0);
|
||||
m_Stream.Write((byte)0x2);
|
||||
|
||||
m_Stream.Write( (byte) 0 );
|
||||
m_Stream.Write( (byte) players.Seats );
|
||||
m_Stream.Write((byte)0);
|
||||
m_Stream.Write((byte)players.Seats);
|
||||
|
||||
int n = 0;
|
||||
for ( int i = 0; i < players.Seats; i++ )
|
||||
{
|
||||
Mobile mobile = players.GetPlayer( i );
|
||||
int n = 0;
|
||||
for (int i = 0; i < players.Seats; i++)
|
||||
{
|
||||
Mobile mobile = players.GetPlayer(i);
|
||||
|
||||
if ( mobile != null )
|
||||
{
|
||||
m_Stream.Write( (int) mobile.Serial );
|
||||
m_Stream.Write( players.DealerPosition == i ? (byte) 0x1 : (byte) 0x2 );
|
||||
m_Stream.Write( (byte) i );
|
||||
if (mobile != null)
|
||||
{
|
||||
m_Stream.Write(mobile.Serial);
|
||||
m_Stream.Write(players.DealerPosition == i ? (byte)0x1 : (byte)0x2);
|
||||
m_Stream.Write((byte)i);
|
||||
|
||||
if ( game.ShowScores || mobile == to )
|
||||
m_Stream.Write( (int) players.GetScore( i ) );
|
||||
else
|
||||
m_Stream.Write( (int) 0 );
|
||||
if (game.ShowScores || mobile == to)
|
||||
m_Stream.Write(players.GetScore(i));
|
||||
else
|
||||
m_Stream.Write(0);
|
||||
|
||||
m_Stream.Write( (short) 0 );
|
||||
m_Stream.Write( (byte) 0 );
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((byte)0);
|
||||
|
||||
m_Stream.Write( players.IsPublic( i ) );
|
||||
m_Stream.Write(players.IsPublic(i));
|
||||
|
||||
m_Stream.WriteAsciiFixed( mobile.Name, 30 );
|
||||
m_Stream.Write( !players.IsInGamePlayer( i ) );
|
||||
m_Stream.WriteAsciiFixed(mobile.Name, 30);
|
||||
m_Stream.Write(!players.IsInGamePlayer(i));
|
||||
|
||||
n++;
|
||||
}
|
||||
else if ( game.ShowScores )
|
||||
{
|
||||
m_Stream.Write( (int) 0 );
|
||||
m_Stream.Write( (byte) 0x2 );
|
||||
m_Stream.Write( (byte) i );
|
||||
n++;
|
||||
}
|
||||
else if (game.ShowScores)
|
||||
{
|
||||
m_Stream.Write(0);
|
||||
m_Stream.Write((byte)0x2);
|
||||
m_Stream.Write((byte)i);
|
||||
|
||||
m_Stream.Write( (int) players.GetScore( i ) );
|
||||
m_Stream.Write(players.GetScore(i));
|
||||
|
||||
m_Stream.Write( (short) 0 );
|
||||
m_Stream.Write( (byte) 0 );
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((byte)0);
|
||||
|
||||
m_Stream.Write( players.IsPublic( i ) );
|
||||
m_Stream.Write(players.IsPublic(i));
|
||||
|
||||
m_Stream.WriteAsciiFixed( "", 30 );
|
||||
m_Stream.Write( true );
|
||||
m_Stream.WriteAsciiFixed("", 30);
|
||||
m_Stream.Write(true);
|
||||
|
||||
n++;
|
||||
}
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( n != players.Seats )
|
||||
{
|
||||
m_Stream.Seek( 10, System.IO.SeekOrigin.Begin );
|
||||
m_Stream.Write( (byte) n );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (n != players.Seats)
|
||||
{
|
||||
m_Stream.Seek(10, SeekOrigin.Begin);
|
||||
m_Stream.Write((byte)n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MahjongGeneralInfo : Packet
|
||||
{
|
||||
public MahjongGeneralInfo( MahjongGame game ) : base( 0xDA )
|
||||
{
|
||||
EnsureCapacity( 13 );
|
||||
public sealed class MahjongGeneralInfo : Packet
|
||||
{
|
||||
public MahjongGeneralInfo(MahjongGame game) : base(0xDA)
|
||||
{
|
||||
EnsureCapacity(13);
|
||||
|
||||
m_Stream.Write( (int) game.Serial );
|
||||
m_Stream.Write( (byte) 0 );
|
||||
m_Stream.Write( (byte) 0x5 );
|
||||
m_Stream.Write(game.Serial);
|
||||
m_Stream.Write((byte)0);
|
||||
m_Stream.Write((byte)0x5);
|
||||
|
||||
m_Stream.Write( (short) 0 );
|
||||
m_Stream.Write( (byte) 0 );
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((byte)0);
|
||||
|
||||
m_Stream.Write( (byte) ((game.ShowScores ? 0x1 : 0x0) | (game.SpectatorVision ? 0x2 : 0x0)) );
|
||||
m_Stream.Write((byte)((game.ShowScores ? 0x1 : 0x0) | (game.SpectatorVision ? 0x2 : 0x0)));
|
||||
|
||||
m_Stream.Write( (byte) game.Dices.First );
|
||||
m_Stream.Write( (byte) game.Dices.Second );
|
||||
m_Stream.Write((byte)game.Dices.First);
|
||||
m_Stream.Write((byte)game.Dices.Second);
|
||||
|
||||
m_Stream.Write( (byte) game.DealerIndicator.Wind );
|
||||
m_Stream.Write( (short) game.DealerIndicator.Position.Y );
|
||||
m_Stream.Write( (short) game.DealerIndicator.Position.X );
|
||||
m_Stream.Write( (byte) game.DealerIndicator.Direction );
|
||||
m_Stream.Write((byte)game.DealerIndicator.Wind);
|
||||
m_Stream.Write((short)game.DealerIndicator.Position.Y);
|
||||
m_Stream.Write((short)game.DealerIndicator.Position.X);
|
||||
m_Stream.Write((byte)game.DealerIndicator.Direction);
|
||||
|
||||
m_Stream.Write( (short) game.WallBreakIndicator.Position.Y );
|
||||
m_Stream.Write( (short) game.WallBreakIndicator.Position.X );
|
||||
}
|
||||
}
|
||||
m_Stream.Write((short)game.WallBreakIndicator.Position.Y);
|
||||
m_Stream.Write((short)game.WallBreakIndicator.Position.X);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MahjongTilesInfo : Packet
|
||||
{
|
||||
public MahjongTilesInfo( MahjongGame game, Mobile to ) : base( 0xDA )
|
||||
{
|
||||
MahjongTile[] tiles = game.Tiles;
|
||||
MahjongPlayers players = game.Players;
|
||||
public sealed class MahjongTilesInfo : Packet
|
||||
{
|
||||
public MahjongTilesInfo(MahjongGame game, Mobile to) : base(0xDA)
|
||||
{
|
||||
MahjongTile[] tiles = game.Tiles;
|
||||
MahjongPlayers players = game.Players;
|
||||
|
||||
EnsureCapacity( 11 + 9 * tiles.Length );
|
||||
EnsureCapacity(11 + 9 * tiles.Length);
|
||||
|
||||
m_Stream.Write( (int) game.Serial );
|
||||
m_Stream.Write( (byte) 0 );
|
||||
m_Stream.Write( (byte) 0x4 );
|
||||
m_Stream.Write(game.Serial);
|
||||
m_Stream.Write((byte)0);
|
||||
m_Stream.Write((byte)0x4);
|
||||
|
||||
m_Stream.Write( (short) tiles.Length );
|
||||
m_Stream.Write((short)tiles.Length);
|
||||
|
||||
foreach ( MahjongTile tile in tiles )
|
||||
{
|
||||
m_Stream.Write( (byte) tile.Number );
|
||||
foreach (MahjongTile tile in tiles)
|
||||
{
|
||||
m_Stream.Write((byte)tile.Number);
|
||||
|
||||
if ( tile.Flipped )
|
||||
{
|
||||
int hand = tile.Dimensions.GetHandArea();
|
||||
if (tile.Flipped)
|
||||
{
|
||||
int hand = tile.Dimensions.GetHandArea();
|
||||
|
||||
if ( hand < 0 || players.IsPublic( hand ) || players.GetPlayer( hand ) == to || (game.SpectatorVision && players.IsSpectator( to )) )
|
||||
m_Stream.Write( (byte)tile.Value );
|
||||
else
|
||||
m_Stream.Write( (byte) 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Stream.Write( (byte) 0 );
|
||||
}
|
||||
if (hand < 0 || players.IsPublic(hand) || players.GetPlayer(hand) == to ||
|
||||
game.SpectatorVision && players.IsSpectator(to))
|
||||
m_Stream.Write((byte)tile.Value);
|
||||
else
|
||||
m_Stream.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Stream.Write((byte)0);
|
||||
}
|
||||
|
||||
m_Stream.Write( (short) tile.Position.Y );
|
||||
m_Stream.Write( (short) tile.Position.X );
|
||||
m_Stream.Write( (byte) tile.StackLevel );
|
||||
m_Stream.Write( (byte) tile.Direction );
|
||||
m_Stream.Write((short)tile.Position.Y);
|
||||
m_Stream.Write((short)tile.Position.X);
|
||||
m_Stream.Write((byte)tile.StackLevel);
|
||||
m_Stream.Write((byte)tile.Direction);
|
||||
|
||||
m_Stream.Write( tile.Flipped ? (byte) 0x10 : (byte) 0x0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
m_Stream.Write(tile.Flipped ? (byte)0x10 : (byte)0x0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MahjongTileInfo : Packet
|
||||
{
|
||||
public MahjongTileInfo( MahjongTile tile, Mobile to ) : base( 0xDA )
|
||||
{
|
||||
MahjongGame game = tile.Game;
|
||||
MahjongPlayers players = game.Players;
|
||||
public sealed class MahjongTileInfo : Packet
|
||||
{
|
||||
public MahjongTileInfo(MahjongTile tile, Mobile to) : base(0xDA)
|
||||
{
|
||||
MahjongGame game = tile.Game;
|
||||
MahjongPlayers players = game.Players;
|
||||
|
||||
EnsureCapacity( 18 );
|
||||
EnsureCapacity(18);
|
||||
|
||||
m_Stream.Write( (int) tile.Game.Serial );
|
||||
m_Stream.Write( (byte) 0 );
|
||||
m_Stream.Write( (byte) 0x3 );
|
||||
m_Stream.Write(tile.Game.Serial);
|
||||
m_Stream.Write((byte)0);
|
||||
m_Stream.Write((byte)0x3);
|
||||
|
||||
m_Stream.Write( (byte) tile.Number );
|
||||
m_Stream.Write((byte)tile.Number);
|
||||
|
||||
if ( tile.Flipped )
|
||||
{
|
||||
int hand = tile.Dimensions.GetHandArea();
|
||||
if (tile.Flipped)
|
||||
{
|
||||
int hand = tile.Dimensions.GetHandArea();
|
||||
|
||||
if ( hand < 0 || players.IsPublic( hand ) || players.GetPlayer( hand ) == to || (game.SpectatorVision && players.IsSpectator( to )) )
|
||||
m_Stream.Write( (byte)tile.Value );
|
||||
else
|
||||
m_Stream.Write( (byte) 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Stream.Write( (byte) 0 );
|
||||
}
|
||||
if (hand < 0 || players.IsPublic(hand) || players.GetPlayer(hand) == to ||
|
||||
game.SpectatorVision && players.IsSpectator(to))
|
||||
m_Stream.Write((byte)tile.Value);
|
||||
else
|
||||
m_Stream.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Stream.Write((byte)0);
|
||||
}
|
||||
|
||||
m_Stream.Write( (short) tile.Position.Y );
|
||||
m_Stream.Write( (short) tile.Position.X );
|
||||
m_Stream.Write( (byte) tile.StackLevel );
|
||||
m_Stream.Write( (byte) tile.Direction );
|
||||
m_Stream.Write((short)tile.Position.Y);
|
||||
m_Stream.Write((short)tile.Position.X);
|
||||
m_Stream.Write((byte)tile.StackLevel);
|
||||
m_Stream.Write((byte)tile.Direction);
|
||||
|
||||
m_Stream.Write( tile.Flipped ? (byte) 0x10 : (byte) 0x0 );
|
||||
}
|
||||
}
|
||||
m_Stream.Write(tile.Flipped ? (byte)0x10 : (byte)0x0);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MahjongRelieve : Packet
|
||||
{
|
||||
public MahjongRelieve( MahjongGame game ) : base( 0xDA )
|
||||
{
|
||||
EnsureCapacity( 9 );
|
||||
public sealed class MahjongRelieve : Packet
|
||||
{
|
||||
public MahjongRelieve(MahjongGame game) : base(0xDA)
|
||||
{
|
||||
EnsureCapacity(9);
|
||||
|
||||
m_Stream.Write( (int) game.Serial );
|
||||
m_Stream.Write( (byte) 0 );
|
||||
m_Stream.Write( (byte) 0x1A );
|
||||
}
|
||||
}
|
||||
m_Stream.Write(game.Serial);
|
||||
m_Stream.Write((byte)0);
|
||||
m_Stream.Write((byte)0x1A);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue