예제 #1
0
 public EconomicSimulator(IStarSystemRepository starSystemRepository, IEmpireRepository empireRepository, IDevelopmentCalculator developmentCalculator, IMilitaryCalculator militaryCalculator)
 {
     _starSystemRepository  = starSystemRepository;
     _empireRepository      = empireRepository;
     _developmentCalculator = developmentCalculator;
     _militaryCalculator    = militaryCalculator;
 }
예제 #2
0
        public GrowthFromSystem()
        {
            _connectedSystems = new StarSystem[]
            {
                new StarSystem {
                    Development = 300, Id = ObjectId.GenerateNewId()
                },
                new StarSystem {
                    Development = 200, Id = ObjectId.GenerateNewId()
                },
                new StarSystem {
                    Development = 400, Id = ObjectId.GenerateNewId()
                }
            };

            _targetSystem = new StarSystem
            {
                Development        = 100.0,
                ConnectedSystemIds = new ObjectId[] { _connectedSystems[0].Id, _connectedSystems[1].Id, _connectedSystems[2].Id },
                Id = ObjectId.GenerateNewId()
            };

            _systems = new StarSystem[]
            {
                _connectedSystems[0],
                _connectedSystems[1],
                _connectedSystems[2],
                new StarSystem {
                    Development = 500.0, Id = ObjectId.GenerateNewId()
                },
                new StarSystem {
                    Development = 250.0, Id = ObjectId.GenerateNewId()
                }
            };

            _empireView = new EmpireSystemsView
            {
                StarSystems = _systems,
                Empire      = new Empire {
                    Alignment = new Alignment {
                        Prosperity = 1.0
                    }
                }
            };

            var developmentCalculator = new DevelopmentCalculator(_configuration.Object);

            developmentCalculator.SetConnectedSystemsOnlyHook(_connectedSystemsOnlyDelegate.Object);
            _developmentCalculator = developmentCalculator;
        }
예제 #3
0
        public void DistributesGrowthBetweenAllSystemEqually()
        {
            _configuration.Setup(x => x.DevelopmentCalculation)
            .Returns(DevelopmentCalculation.EqualDistribution);
            _developmentCalculator = new DevelopmentCalculator(_configuration.Object);
            var result = _developmentCalculator.GrowthFromSystem(_targetSystem, _empireView);

            var income = _targetSystem.Development * Parameters.IncomeRate;

            Assert.Contains(result, value => value.SystemId == _targetSystem.Id && value.Growth == 0.25 * income);
            Assert.Contains(result, value => value.SystemId == _connectedSystems[0].Id && value.Growth == 0.25 * income);
            Assert.Contains(result, value => value.SystemId == _connectedSystems[1].Id && value.Growth == 0.25 * income);
            Assert.Contains(result, value => value.SystemId == _connectedSystems[2].Id && value.Growth == 0.25 * income);
        }
예제 #4
0
        public void GivesFractionOfIncomeToSelfThenDistributesEqually()
        {
            _configuration.Setup(x => x.DevelopmentCalculation)
            .Returns(DevelopmentCalculation.SelfPriorityThenEqual);
            _developmentCalculator = new DevelopmentCalculator(_configuration.Object);
            var result = _developmentCalculator.GrowthFromSystem(_targetSystem, _empireView);

            var income = _targetSystem.Development * Parameters.IncomeRate;
            var incomeForNeighbours = (income * (1 - Parameters.IncomeReservedForSelf)) / 3.0;

            Assert.Contains(result, value => value.SystemId == _targetSystem.Id && value.Growth == Parameters.IncomeReservedForSelf * income);
            Assert.Contains(result, value => value.SystemId == _connectedSystems[0].Id && value.Growth == incomeForNeighbours);
            Assert.Contains(result, value => value.SystemId == _connectedSystems[1].Id && value.Growth == incomeForNeighbours);
            Assert.Contains(result, value => value.SystemId == _connectedSystems[2].Id && value.Growth == incomeForNeighbours);
        }