Example #1
0
        public void Level1ShieldGuy_CorrectlyDeterminesViableMoves_NoShieldMove()
        {
            IronBattleShield shield = new IronBattleShield(3, 0, 0);

            _level1ShieldGuy.SetBattleShield(shield);
            _level1ShieldGuy.BattleShield.DecrementHealth(1);
            _ally1.SetBattleShield(shield);
            _ally2.SetBattleShield(shield);

            _chanceService.PushWhichEventsOccur(0);
            BattleMove returnedMove = _level1ShieldGuy.SelectMove(_shieldGuyTeam, _humanTeam);

            double[] lastEventOccursArgs = _chanceService.LastEventOccursArgs;

            Assert.AreEqual(3, lastEventOccursArgs.Length);
            Assert.AreEqual(0.2, lastEventOccursArgs[0]);
            Assert.AreEqual(0.4, lastEventOccursArgs[1]);
            Assert.AreEqual(0.4, lastEventOccursArgs[2]);

            Assert.AreEqual(BattleMoveType.Attack, returnedMove.MoveType);

            _chanceService.PushWhichEventsOccur(1);
            returnedMove = _level1ShieldGuy.SelectMove(_shieldGuyTeam, _humanTeam);
            ShieldFortifyingMove shieldFortifyingMove = returnedMove as ShieldFortifyingMove;

            Assert.NotNull(shieldFortifyingMove);
            Assert.AreEqual(ShieldFortifyingType.Defense, shieldFortifyingMove.FortifyingType);

            _chanceService.PushWhichEventsOccur(2);
            returnedMove         = _level1ShieldGuy.SelectMove(_shieldGuyTeam, _humanTeam);
            shieldFortifyingMove = returnedMove as ShieldFortifyingMove;
            Assert.NotNull(shieldFortifyingMove);
            Assert.AreEqual(ShieldFortifyingType.Health, shieldFortifyingMove.FortifyingType);
        }
Example #2
0
        public void CopyMethod_ReturnsCorrectResult()
        {
            const int            shieldFortifyingAmount = 3;
            ShieldFortifyingMove move = new ShieldFortifyingMove("foo", TargetType.SingleAlly, null, ShieldFortifyingType.Defense, shieldFortifyingAmount);

            ShieldFortifyingMove copy = new ShieldFortifyingMove(move);

            Assert.AreEqual(ShieldFortifyingType.Defense, copy.FortifyingType);
            Assert.AreEqual(shieldFortifyingAmount, copy.FortifyingAmount);
        }
Example #3
0
        public void Level1ShieldGuy_CorrectlyDeterminesViableMoves_AllMovesAreViable()
        {
            _chanceService.PushWhichEventsOccur(0); //have to set this up to prevent error

            const int        shieldDefense = 2;
            IronBattleShield shield        = new IronBattleShield(2, shieldDefense, 0);

            _ally1.SetBattleShield(shield);
            _ally1.BattleShield.DecrementHealth(shieldDefense + 1);

            _level1ShieldGuy.SelectMove(_shieldGuyTeam, _humanTeam);

            double[] lastEventOccursArgs = _chanceService.LastEventOccursArgs;

            Assert.AreEqual(4, lastEventOccursArgs.Length);
            Assert.AreEqual(0.2, lastEventOccursArgs[0]);
            Assert.AreEqual(0.4, lastEventOccursArgs[1]);
            Assert.AreEqual(0.2, lastEventOccursArgs[2]);
            Assert.AreEqual(0.2, lastEventOccursArgs[3]);

            _chanceService.PushWhichEventsOccur(0);
            BattleMove returnedMove = _level1ShieldGuy.SelectMove(_shieldGuyTeam, _humanTeam);

            Assert.AreEqual(BattleMoveType.Attack, returnedMove.MoveType);


            _chanceService.PushWhichEventsOccur(1);
            returnedMove = _level1ShieldGuy.SelectMove(_shieldGuyTeam, _humanTeam);
            Assert.IsTrue(returnedMove is ShieldMove);


            _chanceService.PushWhichEventsOccur(2);
            returnedMove = _level1ShieldGuy.SelectMove(_shieldGuyTeam, _humanTeam);
            ShieldFortifyingMove shieldFortifyingMove = returnedMove as ShieldFortifyingMove;

            Assert.NotNull(shieldFortifyingMove);
            Assert.AreEqual(ShieldFortifyingType.Defense, shieldFortifyingMove.FortifyingType);


            _chanceService.PushWhichEventsOccur(3);
            returnedMove         = _level1ShieldGuy.SelectMove(_shieldGuyTeam, _humanTeam);
            shieldFortifyingMove = returnedMove as ShieldFortifyingMove;
            Assert.NotNull(shieldFortifyingMove);
            Assert.AreEqual(ShieldFortifyingType.Health, shieldFortifyingMove.FortifyingType);
        }
