示例#1
0
        private void OnSelectIdleCmd(CoreMessage msg)
        {
            int player = msg.Reader.ReadByte();
            int count  = msg.Reader.ReadByte();

            msg.Reader.ReadBytes(count * 7);
            count = msg.Reader.ReadByte();
            msg.Reader.ReadBytes(count * 7);
            count = msg.Reader.ReadByte();
            msg.Reader.ReadBytes(count * 7);
            count = msg.Reader.ReadByte();
            msg.Reader.ReadBytes(count * 7);
            count = msg.Reader.ReadByte();
            msg.Reader.ReadBytes(count * 7);
            count = msg.Reader.ReadByte();
            msg.Reader.ReadBytes(count * 11 + 3);

            Game.RefreshAll();
            Game.WaitForResponse(player);
            SendToPlayer(msg, player);
        }
        private void OnNewTurn(CoreMessage msg)
        {
            Game.TimeReset();
            if (!Game.IsTag)
            {
                Game.RefreshAll();
            }
            Game.CurrentPlayer = msg.Reader.ReadByte();
            SendToAll(msg);

            if (Game.IsTag && Game.TurnCount > 0)
            {
                if (Game.TurnCount % 2 == 0)
                {
                    if (Game.CurPlayers[0].Equals(Game.Players[0]))
                    {
                        Game.CurPlayers[0] = Game.Players[1];
                    }
                    else
                    {
                        Game.CurPlayers[0] = Game.Players[0];
                    }
                }
                else
                {
                    if (Game.CurPlayers[1].Equals(Game.Players[2]))
                    {
                        Game.CurPlayers[1] = Game.Players[3];
                    }
                    else
                    {
                        Game.CurPlayers[1] = Game.Players[2];
                    }
                }
            }

            Game.TurnCount++;
        }
示例#3
0
        private void OnTagSwap(CoreMessage msg)
        {
            GameServerPacket packet = new GameServerPacket(GameMessage.TagSwap);

            int player = msg.Reader.ReadByte();

            packet.Write((byte)player);
            packet.Write(msg.Reader.ReadBytes(2));
            int count = msg.Reader.ReadByte();

            packet.Write((byte)count);
            packet.Write(msg.Reader.ReadBytes(4));

            for (int i = 0; i < count; i++)
            {
                uint code = msg.Reader.ReadUInt32();
                if ((code & 0x80000000) != 0)
                {
                    packet.Write(code);
                }
                else
                {
                    packet.Write(0);
                }
            }

            SendToPlayer(msg, player);
            Game.SendToAllBut(packet, player);

            Game.RefreshExtra(player);
            Game.RefreshMonsters(0, 0x81fff, false);
            Game.RefreshMonsters(1, 0x81fff, false);
            Game.RefreshSpells(0, 0x681fff, false);
            Game.RefreshSpells(1, 0x681fff, false);
            Game.RefreshHand(0, 0x181fff, false);
            Game.RefreshHand(1, 0x181fff, false);
        }
示例#4
0
 private void OnAnnounceNumber(CoreMessage msg)
 {
     int player = msg.Reader.ReadByte();
     int count = msg.Reader.ReadByte();
     msg.Reader.ReadBytes(count * 4);
     Game.WaitForResponse(player);
     SendToPlayer(msg, player);
 }
示例#5
0
 private void OnTossCoin(CoreMessage msg)
 {
     msg.Reader.ReadByte();
     int count = msg.Reader.ReadByte();
     msg.Reader.ReadBytes(count);
     SendToAll(msg);
 }
示例#6
0
        private void OnLpUpdate(CoreMessage msg)
        {
            int player = msg.Reader.ReadByte();
            int value = msg.Reader.ReadInt32();

            switch (msg.Message)
            {
                case GameMessage.LpUpdate:
                    Game.LifePoints[player] = value;
                    break;
                case GameMessage.PayLpCost:
                case GameMessage.Damage:
                    Game.LifePoints[player] -= value;
                    if (Game.LifePoints[player] < 0)
                        Game.LifePoints[player] = 0;
                    break;
                case GameMessage.Recover:
                    Game.LifePoints[player] += value;
                    break;
            }

            SendToAll(msg);
        }
示例#7
0
 private void OnBecomeTarget(CoreMessage msg)
 {
     int count = msg.Reader.ReadByte();
     msg.Reader.ReadBytes(count * 4);
     SendToAll(msg);
 }
示例#8
0
 private void OnCardSelected(CoreMessage msg)
 {
     msg.Reader.ReadByte();
     int count = msg.Reader.ReadByte();
     msg.Reader.ReadBytes(count * 4);
 }
