Exemplo n.º 1
0
        public void ActionPhase(IGame game, ITurn turn, IPlayer player)
        {
            ICard card;

            while (turn.Actions > 0)
            {
                card = Utils.GetCard<Village>(player.Hand);
                if (card != null)
                {
                    turn.PlayAction(card, null);
                    continue;
                }

                card = Utils.GetCard<Market>(player.Hand);
                if (card != null)
                {
                    turn.PlayAction(card, null);
                    continue;
                }

                card = Utils.GetCard<Cellar>(player.Hand);
                if (card != null)
                {
                    IList<ICard> discards = new List<ICard>();
                    foreach (ICard cardInHand in player.Hand)
                    {
                        if (!Object.ReferenceEquals(cardInHand, card))
                        {
                            if ((cardInHand.Type & CardType.Victory) == CardType.Victory &&
                                (cardInHand.Type & CardType.Action) != CardType.Action)
                                discards.Add(cardInHand);
                            else if ((Game.Base.Cards)cardInHand.CardEnum == Game.Base.Cards.Cellar)
                                discards.Add(cardInHand);
                        }
                    }
                    if (discards.Count > 0)
                    {
                        turn.PlayAction(card, discards);
                        continue;
                    }
                }

                card = Utils.GetCard<Smithy>(player.Hand);
                if (card != null)
                {
                    turn.PlayAction(card, null);
                    continue;
                }

                card = Utils.GetCard<Mine>(player.Hand);
                if (card != null)
                {
                    ICard targetCard = Utils.GetCard<Copper>(player.Hand);
                    if (targetCard != null && game.HasAvailable(Game.Base.Cards.Silver))
                    {
                        turn.PlayAction(card, new Mine.MineData { Card = targetCard, TargetType = Game.Base.Cards.Silver });
                        continue;
                    }

                    targetCard = Utils.GetCard<Silver>(player.Hand);
                    if (targetCard != null && game.HasAvailable(Game.Base.Cards.Gold))
                    {
                        turn.PlayAction(card, new Mine.MineData { Card = targetCard, TargetType = Game.Base.Cards.Gold });
                        continue;
                    }
                }

                card = Utils.GetCard<Militia>(player.Hand);
                if (card != null)
                {
                    turn.PlayAction(card, null);
                    continue;
                }

                card = Utils.GetCard<Woodcutter>(player.Hand);
                if (card != null)
                {
                    turn.PlayAction(card, null);
                    continue;
                }

                card = Utils.GetCard<Moat>(player.Hand);
                if (card != null)
                {
                    turn.PlayAction(card, null);
                    continue;
                }

                break;
            }
        }