コード例 #1
0
        public decimal GetLabourPower(UnitCollection units)
        {
            if (units == null)
            {
                throw new ArgumentNullException(nameof(units));
            }

            return(units.GetAll().Sum(u => (u.Amount * u.Unit.Workload)));
        }
コード例 #2
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);
            }
        }