Exemplo n.º 1
0
        public override Card RemodelTrash(PlayerState ps, Kingdom k)
        {
            var trash = ps.Hand.Where(c => c.Type == CardType.Curse);

            // at the end it will transform gold to province
            var provinces = k.GetPile(CardType.Province);

            if (buyAgenda.Provinces > provinces.Count && provinces.Count > 0)
            {
                trash = trash.Concat(ps.Hand.Where(c => c.Type == CardType.Gold));
            }

            if (buyAgenda.Estates <= provinces.Count)
            {
                trash = trash.Concat(ps.Hand.Where(c => c.Type == CardType.Estate));
            }

            trash = trash.Concat(ps.Hand.Where(c => c.Type == CardType.Copper));
            trash = trash.Concat(ps.Hand.OrderBy(c => c.Score(ps.Hand, ps, Phase.Action)));

            return(trash.FirstOrDefault());
        }
Exemplo n.º 2
0
        public override List <Card> ChapelTrash(PlayerState ps, Kingdom k)
        {
            var cards = ps.Hand;

            // allways trash curse
            var trash = cards.Where(c => c.Type == CardType.Curse);

            var neco = trash.ToString();

            // in the beginnig trash estate as well
            var provinces = k.GetPile(CardType.Province);

            if (buyAgenda.Estates <= provinces.Count)
            {
                trash = trash.Concat(cards.Where(c => c.Type == CardType.Estate));
            }

            if (trash.Count() >= 4)
            {
                return(trash.Take(4).ToList());
            }

            // trash only unnecesary coppers
            int coins = cards.Select(c => c.Coins).Sum() + ps.Coins;
            var card  = SelectCardToGain(k.GetWrapper(coins), ps, k, Phase.Buy);
            int price = card == null ? 0 : card.Price;

            if (playerInfo.TreasureTotal > 3)
            {
                var coppers = cards.Where(c => c.Type == CardType.Copper).Take(coins - price);
                trash = trash.Concat(coppers);
                // player info update
                playerInfo.TreasureTotal -= coppers.Count();
            }

            return(trash.Take(4).ToList());
        }
Exemplo n.º 3
0
        public override Card SelectCardToGain(KingdomWrapper wrapper, PlayerState ps, Kingdom k, Phase phase)
        {
            var provinces = k.GetPile(CardType.Province);

            if (buyAgenda.Provinces > provinces.Count && wrapper.GetCard(CardType.Province) != null)
            {
                return(Province.Get());
            }

            var duchies = k.GetPile(CardType.Duchy);

            if (buyAgenda.Duchies > provinces.Count && wrapper.GetCard(CardType.Duchy) != null)
            {
                return(Duchy.Get());
            }

            var estates = k.GetPile(CardType.Estate);

            if (buyAgenda.Estates > provinces.Count && wrapper.GetCard(CardType.Estate) != null)
            {
                return(Estate.Get());
            }

            for (int i = 0; i < buyAgenda.BuyMenu.Count; i++)
            {
                var tuple = buyAgenda.BuyMenu[i];
                if (tuple.Number <= 0)
                {
                    continue;
                }

                var card = wrapper.GetCard(tuple.Card);
                if (card == null)
                {
                    continue;
                }

                tuple.Number--;
                if (tuple.Number == 0)
                {
                    buyAgenda.BuyMenu.RemoveAt(i);
                }
                else
                {
                    buyAgenda.BuyMenu[i] = tuple; // this is a value type, i have to return the value back
                }
                if (card.IsTreasure)
                {
                    playerInfo.TreasureTotal += card.Coins;
                }
                if (card.Type == CardType.Moneylender)
                {
                    playerInfo.TreasureTotal -= 1;
                }
                else if (card.Type == CardType.Bureaucrat)
                {
                    playerInfo.TreasureTotal += 2;
                }
                else if (card.Type == CardType.Mine)
                {
                    playerInfo.TreasureTotal += 1;
                }

                return(card);
            }
            return(null);
        }
Exemplo n.º 4
0
 private bool isGameEnd() => Kingdom.GetPile(CardType.Province).Empty || Kingdom.EmptyPiles >= 3;