Esempio n. 1
0
        public void CastSpell_CorrectlyChecksUserHasEnoughMana_SpellCostMultiplierStatus([Values(4, 8)] int spellCost,
                                                                                         [Values(2, 3)] int costMultiplier1,
                                                                                         [Values(null, 4)] int?costMultiplier2)
        {
            SpellCostMultiplierStatus status1 = new SpellCostMultiplierStatus(1, costMultiplier1);
            Spell spell = new Spell("foo", MagicType.Wind, SpellType.Attack, TargetType.SingleEnemy, spellCost, 5);

            int realCost = spellCost * costMultiplier1;

            if (costMultiplier2.HasValue)
            {
                realCost *= costMultiplier2.Value;
                SpellCostMultiplierStatus status2 = new SpellCostMultiplierStatus(1, costMultiplier2.Value);
                _human.AddStatus(status2);
            }

            int availableMana = realCost - 1;

            _human.SetMana(realCost, availableMana);
            _human.AddStatus(status1);
            _human.SetDeathOnTurnEndEvent();
            _human.AddSpell(spell);
            _human.SetMove(spell);
            _human.SetMoveTarget(_enemy);

            _enemy.SetHealth(100);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.AreEqual(availableMana, _human.CurrentMana);
        }
Esempio n. 2
0
        public void BlindnessStatus_CorrectlyReducesMoveAccuracy([Values(10, 60, 100)] int orignalAccuracy)
        {
            _humanFighter.AddStatus(_blindnessStatus);

            AttackBattleMove attack = new AttackBattleMove("foo", TargetType.SingleEnemy, orignalAccuracy, 0);

            _humanFighter.SetMove(attack, 1);
            _humanFighter.SetMoveTarget(_enemy);
            _chanceService.PushEventOccurs(false); //attack misses
            _humanFighter.SetMove(_runawayMove);

            _enemy.SetMove(_doNothing);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            double accuracyAsPercent        = orignalAccuracy / 100.0;
            double expectedModifiedAccuracy = accuracyAsPercent / 3;

            Assert.AreEqual(expectedModifiedAccuracy, _chanceService.LastChanceVals[0]);
        }
Esempio n. 3
0
        public void ShadeDoesNotTargetFoeAlreadyInflictedWithBlindness()
        {
            StatusMove darkFogMove = _shade1.GetExecutableMoves(_humanTeam)[_darkFogIndex] as StatusMove;

            _humanFighter.AddStatus(darkFogMove?.Status);
            Egg blindEgg = new Egg(MagicType.Fire);

            blindEgg.AddStatus(darkFogMove?.Status);
            Team humanTeam = new Team(TestMenuManager.GetTestMenuManager(), _humanFighter, blindEgg, new Egg(MagicType.Fire));

            _chanceService.PushWhichEventOccurs(_darkFogIndex);

            BattleMoveWithTarget moveWithTarget = null;

            //will throw if multiple targets
            Assert.DoesNotThrow(() => moveWithTarget = _shade1.SetupMove(_shadeTeam, humanTeam));

            Assert.NotNull(moveWithTarget);
            Assert.AreEqual(darkFogMove, moveWithTarget.Move);
            Assert.AreEqual(humanTeam.Fighters[2], moveWithTarget.Target);
        }
        public void AutoEvadeStatus_CorrectlyEvadesAttack_AndDoesNotAttackIfCounterFlagFalse()
        {
            _humanFighter.AddStatus(_evadeButDoNotCounterStatus);

            _humanFighter.SetMove(_doNothing, 1);
            _humanFighter.SetMove(_runawayMove);

            _enemy.SetMove(_basicAttackMove);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.AreEqual(_humanFighter.MaxHealth, _humanFighter.CurrentHealth);
            Assert.AreEqual(_enemy.MaxHealth, _enemy.CurrentHealth);
        }
Esempio n. 5
0
        public void FighterStatusCounterTicksDown_OnTurnEnd()
        {
            Status status = new MagicMultiplierStatus(3, MagicType.Lightning, 1.25);

            _humanFighter.AddStatus(status);

            _humanFighter.OnTurnEnded(new TurnEndedEventArgs(_humanFighter));

            Status returnedStatus = _humanFighter.Statuses[0];

            Assert.AreEqual(2, returnedStatus.TurnCounter);
        }
Esempio n. 6
0
        public void FighterStatus_MultipleInstancesOfStatus_HaveSeparateCounters()
        {
            MagicMultiplierStatus status = new MagicMultiplierStatus(4, MagicType.All, 1.25);

            _humanFighter.AddStatus(status);

            for (var i = 0; i < 2; ++i)
            {
                _humanFighter.OnTurnEnded(new TurnEndedEventArgs(_humanFighter));
            }

            TestHumanFighter fighter2 = new TestHumanFighter("Bob", 1);

            fighter2.AddStatus(status);

            Status returnedStatus = fighter2.Statuses[0];

            Assert.AreEqual(4, returnedStatus.TurnCounter);
        }
Esempio n. 7
0
        public void AddStatus_AppropriatelyRaisesEvent()
        {
            StatMultiplierStatus status = new StatMultiplierStatus(2, StatType.Speed, 1.5);

            _fighter.AddStatus(status);

            List <EventLog> logs = _logger.Logs;

            Assert.AreEqual(1, logs.Count);

            EventLog log = logs[0];

            Assert.AreEqual(_fighter, log.Sender);
            Assert.AreEqual(EventType.StatusAdded, log.Type);

            StatusAddedEventArgs args = log.E as StatusAddedEventArgs;

            Assert.NotNull(args);
            Assert.AreEqual(status, args.Status);
        }
Esempio n. 8
0
        public void CorrectlyCountersAttack()
        {
            _humanFighter.AddStatus(_status);

            _humanFighter.SetDefense(_enemy.Strength);
            _humanFighter.SetMove(_doNothing, 1);
            _humanFighter.SetMove(_runawayMove);

            _enemy.SetMove(_basicAttackMove);
            _enemy.SetHealth(_humanFighter.Strength + 1);
            _chanceService.PushEventsOccur(true, false); //attack hits, not a crit
            _chanceService.PushEventsOccur(true, false); //counter hits, not a crit

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.AreEqual(1, _enemy.CurrentHealth);
        }