Exemplo n.º 1
0
        public void AddWorkers(UnitCollection units, uint amount)
        {
            if (units == null)
            {
                throw new ArgumentNullException(nameof(units));
            }

            units.Add(new UnitAmount(UnitInfo.WorkerUnitType, amount));
        }
Exemplo n.º 2
0
        public decimal GetLabourPower(UnitCollection units)
        {
            if (units == null)
            {
                throw new ArgumentNullException(nameof(units));
            }

            return(units.GetAll().Sum(u => (u.Amount * u.Unit.Workload)));
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
 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);
         }
     }
 }