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 SelectMove_AppropriatelySelectsGoblinPunch() { _mockChanceService.PushEventOccurs(true); var goblinPunch = _goblin.AvailableMoves.Single(am => am.Description == "goblin punch") as MultiTurnBattleMove; if (goblinPunch == null) { throw new AssertionException("goblin punch should not be null"); } BattleMoveWithTarget selectedMove; for (var i = 0; i < goblinPunch.Moves.Count; ++i) { selectedMove = _goblin.SetupMove(_goblinTeam, _humanTeam); var expectedMove = (i == 0) ? goblinPunch : goblinPunch.Moves[i]; Assert.AreEqual(expectedMove, selectedMove.Move); } _mockChanceService.PushEventOccurs(false); selectedMove = _goblin.SetupMove(_goblinTeam, _humanTeam); Assert.AreEqual("attack", selectedMove.Move.Description); Assert.AreEqual(0.75, _mockChanceService.LastChanceVals[1]); }
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 MalevolenceCharge_CorrectlyAddedWhenShadeAbsorbed() { //arrange for (var i = 0; i < 2; ++i) { //the first shade will attack and miss for 2 turns, second shade will charge _chanceService.PushWhichEventsOccur(_malevolenceAttackIndex, _malevolenceChargeIndex); _chanceService.PushEventOccurs(false); } //third turn, first shade absorbs second _chanceService.PushWhichEventsOccur(_absorptionMoveIndex, _malevolenceChargeIndex); //have to set which bonus is set when Shade is absorbed _chanceService.PushWhichEventOccurs(0); //fourth turn, shade attacks and hits _chanceService.PushWhichEventOccurs(_malevolenceAttackNoAbsorptionMoveIndex); _chanceService.PushAttackHitsNotCrit(); _humanFighter.SetDefense(_shade1.Strength); _humanFighter.SetHealth(3); _humanFighter.SetMove(_doNothingMove, 4); _humanFighter.SetMove(_runawayMove); Team shadeTeam = new Team(TestMenuManager.GetTestMenuManager(), _shade1, _shade2); //act _battleManager.Battle(_humanTeam, shadeTeam); //assert Assert.AreEqual(1, _humanFighter.CurrentHealth); }
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 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 RestoreHealthEffect_DoesNotActivate_AttackMisses() { int initialHealth = 100 - _restoreHealthEffect.Percentage; _human.SetHealth(100, initialHealth); _human.SetMove(_attackWithRestoreHealthEffect, 1); _human.SetMove(_runawayMove); _human.SetMoveTarget(_enemy); _chanceService.PushEventOccurs(false); //attack misses _enemy.SetMove(_doNothingMove); _enemy.SetMoveTarget(_enemy); _battleManager.Battle(_humanTeam, _enemyTeam); Assert.AreEqual(initialHealth, _human.CurrentHealth, "humman player's health should not have been restored because the attack missed!"); }
public void BattleManagerCorrectlyExecutesBellSealingMove() { //Arrange List <Shade> shades = _shadeGrouping.GetShades(); _humanFighter.SetSpeed(shades[0].Speed + 1); List <Bell> bells = GetBells(BellType.Copper, BellType.Silver); _input.Push("special", "pray copper", "1", "run", "y"); _chanceService.PushEventOccurs(true); //sealing is effective int attackIndex = shades[0].AvailableMoves.FindIndex(am => am.MoveType == BattleMoveType.Attack); _chanceService.PushWhichEventsOccur(attackIndex, attackIndex, attackIndex); _chanceService.PushEventsOccur(false, false); //both remaining shades will attack //Act _battleManager.Battle(_humanTeam, _shadeTeam, bells.Cast <TerrainInteractable>().ToList()); //Assert //1st shade was sealed Assert.AreEqual(0, shades[0].CurrentHealth); //other shades did not absorb its power Assert.AreEqual(1, shades[1].ShadeExperience); Assert.AreEqual(1, shades[2].ShadeExperience); }
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 CorrectlySealsShade_WhenExecutingPrayMove() { Shade shade = (Shade)TestFighterFactory.GetFighter(TestFighterType.Shade, 1); _logger.Subscribe(EventType.FighterSealed, shade); TestHumanFighter fighter = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); BattleMoveWithTarget moveWithTarget = new BattleMoveWithTarget(_prayMove, shade, fighter); _chanceService.PushEventOccurs(true); //act _copperBell.ExecuteMove(moveWithTarget); //assert Assert.AreEqual(0, shade.CurrentHealth); List <EventLog> logs = _logger.Logs; Assert.AreEqual(1, logs.Count); Assert.AreEqual(EventType.FighterSealed, logs[0].Type); Assert.AreEqual(shade, logs[0].Sender); }
public void StatusTechnique_AppropriatelyAssignsStatusToTarget() { StatMultiplierStatus status = new StatMultiplierStatus(3, StatType.Strength, 1.5); StatusMove statusMove = new StatusMove("raise attack", TargetType.SingleAlly, status); TestHumanFighter fighter2 = new TestHumanFighter("foo 2", 1); _humanTeam = new TestTeam(_humanFighter, fighter2); _humanFighter.SetSpeed(1); _humanFighter.SetMove(statusMove); _chanceService.PushEventOccurs(true); _humanFighter.SetMoveTarget(fighter2); _logger.Subscribe(EventType.StatusAdded, fighter2); BattleMove attack = MoveFactory.Get(BattleMoveType.Attack); fighter2.SetStrength(2); fighter2.SetMove(attack); fighter2.SetMoveTarget(_enemy); _chanceService.PushEventOccurs(true); //attack hits _chanceService.PushEventOccurs(false); //attack is not a crit //enemy won't be killed if the status isn't assigned to _fighter2 _enemy.SetHealth(3); _enemy.SetMove(_doNothing); _enemy.SetMoveTarget(_enemy); //once Statuses are removed after battle, won't be able to _battleManager.Battle(_humanTeam, _enemyTeam); List <EventLog> logs = _logger.Logs; Assert.AreEqual(1, logs.Count); EventLog log = logs[0]; Assert.AreEqual(EventType.StatusAdded, log.Type); StatusAddedEventArgs e = log.E as StatusAddedEventArgs; Assert.NotNull(e); Assert.IsTrue(status.AreEqual(e.Status)); }