示例#9
0
 private void OnSet(CoreMessage msg)
 {
     msg.Reader.ReadBytes(4);
     byte[] raw = msg.Reader.ReadBytes(4);
     GameServerPacket packet = new GameServerPacket(GameMessage.Set);
     packet.Write(0);
     packet.Write(raw);
     Game.SendToAll(packet);
 }
示例#10
0
 private void OnSelectPlace(CoreMessage msg)
 {
     int player = msg.Reader.ReadByte();
     msg.Reader.ReadBytes(5);
     Game.WaitForResponse(player);
     SendToPlayer(msg, player);
 }
示例#11
0
        private int OnSelectChain(CoreMessage msg)
        {
            int player = msg.Reader.ReadByte();
            int count = msg.Reader.ReadByte();
            msg.Reader.ReadBytes(10 + count * 11);

            if (count > 0)
            {
                Game.WaitForResponse(player);
                SendToPlayer(msg, player);
                return 1;
            }

            Game.SetResponse(-1);
            return 0;
        }
示例#12
0
        private void OnSelectCard(CoreMessage msg)
        {
            GameServerPacket packet = new GameServerPacket(msg.Message);

            int player = msg.Reader.ReadByte();
            packet.Write((byte)player);
            packet.Write(msg.Reader.ReadBytes(3));

            int count = msg.Reader.ReadByte();
            packet.Write((byte)count);

            for (int i = 0; i < count; i++)
            {
                int code = msg.Reader.ReadInt32();
                int pl = msg.Reader.ReadByte();
                int loc = msg.Reader.ReadByte();
                int seq = msg.Reader.ReadByte();
                int pos = msg.Reader.ReadByte();
                packet.Write(pl == player ? code : 0);
                packet.Write((byte)pl);
                packet.Write((byte)loc);
                packet.Write((byte)seq);
                packet.Write((byte)pos);
            }

            Game.WaitForResponse(player);
            Game.CurPlayers[player].Send(packet);
        }
示例#13
0
 private void OnFlipSummoning(CoreMessage msg)
 {
     byte[] raw = msg.Reader.ReadBytes(8);
     Game.RefreshSingle(raw[4], raw[5], raw[6]);
     SendToAll(msg);
 }
示例#14
0
 private void OnNewPhase(CoreMessage msg)
 {
     msg.Reader.ReadInt16();
     SendToAll(msg);
     Game.RefreshAll();
 }
