예제 #1
0
        public void TestUseWater()
        {
            TestHelpers.InMethod();
            //log4net.Config.XmlConfigurator.Configure();

            AddBuyPoints();
            AddPlayers(Manufacturer.Singleton, Farmer.Singleton);
            StartGame();

            m_controller.State.BuyLandRights(bp1, p1);
            m_controller.State.BuyLandRights(bp2, p1);

            Assert.That(bp1.Factories.Count, Is.EqualTo(0));
            Assert.That(bp1.WaterRequired, Is.EqualTo(0));

            // We also need to buy a factory to which we will give water
            AddGameAsset(bp1, 0, Factory.Template, 1);

            Assert.That(bp1.Factories.Count, Is.EqualTo(1));
            Factory f1 = bp1.Factories[0];

            Assert.That(bp1.WaterRequired, Is.EqualTo(f1.WaterUsage));

            // And one that we won't
            AddGameAsset(bp2, 1, Factory.Template, 1);

            SeriesEconomicGenerator econGen  = (SeriesEconomicGenerator)m_controller.EconomicGenerator;
            double thisRoundEconomicActivity = 1.2;

            econGen.Deviations[AbstractGameAssetType.Factory][f1.Level] = new double[] { 1, thisRoundEconomicActivity };

            // Move to the water phase
            EndTurns();

            Assert.That(f1.WaterAllocated, Is.EqualTo(0));
            Assert.That(bp1.WaterAllocated, Is.EqualTo(0));
            Assert.That(bp2.WaterAllocated, Is.EqualTo(0));
            Assert.That(p1.Water, Is.EqualTo(bp1.InitialWaterRights + bp2.InitialWaterRights));
            Assert.That(f1.ProjectedRevenue, Is.EqualTo(0));

            int p1WaterBefore = p1.Water;

            m_controller.State.UseWater(f1, p1, f1.WaterUsage);
            Assert.That(p1.Water, Is.EqualTo(p1WaterBefore - f1.WaterUsage));
            Assert.That(f1.WaterAllocated, Is.EqualTo(f1.WaterUsage));
            Assert.That(bp1.WaterAllocated, Is.EqualTo(bp1.WaterRequired));
            Assert.That(bp2.WaterAllocated, Is.EqualTo(0));
            Assert.That(f1.ProjectedRevenue, Is.EqualTo(f1.NormalRevenue * thisRoundEconomicActivity));

            // Move back to the build phase
            EndTurns();

            Assert.That(bp1.WaterAllocated, Is.EqualTo(0));
            Assert.That(bp2.WaterAllocated, Is.EqualTo(0));
            Assert.That(f1.WaterAllocated, Is.EqualTo(0));
            Assert.That(f1.ProjectedRevenue, Is.EqualTo(0));
        }
 public void UpdateConfiguration(IConfigSource configSource)
 {
     Deviations = SeriesEconomicGenerator.LoadSeriesData(configSource);
 }