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); }
public void CastEggs_CorrectlyRemovesEggsFromEnemyTeam_MoreThan3Eggs() { BattleMoveWithTarget move; BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration(); _battleManager.SetEnemyTeam(_enemyTeam); _battleManager.SetHumanTeam(_humanTeam); _battleManager.SetConfig(config); _chicken.MagicalDamage((_chicken.MaxHealth / 2) + 1, MagicType.Lightning); for (var i = 0; i < 2; ++i) { move = _chicken.SetupMove(_enemyTeam, _humanTeam); _chanceService.PushWhichEventOccurs(0); _chanceService.PushWhichEventOccurs(0); _chicken.ExecuteMove(_battleManager, move, _enemyTeam, _humanTeam, _output); } Assert.AreEqual(5, _enemyTeam.Fighters.Count); move = _chicken.SetupMove(_enemyTeam, _humanTeam); _chanceService.PushWhichEventOccurs(0); //have to select the target of the attack _chicken.ExecuteMove(_battleManager, move, _enemyTeam, _humanTeam, _output); Assert.AreEqual(2, _enemyTeam.Fighters.Count); }
public void CastEggs_CorrectlyRemovesEggsFromEnemyTeam_Exactly3Eggs() { BattleMoveWithTarget move; BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration(); _battleManager.SetEnemyTeam(_enemyTeam); _battleManager.SetHumanTeam(_humanTeam); _battleManager.SetConfig(config); for (var i = 0; i < 3; ++i) { move = _chicken.SetupMove(_enemyTeam, _humanTeam); _chanceService.PushWhichEventOccurs(0); _chicken.ExecuteMove(_battleManager, move, _enemyTeam, _humanTeam, _output); } Assert.AreEqual(4, _enemyTeam.Fighters.Count); move = _chicken.SetupMove(_enemyTeam, _humanTeam); _chanceService.PushWhichEventOccurs(0); //have to select the target of the attack _chicken.ExecuteMove(_battleManager, move, _enemyTeam, _humanTeam, _output); Assert.AreEqual(1, _enemyTeam.Fighters.Count); }
public void BattleManager_PrintsCorrectExecutionText_ShieldHealingMove() { _level1ShieldGuy.SetBattleShield(new IronBattleShield(5, 1, 0)); _level1ShieldGuy.BattleShield.DecrementHealth(1); _chanceService.PushWhichEventsOccur(3, 0); //index 0 is attack, 1 is "equip with shield", 2 is "fortify", 3 is "heal" 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} healed {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 CastEggs_ChaosEgg() { Spell spell = SpellFactory.GetSpell("chaos egg"); int damage = spell.Power + _chicken.MagicStrength; _hero.SetHealth(damage + 1); _hero.SetMove(_doNothingMove, 4); _hero.SetMove(_runawayMove); _hero.SetMoveTarget(_hero); _sidekick.SetHealth(damage + 1); _sidekick.SetMove(_doNothingMove); _sidekick.SetMoveTarget(_sidekick); _chanceService.PushWhichEventsOccur(0, 1, 2); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowIntroAndOutroMessages = false }; _battleManager.Battle(_humanTeam, _enemyTeam, config: config); var outputs = _output.GetOutputs(); Assert.AreEqual(7, outputs.Length); // 1 for each egg lay, 1 for actual attack, 3 to output how much damage each fighter took Assert.AreEqual($"{_castPrefix}chaos egg!\n", outputs[3].Message); Assert.AreEqual(1, _hero.CurrentHealth); Assert.AreEqual(1, _sidekick.CurrentHealth); Assert.AreEqual(_chicken.MaxHealth - damage, _chicken.CurrentHealth); }
public void AutoEvadeStatus_CorrectlyPrintsMessage_WhenAdded([Values(1, 4)] int statusDuration, [Values(true, false)] bool shouldCounter) { AutoEvadeStatus evadeStatus = new AutoEvadeStatus(statusDuration, shouldCounter); StatusMove statusMove = new StatusMove("foo", TargetType.Self, evadeStatus); _humanFighter.SetMove(statusMove, 1); //status move hits _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 andCounterString = shouldCounter ? " and counter" : ""; string expectedOutput = $"{_humanFighter.DisplayName} will evade{andCounterString} all attacks for {statusDuration} {turnOrTurns}!\n"; Assert.AreEqual(expectedOutput, 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 BattleManager_AppropriatelyExecutesDanceTechnique_ScreenOutputs() { _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 BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowIntroAndOutroMessages = false, ShowAttackMessages = false, ShowPhysicalDamageMessages = false, ShowDeathMessages = false, ShowExpAndLevelUpMessages = false }; _battleManager.Battle(_humanTeam, _enemyTeam, config: config); MockOutputMessage[] outputs = _output.GetOutputs(); Assert.AreEqual(3, outputs.Length); //dance move has been performed, enemy's stats raised, human's stats lowered Assert.AreEqual($"{_enemy1.DisplayName} {FirstTurnMessage}\n", outputs[0].Message); }
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 CorrectScreenOutputsPrinted([Values(true, false)] bool enemyDies) { _humanFighter.AddStatus(_status); _humanFighter.SetDefense(_enemy.Strength); _humanFighter.SetMove(_doNothing, 1); _humanFighter.SetMove(_runawayMove); _enemy.SetMove(_basicAttackMove); int enemyHealth = _humanFighter.Strength + (enemyDies ? 0 : 1); _enemy.SetHealth(enemyHealth); _chanceService.PushEventsOccur(true, false); //attack hits, not a crit _chanceService.PushEventsOccur(true, false); //counter hits, not a crit BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowIntroAndOutroMessages = false, ShowExpAndLevelUpMessages = false }; _battleManager.Battle(_humanTeam, _enemyTeam, config: config); MockOutputMessage[] outputs = _output.GetOutputs(); int expectedOutputsLength = 4; //enemy attacked, 0 damage taken, counter, damage taken if (enemyDies) { ++expectedOutputsLength; } Assert.AreEqual(expectedOutputsLength, outputs.Length); Assert.AreEqual($"{_humanFighter.DisplayName} counter attacks!\n", outputs[2].Message); }
public void BattleManager_PrintsMessage_SmokeTest() { foreach (BattleShield shield in _shields) { ShieldMove shieldMove = new ShieldMove("foo", TargetType.Self, null, shield); _humanFighter.SetSpeed(1); _humanFighter.SetMove(shieldMove, 1); _humanFighter.SetMove(_runawayMove); _enemy.SetMove(_doNothing); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowIntroAndOutroMessages = false, ShowAttackMessages = false }; _battleManager.Battle(_humanTeam, _enemyTeam, config: config); MockOutputMessage[] outputs = _output.GetOutputs(); Assert.AreEqual(1, outputs.Length); } }
private void SpecialAttackExecutedEvent_Setup(string executionText) { StatusMove moveToExecute = new StatusMove("foo", TargetType.Self, new AutoEvadeStatus(1, false), executionText); _logger.Subscribe(_humanPlayer1, EventType.StatusAdded, EventType.SpecialMoveExecuted); _humanPlayer1.SetMove(moveToExecute, 1); _mockChanceService.PushEventOccurs(true); //status move hits _humanPlayer1.SetMove(_runawayMove); _enemyPlayer1.SetMove(_doNothingMove); _humanTeam = new TestTeam(_humanPlayer1); _enemyTeam = new Team(TestMenuManager.GetTestMenuManager(), _enemyPlayer1); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowIntroAndOutroMessages = false, ShowExpAndLevelUpMessages = false }; _battleManager.Battle(_humanTeam, _enemyTeam, config: config); }
public void BattleManager_ImmediatelyExecutesFieldEffectsAfterCombining() { _enemy1.SetHealth(100, 10); _enemy2.SetHealth(100, 10); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration(); _battleManager.SetConfig(config); _battleManager.SetHumanTeam(_humanTeam); _battleManager.SetEnemyTeam(_enemyTeam); var effect = new RestoreHealthPercentageFieldEffect(TargetType.OwnTeam, "foo", 10, immediatelyExecuted: true); var combinedEffect = new Battle.FieldEffects.CombinedFieldEffect("foo", effect); _battleManager.ImplementEffects(combinedEffect, 10, _enemy1, _enemy2); //these values will be 10 if the heal effect wasn't immediately executed Assert.AreEqual(20, _enemy1.CurrentHealth); Assert.AreEqual(20, _enemy2.CurrentHealth); var effects = _battleManager.GetFieldEffects(); Assert.AreEqual(0, effects.Count); _battleManager.TestOnTurnEnd(); Assert.AreEqual(20, _enemy1.CurrentHealth); Assert.AreEqual(20, _enemy2.CurrentHealth); effects = _battleManager.GetFieldEffects(); Assert.AreEqual(0, effects.Count); }
public override BattleEndStatus Battle(Team humanTeam, Team enemyTeam, List <TerrainInteractable> terrainInteractables = null, BattleManagerBattleConfiguration config = null) { _enemyTeams.Add(enemyTeam); _terrainInteractableLists.Add(terrainInteractables); return(base.Battle(humanTeam, enemyTeam, terrainInteractables, config ?? _myConfig)); }
public TestBattleManager(IChanceService chanceService, IInput input, IOutput output) : base(chanceService, input, output) { _myConfig = new BattleManagerBattleConfiguration(); _enemyTeams = new List <Team>(); _terrainInteractableLists = new List <List <TerrainInteractable> >(); _battleMoveQueues = new Queue <BattleMoveQueue>(); }
public void BattleManager_DoesNotError_IfDanceMovesCannotCombine() { TestDoNothingMove doNothing1 = (TestDoNothingMove)TestMoveFactory.Get(moveType: BattleMoveType.DoNothing); string dangerDanceMessage = "danced the danger dance"; doNothing1.SetMessage(dangerDanceMessage); var dangerDance = (TestDanceMove)TestMoveFactory.Get(moveType: BattleMoveType.Dance); dangerDance.SetDuration(2); dangerDance.SetDanceEffect(DanceEffectType.Danger); dangerDance.AddMove(doNothing1); _human1.SetMove(dangerDance); _human1.SetMoveTarget(_human1); _human1.SetSpeed(1); TestDoNothingMove doNothing2 = (TestDoNothingMove)TestMoveFactory.Get(moveType: BattleMoveType.DoNothing); var mindDance = (TestDanceMove)TestMoveFactory.Get(moveType: BattleMoveType.Dance); string mindDanceMessage = "danced the mind dance"; doNothing2.SetMessage(mindDanceMessage); mindDance.SetDuration(2); mindDance.SetDanceEffect(DanceEffectType.Mind); mindDance.AddMove(doNothing2); _human2.SetMove(mindDance); _human2.SetMoveTarget(_human2); _human2.SetSpeed(1); _enemy1.SetMove(_basicAttack); _enemy1.SetMoveTarget(_human1); _enemy1.SetStrength(_human1.Defense + _human1.MaxHealth + 1); _enemy2.SetMove(_basicAttack); _enemy2.SetMoveTarget(_human2); _enemy2.SetStrength(_human2.Defense + _human2.MaxHealth + 1); _chanceService.PushEventsOccur(true, false, true, false); //attacks hit, don't crit var combine = _combiner.Combine(DanceEffectType.Danger, DanceEffectType.Mind); Assert.That(combine, Is.Null); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { FieldEffectCombiner = _combiner, ShowIntroAndOutroMessages = false, ShowAttackMessages = false, ShowDeathMessages = false, ShowExpAndLevelUpMessages = false, ShowPhysicalDamageMessages = false }; Assert.DoesNotThrow(() => _battleManager.Battle(_humanTeam, _enemyTeam, config: config)); //ensure dance moves were used before human team was defeated MockOutputMessage[] outputs = _output.GetOutputs(); Assert.AreEqual(2, outputs.Length); Assert.AreEqual($"{_human1.DisplayName} {dangerDanceMessage}\n", outputs[0].Message); Assert.AreEqual($"{_human2.DisplayName} {mindDanceMessage}\n", outputs[1].Message); }
public void BattleManager_AppropriatelyCancelsCombinationEffect_IfEitherOwnerDies() { var windDance = (TestDanceMove)TestMoveFactory.Get(moveType: BattleMoveType.Dance); windDance.SetDuration(2); windDance.SetDanceEffect(DanceEffectType.Wind); windDance.AddMove(_doNothingMove); _human1.SetHealth(100, 10); _human1.SetSpeed(1); _human1.SetMove(windDance); _human1.SetMoveTarget(_human1); var fireDance = (TestDanceMove)TestMoveFactory.Get(moveType: BattleMoveType.Dance); fireDance.SetDuration(2); fireDance.SetDanceEffect(DanceEffectType.Fire); fireDance.AddMove(_doNothingMove); fireDance.AddMove(_runawayMove); _human2.SetHealth(100, 10); _human2.SetSpeed(1); _human2.SetMove(fireDance); _human2.SetMoveTarget(_human2); _enemy1.SetStrength(_human1.Defense + _human1.MaxHealth + 1); _enemy1.SetMove(_basicAttack); _enemy1.SetMoveTarget(_human1); _chanceService.PushEventsOccur(true, false); //attack hits, not a crit _enemyTeam = new Team(TestMenuManager.GetTestMenuManager(), _enemy1); RestoreHealthPercentageFieldEffect restoreHealthEffect = new RestoreHealthPercentageFieldEffect(TargetType.OwnTeam, "heal dance", 20, 10); CombinedFieldEffect testCombo = new CombinedFieldEffect("heal dance", restoreHealthEffect); _combiner.AddFakeCombination(DanceEffectType.Wind, DanceEffectType.Fire, testCombo); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { FieldEffectCombiner = _combiner }; _battleManager.Battle(_humanTeam, _enemyTeam, config: config); //will be 30 if the dance effect isn't interrupted Assert.AreEqual(10, _human2.CurrentHealth); }
public void BattleManager_CorrectlyPrintsMessages_ElementalBattleShield([Values("eats pudding", null)] string executionMessage, [Values(MagicType.Ice, MagicType.Fire, MagicType.Earth, MagicType.Lightning)] MagicType shieldMagicType) { const int shieldDefense = 5; const int shieldHealth = 1; ElementalBattleShield shield = new ElementalBattleShield(shieldHealth, shieldDefense, 0, shieldMagicType); ShieldMove shieldMove = new ShieldMove("foo", TargetType.Self, executionMessage, 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 BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowIntroAndOutroMessages = false, ShowAttackMessages = false }; _battleManager.Battle(_humanTeam, _enemyTeam, config: config); MockOutputMessage[] outputs = _output.GetOutputs(); int expectedLength = 3; //damage taken, "equipped with shield," and "shield destroyed" messages if (executionMessage != null) { expectedLength++; } Assert.AreEqual(expectedLength, outputs.Length); int i = 0; if (executionMessage != null) { Assert.AreEqual($"{_humanFighter.DisplayName} {executionMessage}!\n", outputs[i++].Message); } string aOrAn = shieldMagicType == MagicType.Ice || shieldMagicType == MagicType.Earth ? "an" : "a"; Assert.AreEqual($"{_humanFighter.DisplayName} was equipped with {aOrAn} {shieldMagicType.ToString().ToLower()} elemental battle shield!\n", outputs[i].Message); }
private BattleEndStatus BattleThroughSubRegion(SubRegion subRegion, BattleManager manager, Team playerTeam) { bool continuer = true; BattleEndStatus battleEndStatus = BattleEndStatus.None; int numberRegularBattles = subRegion.NumberRegularBattles; for (var i = 0; i <= numberRegularBattles && continuer; ++i) { //var enemyTeam = GetEnemies(subRegion, i); BattleFieldInfo battlefiendInfo = GetBattleFieldInfo(subRegion, i); BattleManagerBattleConfiguration config = GetBattleConfiguration(subRegion, i); if (i == numberRegularBattles) { PrintBossIntro(subRegion.AreaId); } battleEndStatus = manager.Battle(playerTeam, battlefiendInfo.EnemyTeam, battlefiendInfo.TerrainInteractables.ToList(), config); if (battleEndStatus != BattleEndStatus.Victory) { continuer = false; } else { foreach (IFighter player in playerTeam.Fighters) { if (!player.IsAlive()) { player.Revive(1); } player.Heal(player.MaxHealth); player.RestoreMana(player.MaxMana); } _output.WriteLine("HP and Mana fully restored!"); _input.WaitAndClear(_output); } } return(battleEndStatus); }
public void TearDown() { _chanceService = null; _output = null; _input = null; _battleManager = null; _config = null; _regionFactory = null; _regionManager = null; _groupingFactory = null; _teamFactory = null; _mapManager = null; _humanFighter1 = null; _humanFighter2 = null; _humanTeam = null; }
public void NewlyAddedEnemyTeam_CorrectlyWiredIntoEvents() { //Assert _enemyTeam = new TestTeam(_enemyPlayer1); _enemyPlayer1.SetMove(_doNothingMove, 2); _enemyPlayer1.SetMove(_runawayMove); _enemyPlayer2.SetMove(_doNothingMove); bool alreadyAdded = false; _enemyTeam.RoundEnded += delegate(object sender, RoundEndedEventArgs args) { if (!alreadyAdded) { args.Team.Add(_enemyPlayer2); alreadyAdded = true; } }; _humanPlayer1.SetMove(_doNothingMove, 1); _humanPlayer1.SetMove(_basicAttackMove, 1); _humanPlayer1.SetMove(_doNothingMove); _mockChanceService.PushAttackHitsNotCrit(); _humanPlayer1.SetMoveTarget(_enemyPlayer2); _humanPlayer2.SetMove(_doNothingMove); _humanPlayer2.SetMoveTarget(_humanPlayer2); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowExpAndLevelUpMessages = false, ShowIntroAndOutroMessages = false }; //Act _battleManager.Battle(_humanTeam, _enemyTeam, config: config); //Assert MockOutputMessage output = _output.GetOutputs()[1]; Assert.AreEqual($"It did 1 damage!\n", output.Message); }
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); }
private void CombineDanceMove_Setup(string doNothingMessage = "") { var doNothing = (TestDoNothingMove)TestMoveFactory.Get(moveType: BattleMoveType.DoNothing); doNothing.SetMessage(doNothingMessage); var windDance = (TestDanceMove)TestMoveFactory.Get(moveType: BattleMoveType.Dance); windDance.SetDuration(2); windDance.SetDanceEffect(DanceEffectType.Wind); windDance.AddMove(doNothing); windDance.AddMove(doNothing); _human1.SetMove(windDance, 1); _human1.SetMove(_runawayMove); _human1.SetMoveTarget(_human1); _human1.SetHealth(100, 10); var fireDance = (TestDanceMove)TestMoveFactory.Get(moveType: BattleMoveType.Dance); fireDance.SetDuration(2); fireDance.SetDanceEffect(DanceEffectType.Fire); fireDance.AddMove(doNothing); fireDance.AddMove(doNothing); _human2.SetMove(fireDance); _human2.SetMoveTarget(_human2); _human2.SetHealth(100, 10); _enemy1.SetMove(_doNothingMove); _enemy2.SetMove(_doNothingMove); CombinedFieldEffect fakeCombinedEffect = new CombinedFieldEffect("fwee", new RestoreHealthPercentageFieldEffect(TargetType.OwnTeam, "fwee", 80, immediatelyExecuted: true)); _combiner.AddFakeCombination(DanceEffectType.Wind, DanceEffectType.Fire, fakeCombinedEffect); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { FieldEffectCombiner = _combiner, ShowIntroAndOutroMessages = false }; _battleManager.Battle(_humanTeam, _enemyTeam, config: config); }
public void SetUp() { _chanceService = new MockChanceService(); _output = new MockOutput(); _input = new MockInput(); _battleManager = new TestBattleManager(_chanceService, _input, _output); _config = new SilentBattleConfiguration(); _battleManager.SetConfig(_config); _teamFactory = new TestTeamFactory(_chanceService); _mapManager = new MockMapManager(); _decisionManager = new MockDecisionManager(new GodRelationshipManager()); _regionFactory = new MockRegionFactory(_decisionManager); _groupingFactory = new GroupingFactory(_chanceService, _teamFactory, new FighterFactory()); _humanFighter1 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); _humanFighter2 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); _humanTeam = new Team(TestMenuManager.GetTestMenuManager(), _humanFighter1, _humanFighter2); _oneEnemyTeam = GetSingleEnemyTeam(); }
public void AutoEvadeStatus_CorrectlyPrintsMessage_WhenEvaded() { _humanFighter.AddStatus(_evadeButDoNotCounterStatus); _humanFighter.SetMove(_doNothing, 1); _humanFighter.SetMove(_runawayMove); _enemy.SetMove(_basicAttackMove); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowIntroAndOutroMessages = false }; _battleManager.Battle(_humanTeam, _enemyTeam, config: config); MockOutputMessage[] outputs = _output.GetOutputs(); Assert.AreEqual(2, outputs.Count()); Assert.AreEqual($"{_humanFighter.DisplayName} evaded the attack!\n", outputs[1].Message); }
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); }
public void AutoEvadeStatus_CorrectlyPrintsMessage_WhenEvadedAndCountered() { _humanFighter.AddStatus(_evadeAndCounterStatus); _humanFighter.SetMove(_doNothing, 1); _humanFighter.SetMove(_runawayMove); _enemy.SetHealth(_humanFighter.Strength + 1); _enemy.SetMove(_basicAttackMove); _chanceService.PushEventsOccur(true, false); //counter hits and is not a crit BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowIntroAndOutroMessages = false }; _battleManager.Battle(_humanTeam, _enemyTeam, config: config); MockOutputMessage[] outputs = _output.GetOutputs(); Assert.AreEqual(3, outputs.Count()); //original attack, evaded and countered, damage done Assert.AreEqual($"{_humanFighter.DisplayName} evaded the attack and countered!\n", outputs[1].Message); }
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 BattleManager_CorrectlySubscribesToAddedShieldsEvents() { BattleShield shield = new IronBattleShield(1, 0, 0); ShieldMove shieldMove = new ShieldMove("foo", TargetType.Self, null, shield); _humanPlayer1.SetMove(shieldMove, 1); _humanPlayer1.SetMove(_doNothingMove); _humanPlayer1.SetMoveTarget(_humanPlayer1); _humanPlayer1.SetSpeed(1); _enemyPlayer1.SetMove(_basicAttackMove); _enemyPlayer1.SetStrength(1000); _enemyPlayer1.SetMoveTarget(_humanPlayer1); _chanceService.PushEventsOccur(true, false, true, false); //two attacks to end the battle, both hit, neither are crits _logger.Subscribe(EventType.ShieldAdded, _humanPlayer1); _humanTeam = new Team(_menuManager, _humanPlayer1); _enemyTeam = new Team(_menuManager, _enemyPlayer1); BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration { ShowIntroAndOutroMessages = false, ShowDeathMessages = false, ShowExpAndLevelUpMessages = false, ShowShieldAddedMessage = false }; _battleManager.Battle(_humanTeam, _enemyTeam, config: config); MockOutputMessage[] outputs = _output.GetOutputs(); int expectedOutputCount = 2 * 2 + 1; //"enemy attacks!" and "it did ____ damage" message for both attacks, as well as "shield destroyed!" Assert.AreEqual(expectedOutputCount, outputs.Length); }