示例#15
0
        public int Analyse(GameMessage msg, BinaryReader reader, byte[] raw)
        {
            LastMessage = msg;
            CoreMessage cmsg = new CoreMessage(msg, reader, raw);

            switch (msg)
            {
            case GameMessage.Retry:
                OnRetry();
                return(1);

            case GameMessage.Hint:
                OnHint(cmsg);
                break;

            case GameMessage.Win:
                OnWin(cmsg);
                return(2);

            case GameMessage.SelectBattleCmd:
                OnSelectBattleCmd(cmsg);
                return(1);

            case GameMessage.SelectIdleCmd:
                OnSelectIdleCmd(cmsg);
                return(1);

            case GameMessage.SelectEffectYn:
                OnSelectEffectYn(cmsg);
                return(1);

            case GameMessage.SelectYesNo:
                OnSelectYesNo(cmsg);
                return(1);

            case GameMessage.SelectOption:
                OnSelectOption(cmsg);
                return(1);

            case GameMessage.SelectCard:
            case GameMessage.SelectTribute:
                OnSelectCard(cmsg);
                return(1);

            case GameMessage.SelectChain:
                return(OnSelectChain(cmsg));

            case GameMessage.SelectPlace:
            case GameMessage.SelectDisfield:
            case GameMessage.SelectPosition:
                OnSelectPlace(cmsg);
                return(1);

            case GameMessage.SelectCounter:
                OnSelectCounter(cmsg);
                return(1);

            case GameMessage.SelectSum:
                OnSelectSum(cmsg);
                return(1);

            case GameMessage.SortCard:
            case GameMessage.SortChain:
                OnSortCard(cmsg);
                return(1);

            case GameMessage.ConfirmDecktop:
                OnConfirmDecktop(cmsg);
                break;

            case GameMessage.ConfirmCards:
                OnConfirmCards(cmsg);
                break;

            case GameMessage.ShuffleDeck:
            case GameMessage.RefreshDeck:
                SendToAll(cmsg, 1);
                break;

            case GameMessage.ShuffleHand:
                OnShuffleHand(cmsg);
                break;

            case GameMessage.SwapGraveDeck:
                OnSwapGraveDeck(cmsg);
                break;

            case GameMessage.ReverseDeck:
                SendToAll(cmsg, 0);
                break;

            case GameMessage.DeckTop:
                SendToAll(cmsg, 6);
                break;

            case GameMessage.ShuffleSetCard:
                OnShuffleSetCard(cmsg);
                break;

            case GameMessage.NewTurn:
                OnNewTurn(cmsg);
                break;

            case GameMessage.NewPhase:
                OnNewPhase(cmsg);
                break;

            case GameMessage.Move:
                OnMove(cmsg);
                break;

            case GameMessage.PosChange:
                OnPosChange(cmsg);
                break;

            case GameMessage.Set:
                OnSet(cmsg);
                break;

            case GameMessage.Swap:
                SendToAll(cmsg, 16);
                break;

            case GameMessage.FieldDisabled:
                SendToAll(cmsg, 4);
                break;

            case GameMessage.Summoned:
            case GameMessage.SpSummoned:
            case GameMessage.FlipSummoned:
                SendToAll(cmsg, 0);
                Game.RefreshMonsters(0);
                Game.RefreshMonsters(1);
                Game.RefreshSpells(0);
                Game.RefreshSpells(1);
                break;

            case GameMessage.Summoning:
            case GameMessage.SpSummoning:
                SendToAll(cmsg, 8);
                break;

            case GameMessage.FlipSummoning:
                OnFlipSummoning(cmsg);
                break;

            case GameMessage.Chaining:
                SendToAll(cmsg, 16);
                break;

            case GameMessage.Chained:
                SendToAll(cmsg, 1);
                Game.RefreshAll();
                break;

            case GameMessage.ChainSolving:
                SendToAll(cmsg, 1);
                break;

            case GameMessage.ChainSolved:
                SendToAll(cmsg, 1);
                Game.RefreshAll();
                break;

            case GameMessage.ChainEnd:
                SendToAll(cmsg, 0);
                Game.RefreshAll();
                break;

            case GameMessage.ChainNegated:
            case GameMessage.ChainDisabled:
                SendToAll(cmsg, 1);
                break;

            case GameMessage.CardSelected:
                OnCardSelected(cmsg);
                break;

            case GameMessage.RandomSelected:
                OnRandomSelected(cmsg);
                break;

            case GameMessage.BecomeTarget:
                OnBecomeTarget(cmsg);
                break;

            case GameMessage.Draw:
                OnDraw(cmsg);
                break;

            case GameMessage.Damage:
            case GameMessage.Recover:
            case GameMessage.LpUpdate:
            case GameMessage.PayLpCost:
                OnLpUpdate(cmsg);
                break;

            case GameMessage.Equip:
                SendToAll(cmsg, 8);
                break;

            case GameMessage.Unequip:
                SendToAll(cmsg, 4);
                break;

            case GameMessage.CardTarget:
            case GameMessage.CancelTarget:
                SendToAll(cmsg, 8);
                break;

            case GameMessage.AddCounter:
            case GameMessage.RemoveCounter:
                SendToAll(cmsg, 7);
                break;

            case GameMessage.Attack:
                SendToAll(cmsg, 8);
                break;

            case GameMessage.Battle:
                SendToAll(cmsg, 26);
                break;

            case GameMessage.AttackDiabled:
                SendToAll(cmsg, 0);
                break;

            case GameMessage.DamageStepStart:
            case GameMessage.DamageStepEnd:
                SendToAll(cmsg, 0);
                Game.RefreshMonsters(0);
                Game.RefreshMonsters(1);
                break;

            case GameMessage.MissedEffect:
                OnMissedEffect(cmsg);
                break;

            case GameMessage.TossCoin:
            case GameMessage.TossDice:
                OnTossCoin(cmsg);
                break;

            case GameMessage.AnnounceRace:
                OnAnnounceRace(cmsg);
                return(1);

            case GameMessage.AnnounceAttrib:
                OnAnnounceAttrib(cmsg);
                return(1);

            case GameMessage.AnnounceCard:
                OnAnnounceCard(cmsg);
                return(1);

            case GameMessage.AnnounceNumber:
                OnAnnounceNumber(cmsg);
                return(1);

            case GameMessage.CardHint:
                SendToAll(cmsg, 9);
                break;

            case GameMessage.MatchKill:
                OnMatchKill(cmsg);
                break;

            case GameMessage.TagSwap:
                OnTagSwap(cmsg);
                break;

            default:
                throw new Exception("[GameAnalyser] Unhandled packet id: " + msg);
            }
            return(0);
        }
