/// <summary> /// Sets the quantity and type of animals in the housing and returns /// the new object. /// </summary> /// <param name="type"></param> /// <param name="count"></param> /// <returns></returns> public AnimalHousing SetAnimals(AnimalResource type, int count) { if (count > Capacity) { throw new ArgumentOutOfRangeException("count"); } return(new AnimalHousing(Id, Capacity, type, count)); }
public AnimalManager RemoveAnimals(AnimalResource type, int count) { ImmutableDictionary <string, AnimalHousing> newHousings = null; var matches = housings.Values.Where(x => x.AnimalType == type).OrderBy(x => x.AnimalCount); foreach (var m in matches) { var toRemove = m.AnimalCount < count ? m.AnimalCount : count; newHousings = housings.SetItem(m.Id, m.SetAnimals(type, m.AnimalCount - toRemove)); count -= toRemove; if (count == 0) { break; } } return(newHousings == null ? this : new AnimalManager(newHousings)); }
public void DistributeDelayedResources(List <GameActionNotice> resultingNotices) { foreach (var kvp in delayedResources) { var player = kvp.Key; foreach (var cache in kvp.Value.Values) { if (!(Enum.IsDefined(typeof(AnimalResource), cache.Type.ToString()))) { player.AddResource(cache); } else { AnimalResource animalType = (AnimalResource)cache.Type;// (AnimalResource)Enum.Parse(typeof(AnimalResource), cache.Type.ToString()); ((AgricolaGame)player.Game).AddInterrupt(new AssignAnimalsAction(player, animalType, cache.Count, resultingNotices)); } } } delayedResources.Clear(); }
public Farmyard RemoveAnimals(AnimalResource type, int count) { return(Farmyard = Farmyard.RemoveAnimals(type, count)); }
public Farmyard RemoveAnimals(AnimalResource type, int count) { return(new Farmyard(Grid, Pastures, Fences, AnimalManager.RemoveAnimals(type, count), HouseType)); }
public int AnimalCount(AnimalResource Type) { return(AnimalManager.GetAnimalCount(Type)); }
public int GetAnimalCount(AnimalResource type) { return(housings.Values.Where(x => x.AnimalType == type).Sum(y => y.AnimalCount)); }
public TakeAnimalActionTrigger(AnimalResource animalType = AnimalResource.Sheep) : base() { this.AnimalType = animalType; }
public AssignAnimalsAction(AgricolaPlayer player, AnimalResource animalType, int animalCount, List <GameActionNotice> resultingNotices) : this(player, new ResourceCache[] { new ResourceCache((Resource)animalType, animalCount) }, resultingNotices) { }