public TroopDistributionResult Calculate(TroopDistributionCommand command)
        {
            var trainingDataResult = _dataProvider.GetTrainingData();

            var bluforPlayers = (int)Math.Ceiling(command.IsPvp ? GetBluforPlayersForPvp(command) : command.PlayersForCalculation);
            var opforPlayers  = command.PlayersForCalculation - bluforPlayers;

            Platoon blufor = ConvertTrainingSet(trainingDataResult, bluforPlayers, command.MinimumFireteamSize, TeamSide.Blufor);
            Platoon opfor  = null;

            if (opforPlayers != 0)
            {
                opfor = ConvertTrainingSet(trainingDataResult, opforPlayers, command.MinimumFireteamSize, TeamSide.Opfor);
            }

            var unusedPlayers = command.PlayersForCalculation - (bluforPlayers + opforPlayers);

            return(new TroopDistributionResult
            {
                Blufor = blufor,
                Opfor = opfor,
                SpecialRoles = command.SpecialRolePlayers != 0 ? new SpecialPlatoon("Special roles", command.SpecialRolePlayers) : null,
                ExtraPlayers = unusedPlayers != 0 ? new SpecialPlatoon("Unused players", unusedPlayers) : null,
                Zeus = command.IsPvp ? null : new SpecialPlatoon("Zeus", command.NumberOfZeuses)
            });
        }
Пример #2
0
        private bool GetCommand(out TroopDistributionCommand command)
        {
            try
            {
                command = new TroopDistributionCommand
                {
                    IsPvp               = IsPvp,
                    NumberOfPlayers     = NumberOfPlayers,
                    Ratio               = IsPvp ? Ratio : new decimal?(),
                    SpecialRolePlayers  = SpecialRolePlayers,
                    MinimumFireteamSize = IdealFireteamSize,
                    NumberOfZeuses      = IsPvp ? 0 : 1
                };

                return(true);
            }
            catch (Exception)
            {
                command = new TroopDistributionCommand();
                return(false);
            }
        }
 private decimal GetBluforPlayersForPvp(TroopDistributionCommand command)
 {
     return(command.PlayersForCalculation * command.Ratio.Value);
 }