Exemplo n.º 1
0
        public void BattleManager_CorrectlyPrintsDamageOutput()
        {
            int damage = (_shield.MaxHealth + _shield.Defense) - 1;

            _enemyPlayer1.SetMove(_basicAttackMove);
            _enemyPlayer1.SetStrength(damage);
            _enemyPlayer1.SetMoveTarget(_humanPlayer1);
            _chanceService.PushEventsOccur(true, false); //attack hits, not crit

            _humanPlayer1.SetBattleShield(_shield as BattleShield);
            BattleShield fighterShield = _humanPlayer1.BattleShield;

            _humanPlayer1.SetMove(_doNothingMove, 1);
            _humanPlayer1.SetMove(_runawayMove);
            _humanPlayer1.SetMoveTarget(_humanPlayer1);

            _humanTeam = new Team(_menuManager, _humanPlayer1);
            _enemyTeam = new Team(_menuManager, _enemyPlayer1);

            BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration
            {
                ShowIntroAndOutroMessages = false
            };

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

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.AreEqual(2, outputs.Length); //enemy attacks and shield took damage message

            MockOutputMessage output = outputs[1];

            Assert.AreEqual($"{fighterShield.Owner.DisplayName}'s {fighterShield.GetDisplayText(false)} took {damage} damage!\n", output.Message);
        }
Exemplo n.º 2
0
        public void ConditionalDanceMove_ExecutesAppropriateEffectWhenDanceInEffect([Values(DanceEffectType.Fire, DanceEffectType.Danger)] DanceEffectType danceEffectType)
        {
            _testTechnique.ClearEffects();
            _testTechnique.SetDanceEffect(danceEffectType);

            RestorationBattleMoveEffect conditionalHealEffect = GetRestoreHealthEffect(danceEffectType);
            AttackBattleMove            attackWithHeal        = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 0, effects: conditionalHealEffect);

            _human2.SetMove(_testTechnique, 1);
            _human2.SetSpeed(1);

            _human1.SetHealth(100, 10);
            _human1.SetMove(attackWithHeal, 1);
            _chanceService.PushEventsOccur(true, false); //attack hits, is not crit
            _human1.SetStrength(_enemy1.MaxHealth);
            _human1.SetMoveTarget(_enemy1);

            _enemyTeam = new Team(_menuManager, _enemy1);

            _enemy1.SetDefense(0);
            _enemy1.SetMove(_doNothingMove);
            _enemy1.SetMoveTarget(_enemy1);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.AreEqual(20, _human1.CurrentHealth, "Human1 should have regained 10 HP when the attack was successful and the dance effect was active");
        }
Exemplo n.º 3
0
        public void StatusMove_AppropriatelyChecksAccuracy([Values(10, 25, 50, 90)] int accuracy)
        {
            //Arrange
            Status     status = new BlindStatus(2);
            StatusMove move   = new StatusMove("foo", TargetType.SingleEnemy, status, accuracy: accuracy);

            _team1Fighter.SetMove(move, 1);
            _team1Fighter.SetMoveTarget(_team2Fighter);
            _team1Fighter.SetMove(_runawayMove);

            _team2Fighter.SetMove(_doNothingMove);

            _chanceService.PushEventOccurs(false);

            BattleManagerBattleConfiguration config = new SilentBattleConfiguration();

            //Act
            _battleManager.Battle(_team1, _team2, config: config);

            //Assert
            Assert.Null(_team2Fighter.Statuses.FirstOrDefault(s => s.AreEqual(status)));

            double expectedChance = accuracy / 100.0;

            Assert.AreEqual(expectedChance, _chanceService.LastChanceVals[0]);
        }
