Exemplo n.º 1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            int length = reader.ReadInt();

            m_Tiles = new MahjongTile[length];

            for (int i = 0; i < length; i++)
            {
                m_Tiles[i] = new MahjongTile(this, reader);
            }

            m_DealerIndicator = new MahjongDealerIndicator(this, reader);

            m_WallBreakIndicator = new MahjongWallBreakIndicator(this, reader);

            m_Dices = new MahjongDices(this, reader);

            m_Players = new MahjongPlayers(this, reader);

            m_ShowScores      = reader.ReadBool();
            m_SpectatorVision = reader.ReadBool();

            m_LastReset = DateTime.Now;
        }
Exemplo n.º 2
0
        public MahjongGame() : base(0xFAA)
        {
            Weight = 5.0;

            BuildWalls();
            m_DealerIndicator    = new MahjongDealerIndicator(this, new Point2D(300, 300), MahjongPieceDirection.Up, MahjongWind.North);
            m_WallBreakIndicator = new MahjongWallBreakIndicator(this, new Point2D(335, 335));
            m_Dices     = new MahjongDices(this);
            m_Players   = new MahjongPlayers(this, MaxPlayers, BaseScore);
            m_LastReset = DateTime.Now;
        }
Exemplo n.º 3
0
        public MahjongGame()
            : base(0xFAA)
        {
            Weight = 5.0;

            BuildWalls();
            m_DealerIndicator = new MahjongDealerIndicator( this, new Point2D( 300, 300 ), MahjongPieceDirection.Up, MahjongWind.North );
            m_WallBreakIndicator = new MahjongWallBreakIndicator( this, new Point2D( 335, 335 ) );
            m_Dices = new MahjongDices( this );
            m_Players = new MahjongPlayers( this, MaxPlayers, BaseScore );
            m_LastReset = DateTime.Now;
        }
Exemplo n.º 4
0
        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 = Core.Now;
            Level       = SecureLevel.CoOwners;
        }
Exemplo n.º 5
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 1:
            {
                m_Level = (SecureLevel)reader.ReadInt();

                goto case 0;
            }

            case 0:
            {
                if (version < 1)
                {
                    m_Level = SecureLevel.CoOwners;
                }

                int length = reader.ReadInt();
                m_Tiles = new MahjongTile[length];

                for (int i = 0; i < length; i++)
                {
                    m_Tiles[i] = new MahjongTile(this, reader);
                }

                m_DealerIndicator = new MahjongDealerIndicator(this, reader);

                m_WallBreakIndicator = new MahjongWallBreakIndicator(this, reader);

                m_Dices = new MahjongDices(this, reader);

                m_Players = new MahjongPlayers(this, reader);

                m_ShowScores      = reader.ReadBool();
                m_SpectatorVision = reader.ReadBool();

                m_LastReset = DateTime.Now;

                break;
            }
            }
        }
Exemplo n.º 6
0
        public MahjongTilesInfo(MahjongGame game, Mobile to)
            : base(0xDA)
        {
            MahjongTile[]  tiles   = game.Tiles;
            MahjongPlayers players = game.Players;

            EnsureCapacity(11 + 9 * tiles.Length);

            m_Stream.Write(game.Serial);
            m_Stream.Write((byte)0);
            m_Stream.Write((byte)0x4);

            m_Stream.Write((short)tiles.Length);

            foreach (MahjongTile tile in tiles)
            {
                m_Stream.Write((byte)tile.Number);

                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);
                }

                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);
            }
        }
Exemplo n.º 7
0
        public void ResetGame(Mobile from)
        {
            if (DateTime.Now - m_LastReset < TimeSpan.FromSeconds(5.0))
            {
                return;
            }

            m_LastReset = DateTime.Now;

            if (from != null)
            {
                m_Players.SendLocalizedMessage(1062771, from.Name);                   // ~1_name~ has reset the game.
            }
            m_Players.SendRelievePacket(true, true);

            BuildWalls();
            m_DealerIndicator    = new MahjongDealerIndicator(this, new Point2D(300, 300), MahjongPieceDirection.Up, MahjongWind.North);
            m_WallBreakIndicator = new MahjongWallBreakIndicator(this, new Point2D(335, 335));
            m_Players            = new MahjongPlayers(this, MaxPlayers, BaseScore);
        }
