コード例 #1
0
        public void BloodMove_MoreEffectiveForCopperBellThanCopperBell()
        {
            //arrange
            Shade shade = FighterFactory.GetShade(1);
            BattleMoveWithTarget moveWithTarget = new BattleMoveWithTargetAndNumberInput(_bloodMove, shade, _fighter, 0);

            _chanceService.PushEventsOccur(false, false);

            //act
            _copperBell.ExecuteMove(moveWithTarget);
            _silverBell.ExecuteMove(moveWithTarget);

            //assert
            List <double> chances = _chanceService.LastChanceVals;

            Assert.Greater(chances[0], chances[1]);
        }
コード例 #2
0
        public void CorrectlyRaisesMoveExecutorsMaxHealth_ByShadeLevel_DominatingMoveSucceeds([Range(1, 4)] int shadeLevel)
        {
            Shade            shade            = FighterFactory.GetShade(1, shadeLevel: shadeLevel);
            TestHumanFighter fighter          = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            const int        initialMaxHealth = 10;

            fighter.SetHealth(initialMaxHealth);

            BattleMoveWithTargetAndNumberInput moveWithTarget = new BattleMoveWithTargetAndNumberInput(_bloodMove, shade, fighter, 1);

            _chanceService.PushEventOccurs(true);

            //act
            _copperBell.ExecuteMove(moveWithTarget);

            //assert
            int expectedMaxHealth = initialMaxHealth + shadeLevel;

            Assert.AreEqual(expectedMaxHealth, fighter.MaxHealth);
        }
コード例 #3
0
        public void BloodMove_DifferentOfferedBloodValues_CorrectlyGeneratesDifferentChanceSuccessRates()
        {
            TestHumanFighter fighter = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);

            for (var i = 1; i <= 4; ++i)
            {
                Shade shade = (Shade)TestFighterFactory.GetFighter(TestFighterType.Shade, 1);
                shade.PhysicalDamage(1);

                BattleMoveWithTargetAndNumberInput moveWithTarget = new BattleMoveWithTargetAndNumberInput(_bloodMove, shade, fighter, i);

                _chanceService.PushEventOccurs(true);

                //act
                _silverBell.ExecuteMove(moveWithTarget);

                //assert
                double expectedChance = 0.5 + (i * 0.05);
                Assert.AreEqual(expectedChance, _chanceService.LastChanceVals[i - 1],
                                $"for index value {i}");
            }
        }
コード例 #4
0
        public void BloodMove_DifferentShadeLevels_CorrectlyGeneratesDifferentChanceSuccessRates(
            [Range(1, 5)] int shadeLevel, [Range(0, 1)] int damage)
        {
            double expectedChance = damage == 0 ? 1.0 / 3 : 0.5;
            int    levelDiff      = shadeLevel - 1;
            double chanceDecrease = levelDiff * 0.1;

            expectedChance  = Math.Max(expectedChance - chanceDecrease, 0.1);
            expectedChance += .05;

            Shade shade = FighterFactory.GetShade(1, shadeLevel: shadeLevel);

            shade.PhysicalDamage(damage);

            BattleMoveWithTargetAndNumberInput moveWithTarget = new BattleMoveWithTargetAndNumberInput(_bloodMove, shade, _fighter, 1);

            _chanceService.PushEventOccurs(true);

            //act
            _silverBell.ExecuteMove(moveWithTarget);

            //assert
            Assert.AreEqual(expectedChance, _chanceService.LastChanceVals[0]);
        }
コード例 #5
0
        public void BloodMove_DifferentEnemyHealthLevels_CorrectlyGeneratesDifferentChanceSuccessRates()
        {
            double[]         expectedChances = { 1.0 / 3 + .05, 0.55, 0.7, 0.85 };
            TestHumanFighter fighter         = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);

            for (var i = 0; i < 4; ++i)
            {
                Shade shade = (Shade)TestFighterFactory.GetFighter(TestFighterType.Shade, 1);
                shade.PhysicalDamage(i);
                int currentHealth = shade.CurrentHealth;
                Assert.AreEqual(4, shade.MaxHealth);

                BattleMoveWithTargetAndNumberInput moveWithTarget = new BattleMoveWithTargetAndNumberInput(_bloodMove, shade, fighter, 1);

                _chanceService.PushEventOccurs(true);

                //act
                _silverBell.ExecuteMove(moveWithTarget);

                //assert
                Assert.LessOrEqual(Math.Abs(expectedChances[i] - _chanceService.LastChanceVals[i]), 0.0001,
                                   $"for index value {i}, shade health was {currentHealth} out of {shade.MaxHealth}");
            }
        }
