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,52 +1,51 @@
|
|||
namespace Server.Items
|
||||
{
|
||||
[Flippable( 0xE1C, 0xFAD )]
|
||||
public class Backgammon : BaseBoard
|
||||
{
|
||||
[Constructible]
|
||||
public Backgammon() : base( 0xE1C )
|
||||
{
|
||||
}
|
||||
[Flippable(0xE1C, 0xFAD)]
|
||||
public class Backgammon : BaseBoard
|
||||
{
|
||||
[Constructible]
|
||||
public Backgammon() : base(0xE1C)
|
||||
{
|
||||
}
|
||||
|
||||
public override void CreatePieces()
|
||||
{
|
||||
for ( int i = 0; i < 5; i++ )
|
||||
{
|
||||
CreatePiece( new PieceWhiteChecker( this ), 42, ( 17 * i ) + 6 );
|
||||
CreatePiece( new PieceBlackChecker( this ), 42, ( 17 * i ) + 119 );
|
||||
public Backgammon(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
CreatePiece( new PieceBlackChecker( this ), 142, ( 17 * i ) + 6 );
|
||||
CreatePiece( new PieceWhiteChecker( this ), 142, ( 17 * i ) + 119 );
|
||||
}
|
||||
public override void CreatePieces()
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
CreatePiece(new PieceWhiteChecker(this), 42, 17 * i + 6);
|
||||
CreatePiece(new PieceBlackChecker(this), 42, 17 * i + 119);
|
||||
|
||||
for ( int i = 0; i < 3; i++ )
|
||||
{
|
||||
CreatePiece( new PieceBlackChecker( this ), 108, ( 17 * i ) + 6 );
|
||||
CreatePiece( new PieceWhiteChecker( this ), 108, ( 17 * i ) + 153 );
|
||||
}
|
||||
CreatePiece(new PieceBlackChecker(this), 142, 17 * i + 6);
|
||||
CreatePiece(new PieceWhiteChecker(this), 142, 17 * i + 119);
|
||||
}
|
||||
|
||||
for ( int i = 0; i < 2; i++ )
|
||||
{
|
||||
CreatePiece( new PieceWhiteChecker( this ), 223, ( 17 * i ) + 6 );
|
||||
CreatePiece( new PieceBlackChecker( this ), 223, ( 17 * i ) + 170 );
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
CreatePiece(new PieceBlackChecker(this), 108, 17 * i + 6);
|
||||
CreatePiece(new PieceWhiteChecker(this), 108, 17 * i + 153);
|
||||
}
|
||||
|
||||
public Backgammon( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
CreatePiece(new PieceWhiteChecker(this), 223, 17 * i + 6);
|
||||
CreatePiece(new PieceBlackChecker(this), 223, 17 * i + 170);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,154 +1,149 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Multis;
|
||||
using Server.Network;
|
||||
using Server.ContextMenus;
|
||||
using Server.Gumps;
|
||||
using Server.Multis;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public abstract class BaseBoard : Container, ISecurable
|
||||
{
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public SecureLevel Level { get; set; }
|
||||
public abstract class BaseBoard : Container, ISecurable
|
||||
{
|
||||
public BaseBoard(int itemID) : base(itemID)
|
||||
{
|
||||
CreatePieces();
|
||||
|
||||
public BaseBoard( int itemID ) : base( itemID )
|
||||
{
|
||||
CreatePieces();
|
||||
Weight = 5.0;
|
||||
}
|
||||
|
||||
Weight = 5.0;
|
||||
}
|
||||
public BaseBoard(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void CreatePieces();
|
||||
public override bool DisplaysContent => false; // Do not display (x items, y stones)
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
for ( int i = Items.Count - 1; i >= 0; --i )
|
||||
{
|
||||
if ( i < Items.Count )
|
||||
Items[i].Delete();
|
||||
}
|
||||
public override bool IsDecoContainer => false;
|
||||
|
||||
CreatePieces();
|
||||
}
|
||||
public override TimeSpan DecayTime => TimeSpan.FromDays(1.0);
|
||||
|
||||
public void CreatePiece( BasePiece piece, int x, int y )
|
||||
{
|
||||
AddItem( piece );
|
||||
piece.Location = new Point3D( x, y, 0 );
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public SecureLevel Level{ get; set; }
|
||||
|
||||
public override bool DisplaysContent => false; // Do not display (x items, y stones)
|
||||
public abstract void CreatePieces();
|
||||
|
||||
public override bool IsDecoContainer => false;
|
||||
public void Reset()
|
||||
{
|
||||
for (int i = Items.Count - 1; i >= 0; --i)
|
||||
if (i < Items.Count)
|
||||
Items[i].Delete();
|
||||
|
||||
public BaseBoard( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
CreatePieces();
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 1 ); // version
|
||||
public void CreatePiece(BasePiece piece, int x, int y)
|
||||
{
|
||||
AddItem(piece);
|
||||
piece.Location = new Point3D(x, y, 0);
|
||||
}
|
||||
|
||||
writer.Write( (int)Level );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(1); // version
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
writer.Write((int)Level);
|
||||
}
|
||||
|
||||
if ( version == 1 )
|
||||
Level = (SecureLevel)reader.ReadInt();
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if ( Weight == 1.0 )
|
||||
Weight = 5.0;
|
||||
}
|
||||
if (version == 1)
|
||||
Level = (SecureLevel)reader.ReadInt();
|
||||
|
||||
public override TimeSpan DecayTime => TimeSpan.FromDays( 1.0 );
|
||||
if (Weight == 1.0)
|
||||
Weight = 5.0;
|
||||
}
|
||||
|
||||
public override bool OnDragDrop( Mobile from, Item dropped )
|
||||
{
|
||||
return ( dropped is BasePiece piece && piece.Board == this && base.OnDragDrop( from, dropped ) );
|
||||
}
|
||||
public override bool OnDragDrop(Mobile from, Item dropped)
|
||||
{
|
||||
return dropped is BasePiece piece && piece.Board == this && base.OnDragDrop(from, dropped);
|
||||
}
|
||||
|
||||
public override bool OnDragDropInto( Mobile from, Item dropped, Point3D point )
|
||||
{
|
||||
if ( dropped is BasePiece piece && piece.Board == this && base.OnDragDropInto( from, dropped, point ) )
|
||||
{
|
||||
Packet p = new PlaySound( 0x127, GetWorldLocation() );
|
||||
public override bool OnDragDropInto(Mobile from, Item dropped, Point3D point)
|
||||
{
|
||||
if (dropped is BasePiece piece && piece.Board == this && base.OnDragDropInto(from, dropped, point))
|
||||
{
|
||||
Packet p = new PlaySound(0x127, GetWorldLocation());
|
||||
|
||||
p.Acquire();
|
||||
p.Acquire();
|
||||
|
||||
if ( RootParent == from )
|
||||
{
|
||||
from.Send( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ( NetState state in GetClientsInRange( 2 ) )
|
||||
state.Send( p );
|
||||
}
|
||||
if (RootParent == from)
|
||||
from.Send(p);
|
||||
else
|
||||
foreach (NetState state in GetClientsInRange(2))
|
||||
state.Send(p);
|
||||
|
||||
p.Release();
|
||||
p.Release();
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
|
||||
{
|
||||
base.GetContextMenuEntries( from, list );
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
|
||||
if ( ValidateDefault( from, this ) )
|
||||
list.Add( new DefaultEntry( from, this ) );
|
||||
if (ValidateDefault(from, this))
|
||||
list.Add(new DefaultEntry(from, this));
|
||||
|
||||
SetSecureLevelEntry.AddTo( from, this, list );
|
||||
}
|
||||
SetSecureLevelEntry.AddTo(from, this, list);
|
||||
}
|
||||
|
||||
public static bool ValidateDefault( Mobile from, BaseBoard board )
|
||||
{
|
||||
if ( from.AccessLevel >= AccessLevel.GameMaster )
|
||||
return true;
|
||||
public static bool ValidateDefault(Mobile from, BaseBoard board)
|
||||
{
|
||||
if (from.AccessLevel >= AccessLevel.GameMaster)
|
||||
return true;
|
||||
|
||||
if ( !from.Alive )
|
||||
return false;
|
||||
if (!from.Alive)
|
||||
return false;
|
||||
|
||||
if ( board.IsChildOf( from.Backpack ) )
|
||||
return true;
|
||||
if (board.IsChildOf(from.Backpack))
|
||||
return true;
|
||||
|
||||
object root = board.RootParent;
|
||||
object root = board.RootParent;
|
||||
|
||||
if ( root is Mobile && root != from )
|
||||
return false;
|
||||
if (root is Mobile && root != from)
|
||||
return false;
|
||||
|
||||
if ( board.Deleted || board.Map != from.Map || !from.InRange( board.GetWorldLocation(), 1 ) )
|
||||
return false;
|
||||
if (board.Deleted || board.Map != from.Map || !from.InRange(board.GetWorldLocation(), 1))
|
||||
return false;
|
||||
|
||||
BaseHouse house = BaseHouse.FindHouseAt( board );
|
||||
BaseHouse house = BaseHouse.FindHouseAt(board);
|
||||
|
||||
return ( house != null && house.IsOwner( from ) );
|
||||
}
|
||||
return house != null && house.IsOwner(from);
|
||||
}
|
||||
|
||||
public class DefaultEntry : ContextMenuEntry
|
||||
{
|
||||
private Mobile m_From;
|
||||
private BaseBoard m_Board;
|
||||
public class DefaultEntry : ContextMenuEntry
|
||||
{
|
||||
private BaseBoard m_Board;
|
||||
private Mobile m_From;
|
||||
|
||||
public DefaultEntry( Mobile from, BaseBoard board ) : base( 6162, from.AccessLevel >= AccessLevel.GameMaster ? -1 : 1 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Board = board;
|
||||
}
|
||||
public DefaultEntry(Mobile from, BaseBoard board) : base(6162,
|
||||
from.AccessLevel >= AccessLevel.GameMaster ? -1 : 1)
|
||||
{
|
||||
m_From = from;
|
||||
m_Board = board;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
if ( ValidateDefault( m_From, m_Board ) )
|
||||
m_Board.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void OnClick()
|
||||
{
|
||||
if (ValidateDefault(m_From, m_Board))
|
||||
m_Board.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,94 +1,95 @@
|
|||
namespace Server.Items
|
||||
{
|
||||
public class BasePiece : Item
|
||||
{
|
||||
public BaseBoard Board { get; set; }
|
||||
public class BasePiece : Item
|
||||
{
|
||||
public BasePiece(int itemID, BaseBoard board) : base(itemID)
|
||||
{
|
||||
Board = board;
|
||||
}
|
||||
|
||||
public override bool IsVirtualItem => true;
|
||||
public BasePiece(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public BasePiece( int itemID, BaseBoard board ) : base( itemID )
|
||||
{
|
||||
Board = board;
|
||||
}
|
||||
public BaseBoard Board{ get; set; }
|
||||
|
||||
public BasePiece( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override bool IsVirtualItem => true;
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override bool CanTarget => false;
|
||||
|
||||
writer.Write( (int) 0 );
|
||||
writer.Write( Board );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
writer.Write(0);
|
||||
writer.Write(Board);
|
||||
}
|
||||
|
||||
int version = reader.ReadInt();
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Board = (BaseBoard)reader.ReadItem();
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if ( Board == null || Parent == null )
|
||||
Delete();
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Board = (BaseBoard)reader.ReadItem();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Board == null || Parent == null)
|
||||
Delete();
|
||||
|
||||
public override void OnSingleClick( Mobile from )
|
||||
{
|
||||
if ( Board == null || Board.Deleted )
|
||||
Delete();
|
||||
else if ( !IsChildOf( Board ) )
|
||||
Board.DropItem( this );
|
||||
else
|
||||
base.OnSingleClick( from );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnDragLift( Mobile from )
|
||||
{
|
||||
if ( Board == null || Board.Deleted )
|
||||
{
|
||||
Delete();
|
||||
return false;
|
||||
}
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
if (Board == null || Board.Deleted)
|
||||
Delete();
|
||||
else if (!IsChildOf(Board))
|
||||
Board.DropItem(this);
|
||||
else
|
||||
base.OnSingleClick(from);
|
||||
}
|
||||
|
||||
if ( !IsChildOf( Board ) )
|
||||
{
|
||||
Board.DropItem( this );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public override bool OnDragLift(Mobile from)
|
||||
{
|
||||
if (Board == null || Board.Deleted)
|
||||
{
|
||||
Delete();
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool CanTarget => false;
|
||||
if (!IsChildOf(Board))
|
||||
{
|
||||
Board.DropItem(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool DropToMobile( Mobile from, Mobile target, Point3D p )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool DropToItem( Mobile from, Item target, Point3D p )
|
||||
{
|
||||
return ( target == Board && p.X != -1 && p.Y != -1 && base.DropToItem( from, target, p ) );
|
||||
}
|
||||
public override bool DropToMobile(Mobile from, Mobile target, Point3D p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool DropToWorld( Mobile from, Point3D p )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public override bool DropToItem(Mobile from, Item target, Point3D p)
|
||||
{
|
||||
return target == Board && p.X != -1 && p.Y != -1 && base.DropToItem(from, target, p);
|
||||
}
|
||||
|
||||
public override int GetLiftSound( Mobile from )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
public override bool DropToWorld(Mobile from, Point3D p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int GetLiftSound(Mobile from)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +1,41 @@
|
|||
namespace Server.Items
|
||||
{
|
||||
public class CheckerBoard : BaseBoard
|
||||
{
|
||||
public override int LabelNumber => 1016449; // a checker board
|
||||
public class CheckerBoard : BaseBoard
|
||||
{
|
||||
[Constructible]
|
||||
public CheckerBoard() : base(0xFA6)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public CheckerBoard() : base( 0xFA6 )
|
||||
{
|
||||
}
|
||||
public CheckerBoard(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void CreatePieces()
|
||||
{
|
||||
for ( int i = 0; i < 4; i++ )
|
||||
{
|
||||
CreatePiece( new PieceWhiteChecker( this ), ( 50 * i ) + 45, 25 );
|
||||
CreatePiece( new PieceWhiteChecker( this ), ( 50 * i ) + 70, 50 );
|
||||
CreatePiece( new PieceWhiteChecker( this ), ( 50 * i ) + 45, 75 );
|
||||
CreatePiece( new PieceBlackChecker( this ), ( 50 * i ) + 70, 150 );
|
||||
CreatePiece( new PieceBlackChecker( this ), ( 50 * i ) + 45, 175 );
|
||||
CreatePiece( new PieceBlackChecker( this ), ( 50 * i ) + 70, 200 );
|
||||
}
|
||||
}
|
||||
public override int LabelNumber => 1016449; // a checker board
|
||||
|
||||
public CheckerBoard( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override void CreatePieces()
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
CreatePiece(new PieceWhiteChecker(this), 50 * i + 45, 25);
|
||||
CreatePiece(new PieceWhiteChecker(this), 50 * i + 70, 50);
|
||||
CreatePiece(new PieceWhiteChecker(this), 50 * i + 45, 75);
|
||||
CreatePiece(new PieceBlackChecker(this), 50 * i + 70, 150);
|
||||
CreatePiece(new PieceBlackChecker(this), 50 * i + 45, 175);
|
||||
CreatePiece(new PieceBlackChecker(this), 50 * i + 70, 200);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,52 +1,52 @@
|
|||
namespace Server.Items
|
||||
{
|
||||
public class PieceWhiteChecker : BasePiece
|
||||
{
|
||||
public override string DefaultName => "white checker";
|
||||
public class PieceWhiteChecker : BasePiece
|
||||
{
|
||||
public PieceWhiteChecker(BaseBoard board) : base(0x3584, board)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceWhiteChecker( BaseBoard board ) : base( 0x3584, board )
|
||||
{
|
||||
}
|
||||
public PieceWhiteChecker(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceWhiteChecker( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "white checker";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class PieceBlackChecker : BasePiece
|
||||
{
|
||||
public override string DefaultName => "black checker";
|
||||
public class PieceBlackChecker : BasePiece
|
||||
{
|
||||
public PieceBlackChecker(BaseBoard board) : base(0x358B, board)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceBlackChecker( BaseBoard board ) : base( 0x358B, board )
|
||||
{
|
||||
}
|
||||
public PieceBlackChecker(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceBlackChecker( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "black checker";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,302 +1,302 @@
|
|||
namespace Server.Items
|
||||
{
|
||||
public class PieceWhiteKing : BasePiece
|
||||
{
|
||||
public override string DefaultName => "white king";
|
||||
public class PieceWhiteKing : BasePiece
|
||||
{
|
||||
public PieceWhiteKing(BaseBoard board) : base(0x3587, board)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceWhiteKing( BaseBoard board ) : base( 0x3587, board )
|
||||
{
|
||||
}
|
||||
public PieceWhiteKing(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceWhiteKing( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "white king";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class PieceBlackKing : BasePiece
|
||||
{
|
||||
public override string DefaultName => "black king";
|
||||
public class PieceBlackKing : BasePiece
|
||||
{
|
||||
public PieceBlackKing(BaseBoard board) : base(0x358E, board)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceBlackKing( BaseBoard board ) : base( 0x358E, board )
|
||||
{
|
||||
}
|
||||
public PieceBlackKing(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceBlackKing( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "black king";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class PieceWhiteQueen : BasePiece
|
||||
{
|
||||
public override string DefaultName => "white queen";
|
||||
public class PieceWhiteQueen : BasePiece
|
||||
{
|
||||
public PieceWhiteQueen(BaseBoard board) : base(0x358A, board)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceWhiteQueen( BaseBoard board ) : base( 0x358A, board )
|
||||
{
|
||||
}
|
||||
public PieceWhiteQueen(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceWhiteQueen( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "white queen";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class PieceBlackQueen : BasePiece
|
||||
{
|
||||
public override string DefaultName => "black queen";
|
||||
public class PieceBlackQueen : BasePiece
|
||||
{
|
||||
public PieceBlackQueen(BaseBoard board) : base(0x3591, board)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceBlackQueen( BaseBoard board ) : base( 0x3591, board )
|
||||
{
|
||||
}
|
||||
public PieceBlackQueen(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceBlackQueen( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "black queen";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class PieceWhiteRook : BasePiece
|
||||
{
|
||||
public override string DefaultName => "white rook";
|
||||
public class PieceWhiteRook : BasePiece
|
||||
{
|
||||
public PieceWhiteRook(BaseBoard board) : base(0x3586, board)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceWhiteRook( BaseBoard board ) : base( 0x3586, board )
|
||||
{
|
||||
}
|
||||
public PieceWhiteRook(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceWhiteRook( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "white rook";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class PieceBlackRook : BasePiece
|
||||
{
|
||||
public override string DefaultName => "black rook";
|
||||
public class PieceBlackRook : BasePiece
|
||||
{
|
||||
public PieceBlackRook(BaseBoard board) : base(0x358D, board)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceBlackRook( BaseBoard board ) : base( 0x358D, board )
|
||||
{
|
||||
}
|
||||
public PieceBlackRook(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceBlackRook( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "black rook";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class PieceWhiteBishop : BasePiece
|
||||
{
|
||||
public override string DefaultName => "white bishop";
|
||||
public class PieceWhiteBishop : BasePiece
|
||||
{
|
||||
public PieceWhiteBishop(BaseBoard board) : base(0x3585, board)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceWhiteBishop( BaseBoard board ) : base( 0x3585, board )
|
||||
{
|
||||
}
|
||||
public PieceWhiteBishop(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceWhiteBishop( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "white bishop";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class PieceBlackBishop : BasePiece
|
||||
{
|
||||
public override string DefaultName => "black bishop";
|
||||
public class PieceBlackBishop : BasePiece
|
||||
{
|
||||
public PieceBlackBishop(BaseBoard board) : base(0x358C, board)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceBlackBishop( BaseBoard board ) : base( 0x358C, board )
|
||||
{
|
||||
}
|
||||
public PieceBlackBishop(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceBlackBishop( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "black bishop";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class PieceWhiteKnight : BasePiece
|
||||
{
|
||||
public override string DefaultName => "white knight";
|
||||
public class PieceWhiteKnight : BasePiece
|
||||
{
|
||||
public PieceWhiteKnight(BaseBoard board) : base(0x3588, board)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceWhiteKnight( BaseBoard board ) : base( 0x3588, board )
|
||||
{
|
||||
}
|
||||
public PieceWhiteKnight(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceWhiteKnight( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "white knight";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class PieceBlackKnight : BasePiece
|
||||
{
|
||||
public override string DefaultName => "black knight";
|
||||
public class PieceBlackKnight : BasePiece
|
||||
{
|
||||
public PieceBlackKnight(BaseBoard board) : base(0x358F, board)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceBlackKnight( BaseBoard board ) : base( 0x358F, board )
|
||||
{
|
||||
}
|
||||
public PieceBlackKnight(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceBlackKnight( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "black knight";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class PieceWhitePawn : BasePiece
|
||||
{
|
||||
public override string DefaultName => "white pawn";
|
||||
public class PieceWhitePawn : BasePiece
|
||||
{
|
||||
public PieceWhitePawn(BaseBoard board) : base(0x3589, board)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceWhitePawn( BaseBoard board ) : base( 0x3589, board )
|
||||
{
|
||||
}
|
||||
public PieceWhitePawn(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceWhitePawn( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "white pawn";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class PieceBlackPawn : BasePiece
|
||||
{
|
||||
public override string DefaultName => "black pawn";
|
||||
public class PieceBlackPawn : BasePiece
|
||||
{
|
||||
public PieceBlackPawn(BaseBoard board) : base(0x3590, board)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceBlackPawn( BaseBoard board ) : base( 0x3590, board )
|
||||
{
|
||||
}
|
||||
public PieceBlackPawn(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PieceBlackPawn( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "black pawn";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +1,66 @@
|
|||
namespace Server.Items
|
||||
{
|
||||
public class Chessboard : BaseBoard
|
||||
{
|
||||
public override int LabelNumber => 1016450; // a chessboard
|
||||
public class Chessboard : BaseBoard
|
||||
{
|
||||
[Constructible]
|
||||
public Chessboard() : base(0xFA6)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public Chessboard() : base( 0xFA6 )
|
||||
{
|
||||
}
|
||||
public Chessboard(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void CreatePieces()
|
||||
{
|
||||
for ( int i = 0; i < 8; i++ )
|
||||
{
|
||||
CreatePiece( new PieceBlackPawn( this ), 67, ( 25 * i ) + 17 );
|
||||
CreatePiece( new PieceWhitePawn( this ), 192, ( 25 * i ) + 17 );
|
||||
}
|
||||
public override int LabelNumber => 1016450; // a chessboard
|
||||
|
||||
// Rook
|
||||
CreatePiece( new PieceBlackRook( this ), 42, 5 );
|
||||
CreatePiece( new PieceBlackRook( this ), 42, 180 );
|
||||
public override void CreatePieces()
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
CreatePiece(new PieceBlackPawn(this), 67, 25 * i + 17);
|
||||
CreatePiece(new PieceWhitePawn(this), 192, 25 * i + 17);
|
||||
}
|
||||
|
||||
CreatePiece( new PieceWhiteRook( this ), 216, 5 );
|
||||
CreatePiece( new PieceWhiteRook( this ), 216, 180 );
|
||||
// Rook
|
||||
CreatePiece(new PieceBlackRook(this), 42, 5);
|
||||
CreatePiece(new PieceBlackRook(this), 42, 180);
|
||||
|
||||
// Knight
|
||||
CreatePiece( new PieceBlackKnight( this ), 42, 30 );
|
||||
CreatePiece( new PieceBlackKnight( this ), 42, 155 );
|
||||
CreatePiece(new PieceWhiteRook(this), 216, 5);
|
||||
CreatePiece(new PieceWhiteRook(this), 216, 180);
|
||||
|
||||
CreatePiece( new PieceWhiteKnight( this ), 216, 30 );
|
||||
CreatePiece( new PieceWhiteKnight( this ), 216, 155 );
|
||||
// Knight
|
||||
CreatePiece(new PieceBlackKnight(this), 42, 30);
|
||||
CreatePiece(new PieceBlackKnight(this), 42, 155);
|
||||
|
||||
// Bishop
|
||||
CreatePiece( new PieceBlackBishop( this ), 42, 55 );
|
||||
CreatePiece( new PieceBlackBishop( this ), 42, 130 );
|
||||
CreatePiece(new PieceWhiteKnight(this), 216, 30);
|
||||
CreatePiece(new PieceWhiteKnight(this), 216, 155);
|
||||
|
||||
CreatePiece( new PieceWhiteBishop( this ), 216, 55 );
|
||||
CreatePiece( new PieceWhiteBishop( this ), 216, 130 );
|
||||
// Bishop
|
||||
CreatePiece(new PieceBlackBishop(this), 42, 55);
|
||||
CreatePiece(new PieceBlackBishop(this), 42, 130);
|
||||
|
||||
// Queen
|
||||
CreatePiece( new PieceBlackQueen( this ), 42, 105 );
|
||||
CreatePiece( new PieceWhiteQueen( this ), 216, 105 );
|
||||
CreatePiece(new PieceWhiteBishop(this), 216, 55);
|
||||
CreatePiece(new PieceWhiteBishop(this), 216, 130);
|
||||
|
||||
// King
|
||||
CreatePiece( new PieceBlackKing( this ), 42, 80 );
|
||||
CreatePiece( new PieceWhiteKing( this ), 216, 80 );
|
||||
}
|
||||
// Queen
|
||||
CreatePiece(new PieceBlackQueen(this), 42, 105);
|
||||
CreatePiece(new PieceWhiteQueen(this), 216, 105);
|
||||
|
||||
public Chessboard( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
// King
|
||||
CreatePiece(new PieceBlackKing(this), 42, 80);
|
||||
CreatePiece(new PieceWhiteKing(this), 216, 80);
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,50 +2,50 @@ using Server.Network;
|
|||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class Dices : Item, ITelekinesisable
|
||||
{
|
||||
[Constructible]
|
||||
public Dices() : base( 0xFA7 )
|
||||
{
|
||||
Weight = 1.0;
|
||||
}
|
||||
public class Dices : Item, ITelekinesisable
|
||||
{
|
||||
[Constructible]
|
||||
public Dices() : base(0xFA7)
|
||||
{
|
||||
Weight = 1.0;
|
||||
}
|
||||
|
||||
public Dices( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public Dices(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( !from.InRange( GetWorldLocation(), 2 ) )
|
||||
return;
|
||||
public void OnTelekinesis(Mobile from)
|
||||
{
|
||||
Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x376A, 9, 32, 5022);
|
||||
Effects.PlaySound(Location, Map, 0x1F5);
|
||||
|
||||
Roll( from );
|
||||
}
|
||||
Roll(from);
|
||||
}
|
||||
|
||||
public void OnTelekinesis( Mobile from )
|
||||
{
|
||||
Effects.SendLocationParticles( EffectItem.Create( Location, Map, EffectItem.DefaultDuration ), 0x376A, 9, 32, 5022 );
|
||||
Effects.PlaySound( Location, Map, 0x1F5 );
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!from.InRange(GetWorldLocation(), 2))
|
||||
return;
|
||||
|
||||
Roll( from );
|
||||
}
|
||||
Roll(from);
|
||||
}
|
||||
|
||||
public void Roll( Mobile from )
|
||||
{
|
||||
PublicOverheadMessage( MessageType.Regular, 0, false,
|
||||
$"*{from.Name} rolls {Utility.Random(1, 6)}, {Utility.Random(1, 6)}*");
|
||||
}
|
||||
public void Roll(Mobile from)
|
||||
{
|
||||
PublicOverheadMessage(MessageType.Regular, 0, false,
|
||||
$"*{from.Name} rolls {Utility.Random(1, 6)}, {Utility.Random(1, 6)}*");
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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