示例#16
0
        private void OnTagSwap(CoreMessage msg)
        {
            GameServerPacket packet = new GameServerPacket(GameMessage.TagSwap);

            int player = msg.Reader.ReadByte();
            packet.Write((byte)player);
            packet.Write(msg.Reader.ReadBytes(2));
            int count = msg.Reader.ReadByte();
            packet.Write((byte)count);
            packet.Write(msg.Reader.ReadBytes(4));

            for (int i = 0; i < count; i++)
            {
                uint code = msg.Reader.ReadUInt32();
                if ((code & 0x80000000) != 0)
                    packet.Write(code);
                else
                    packet.Write(0);
            }

            SendToPlayer(msg, player);
            Game.SendToAllBut(packet, player);

            Game.RefreshExtra(player);
            Game.RefreshMonsters(0, 0x81fff, false);
            Game.RefreshMonsters(1, 0x81fff, false);
            Game.RefreshSpells(0, 0x681fff, false);
            Game.RefreshSpells(1, 0x681fff, false);
            Game.RefreshHand(0, 0x181fff, false);
            Game.RefreshHand(1, 0x181fff, false);
        }
示例#17
0
 private void SendToAll(CoreMessage msg, int length)
 {
     if (length == 0)
     {
         Game.SendToAll(new GameServerPacket(msg.Message));
         return;
     }
     msg.Reader.ReadBytes(length);
     SendToAll(msg);
 }
示例#18
0
 private void OnSelectSum(CoreMessage msg)
 {
     msg.Reader.ReadByte();
     int player = msg.Reader.ReadByte();
     msg.Reader.ReadBytes(6);
     int count = msg.Reader.ReadByte();
     msg.Reader.ReadBytes(count * 11);
     Game.WaitForResponse(player);
     SendToPlayer(msg, player);
 }
示例#19
0
        private void OnPosChange(CoreMessage msg)
        {
            byte[] raw = msg.Reader.ReadBytes(9);
            SendToAll(msg);

            int cc = raw[4];
            int cl = raw[5];
            int cs = raw[6];
            int pp = raw[7];
            int cp = raw[8];
            if ((pp & (int)CardPosition.FaceDown) != 0 && (cp & (int)CardPosition.FaceUp) != 0)
                Game.RefreshSingle(cc, cl, cs);
        }
示例#20
0
 private void OnSortCard(CoreMessage msg)
 {
     int player = msg.Reader.ReadByte();
     int count = msg.Reader.ReadByte();
     msg.Reader.ReadBytes(count * 7);
     Game.WaitForResponse(player);
     SendToPlayer(msg, player);
 }
示例#21
0
 private void OnFlipSummoning(CoreMessage msg)
 {
     byte[] raw = msg.Reader.ReadBytes(8);
     Game.RefreshSingle(raw[4], raw[5], raw[6]);
     SendToAll(msg);
 }
示例#22
0
 private void OnConfirmDecktop(CoreMessage msg)
 {
     msg.Reader.ReadByte();
     int count = msg.Reader.ReadByte();
     msg.Reader.ReadBytes(count * 7);
     SendToAll(msg);
 }
示例#23
0
 private void OnRandomSelected(CoreMessage msg)
 {
     msg.Reader.ReadByte();
     int count = msg.Reader.ReadByte();
     msg.Reader.ReadBytes(count * 4);
     SendToAll(msg);
 }
示例#24
0
        private void OnConfirmCards(CoreMessage msg)
        {
            int player = msg.Reader.ReadByte();
            int count = msg.Reader.ReadByte();
            msg.Reader.ReadBytes(count * 7);

            byte[] buffer = msg.CreateBuffer();
            GameServerPacket packet = new GameServerPacket(msg.Message);
            packet.Write(buffer);
            if ((CardLocation)buffer[7] == CardLocation.Hand)
                Game.SendToAll(packet);
            else
                Game.CurPlayers[player].Send(packet);
        }
示例#25
0
        private void OnDraw(CoreMessage msg)
        {
            GameServerPacket packet = new GameServerPacket(msg.Message);
            int player = msg.Reader.ReadByte();
            int count = msg.Reader.ReadByte();
            packet.Write((byte)player);
            packet.Write((byte)count);

            for (int i = 0; i < count; i++)
            {
                uint code = msg.Reader.ReadUInt32();
                if ((code & 0x80000000) != 0)
                    packet.Write(code);
                else
                    packet.Write(0);
            }

            SendToPlayer(msg, player);
            Game.SendToAllBut(packet, player);
        }
