示例#1
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);
        }
示例#2
0
 public IEnumerable <Noble> CanReceiveVisitFrom()
 {
     foreach (var noble in box.NobleList)
     {
         bool visitable = Gems.GetAllGems().All(gem => player.Bonus(gem) >= noble.RequiredQuantity(gem));
         if (visitable)
         {
             yield return(noble);
         }
     }
 }
示例#3
0
        public Market(int gemCount, int goldCount)
        {
            gems = new List <Gem>();
            foreach (var gem in Gems.GetAllGems())
            {
                foreach (var i in Enumerable.Range(0, gemCount))
                {
                    gems.Add(gem);
                }
            }

            foreach (var i in Enumerable.Range(0, goldCount))
            {
                gems.Add(Gems.Gold);
            }
        }
示例#4
0
 private IEnumerable <Gem> TwoSameRandomGems() => Gems.GetAllGems()
 .Where(gem => market.CanBeTakenTwoOfType(gem))
 .ToList()
 .RandomizeList()
 .FirstOrDefault()?
 .Get(2);
示例#5
0
 private IEnumerable <Gem> ThreeRandomGems() => Gems.GetAllGems()
 .Where(gem => market.AvaliableOfType(gem) > 0)
 .ToList()
 .RandomizeList()
 .Take(3);
示例#6
0
 private string AreMissingText()
 {
     return(Gems.GetAllGems()
            .SelectMany(gem => gem.Get(Missing(gem)))
            .JoinList());
 }
示例#7
0
 private string WouldSpendText()
 {
     return(Gems.GetAllGems()
            .SelectMany(gem => gem.Get(WouldSpend(gem)))
            .JoinList());
 }
示例#8
0
 private int RequiredGold() => Gems.GetAllGems().Sum(gem => Missing(gem));
示例#9
0
 public bool CanAfford() => Gems.GetAllGems().All(gem => player.TotalGems(gem) >= WouldSpend(gem));
示例#10
0
 public bool IsFree() => Gems.GetAllGems().All(gem => player.Bonus(gem) >= WouldSpend(gem));
示例#11
0
 public int Cost() => Gems.GetAllGems().Sum(x => WouldSpend(x));