public void PowerAuraAbilityUnitTest() { OutputHelper.Display.ClearUserOutput(); Player player = new Player("test", PlayerClassType.Warrior) { MaxRagePoints = 150, RagePoints = 150 }; player.Abilities.Add(new PlayerAbility( "power aura", 150, 1, WarriorAbility.PowerAura, 6)); OutputHelper.Display.ClearUserOutput(); int abilityIndex = player.Abilities.FindIndex( f => f.WarAbilityCategory == WarriorAbility.PowerAura); string[] inputInfo = new[] { "ability", "power", "aura" }; PlayerHelper.AbilityInfo(player, inputInfo); Assert.AreEqual("Power Aura", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Rage Cost: 150", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Power Aura Amount: 15", OutputHelper.Display.Output[3][2]); Assert.AreEqual("Strength is increased by 15 for 10 minutes.", OutputHelper.Display.Output[4][2]); string[] input = new[] { "use", "power", "aura" }; string abilityName = InputHelper.ParseInput(input); Assert.AreEqual("power aura", abilityName); int baseStr = player.Strength; int?baseRage = player.RagePoints; int?baseMaxRage = player.MaxRagePoints; player.UseAbility(input); int?rageCost = player.Abilities[abilityIndex].RageCost; Assert.AreEqual(baseMaxRage - rageCost, player.RagePoints); Assert.AreEqual("You generate a Power Aura around yourself.", OutputHelper.Display.Output[5][2]); OutputHelper.Display.ClearUserOutput(); Assert.AreEqual( baseRage - player.Abilities[abilityIndex].RageCost, player.RagePoints); Assert.AreEqual(player.Strength, baseStr + player.Abilities[abilityIndex].ChangeAmount.Amount); Assert.AreEqual( player.MaxRagePoints, baseMaxRage + player.Abilities[abilityIndex].ChangeAmount.Amount * 10); Assert.AreEqual(true, player.Effects[0] is ChangeStatEffect); ChangeStatEffect changeStatEffect = player.Effects[0] as ChangeStatEffect; for (int i = 0; i < 600; i++) { changeStatEffect.ProcessChangeStatRound(player); } GameHelper.RemovedExpiredEffectsAsync(player); Thread.Sleep(1000); Assert.AreEqual(false, player.Effects.Any()); Assert.AreEqual(baseStr, player.Strength); Assert.AreEqual(baseMaxRage, player.MaxRagePoints); Assert.AreEqual(player.MaxRagePoints - rageCost, player.RagePoints); }
public void ConstitutionPotionUnitTest() { OutputHelper.Display.ClearUserOutput(); Player player = new Player("test", PlayerClassType.Mage) { Inventory = new List <IItem> { new StatPotion(PotionStrength.Minor, StatType.Constitution) } }; int potionIndex = player.Inventory.FindIndex(f => f.GetType() == typeof(StatPotion)); string[] input = new[] { "drink", "constitution" }; string potionName = InputHelper.ParseInput(input); Assert.AreEqual("constitution", potionName); StatPotion potion = player.Inventory[potionIndex] as StatPotion; int statAmount = potion.StatAmount; StatType statType = potion.StatPotionType; int baseConst = player.Constitution; int baseMaxHitPoints = player.MaxHitPoints; player.AttemptDrinkPotion(InputHelper.ParseInput(input)); string drankStatString = $"You drank a potion and increased {statType} by {statAmount}."; Assert.AreEqual(drankStatString, OutputHelper.Display.Output[0][2]); Assert.AreEqual(baseConst + statAmount, player.Constitution); Assert.AreEqual(baseMaxHitPoints + (statAmount * 10), player.MaxHitPoints); Assert.IsEmpty(player.Inventory); Assert.AreEqual(true, player.Effects[0] is ChangeStatEffect); ChangeStatEffect changeStatEffect = player.Effects[0] as ChangeStatEffect; for (int i = 1; i < 601; i++) { Assert.AreEqual(i, player.Effects[0].CurrentRound); changeStatEffect.ProcessChangeStatRound(player); } GameHelper.RemovedExpiredEffectsAsync(player); Thread.Sleep(1000); Assert.AreEqual(false, player.Effects.Any()); Assert.AreEqual(baseConst, player.Constitution); Assert.AreEqual(baseMaxHitPoints, player.MaxHitPoints); player.AttemptDrinkPotion(InputHelper.ParseInput(input)); Assert.AreEqual("What potion did you want to drink?", OutputHelper.Display.Output[1][2]); }
public void SwiftAuraAbilityUnitTest() { OutputHelper.Display.ClearUserOutput(); Player player = new Player("placeholder", PlayerClassType.Archer); GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); player.Abilities.Add(new PlayerAbility( "swift aura", 150, 1, ArcherAbility.SwiftAura, 6)); string[] input = new[] { "use", "swift", "aura" }; PlayerHelper.AbilityInfo(player, input); Assert.AreEqual("Swift Aura", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Combo Cost: 150", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Swift Aura Amount: 15", OutputHelper.Display.Output[3][2]); Assert.AreEqual("Dexterity is increased by 15 for 10 minutes.", OutputHelper.Display.Output[4][2]); int baseDex = player.Dexterity; int?baseCombo = player.ComboPoints; int?baseMaxCombo = player.MaxComboPoints; int abilityIndex = player.Abilities.FindIndex(f => f.Name == InputHelper.ParseInput(input)); player.UseAbility(input); Assert.AreEqual(player.Dexterity, baseDex + player.Abilities[abilityIndex].ChangeAmount.Amount); Assert.AreEqual( baseCombo - player.Abilities[abilityIndex].ComboCost, player.ComboPoints); Assert.AreEqual( player.MaxComboPoints, baseMaxCombo + (player.Abilities[abilityIndex].ChangeAmount.Amount * 10)); Assert.AreEqual("You generate a Swift Aura around yourself.", OutputHelper.Display.Output[5][2]); ChangeStatEffect changeStatEffect = player.Effects[0] as ChangeStatEffect; for (int i = 1; i < 601; i++) { Assert.AreEqual(i, player.Effects[0].CurrentRound); changeStatEffect.ProcessChangeStatRound(player); } GameHelper.RemovedExpiredEffectsAsync(player); Thread.Sleep(1000); Assert.AreEqual(false, player.Effects.Any()); Assert.AreEqual(baseDex, player.Dexterity); Assert.AreEqual(baseMaxCombo, player.MaxComboPoints); Assert.AreEqual(baseCombo - player.Abilities[abilityIndex].ComboCost, player.ComboPoints); }
public void ArcaneIntellectSpellUnitTest() { OutputHelper.Display.ClearUserOutput(); Player player = new Player("test", PlayerClassType.Mage) { MaxManaPoints = 150, ManaPoints = 150 }; player.Spellbook.Add(new PlayerSpell( "arcane intellect", 150, 1, SpellType.ArcaneIntellect, 6)); string[] infoInput = new[] { "spell", "arcane", "intellect" }; PlayerHelper.SpellInfo(player, infoInput); Assert.AreEqual("Arcane Intellect", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Mana Cost: 150", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Arcane Intellect Amount: 15", OutputHelper.Display.Output[3][2]); Assert.AreEqual("_Intelligence is increased by 15 for 10 minutes.", OutputHelper.Display.Output[4][2]); OutputHelper.Display.ClearUserOutput(); int baseInt = player.Intelligence; int?baseMana = player.ManaPoints; int?baseMaxMana = player.MaxManaPoints; int spellIndex = player.Spellbook.FindIndex( f => f.SpellCategory == SpellType.ArcaneIntellect); string[] input = new[] { "cast", "arcane", "intellect" }; string spellName = InputHelper.ParseInput(input); Assert.AreEqual("arcane intellect", spellName); player.CastSpell(spellName); Assert.AreEqual(baseMaxMana - player.Spellbook[spellIndex].ManaCost, player.ManaPoints); Assert.AreEqual(player.Intelligence, baseInt + player.Spellbook[spellIndex].ChangeAmount.Amount); Assert.AreEqual( baseMana - player.Spellbook[spellIndex].ManaCost, player.ManaPoints); Assert.AreEqual( baseMaxMana + (player.Spellbook[spellIndex].ChangeAmount.Amount * 10), player.MaxManaPoints); Assert.AreEqual("You cast Arcane Intellect on yourself.", OutputHelper.Display.Output[0][2]); ChangeStatEffect changeStatEffect = player.Effects[0] as ChangeStatEffect; for (int i = 0; i < 10; i++) { changeStatEffect.ProcessChangeStatRound(player); } UserOutput defaultEffectOutput = OutputHelper.ShowEffects(player); Assert.AreEqual("Player _Effects:", defaultEffectOutput.Output[0][2]); Assert.AreEqual(Settings.FormatGeneralInfoText(), defaultEffectOutput.Output[1][0]); Assert.AreEqual("(590 seconds) Arcane Intellect", defaultEffectOutput.Output[1][2]); for (int i = 0; i < 590; i++) { changeStatEffect.ProcessChangeStatRound(player); } GameHelper.RemovedExpiredEffectsAsync(player); Thread.Sleep(1000); Assert.AreEqual(false, player.Effects.Any()); Assert.AreEqual(baseInt, player.Intelligence); Assert.AreEqual(0, player.ManaPoints); Assert.AreEqual(baseMaxMana, player.MaxManaPoints); defaultEffectOutput = OutputHelper.ShowEffects(player); Assert.AreEqual("Player _Effects:", defaultEffectOutput.Output[0][2]); Assert.AreEqual(Settings.FormatInfoText(), defaultEffectOutput.Output[1][0]); Assert.AreEqual("None.", defaultEffectOutput.Output[1][2]); }