Exemplo n.º 1
0
        public override string ToString()
        {
            if (!CanReserve())
            {
                return($"You can not reserve the development. You have already reserved {MaxReservesAllowed}");
            }

            string goldText = WouldTakeGoldToken() ? ", and you would take a gold token" : ", but you would not take any gold token";

            return($"You can reserve {development.ToString()}{goldText}");
        }
Exemplo n.º 2
0
        public void BuyCard(Development development)
        {
            if (!deck.Contains(development))
            {
                throw new NotFoundException($"Can not take {development.ToString()} because it is not in the deck");
            }

            if (!IsVisible(development))
            {
                throw new DomainException($"Can not take {development.ToString()} because it is not visible");
            }

            TakeCard(development);
        }
Exemplo n.º 3
0
        public void Purchase(Deck deck, Market market)
        {
            if (!CanAffordPayingGold())
            {
                throw new DomainException($"{player.ToString()} can not afford {development.ToString()}");
            }

            var goldSpended = Enumerable.Range(0, RequiredGold()).Select(x => Gems.Gold).ToArray();

            player.TakeGems(goldSpended);
            market.Add(goldSpended);

            var expenses = new List <Gem>();

            foreach (var gem in Gems.GetAllGems())
            {
                foreach (int i in Enumerable.Range(0, WouldSpend(gem)))
                {
                    expenses.Add(gem);
                    market.Add(gem);
                }
            }
            player.TakeGems(expenses.ToArray());
            deck.BuyCard(development);
            player.BuyCard(development);
        }