Exemplo n.º 4
0
        public void ConditionalEffect_AppropriatelyFired_WhenNotEvadedConditionMet([Values(10, 20)] int percentage)
        {
            AttackBattleMove conditionalHealMove = GetNotEvadeRestoreHealthAttack(percentage);

            _team1Fighter.SetHealth(100, 10);
            _team1Fighter.SetMove(conditionalHealMove, 1);
            _team1Fighter.SetMoveTarget(_team2Fighter);
            _team1Fighter.SetMove(_runawayMove);

            _chanceService.PushAttackHitsNotCrit();

            _team2Fighter.SetHealth(100);
            _team2Fighter.SetMove(_doNothingMove);

            _battleManager.Battle(_team1, _team2);

            int expectedRemainingHealth = 10 + percentage;

            Assert.AreEqual(expectedRemainingHealth, _team1Fighter.CurrentHealth, $"The attack wasn't evaded, so the user should have regained {percentage} HP");
        }
Exemplo n.º 5
0
        public void StatusesRemoved_OnRoundEnd()
        {
            StatMultiplierStatus boostDefenseStatus = new StatMultiplierStatus(1, StatType.Defense, 2);

            _humanFighter.SetDefense(1);
            _humanFighter.SetHealth(1);
            _humanFighter.AddStatus(boostDefenseStatus);
            _humanFighter.SetMove(_doNothing, 1);
            _humanFighter.SetMove(_runawayMove);

            _enemy.SetMove(_basicAttackMove);
            _enemy.SetMoveTarget(_humanFighter);
            _enemy.SetStrength(2);

            _chanceService.PushEventsOccur(true, false);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.AreEqual(1, _humanFighter.CurrentHealth);
        }
        private void PhysicalDamageEvent_Setup(int expectedDamage, bool showPhysicalDamageMessages)
        {
            Team             mixedPlayerTeam = new Team(_menuManager, _humanPlayer1, _enemyPlayer1);
            TestEnemyFighter enemy3          = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);
            Team             enemyTeam       = new Team(_menuManager, _enemyPlayer2, enemy3);

            _humanPlayer1.SetSpeed(2);
            _humanPlayer1.SetStrength(expectedDamage);
            _humanPlayer1.SetMove(_basicAttackMove, 1);
            _humanPlayer1.SetMove(_runawayMove);
            _humanPlayer1.SetMoveTarget(_enemyPlayer2);
            _enemyPlayer2.SetHealth(expectedDamage + 1);

            _enemyPlayer1.SetSpeed(1);
            _enemyPlayer1.SetStrength(expectedDamage);
            _enemyPlayer1.SetMove(_basicAttackMove);
            _enemyPlayer1.SetMoveTarget(enemy3);
            enemy3.SetHealth(expectedDamage + 1);

            _mockChanceService.PushEventsOccur(true, false, true, false); //both attacks hit, neither are crits
            _logger.Subscribe(EventType.DamageTaken, _enemyPlayer2);
            _logger.Subscribe(EventType.DamageTaken, enemy3);

            _enemyPlayer2.SetMove(_doNothingMove);
            enemy3.SetMove(_doNothingMove);

            BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration
            {
                ShowIntroAndOutroMessages  = false,
                ShowExpAndLevelUpMessages  = false,
                ShowDeathMessages          = false,
                ShowAttackMessages         = false,
                ShowPhysicalDamageMessages = showPhysicalDamageMessages
            };

            _battleManager.Battle(mixedPlayerTeam, enemyTeam, config: config);
        }
        public void RestoreHealthEffect_AppropriatelyExecuted_AttackHits()
        {
            int initialHealth = 100 - _restoreHealthEffect.Percentage;

            _human.SetHealth(100, initialHealth);
            _human.SetMana(100, 0);
            _human.SetMove(_attackWithRestoreHealthEffect);
            _human.SetMoveTarget(_enemy);
            _chanceService.PushEventsOccur(true, false); //attack hits, not a crit

            _enemy.SetMove(_doNothingMove);
            _enemy.SetMoveTarget(_enemy);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.AreEqual(_human.MaxHealth, _human.CurrentHealth, "humman player's health should have been restored when the attack hit!");
            Assert.AreEqual(0, _human.CurrentMana, "humman player's mana should have been unaffected by the restore effect!");
        }