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

            game.WallBreakIndicator.Move(new Point2D(x, y));
        }
        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();

            game.Players.TransferScore(state.Mobile, to, amount);
        }
示例#3
0
        public MahjongTile(MahjongGame game, GenericReader reader)
        {
            m_Game = game;

            int version = reader.ReadInt();

            m_Number     = reader.ReadInt();
            m_Value      = (MahjongTileType)reader.ReadInt();
            m_Position   = reader.ReadPoint2D();
            m_StackLevel = reader.ReadInt();
            m_Direction  = (MahjongPieceDirection)reader.ReadInt();
            m_Flipped    = reader.ReadBool();
        }
        public static void TogglePublicHand(MahjongGame game, NetState state, PacketReader pvSrc)
        {
            if (game == null || !game.Players.IsInGamePlayer(state.Mobile))
            {
                return;
            }

            pvSrc.ReadInt16();
            pvSrc.ReadByte();

            bool publicHand = pvSrc.ReadBoolean();

            game.Players.SetPublic(game.Players.GetPlayerIndex(state.Mobile), publicHand);
        }
        public static void ChangeOption(MahjongGame game, NetState state, PacketReader pvSrc)
        {
            if (game == null || !game.Players.IsInGameDealer(state.Mobile))
            {
                return;
            }

            pvSrc.ReadInt16();
            pvSrc.ReadByte();

            int options = pvSrc.ReadByte();

            game.ShowScores      = (options & 0x1) != 0;
            game.SpectatorVision = (options & 0x2) != 0;
        }
        public MahjongPlayers(MahjongGame game, int maxPlayers, int baseScore)
        {
            m_Game       = game;
            m_Spectators = new ArrayList();

            m_Players    = new Mobile[maxPlayers];
            m_InGame     = new bool[maxPlayers];
            m_PublicHand = new bool[maxPlayers];
            m_Scores     = new int[maxPlayers];

            for (int i = 0; i < m_Scores.Length; i++)
            {
                m_Scores[i] = baseScore;
            }
        }
        public static void MoveDealerIndicator(MahjongGame game, NetState state, PacketReader pvSrc)
        {
            if (game == null || !game.Players.IsInGameDealer(state.Mobile))
            {
                return;
            }

            MahjongPieceDirection direction = GetDirection(pvSrc.ReadByte());

            MahjongWind wind = GetWind(pvSrc.ReadByte());

            int y = pvSrc.ReadInt16();
            int x = pvSrc.ReadInt16();

            game.DealerIndicator.Move(new Point2D(x, y), direction, wind);
        }
        public static void OpenSeat(MahjongGame game, NetState state, PacketReader pvSrc)
        {
            if (game == null || !game.Players.IsInGameDealer(state.Mobile))
            {
                return;
            }

            int position = pvSrc.ReadByte();

            if (game.Players.GetPlayer(position) == state.Mobile)
            {
                return;
            }

            game.Players.OpenSeat(position);
        }
示例#9
0
        public MahjongTilesInfo(MahjongGame game, Mobile to) : base(0xDA)
        {
            MahjongTile[]  tiles   = game.Tiles;
            MahjongPlayers players = game.Players;

            EnsureCapacity(11 + 9 * tiles.Length);

            Stream.Write((int)game.Serial);
            Stream.Write((byte)0);
            Stream.Write((byte)0x4);

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

            foreach (MahjongTile tile in tiles)
            {
                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);
            }
        }
        public MahjongPlayers(MahjongGame game, GenericReader reader)
        {
            m_Game       = game;
            m_Spectators = new ArrayList();

            int version = reader.ReadInt();

            int seats = reader.ReadInt();

            m_Players    = new Mobile[seats];
            m_InGame     = new bool[seats];
            m_PublicHand = new bool[seats];
            m_Scores     = new int[seats];

            for (int i = 0; i < seats; i++)
            {
                m_Players[i]    = reader.ReadMobile();
                m_PublicHand[i] = reader.ReadBool();
                m_Scores[i]     = reader.ReadInt();
            }

            m_DealerPosition = reader.ReadInt();
        }
        public static void OnPacket(NetState state, PacketReader pvSrc)
        {
            MahjongGame game = World.FindItem(pvSrc.ReadInt32()) as MahjongGame;

            if (game != null)
            {
                game.Players.CheckPlayers();
            }

            pvSrc.ReadByte();

            int cmd = pvSrc.ReadByte();

            OnMahjongPacketReceive onReceive = GetSubCommandDelegate(cmd);

            if (onReceive != null)
            {
                onReceive(game, state, pvSrc);
            }
            else
            {
                pvSrc.Trace(state);
            }
        }
示例#12
0
        public MahjongGeneralInfo(MahjongGame game) : base(0xDA)
        {
            EnsureCapacity(13);

            Stream.Write((int)game.Serial);
            Stream.Write((byte)0);
            Stream.Write((byte)0x5);

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

            Stream.Write((byte)((game.ShowScores ? 0x1 : 0x0) | (game.SpectatorVision ? 0x2 : 0x0)));

            Stream.Write((byte)game.Dices.First);
            Stream.Write((byte)game.Dices.Second);

            Stream.Write((byte)game.DealerIndicator.Wind);
            Stream.Write((short)game.DealerIndicator.Position.Y);
            Stream.Write((short)game.DealerIndicator.Position.X);
            Stream.Write((byte)game.DealerIndicator.Direction);

            Stream.Write((short)game.WallBreakIndicator.Position.Y);
            Stream.Write((short)game.WallBreakIndicator.Position.X);
        }
示例#13
0
 public MahjongDices(MahjongGame game)
 {
     m_Game   = game;
     m_First  = Utility.Random(1, 6);
     m_Second = Utility.Random(1, 6);
 }
示例#14
0
 public MahjongWallBreakIndicator(MahjongGame game, Point2D position)
 {
     m_Game     = game;
     m_Position = position;
 }
示例#15
0
 public ResetGameEntry(MahjongGame game) : base(6162)
 {
     m_Game = game;
 }
示例#16
0
        public MahjongPlayersInfo(MahjongGame game, Mobile to) : base(0xDA)
        {
            MahjongPlayers players = game.Players;

            EnsureCapacity(11 + 45 * players.Seats);

            Stream.Write((int)game.Serial);
            Stream.Write((byte)0);
            Stream.Write((byte)0x2);

            Stream.Write((byte)0);
            Stream.Write((byte)players.Seats);

            int n = 0;

            for (int i = 0; i < players.Seats; i++)
            {
                Mobile mobile = players.GetPlayer(i);

                if (mobile != null)
                {
                    Stream.Write((int)mobile.Serial);
                    Stream.Write(players.DealerPosition == i ? (byte)0x1 : (byte)0x2);
                    Stream.Write((byte)i);

                    if (game.ShowScores || mobile == to)
                    {
                        Stream.Write((int)players.GetScore(i));
                    }
                    else
                    {
                        Stream.Write((int)0);
                    }

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

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

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

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

                    Stream.Write((int)players.GetScore(i));

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

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

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

                    n++;
                }
            }

            if (n != players.Seats)
            {
                Stream.Seek(10, System.IO.SeekOrigin.Begin);
                Stream.Write((byte)n);
            }
        }