public void BattleManager_PrintsCorrectExecutionText_ShieldFortifyingMove() { _level1ShieldGuy.SetBattleShield(new IronBattleShield(5, 1, 0)); _chanceService.PushWhichEventsOccur(2, 0); //index 0 is attack, 1 is "equip with shield", and 2 is "fortify." Second index supplied so it won't error when selecting second turn's move _ally1.SetMove(_doNothingMove); _ally2.SetMove(_doNothingMove); _humanFighter.SetMove(_doNothingMove, 1); _humanFighter.SetMove(_runawayMove); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowIntroAndOutroMessages = false }; _battleManager.Battle(_humanTeam, _shieldGuyTeam, config: config); MockOutputMessage[] outputs = _output.GetOutputs(); Assert.AreEqual(1, outputs.Length); string displayName = _level1ShieldGuy.DisplayName; string expectedOutput = $"{displayName} strengthened {displayName}'s shield!\n"; Assert.AreEqual(expectedOutput, outputs[0].Message); }
public void StatusMove_AppropriatelyDisplaysExecutionText() { const string executionText = "performs the foo ritual"; Status status = new MagicMultiplierStatus(2, MagicType.Water, 2); StatusMove move = new StatusMove("foo", TargetType.Self, status, executionText); _team1Fighter.SetMove(move, 1); _team1Fighter.SetMove(_runawayMove); _team2Fighter.SetMove(_doNothingMove); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowIntroAndOutroMessages = false, ShowExpAndLevelUpMessages = false }; //status move hits _chanceService.PushEventOccurs(true); _battleManager.Battle(_team1, _team2, config: config); MockOutputMessage[] outputs = _output.GetOutputs(); Assert.AreEqual(2, outputs.Length); string expectedStatusOutput = $"{_team1Fighter.DisplayName} {executionText}!\n"; Assert.AreEqual(expectedStatusOutput, outputs[0].Message); }
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); }
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 MoveWithNeverMissEffect_BypassesAccuracyCheck() { _human.SetMove(_attackWithNeverMissEffect); _human.SetMoveTarget(_enemy); _chanceService.PushEventsOccur(false); //just check the crit _enemy.SetMove(_doNothingMove); //Will throw if both hit and crit chances checked Assert.DoesNotThrow(() => _battleManager.Battle(_humanTeam, _enemyTeam)); }
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); } }
private void MissedEvent_Setup(bool showAttackMessages) { 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.SetMove(_basicAttackMove, 1); _humanPlayer1.SetMove(_runawayMove); _humanPlayer1.SetMoveTarget(_enemyPlayer2); _enemyPlayer1.SetSpeed(1); _enemyPlayer1.SetMove(_basicAttackMove); _enemyPlayer1.SetMoveTarget(enemy3); _mockChanceService.PushEventsOccur(false, false); //both attacks miss _logger.Subscribe(EventType.AttackMissed, _humanPlayer1); _logger.Subscribe(EventType.AttackMissed, _enemyPlayer1); _enemyPlayer2.SetMove(_doNothingMove); enemy3.SetMove(_doNothingMove); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowIntroAndOutroMessages = false, ShowExpAndLevelUpMessages = false, ShowPhysicalDamageMessages = false, ShowAttackMessages = showAttackMessages }; _battleManager.Battle(mixedPlayerTeam, enemyTeam, config: config); }
private Team GetSingleEnemyTeam() { TestEnemyFighter enemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1); enemy.SetMove(_doNothingMove); return(new TestTeam(enemy)); }
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); }
public void CorrectlyPrintsMessages_WhenAdded([Values(1, 3)] int statusDuration) { CounterAttackStatus status = new CounterAttackStatus(statusDuration); StatusMove statusMove = new StatusMove("foo", TargetType.Self, status); _humanFighter.SetMove(statusMove, 1); _chanceService.PushEventOccurs(true); _humanFighter.SetMove(_runawayMove); _enemy.SetMove(_doNothing); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowIntroAndOutroMessages = false }; _battleManager.Battle(_humanTeam, _enemyTeam, config: config); MockOutputMessage[] outputs = _output.GetOutputs(); Assert.AreEqual(1, outputs.Length); string turnOrTurns = statusDuration == 1 ? "turn" : "turns"; string expectedOutput = $"{_humanFighter.DisplayName} will counter any attack for {statusDuration} {turnOrTurns}!\n"; Assert.AreEqual(expectedOutput, outputs[0].Message); }
public void BattleManager_CorrectlySetsShield_WhenExecutingShieldMove() { const int shieldDefense = 5; const int shieldHealth = 1; ElementalBattleShield shield = new ElementalBattleShield(shieldHealth, shieldDefense, 0, MagicType.Lightning); ShieldMove shieldMove = new ShieldMove("foo", TargetType.Self, null, shield); _humanFighter.SetSpeed(1); _humanFighter.SetMove(shieldMove, 1); _humanFighter.SetMove(_runawayMove); _enemy.SetStrength(shieldHealth + shieldDefense); _enemy.SetMove(_basicAttackMove); _chanceService.PushEventsOccur(true, false); //attack hits, is not a crit _battleManager.Battle(_humanTeam, _enemyTeam); Assert.AreEqual(_humanFighter.MaxHealth, _humanFighter.CurrentHealth); }
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 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); }
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 BattleManager_CorrectlyPrintsMessages_TargetHasShield([Values("eats pudding", null)] string executionMessage) { const int shieldDefense = 5; const int shieldHealth = 1; IronBattleShield shield = new IronBattleShield(shieldHealth, shieldDefense, 0); ShieldBusterMove shieldBusterMove = new ShieldBusterMove("foo", TargetType.SingleEnemy, executionMessage); _humanFighter.SetSpeed(1); _humanFighter.SetMove(shieldBusterMove, 1); _humanFighter.SetMove(_runawayMove); _humanFighter.SetMoveTarget(_enemy); _enemy.SetBattleShield(shield); //_logger.SubscribeAll(_enemy.BattleShield); _enemy.SetMove(_doNothingMove); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowIntroAndOutroMessages = false }; _battleManager.Battle(_humanTeam, _enemyTeam, config: config); MockOutputMessage[] outputs = _output.GetOutputs(); int expectedLength = 1; if (executionMessage != null) { expectedLength++; } Assert.AreEqual(expectedLength, outputs.Length); int i = 0; if (executionMessage != null) { Assert.AreEqual($"{_humanFighter.DisplayName} {executionMessage}!\n", outputs[i++].Message); } Assert.AreEqual($"{_enemy.DisplayName}'s shield was destroyed!\n", outputs[i].Message); }
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); }
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 CorrectlyHandles_MultiTurnMoves() { DoNothingMove firstMove = new DoNothingMove("foo"); DoNothingMove secondMove = new DoNothingMove("bar"); DoNothingMove thirdMove = new DoNothingMove("baz"); TestMultiTurnMove multiTurnMove = new TestMultiTurnMove("foo", TargetType.Self, firstMove, secondMove, thirdMove); TestEnemyFighter enemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1); enemy.SetMove(new DoNothingMove("fwop")); _enemyTeam = new Team(TestMenuManager.GetTestMenuManager(), enemy); TestHumanFighter human = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); human.AddSpecialMove(multiTurnMove); _playerTeam = new Team(_manager, human); _manager.InitializeForBattle(_playerTeam, _enemyTeam); _input.Push(new List <string> { "fight", "special move", "foo", "1" }); List <HumanFighter> inputList = new List <HumanFighter> { human }; List <BattleMoveWithTarget> returnedList = _manager.GetInputs(inputList); Assert.AreEqual(firstMove, returnedList[0].Move); returnedList = _manager.GetInputs(inputList); Assert.AreEqual(secondMove, returnedList[0].Move); returnedList = _manager.GetInputs(inputList); Assert.AreEqual(thirdMove, returnedList[0].Move); }
public void SetUp() { _output = new MockOutput(); _input = new MockInput(); _menuManager = new TestMenuManager(_input, _output); _chanceService = new MockChanceService(); _battleManager = new TestBattleManager(_chanceService, _input, _output); _logger = new EventLogger(); _human = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); _enemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1); _humanTeam = new TestTeam(_human); _enemyTeam = new Team(_menuManager, _enemy); _human.SetSpeed(10); _enemy.SetSpeed(0); doNothing = new DoNothingMove(); _enemy.SetMove(doNothing); _fireballSpell = SpellFactory.GetSpell(MagicType.Fire, 1); }
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}!"); }
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!"); }
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 BattleManagerCorrectlyIdentifiesBellInIntro() { List <Bell> bells = GetBells(BellType.Copper, BellType.Silver); _humanFighter.SetMove(_runawayMove); _enemy.SetMove(_doNothingMove); _battleManager.Battle(_humanTeam, _enemyTeam, bells.Cast <TerrainInteractable>().ToList()); MockOutputMessage[] outputs = _output.GetOutputs(); int bellIntroIndex = 1 + _enemyTeam.Fighters.Count; //"time for a battle" and then each "encountered ____" foreach (Bell bell in bells) { MockOutputMessage output = outputs[bellIntroIndex]; Assert.AreEqual($"There is a {bell.DisplayName} on the field\n", output.Message); bellIntroIndex++; } Assert.AreEqual(bellIntroIndex, _output.GetClearIndices()[1]); }
public void BattleManager_AppropriatelyExecutesDanceTechnique_DoesNotThrowException() { _enemy1.SetMove(_testTechnique); _enemy1.SetSpeed(10); _enemy2.SetMove(_doNothingMove); _human1.SetMove(_basicAttack); _human1.SetMoveTarget(_enemy1); _human1.SetStrength(EnemyDefenseAfterDanceMove + _enemy1.MaxHealth); _human2.SetMove(_basicAttack); _human2.SetMoveTarget(_enemy2); _human2.SetStrength(EnemyDefenseAfterDanceMove + _enemy2.MaxHealth); _chanceService.PushEventsOccur(true, false, true, false); //set up attack hits, attack crits for both attacks Assert.DoesNotThrow(() => { _battleManager.Battle(_humanTeam, _enemyTeam); }); }