Пример #1
0
        public void DifficultyController_UpdatePlayerStatus()
        {
            DifficultyController dc = new DifficultyController(validStrings[0].Item1);

            Assert.AreEqual(1.1, dc.GetPlayerStatus(), "Player status should be 1.1");
            Assert.AreEqual(0, dc.GetEndLocationChance(), "Should be no chance of end location");
            Assert.AreEqual(0.9d, dc.GetEventModifier(), 0.0001, "Event modifier should be 0.9");
            Assert.AreEqual(0, dc.GetPlayerStatusTracker().Count, "Status tracker should be empty");
            //Assert.IsTrue(40 / 100 <= dc.GetEventChance() && dc.GetEventChance() <= 80 / 100, "Event chance should be between 40% and 80%");

            int    statsSum  = 300;
            double invValue  = 0.125;
            double newStatus = (double)statsSum / 400 + invValue;
            double current   = dc.GetPlayerStatus();
            double expected  = 0.75d * current + (1 - 0.75d) * newStatus;

            dc.UpdatePlayerStatus(statsSum, invValue);
            Assert.AreEqual(expected, dc.GetPlayerStatus(), "Player status should be the same as expected");

            statsSum  = 320;
            invValue  = 0.1;
            newStatus = (double)statsSum / 400 + invValue;
            current   = dc.GetPlayerStatus();
            expected  = 0.75d * current + (1 - 0.75d) * newStatus;

            dc.UpdatePlayerStatus(statsSum, invValue);
            Assert.AreEqual(expected, dc.GetPlayerStatus(), "Player status should be the same as expected");
        }
Пример #2
0
        /// <summary>
        /// Updates the dc
        /// </summary>
        public void DrawDifficultyController()
        {
            DifficultyController dc = mc.GetDifficultyController();

            playerStatusLabel.Content  = dc.GetPlayerStatus();
            eventModifierLabel.Content = dc.GetEventModifier();
            endLocChanceLabel.Content  = dc.GetEndLocationChance();
            eventChanceLabel.Content   = dc.GetEventChance();

            List <double> tracker = dc.GetPlayerStatusTracker();

            trackerLB.ItemsSource = tracker;

            List <double> yValues = new List <double>();

            if (tracker.Count > 0)
            {
                var bestFit = dc.GenerateBestFitLine();

                foreach (var fit in bestFit)
                {
                    yValues.Add(fit.Item2);
                }
            }
            bestFitLineLB.ItemsSource = yValues;
        }
Пример #3
0
        public void DifficultyController_StandardConstructor()
        {
            DifficultyController dc = new DifficultyController();

            Assert.AreEqual(1, dc.GetPlayerStatus(), "Player status should be 1");
            Assert.AreEqual(0, dc.GetEndLocationChance(), "Should be no chance of end location");
            Assert.AreEqual(1d, dc.GetEventModifier(), "Event modifier should be 1");
            Assert.AreEqual(0, dc.GetPlayerStatusTracker().Count, "Status tracker should be empty");
            //Assert.IsTrue(40 / 100 <= dc.GetEventChance() && dc.GetEventChance() <= 80 / 100, "Event chance should be between 40% and 80%");
        }
Пример #4
0
        public void DifficultyController_ParseFromString()
        {
            DifficultyController dc = new DifficultyController(validStrings[0].Item1);

            Assert.AreEqual(1.1, dc.GetPlayerStatus(), "Player status should be 1.1");
            Assert.AreEqual(0, dc.GetEndLocationChance(), "Should be no chance of end location");
            Assert.AreEqual(0.9d, dc.GetEventModifier(), 0.0001, "Event modifier should be 0.9");
            Assert.AreEqual(0, dc.GetPlayerStatusTracker().Count, "Status tracker should be empty");
            Assert.IsTrue(0.4d <= dc.GetEventChance() && dc.GetEventChance() <= 0.8d, "Event chance should be between 40% and 80%");

            dc = new DifficultyController(validStrings[2].Item1);
            Assert.AreEqual(1.1, dc.GetPlayerStatus(), "Player status should be 1.1");
            Assert.AreEqual(0, dc.GetEndLocationChance(), "Should be no chance of end location");
            Assert.AreEqual(0.9d, dc.GetEventModifier(), 0.0001, "Event modifier should be 0.9");
            Assert.AreEqual(5, dc.GetPlayerStatusTracker().Count, "Status tracker should be empty");
            //Assert.IsTrue(40 / 100 <= dc.GetEventChance() && dc.GetEventChance() <= 80 / 100, "Event chance should be between 40% and 80%");
        }