Commit fce2d82b authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:moecube/windbot

parents d561ae5f 49f09bc4
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using WindBot.Game.AI; using WindBot.Game.AI;
using YGOSharp.Network; using YGOSharp.Network;
...@@ -105,6 +106,7 @@ namespace WindBot.Game ...@@ -105,6 +106,7 @@ namespace WindBot.Game
_messages.Add(GameMessage.ShuffleHand, OnShuffleHand); _messages.Add(GameMessage.ShuffleHand, OnShuffleHand);
_messages.Add(GameMessage.ShuffleExtra, OnShuffleExtra); _messages.Add(GameMessage.ShuffleExtra, OnShuffleExtra);
_messages.Add(GameMessage.ShuffleSetCard, OnShuffleSetCard); _messages.Add(GameMessage.ShuffleSetCard, OnShuffleSetCard);
_messages.Add(GameMessage.SwapGraveDeck, OnSwapGraveDeck);
_messages.Add(GameMessage.TagSwap, OnTagSwap); _messages.Add(GameMessage.TagSwap, OnTagSwap);
_messages.Add(GameMessage.NewTurn, OnNewTurn); _messages.Add(GameMessage.NewTurn, OnNewTurn);
_messages.Add(GameMessage.NewPhase, OnNewPhase); _messages.Add(GameMessage.NewPhase, OnNewPhase);
...@@ -491,6 +493,36 @@ namespace WindBot.Game ...@@ -491,6 +493,36 @@ namespace WindBot.Game
} }
} }
private void OnSwapGraveDeck(BinaryReader packet)
{
int player = GetLocalPlayer(packet.ReadByte());
IList<ClientCard> tmpDeckList = _duel.Fields[player].Deck.ToList();
_duel.Fields[player].Deck.Clear();
int seq = 0;
foreach(var card in _duel.Fields[player].Graveyard)
{
if (card.IsExtraCard())
{
_duel.Fields[player].ExtraDeck.Add(card);
card.Location = CardLocation.Extra;
card.Position = (int)CardPosition.FaceDown;
// TODO: face-up P cards
}
else
{
_duel.Fields[player].Deck.Add(card);
card.Location = CardLocation.Deck;
card.Sequence = seq++;
}
}
_duel.Fields[player].Graveyard.Clear();
foreach (var card in tmpDeckList)
{
_duel.Fields[player].Graveyard.Add(card);
card.Location = CardLocation.Grave;
}
}
private void OnTagSwap(BinaryReader packet) private void OnTagSwap(BinaryReader packet)
{ {
int player = GetLocalPlayer(packet.ReadByte()); int player = GetLocalPlayer(packet.ReadByte());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment