public void AddWorkers(UnitCollection units, uint amount) { if (units == null) { throw new ArgumentNullException(nameof(units)); } units.Add(new UnitAmount(UnitInfo.WorkerUnitType, amount)); }
public decimal GetLabourPower(UnitCollection units) { if (units == null) { throw new ArgumentNullException(nameof(units)); } return(units.GetAll().Sum(u => (u.Amount * u.Unit.Workload))); }
public decimal GetMilitaryPower(UnitCollection units, MilitarySide side) { if (units == null) { throw new ArgumentNullException(nameof(units)); } switch (side) { case MilitarySide.Ofense: return(units.GetAll().Sum(u => (u.Amount * (u.Unit.Ofense)))); case MilitarySide.Defense: return(units.GetAll().Sum(u => (u.Amount * (u.Unit.Defense)))); case MilitarySide.Both: return(units.GetAll().Sum(u => (u.Amount * (u.Unit.Ofense + u.Unit.Defense)))); default: throw new ArgumentOutOfRangeException(nameof(side), side, null); } }
public void Substract(UnitCollection manySubstract) { foreach (var razedDefender in manySubstract._units) { if (this._units.ContainsKey(razedDefender.Key)) { uint currentAmount = this._units[razedDefender.Key]; if (currentAmount > razedDefender.Value) { currentAmount -= razedDefender.Value; } else { currentAmount = 0; } this._units[razedDefender.Key] = currentAmount; } else { this._units.Add(razedDefender.Key, 0); } } }