コード例 #6
0
        public void CorrectlySealsShade_WhenExecutingControlMove()
        {
            Shade shade = (Shade)TestFighterFactory.GetFighter(TestFighterType.Shade, 1);

            _logger.Subscribe(EventType.FighterSealed, shade);
            TestHumanFighter fighter = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);

            BattleMoveWithTargetAndNumberInput moveWithTarget = new BattleMoveWithTargetAndNumberInput(_bloodMove, shade, fighter, 0);

            _chanceService.PushEventOccurs(true);

            //act
            _copperBell.ExecuteMove(moveWithTarget);

            //assert
            Assert.AreEqual(0, shade.CurrentHealth);

            List <EventLog> logs = _logger.Logs;

            Assert.AreEqual(1, logs.Count);

            Assert.AreEqual(EventType.FighterSealed, logs[0].Type);
            Assert.AreEqual(shade, logs[0].Sender);
        }
コード例 #7
0
        //TODO: this should have return type void and print messages should queue off events, not a return value
        public bool ExecuteMove(BattleMoveWithTarget battleMoveWithTarget)
        {
            bool     moveSucceeded = false;
            BellMove bellMove      = battleMoveWithTarget.Move as BellMove;

            if (bellMove == null)
            {
                throw new InvalidOperationException($"Bell.ExecuteMove() was erroneously called for a move that was not a Bell move. Movetype: {battleMoveWithTarget.Move.MoveType}");
            }

            Shade targetAsShade = battleMoveWithTarget.Target as Shade;

            if (targetAsShade == null)
            {
                throw new InvalidOperationException($"Bell.ExecuteMove() was given a target that was not a shade! target: {battleMoveWithTarget.Target}");
            }

            int    healthDiff       = targetAsShade.MaxHealth - targetAsShade.CurrentHealth;
            double healthPercentage = ((double)targetAsShade.CurrentHealth) / targetAsShade.MaxHealth;

            double chance = 1.0 / 3;

            if (healthDiff > 0)
            {
                if (healthPercentage < 0.26)
                {
                    chance = 0.8;
                }
                else if (healthPercentage < 0.51)
                {
                    chance = 0.65;
                }
                else if (healthPercentage < 0.76)
                {
                    chance = 0.5;
                }
            }

            if (targetAsShade.ShadeExperience > 1)
            {
                int levelDiff = targetAsShade.ShadeExperience - 1;

                chance -= 0.1 * levelDiff;

                //minimum chance is 10% that it works
                chance = Math.Max(.1, chance);
            }

            if (bellMove.BellMoveType == BellMoveType.ControlMove)
            {
                BattleMoveWithTargetAndNumberInput moveWithNumber = battleMoveWithTarget as BattleMoveWithTargetAndNumberInput;

                if (moveWithNumber == null)
                {
                    throw new InvalidOperationException("Bell.ExecuteMove() should be supplied a BattleMoveWIthTargetAndNUmberInput if the move was a control type Bell move");
                }

                int bloodAmount = moveWithNumber.NumberValue;

                chance += bloodAmount * 0.05;
            }

            if ((BellType == BellType.Silver && bellMove.BellMoveType == BellMoveType.SealMove) ||
                (BellType == BellType.Copper && bellMove.BellMoveType == BellMoveType.ControlMove))
            {
                chance += .25;
            }

            if (ChanceService.EventOccurs(chance))
            {
                int healAmount = targetAsShade.CurrentHealth;
                targetAsShade.Seal();

                moveSucceeded = true;

                if (bellMove.BellMoveType == BellMoveType.SealMove)
                {
                    battleMoveWithTarget.Owner.Heal(healAmount);
                }
                else if (bellMove.BellMoveType == BellMoveType.ControlMove)
                {
                    battleMoveWithTarget.Owner.RaiseMaxHealth(targetAsShade.ShadeExperience);
                }
            }

            return(moveSucceeded);
        }