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); } }
public void CopyMethod_ReturnsAppropriateResponse([Values(MagicType.Fire, MagicType.Water)] MagicType shieldMagicType, [Values(1, 7)] int shieldHealth, [Values(2, 4)] int shieldDefense) { ElementalBattleShield shield = new ElementalBattleShield(shieldHealth, shieldDefense, 0, MagicType.Lightning); ShieldMove shieldMove = new ShieldMove("foo", TargetType.Self, null, shield); ShieldMove copy = new ShieldMove(shieldMove); Assert.AreNotEqual(shieldMove.Shield, copy.Shield); Assert.IsTrue(shieldMove.Shield.AreEqual(copy.Shield)); }
public void FirstBattle_BarbarianDoesNothingWhileEquippedWithShield() { _barbarian.PreBattleSetup(_enemyTeam, _humanTeam, _output, BattleConfigurationSpecialFlag.FirstBarbarianBattle); BattleMoveWithTarget moveWithTarget = _barbarian.GetZeroTurnMove(_enemyTeam, _humanTeam); ShieldMove move = moveWithTarget.Move as ShieldMove; _barbarian.SetBattleShield(move?.Shield as BattleShield); BattleMove battleMove = _barbarian.SelectMove(_enemyTeam, _humanTeam); Assert.IsAssignableFrom <DoNothingMove>(battleMove); }
public void GetZeroTurnMove_FirstBattle_IsUnbustableShieldMove() { //Arrange _barbarian.PreBattleSetup(_enemyTeam, _humanTeam, _output, BattleConfigurationSpecialFlag.FirstBarbarianBattle); //Act BattleMoveWithTarget moveWithTarget = _barbarian.GetZeroTurnMove(_enemyTeam, _humanTeam); //Assert ShieldMove move = moveWithTarget.Move as ShieldMove; Assert.NotNull(move); IBattleShield shield = move.Shield; Assert.AreEqual(1, shield.ShieldBusterDefense); }
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); }
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 ShieldGuy(int level, IChanceService chanceService, string name = null) : base(name ?? "Shield Guy" , level , LevelUpManager.GetHealthByLevel <ShieldGuy>(level) , LevelUpManager.GetManaByLevel <ShieldGuy>(level) , LevelUpManager.GetStrengthByLevel <ShieldGuy>(level) , LevelUpManager.GetDefenseByLevel <ShieldGuy>(level) , LevelUpManager.GetSpeedByLevel <ShieldGuy>(level) , LevelUpManager.GetEvadeByLevel <ShieldGuy>(level) , LevelUpManager.GetLuckByLevel <ShieldGuy>(level) , chanceService , SpellFactory.GetSpellsByLevel <ShieldGuy>(level) , MoveFactory.GetMovesByLevel <ShieldGuy>(level)) { _basicAttack = AvailableMoves.FirstOrDefault(bm => bm.MoveType == BattleMoveType.Attack); _ironShieldMove = AvailableMoves.FirstOrDefault(bm => bm is ShieldMove) as ShieldMove; _healShield = AvailableMoves.FirstOrDefault(bm => bm is ShieldFortifyingMove && ((ShieldFortifyingMove)bm).FortifyingType == ShieldFortifyingType.Health) as ShieldFortifyingMove; _fortifyShield = AvailableMoves.FirstOrDefault(bm => bm is ShieldFortifyingMove && ((ShieldFortifyingMove)bm).FortifyingType == ShieldFortifyingType.Defense) as ShieldFortifyingMove; }
public void BattleManager_CorrectlyUnsubscribes_OnceShieldRemovedFromPlayer() { 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); _battleManager.Battle(_humanTeam, _enemyTeam); int outputCountBefore = _output.GetOutputs().Length; ShieldAddedEventArgs e = _logger.Logs[0].E as ShieldAddedEventArgs; Assert.NotNull(e); BattleShield shieldCopy = e.BattleShield; shieldCopy.OnDamageTaken(new PhysicalDamageTakenEventArgs(7)); int outputCountAfter = _output.GetOutputs().Length; Assert.AreEqual(outputCountBefore, outputCountAfter); }
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); }