public void AttackMovePower_AppropriatelyAffectsDamage() { _logger.Subscribe(_team2Fighter, EventType.DamageTaken); int weakAttackPower = 4; int strongAttackPower = 8; AttackBattleMove weakerAttack = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 0, weakAttackPower); AttackBattleMove strongerAttack = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 0, strongAttackPower); _team1Fighter.SetStrength(0); _team1Fighter.SetMove(weakerAttack, 1); _team1Fighter.SetMove(strongerAttack, 1); _chanceService.PushEventsOccur(true, false, true, false); //attacks hit, not crits _team2Fighter.SetHealth(weakAttackPower + strongAttackPower); _team2Fighter.SetMove(_doNothingMove); _battleManager.Battle(_team1, _team2); List <EventLog> logs = _logger.Logs; Assert.AreEqual(2, logs.Count); PhysicalDamageTakenEventArgs e = logs[0].E as PhysicalDamageTakenEventArgs; Assert.NotNull(e); Assert.AreEqual(weakAttackPower, e.Damage); e = logs[1].E as PhysicalDamageTakenEventArgs; Assert.NotNull(e); Assert.AreEqual(strongAttackPower, e.Damage); }
public void CorrectlySetsBattleMoves_UponEnteringRegion() { BattleMove superAttack = new AttackBattleMove("foo", TargetType.SingleEnemy, 80, 20, 5); BattleMove fastAttack = new AttackBattleMove("bar", TargetType.SingleEnemy, 100, 0, 0, 2); Assert.False(_humanFighter1.AllSpecialMoves.Contains(superAttack)); Assert.False(_humanFighter1.AllSpecialMoves.Contains(fastAttack)); TeamConfiguration bossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1)); SubRegion subRegion = new SubRegion(WorldSubRegion.Fields, 1, new [] { new ChanceEvent <int>(1, 1), }, new[] { FighterType.Egg }, new BattlefieldConfiguration(bossConfiguration, null)); SubRegion[] subRegions = { subRegion }; Region fakeFieldsRegion = new Region(WorldRegion.Fields, new[] { superAttack, fastAttack }, subRegions); _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion); _teamFactory.PushTeams(_oneEnemyTeam); _regionManager = GetRegionManager(); _humanFighter1.SetMove(_runawayMove); _humanFighter1.SetMoveTarget(_humanFighter1); _humanFighter2.SetMove(_doNothingMove); _regionManager.Battle(_battleManager, _humanTeam); Assert.True(_humanFighter1.AllSpecialMoves.Contains(superAttack)); Assert.True(_humanFighter1.AllSpecialMoves.Contains(fastAttack)); }
public void ConditionalDanceMove_ExecutesAppropriateEffectWhenDanceNotInEffect([Values(DanceEffectType.Water, DanceEffectType.Wind)] DanceEffectType danceEffectType) { _testTechnique.ClearEffects(); _testTechnique.SetDanceEffect(DanceEffectType.Soul); RestorationBattleMoveEffect conditionalHealEffect = GetRestoreHealthEffect(danceEffectType); AttackBattleMove attackWithHeal = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 0, effects: conditionalHealEffect); _human2.SetMove(_testTechnique, 1); _human2.SetSpeed(1); const int initialHealth = 10; _human1.SetHealth(100, initialHealth); _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(initialHealth, _human1.CurrentHealth, "Human1 should not have had their health altered, the active dance effect's didn't match the conditional heal!"); }
public void ConditionalAttackBoostMove_ExecutesAppropriateEffectWhenDanceNotInEffect([Values(DanceEffectType.Water, DanceEffectType.Wind)] DanceEffectType danceEffectType) { _testTechnique.ClearEffects(); _testTechnique.SetDanceEffect(DanceEffectType.Soul); const int attackBoostMultiplier = 2; AttackBoostBattleMoveEffect conditionalAttackBoostEffect = GetAttackBoostEffect(attackBoostMultiplier, danceEffectType); AttackBattleMove attackWithBoost = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 0, effects: conditionalAttackBoostEffect); _human2.SetMove(_testTechnique, 1); _human2.SetMove(_doNothingMove); _human2.SetSpeed(1); const int initialAttackStrength = 2; const int expectedDamage = initialAttackStrength; _human1.SetStrength(initialAttackStrength); _human1.SetMove(attackWithBoost, 1); _chanceService.PushAttackHitsNotCrit(); _human1.SetMove(_runawayMove); _human1.SetMoveTarget(_enemy1); _enemyTeam = new Team(_menuManager, _enemy1); _enemy1.SetDefense(0); _enemy1.SetHealth(100); _enemy1.SetMove(_doNothingMove); _enemy1.SetMoveTarget(_enemy1); _battleManager.Battle(_humanTeam, _enemyTeam); const int expectedRemainingHealth = 100 - expectedDamage; Assert.AreEqual(expectedRemainingHealth, _enemy1.CurrentHealth, "Human1's strength should not have been mutliplied, since the dance effect condition was not met!"); }
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"); }
private AttackBattleMove GetNotEvadeRestoreHealthAttack(int percentage) { NotEvadedBattleCondition notEvadedCondition = new NotEvadedBattleCondition(); RestorationBattleMoveEffect restorationEffect = new RestorationBattleMoveEffect(RestorationType.Health, percentage, BattleMoveEffectActivationType.OnAttackHit, notEvadedCondition); CannotBeEvadedBattleMoveEffect cannotBeEvadedEffect = new CannotBeEvadedBattleMoveEffect(); BattleMoveEffect[] effects = { restorationEffect, cannotBeEvadedEffect }; AttackBattleMove attackMove = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 0, effects: effects); return(attackMove); }
public void TestEnemyFighter_GetMove_CorrectlyGetsIndefiniteMove() { AttackBattleMove move = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 0); _enemy.SetMove(move); for (var i = 0; i < 10; ++i) { BattleMove returnedMove = _enemy.GetMove(); Assert.AreEqual(move, returnedMove); } }
public void TestEnemyFighter_GetMove_ThrowsException_NoMoveInQueue() { AttackBattleMove threeTurnMove = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 0); BattleMove sixTurnMove = new SpecialMove("bar", BattleMoveType.Special, TargetType.Self, null); _enemy.SetMove(threeTurnMove, 3); _enemy.SetMove(sixTurnMove, 6); for (var i = 0; i < 9; ++i) { _enemy.GetMove(); } Assert.Throws <IndexOutOfRangeException>(() => _enemy.GetMove()); }
public void TestEnemyFighter_GetMove_CorrectlyGetsMovesBasedOnNumberOfCalls() { BattleMove threeTurnMove = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 0); BattleMove indefiniteMove = new SpecialMove("bar", BattleMoveType.Special, TargetType.Self, null); _enemy.SetMove(threeTurnMove, 3); _enemy.SetMove(indefiniteMove); for (var i = 0; i < 10; ++i) { BattleMove returnedMove = _enemy.GetMove(); BattleMove expectedReturn = (i < 3) ? threeTurnMove : indefiniteMove; Assert.AreEqual(expectedReturn, returnedMove); } }
public void BlindnessStatus_DoesNotAffectNeverMissAttack() { _logger.Subscribe(_humanFighter, EventType.AttackSuccessful); _humanFighter.AddStatus(_blindnessStatus); AttackBattleMove attack = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 0, effects: new NeverMissBattleMoveEffect()); _humanFighter.SetMove(attack, 1); _humanFighter.SetMoveTarget(_enemy); _chanceService.PushEventOccurs(false); //attack is not crit _humanFighter.SetMove(_runawayMove); _enemy.SetMove(_doNothing); _battleManager.Battle(_humanTeam, _enemyTeam); Assert.NotNull(_logger.Logs.FirstOrDefault(log => log.Sender == _humanFighter && log.Type == EventType.AttackSuccessful)); }
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"); }
public void MoveWithCannotBeEvadedEffect_HitsOpponentThatEvaded() { CannotBeEvadedBattleMoveEffect cannotBeEvadedEffect = new CannotBeEvadedBattleMoveEffect(); AttackBattleMove noEvadeAttack = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 10, effects: cannotBeEvadedEffect); _human.SetMove(noEvadeAttack, 1); _human.SetMove(_runawayMove); _human.SetMoveTarget(_enemy); _chanceService.PushAttackHitsNotCrit(); //attack hits, not a crit AutoEvadeStatus autoEvadeStatus = new AutoEvadeStatus(1, false); _enemy.AddStatus(autoEvadeStatus); _enemy.SetMove(_doNothingMove); _enemy.SetHealth(_human.Strength + 1); _battleManager.Battle(_humanTeam, _enemyTeam); Assert.AreEqual(1, _enemy.CurrentHealth, "attack should have hit even though enemy had an AutoEvade status!"); }
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]); }
public void BattleManager_AppropriatelyTicksDownDanceEffectCounter([Values(DanceEffectType.Heart, DanceEffectType.Danger)] DanceEffectType danceEffectType) { const int danceDuration = 4; RestorationBattleMoveEffect conditionalHealEffect = GetRestoreHealthEffect(danceEffectType); AttackBattleMove attackWithHeal = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 0, effects: conditionalHealEffect); _testTechnique.ClearEffects(); _testTechnique.SetDanceEffect(danceEffectType); _testTechnique.SetDuration(danceDuration); _human1.SetMove(_testTechnique, 1); _human1.SetMove(_doNothingMove); _human1.SetMoveTarget(_human1); _human1.SetSpeed(1); _human2.SetHealth(100, 10); _human2.SetMove(attackWithHeal, 6); for (var i = 0; i < 6; ++i) { _chanceService.PushEventsOccur(true, false); //attack hits, does not miss } _human2.SetMove(_runawayMove); _human2.SetMoveTarget(_enemy1); _human2.SetStrength(_enemy1.Defense); _enemy1.SetHealth(100); _enemy1.SetMove(_doNothingMove); _enemy1.SetMoveTarget(_enemy1); _enemy2.SetHealth(100); _enemy2.SetMove(_doNothingMove); _enemy2.SetMoveTarget(_enemy2); _battleManager.Battle(_humanTeam, _enemyTeam); int expectedHealth = 10 + (danceDuration * 10); Assert.AreEqual(expectedHealth, _human2.CurrentHealth); //will be 20 higher if the effect doesn't wear off }
public void MultipleEffects_Fired_OnAttackHit([Values(10, 20)] int restoreAmount) { _human.SetHealth(100, 10); _human.SetMana(100, 10); _restoreManaEffect = new RestorationBattleMoveEffect(RestorationType.Mana, restoreAmount, BattleMoveEffectActivationType.OnAttackHit); _restoreHealthEffect = new RestorationBattleMoveEffect(RestorationType.Health, restoreAmount, BattleMoveEffectActivationType.OnAttackHit); BattleMove attackWithRestoreEffects = new AttackBattleMove("", TargetType.SingleEnemy, 100, 0, effects: new BattleMoveEffect[] { _restoreManaEffect, _restoreHealthEffect }); _human.SetMove(attackWithRestoreEffects); _human.SetMoveTarget(_enemy); _chanceService.PushAttackHitsNotCrit(); //attack hits, not a crit _enemy.SetMove(_doNothingMove); _enemy.SetMoveTarget(_enemy); _battleManager.Battle(_humanTeam, _enemyTeam); int expectedCurrentAmount = 10 + restoreAmount; Assert.AreEqual(expectedCurrentAmount, _human.CurrentMana, $"humman player's mana should have been restored by {restoreAmount} when the attack hit!"); Assert.AreEqual(expectedCurrentAmount, _human.CurrentHealth, $"humman player's health should have been restored by {restoreAmount} when the attack hit!"); }
public void ConditionalEffect_AppropriatelySuppressed_WhenNotEvadedConditionNotMet([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(); AutoEvadeStatus autoEvadeStatus = new AutoEvadeStatus(1, false); _team2Fighter.AddStatus(autoEvadeStatus); _team2Fighter.SetHealth(100); _team2Fighter.SetMove(_doNothingMove); _battleManager.Battle(_team1, _team2); int expectedRemainingHealth = 10; Assert.AreEqual(expectedRemainingHealth, _team1Fighter.CurrentHealth, "The enemy had evade status, so the user should not have regained any HP"); }
public void MoveWithAttackBoostEffect_CorrectlyCalculatesDamage([Values(0.25, 0.5, 2.0, 3.0)] double multiplier) { const int humanStrength = 4; AttackBoostBattleMoveEffect attackBoostEffect = new AttackBoostBattleMoveEffect(multiplier); AttackBattleMove attackBoostAttack = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 10, effects: attackBoostEffect); _human.SetStrength(humanStrength); _human.SetMove(attackBoostAttack, 1); _human.SetMove(_runawayMove); _human.SetMoveTarget(_enemy); _chanceService.PushAttackHitsNotCrit(); //attack hits, not a crit _enemy.SetMove(_doNothingMove); _enemy.SetHealth(100); _battleManager.Battle(_humanTeam, _enemyTeam); int expectedDamage = (int)(humanStrength * multiplier); int expectedRemainingHealth = 100 - expectedDamage; int actualDamage = 100 - _enemy.CurrentHealth; Assert.AreEqual(expectedRemainingHealth, _enemy.CurrentHealth, $"attack should have hit for {expectedDamage} damage, isntead of {actualDamage}!"); }
protected int CalculateAttackPower(IFighter attacker, IFighter defender, AttackBattleMove attackMove, bool isCrit) { double attackMultiplier = CalculateStatMultiplier(attacker, StatType.Strength); if (isCrit) { attackMultiplier *= 2; } int attackerStrength = attacker.Strength; List <AttackBoostBattleMoveEffect> attackBoostEffects = attackMove.BattleMoveEffects.OfType <AttackBoostBattleMoveEffect>().Where(e => IsEffectConditionMet(e, attacker, defender)).ToList(); if (attackBoostEffects.Any()) { double totalAttackBoostMultiplier = attackBoostEffects.Sum(e => e.Multiplier); attackerStrength = (int)(attackerStrength * totalAttackBoostMultiplier); } int initialAttackPower = attackerStrength + attackMove.AttackPower; int calculatedAttackPower = (int)(initialAttackPower * attackMultiplier); return(calculatedAttackPower); }
public void MultipleEffects_OnlyEffectsWhoseConditionsAreMet_AreFired([Values(10, 20)] int restoreAmount) { _human.SetHealth(100, 10); _human.SetMana(100, 10); _restoreManaEffect = new RestorationBattleMoveEffect(RestorationType.Mana, restoreAmount, BattleMoveEffectActivationType.OnAttackHit, new DanceBattleCondition(DanceEffectType.Soul)); _restoreHealthEffect = new RestorationBattleMoveEffect(RestorationType.Health, restoreAmount, BattleMoveEffectActivationType.OnAttackHit, new DanceBattleCondition(DanceEffectType.Fire)); BattleMove attackWithRestoreEffects = new AttackBattleMove("", TargetType.SingleEnemy, 100, 0, effects: new BattleMoveEffect[] { _restoreManaEffect, _restoreHealthEffect }); _human.SetMove(attackWithRestoreEffects); _human.SetMoveTarget(_enemy); _chanceService.PushAttackHitsNotCrit(); //attack hits, not a crit TestHumanFighter dancer = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "dancer"); TestDanceMove danceMove = new TestDanceMove("bar", TargetType.Field, 2); danceMove.SetDanceEffect(DanceEffectType.Fire); danceMove.AddMove(_doNothingMove); dancer.SetSpeed(1); dancer.SetMove(danceMove); dancer.SetMoveTarget(dancer); _humanTeam.Add(dancer, false); _enemy.SetMove(_doNothingMove); _enemy.SetMoveTarget(_enemy); _battleManager.Battle(_humanTeam, _enemyTeam); int expectedCurrentAmount = 10 + restoreAmount; Assert.AreEqual(10, _human.CurrentMana, "humman player's mana should not have been restored, the dance condition wasn't met!"); Assert.AreEqual(expectedCurrentAmount, _human.CurrentHealth, $"humman player's health should have been restored by {restoreAmount} when the attack hit!"); }
public void CalculatedAttackPowerCannotBeNegative() { _logger.Subscribe(_team2Fighter, EventType.DamageTaken); AttackBattleMove attack = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 0, -1); _team1Fighter.SetStrength(0); _team1Fighter.SetMove(attack, 1); _team1Fighter.SetMove(_runawayMove, 1); _chanceService.PushEventsOccur(true, false); //attack hit, not crits _team2Fighter.SetMove(_doNothingMove); _battleManager.Battle(_team1, _team2); List <EventLog> logs = _logger.Logs; Assert.AreEqual(1, logs.Count); PhysicalDamageTakenEventArgs e = logs[0].E as PhysicalDamageTakenEventArgs; Assert.NotNull(e); Assert.AreEqual(0, e.Damage); }
public void SelectMove_MultiTurnMoveSelected() { var enemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1); var enemyTeam = new Team(_menuManager, enemy); var human = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); var humanTeam = new Team(_menuManager, human); var fooMove = new DoNothingMove("Foo!"); var barMove = new DoNothingMove("Bar!"); var bazMove = new AttackBattleMove("Baz", TargetType.SingleEnemy, 50, 100); var multiTurnMove = new MultiTurnBattleMove("multi turn move", TargetType.SingleEnemy, fooMove, barMove, bazMove); enemy.SetAvailableMove(multiTurnMove); var selectedMove = enemy.SetupMove(enemyTeam, humanTeam); Assert.AreEqual(multiTurnMove, selectedMove.Move); var attack = MoveFactory.Get(BattleMoveType.Attack); enemy.SetAvailableMove(attack); selectedMove = enemy.SetupMove(enemyTeam, humanTeam); Assert.AreEqual(barMove, selectedMove.Move); selectedMove = enemy.SetupMove(enemyTeam, humanTeam); Assert.AreEqual(bazMove, selectedMove.Move); selectedMove = enemy.SetupMove(enemyTeam, humanTeam); Assert.AreEqual(attack, selectedMove.Move); }