Example #4
0
 public ShieldGuy(int level, IChanceService chanceService, string name = null) :
     base(name ?? "Shield Guy"
          , level
          , LevelUpManager.GetHealthByLevel <ShieldGuy>(level)
          , LevelUpManager.GetManaByLevel <ShieldGuy>(level)
          , LevelUpManager.GetStrengthByLevel <ShieldGuy>(level)
          , LevelUpManager.GetDefenseByLevel <ShieldGuy>(level)
          , LevelUpManager.GetSpeedByLevel <ShieldGuy>(level)
          , LevelUpManager.GetEvadeByLevel <ShieldGuy>(level)
          , LevelUpManager.GetLuckByLevel <ShieldGuy>(level)
          , chanceService
          , SpellFactory.GetSpellsByLevel <ShieldGuy>(level)
          , MoveFactory.GetMovesByLevel <ShieldGuy>(level))
 {
     _basicAttack    = AvailableMoves.FirstOrDefault(bm => bm.MoveType == BattleMoveType.Attack);
     _ironShieldMove = AvailableMoves.FirstOrDefault(bm => bm is ShieldMove) as ShieldMove;
     _healShield     = AvailableMoves.FirstOrDefault(bm => bm is ShieldFortifyingMove && ((ShieldFortifyingMove)bm).FortifyingType == ShieldFortifyingType.Health) as ShieldFortifyingMove;
     _fortifyShield  = AvailableMoves.FirstOrDefault(bm => bm is ShieldFortifyingMove && ((ShieldFortifyingMove)bm).FortifyingType == ShieldFortifyingType.Defense) as ShieldFortifyingMove;
 }
Example #5
0
        public void BattleManager_CorrectlyPrintsErrorMessage_TargetHasNoShieldEquipped()
        {
            ShieldFortifyingMove shieldFortifyingMove = new ShieldFortifyingMove("foo", TargetType.Self, null, ShieldFortifyingType.Defense, 5);

            _humanFighter.SetMove(shieldFortifyingMove, 1);
            _humanFighter.SetMove(_runawayMove);
            _humanFighter.SetMoveTarget(_humanFighter);

            _enemy.SetMove(_doNothing);

            BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration
            {
                ShowIntroAndOutroMessages = false
            };

            _battleManager.Battle(_humanTeam, _enemyTeam, config: config);

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.AreEqual(1, outputs.Length);
            Assert.AreEqual($"But it failed because {_humanFighter.DisplayName} did not have a battleShield equipped!\n", outputs[0].Message);
        }
Example #6
0
        public void BattleManager_CorrectlyExecutes_ShieldFortifyingMove([Values(ShieldFortifyingType.Defense, ShieldFortifyingType.Health)] ShieldFortifyingType shieldFortifyingType)
        {
            ElementalBattleShield shield = new ElementalBattleShield(10, 5, 0, MagicType.Fire);

            shield.DecrementHealth(5);
            _humanFighter.SetBattleShield(shield);
            IBattleShield copiedShield = _humanFighter.BattleShield;

            ShieldFortifyingMove shieldFortifyingMove = new ShieldFortifyingMove("foo", TargetType.Self, null, shieldFortifyingType, 5);

            _humanFighter.SetMove(shieldFortifyingMove, 1);
            _humanFighter.SetMove(_runawayMove);
            _humanFighter.SetMoveTarget(_humanFighter);

            _enemy.SetMove(_doNothing);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.NotNull(copiedShield);

            int actualValue = shieldFortifyingType == ShieldFortifyingType.Defense ? copiedShield.Defense : copiedShield.CurrentHealth;

            Assert.AreEqual(10, actualValue);
        }