Ejemplo n.º 1
0
        public Battle(  
            IDictionary<CombatUnitType, int> attackers, 
            IDictionary<CombatUnitType, int> defenders, 
            IList<ValidCombatUnitTypes> attackerCasualtyOrder,
            IList<ValidCombatUnitTypes> defenderCasualtyOrder,
            IHitGenerator hitGenerator)
        {
            if (attackers == null || attackers.Count == 0 || attackers.Values.Sum() == 0)
                throw new ArgumentException("attackers");
            if (defenders == null || defenders.Count == 0 || defenders.Values.Sum() == 0)
                throw new ArgumentException("defenders");
            if (attackerCasualtyOrder == null || attackerCasualtyOrder.Count == 0)
                throw new ArgumentException("attackerCasualtyOrder");
            if (defenderCasualtyOrder == null || defenderCasualtyOrder.Count == 0)
                throw new ArgumentException("defenderCasualtyOrder");

            Attackers = new Dictionary<CombatUnitType,int>(attackers);
            SurvivingAttackers = new Dictionary<CombatUnitType, int>(attackers);
            AttackerCasualtyOrder = attackerCasualtyOrder;

            Defenders =  new Dictionary<CombatUnitType,int>(defenders);
            SurvivingDefenders = new Dictionary<CombatUnitType, int>(defenders);
            DefenderCasualtyOrder = defenderCasualtyOrder;

            AttackerHits = new List<int>();
            DefenderHits = new List<int>();
            RoundCount = 0;
            _hitGenerator = hitGenerator;
        }
Ejemplo n.º 2
0
        public MainWindowViewModel()
        {
            _unitTypesInBattle = GetAvailableUnitTypes();
            _currentDefenders = new Dictionary<CombatUnitType, int>();
            _currentAttackers = new Dictionary<CombatUnitType, int>();

            _simulationWorker = new BackgroundWorker();
            _simulationWorker.DoWork += HandleSimulationWorkerDoWork;
            _simulationWorker.ProgressChanged += HandleSimulationWorkerProgressChanged;
            _simulationWorker.WorkerReportsProgress = true;

            IsProgressBarVisible = false;
            SimulationRuns = 10000;
            _hitGenerator = new HitGenerator();

            _simulationResultsViewModel = new SimulationResultsViewModel();
            _attackerCasualtyOrderViewModel = new CasualtyOrderViewModel(GetInitialAttackerCasualtyOrder());
            _defenderCasualtyOrderViewModel = new CasualtyOrderViewModel(GetInitialDefenderCasualtyOrder());
        }
Ejemplo n.º 3
0
 protected void SetUp()
 {
     _die = Substitute.For<IDie>();
     _hitGenerator = new HitGenerator(_die);
     _units = new Dictionary<CombatUnitType,int>() { {TestUtils.CreateInfantryType(), 1 } };
 }
Ejemplo n.º 4
0
 protected void Setup()
 {
     _attackers = new Dictionary<CombatUnitType, int>() { { TestUtils.CreateTankType(), 2 }, { TestUtils.CreateInfantryType(), 1 } };
     _defenders = new Dictionary<CombatUnitType, int>() { { TestUtils.CreateTankType(), 1 }, { TestUtils.CreateInfantryType(), 1 } };
     _attackerCasualtyOrder = TestUtils.CreateStandardCasualtyOrder();
     _defenderCasualtyOrder = TestUtils.CreateStandardCasualtyOrder();
     _hitGenerator = Substitute.For<IHitGenerator>();
     _battle = new Battle(_attackers, _defenders, _attackerCasualtyOrder, _defenderCasualtyOrder, _hitGenerator);
 }