Exemplo n.º 8
0
        public MahjongTileInfo(MahjongTile tile, Mobile to) : base(0xDA)
        {
            MahjongGame    game    = tile.Game;
            MahjongPlayers players = game.Players;

            EnsureCapacity(18);

            Stream.Write(tile.Game.Serial);
            Stream.Write((byte)0);
            Stream.Write((byte)0x3);

            Stream.Write((byte)tile.Number);

            if (tile.Flipped)
            {
                int hand = tile.Dimensions.GetHandArea();

                if (hand < 0 || players.IsPublic(hand) || players.GetPlayer(hand) == to ||
                    (game.SpectatorVision && players.IsSpectator(to)))
                {
                    Stream.Write((byte)tile.Value);
                }
                else
                {
                    Stream.Write((byte)0);
                }
            }
            else
            {
                Stream.Write((byte)0);
            }

            Stream.Write((short)tile.Position.Y);
            Stream.Write((short)tile.Position.X);
            Stream.Write((byte)tile.StackLevel);
            Stream.Write((byte)tile.Direction);

            Stream.Write(tile.Flipped ? (byte)0x10 : (byte)0x0);
        }
Exemplo n.º 9
0
        public MahjongPlayersInfo(MahjongGame game, Mobile to)
            : base(0xDA)
        {
            MahjongPlayers players = game.Players;

            EnsureCapacity(11 + 45 * players.Seats);

            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);

            int n = 0;

            for (int i = 0; i < players.Seats; i++)
            {
                Mobile mobile = players.GetPlayer(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(players.GetScore(i));
                    }
                    else
                    {
                        m_Stream.Write(0);
                    }

                    m_Stream.Write((short)0);
                    m_Stream.Write((byte)0);

                    m_Stream.Write(players.IsPublic(i));

                    m_Stream.WriteAsciiFixed(mobile.Name, 30);
                    m_Stream.Write(!players.IsInGamePlayer(i));

                    n++;
                }
                else if (game.ShowScores)
                {
                    m_Stream.Write(0);
                    m_Stream.Write((byte)0x2);
                    m_Stream.Write((byte)i);

                    m_Stream.Write(players.GetScore(i));

                    m_Stream.Write((short)0);
                    m_Stream.Write((byte)0);

                    m_Stream.Write(players.IsPublic(i));

                    m_Stream.WriteAsciiFixed("", 30);
                    m_Stream.Write(true);

                    n++;
                }
            }

            if (n != players.Seats)
            {
                m_Stream.Seek(10, System.IO.SeekOrigin.Begin);
                m_Stream.Write((byte)n);
            }
        }
Exemplo n.º 10
0
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			switch ( version )
			{
				case 1:
				{
					m_Level = (SecureLevel)reader.ReadInt();

					goto case 0;
				}
				case 0:
				{
					if ( version < 1 )
						m_Level = SecureLevel.CoOwners;

					int length = reader.ReadInt();
					m_Tiles = new MahjongTile[length];

					for ( int i = 0; i < length; i++ )
						m_Tiles[i] = new MahjongTile( this, reader );

					m_DealerIndicator = new MahjongDealerIndicator( this, reader );

					m_WallBreakIndicator = new MahjongWallBreakIndicator( this, reader );

					m_Dices = new MahjongDices( this, reader );

					m_Players = new MahjongPlayers( this, reader );

					m_ShowScores = reader.ReadBool();
					m_SpectatorVision = reader.ReadBool();

					m_LastReset = DateTime.UtcNow;

					break;
				}
			}
		}
Exemplo n.º 11
0
		public void ResetGame( Mobile from )
		{
			if ( DateTime.UtcNow - m_LastReset < TimeSpan.FromSeconds( 5.0 ) )
				return;

			m_LastReset = DateTime.UtcNow;

			if ( from != null )
				m_Players.SendLocalizedMessage( 1062771, from.Name ); // ~1_name~ has reset the game.

			m_Players.SendRelievePacket( true, true );

			BuildWalls();
			m_DealerIndicator = new MahjongDealerIndicator( this, new Point2D( 300, 300 ), MahjongPieceDirection.Up, MahjongWind.North );
			m_WallBreakIndicator = new MahjongWallBreakIndicator( this, new Point2D( 335, 335 ) );
			m_Players = new MahjongPlayers( this, MaxPlayers, BaseScore );
		}
Exemplo n.º 12
0
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            int length = reader.ReadInt();
            m_Tiles = new MahjongTile[length];

            for ( int i = 0; i < length; i++ )
            {
                m_Tiles[i] = new MahjongTile( this, reader );
            }

            m_DealerIndicator = new MahjongDealerIndicator( this, reader );

            m_WallBreakIndicator = new MahjongWallBreakIndicator( this, reader );

            m_Dices = new MahjongDices( this, reader );

            m_Players = new MahjongPlayers( this, reader );

            m_ShowScores = reader.ReadBool();
            m_SpectatorVision = reader.ReadBool();

            m_LastReset = DateTime.Now;
        }