示例#26
0
        private void OnShuffleHand(CoreMessage msg)
        {
            GameServerPacket packet = new GameServerPacket(msg.Message);
            int player = msg.Reader.ReadByte();
            int count = msg.Reader.ReadByte();
            packet.Write((byte)player);
            packet.Write((byte)count);

            msg.Reader.ReadBytes(count * 4);
            for (int i = 0; i < count; i++)
                packet.Write(0);

            SendToPlayer(msg, player);
            Game.SendToAllBut(packet, player);
            Game.RefreshHand(player, 0x181fff, false);
        }
示例#27
0
 private void OnMissedEffect(CoreMessage msg)
 {
     int player = msg.Reader.ReadByte();
     msg.Reader.ReadBytes(7);
     SendToPlayer(msg, player);
 }
示例#28
0
 private void OnSwapGraveDeck(CoreMessage msg)
 {
     int player = msg.Reader.ReadByte();
     SendToAll(msg);
     Game.RefreshGrave(player);
 }
示例#29
0
 private void OnAnnounceCard(CoreMessage msg)
 {
     int player = msg.Reader.ReadByte();
     Game.WaitForResponse(player);
     SendToPlayer(msg, player);
 }
示例#30
0
 private void OnShuffleSetCard(CoreMessage msg)
 {
     int count = msg.Reader.ReadByte();
     msg.Reader.ReadBytes(count * 8);
     SendToAll(msg);
     Game.RefreshMonsters(0, 0x181fff, false);
     Game.RefreshMonsters(1, 0x181fff, false);
 }
示例#31
0
 private void OnMatchKill(CoreMessage msg)
 {
     msg.Reader.ReadInt32();
     if (Game.IsMatch)
     {
         Game.MatchKill();
         SendToAll(msg);
     }
 }
示例#32
0
        private void OnNewTurn(CoreMessage msg)
        {
            Game.TimeReset();
            if (!Game.IsTag)
                Game.RefreshAll();
            Game.CurrentPlayer = msg.Reader.ReadByte();
            SendToAll(msg);

            if (Game.IsTag && Game.TurnCount > 0)
            {
                if (Game.TurnCount % 2 == 0)
                {
                    if (Game.CurPlayers[0].Equals(Game.Players[0]))
                        Game.CurPlayers[0] = Game.Players[1];
                    else
                        Game.CurPlayers[0] = Game.Players[0];
                }
                else
                {
                    if (Game.CurPlayers[1].Equals(Game.Players[2]))
                        Game.CurPlayers[1] = Game.Players[3];
                    else
                        Game.CurPlayers[1] = Game.Players[2];
                }
            }
            Game.TurnCount++;
        }
示例#33
0
 private void SendToAll(CoreMessage msg)
 {
     byte[] buffer = msg.CreateBuffer();
     GameServerPacket packet = new GameServerPacket(msg.Message);
     packet.Write(buffer);
     Game.SendToAll(packet);
 }
示例#34
0
 private void OnNewPhase(CoreMessage msg)
 {
     msg.Reader.ReadByte();
     SendToAll(msg);
     Game.RefreshAll();
 }
示例#35
0
 private void SendToPlayer(CoreMessage msg, int player)
 {
     if (player != 0 && player != 1)
         return;
     byte[] buffer = msg.CreateBuffer();
     GameServerPacket packet = new GameServerPacket(msg.Message);
     packet.Write(buffer);
     Game.CurPlayers[player].Send(packet);
 }
示例#36
0
        private void OnMove(CoreMessage msg)
        {
            byte[] raw = msg.Reader.ReadBytes(16);
            int pc = raw[4];
            int pl = raw[5];
            int cc = raw[8];
            int cl = raw[9];
            int cs = raw[10];
            int cp = raw[11];

            SendToPlayer(msg, cc);
            GameServerPacket packet = new GameServerPacket(msg.Message);
            packet.Write(raw);
            if (!Convert.ToBoolean((cl & ((int)CardLocation.Grave + (int)CardLocation.Overlay))) && Convert.ToBoolean((cl & ((int)CardLocation.Deck + (int)CardLocation.Hand)))
                || Convert.ToBoolean((cp & (int)CardPosition.FaceDown)))
            {
                packet.SetPosition(2);
                packet.Write(0);
            }
            Game.SendToAllBut(packet, cc);

            if (cl != 0 && (cl & 0x80) == 0 && (cl != pl || pc != cc))
                Game.RefreshSingle(cc, cl, cs);
        }