public void Process(GameField game, Player caster, Player opponent, PokemonCard pokemonSource)
        {
            var choices = caster.Deck.Cards.Take(AmountToPickFrom).ToList();

            var message  = new DeckSearchMessage(choices, CardUtil.GetCardFilters(CardType, EnergyType), AmountToPick);
            var response = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message.ToNetworkMessage(game.Id));
            var cards    = new HashSet <Card>(response.Cards.Select(id => game.Cards[id]));

            var discardedCards = new List <Card>();
            var cardsDrawn     = new List <Card>();

            foreach (var card in choices)
            {
                if (cards.Contains(card))
                {
                    if (revealPickedCards)
                    {
                        card.RevealToAll();
                    }
                    cardsDrawn.Add(card);
                }
                else if (ShuffleBack)
                {
                    caster.Deck.Cards.Push(card);
                }
                else
                {
                    card.RevealToAll();
                    discardedCards.Add(card);
                }
            }

            if (shuffleBack)
            {
                caster.Deck.Shuffle();
            }

            caster.DrawCardsFromDeck(cardsDrawn);
            caster.DiscardPile.AddRange(discardedCards);

            game.SendEventToPlayers(new CardsDiscardedEvent()
            {
                Cards = discardedCards, Player = caster.Id
            });
        }
Exemple #2
0
        public static List <NetworkId> TriggerDeckSearch(this IDeckSearcher deckSearcher, Player owner)
        {
            var message  = new DeckSearchMessage(owner.Deck.Cards.ToList(), deckSearcher.GetDeckFilters(), deckSearcher.GetNumberOfCards());
            var response = owner.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(message.ToNetworkMessage(owner.Id));

            if (response.Cards.Count != deckSearcher.GetNumberOfCards())
            {
                throw new Exception("Cheating!?");
            }

            owner.Deck.Shuffle();
            return(response.Cards);
        }
        public void Process(GameField game, Player caster, Player opponent, PokemonCard pokemonSource)
        {
            var filters       = CardUtil.GetCardFilters(CardType);
            var searchMessage = new DeckSearchMessage(opponent.Hand, filters, Amount);
            var response      = caster.NetworkPlayer.SendAndWaitForResponse <CardListMessage>(searchMessage.ToNetworkMessage(game.Id));

            foreach (var id in response.Cards)
            {
                var card = game.Cards[id];

                if (shuffleIntoDeck)
                {
                    opponent.Hand.Remove(card);
                    opponent.Deck.ShuffleInCard(card);

                    game.SendEventToPlayers(new CardsDiscardedEvent()
                    {
                        Cards = new List <Card> {
                            card
                        }, Player = opponent.Id
                    });
                }
                else
                {
                    opponent.DiscardCard(card);
                }
            }
        }