Exemplo n.º 1
0
        public bool BuyBuilding(int settlementId, IBuilding building, int count = 1)
        {
            var cost = building.GetCost().ToDictionary(p => p.Key, p => p.Value * count);

            if (settlementId < Settlements.Count && HasEnoughResources(cost))
            {
                Settlement settlement = Settlements.Find(s => s.Id == settlementId);

                settlement.AddBuilding(building, count);
                Resources.Subtract(cost);

                return(true);
            }
            return(false);
        }