public void DoubleShotAbilityUnitTest() { Player player = new Player("test", PlayerClassType.Archer) { MaxComboPoints = 100, ComboPoints = 100, MaxHitPoints = 100, HitPoints = 10 }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); Monster monster = new Monster(3, MonsterType.Demon) { HitPoints = 100, MaxHitPoints = 100, InCombat = true }; MonsterBuilder.BuildMonster(monster); int abilityIndex = player.Abilities.FindIndex( f => f.ArcAbilityCategory == ArcherAbility.Double); string[] inputInfo = new[] { "ability", "double" }; PlayerHelper.AbilityInfo(player, inputInfo); Assert.AreEqual("Double Shot", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Combo Cost: 25", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Instant Damage: 25", OutputHelper.Display.Output[3][2]); Assert.AreEqual( "Two arrows are fired which each cause instant damage. Cost and damage are per arrow.", OutputHelper.Display.Output[4][2]); string[] input = new[] { "use", "double" }; string abilityName = InputHelper.ParseInput(input); Assert.AreEqual("double", abilityName); int arrowCount = player.PlayerQuiver.Quantity; player.UseAbility(monster, input); Assert.AreEqual(arrowCount - 2, player.PlayerQuiver.Quantity); int?comboCost = player.Abilities[abilityIndex].ComboCost; int hitAmount = player.Abilities[abilityIndex].Offensive.Amount; Assert.AreEqual(monster.MaxHitPoints - (2 * hitAmount), monster.HitPoints); Assert.AreEqual(player.MaxComboPoints - (2 * comboCost), player.ComboPoints); string attackString = $"Your double shot hit the {monster.Name} for 25 physical damage."; Assert.AreEqual(attackString, OutputHelper.Display.Output[5][2]); Assert.AreEqual(attackString, OutputHelper.Display.Output[6][2]); player.MaxComboPoints = 25; player.ComboPoints = player.MaxComboPoints; monster.MaxHitPoints = 100; monster.HitPoints = monster.MaxHitPoints; arrowCount = player.PlayerQuiver.Quantity; player.UseAbility(monster, input); Assert.AreEqual(arrowCount - 1, player.PlayerQuiver.Quantity); Assert.AreEqual(player.MaxComboPoints - comboCost, player.ComboPoints); Assert.AreEqual(attackString, OutputHelper.Display.Output[7][2]); const string outOfComboString = "You didn't have enough combo points for the second shot!"; Assert.AreEqual(outOfComboString, OutputHelper.Display.Output[8][2]); }
public void PlayerResistanceUnitTest() { Player player = new Player("test", PlayerClassType.Mage) { MaxManaPoints = 100, ManaPoints = 100 }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); Monster monster = new Monster(3, MonsterType.Elemental); while (monster.ElementalCategory != ElementalType.Air) { monster = new Monster(3, MonsterType.Elemental); } MonsterBuilder.BuildMonster(monster); foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped)) { IEquipment eItem = item as IEquipment; eItem.Equipped = false; } Assert.AreEqual(player.Level * 5, player.FireResistance); Assert.AreEqual(player.Level * 5, player.FrostResistance); Assert.AreEqual(player.Level * 5, player.ArcaneResistance); int arcaneResistance = player.ArcaneResistance; double resistanceMod = (100 - arcaneResistance) / 100.0; int spellIndex = monster.Spellbook.FindIndex( f => f.SpellCategory == SpellType.Lightning); monster.Spellbook[spellIndex].CastArcaneOffense(monster, player, spellIndex); int reducedDamage = (int)(monster.Spellbook[spellIndex].Offensive.Amount * resistanceMod); Assert.AreEqual(player.HitPoints, player.MaxHitPoints - reducedDamage); }
public void HealSpellUnitTest() { Player player = new Player("test", PlayerClassType.Mage) { MaxManaPoints = 100, ManaPoints = 100, MaxHitPoints = 100, HitPoints = 50 }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); string[] inputInfo = new[] { "spell", "heal" }; int spellIndex = player.Spellbook.FindIndex( f => f.SpellCategory == SpellType.Heal); PlayerHelper.SpellInfo(player, inputInfo); Assert.AreEqual("Heal", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Mana Cost: 25", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Heal Amount: 50", OutputHelper.Display.Output[3][2]); string[] input = new[] { "cast", "heal" }; string spellName = InputHelper.ParseInput(input); Assert.AreEqual("heal", spellName); player.CastSpell(spellName); Assert.AreEqual(player.MaxManaPoints - player.Spellbook[spellIndex].ManaCost, player.ManaPoints); string healString = $"You heal yourself for {player.Spellbook[spellIndex].Healing.HealAmount} health."; Assert.AreEqual(healString, OutputHelper.Display.Output[4][2]); Assert.AreEqual(player.MaxHitPoints, player.HitPoints); }
public int ArmorRating(Monster opponent) { int totalArmorRating = GearHelper.CheckArmorRating(this); int levelDiff = opponent.Level - Level; double armorMultiplier = 1.00 + (-(double)levelDiff / 5); double adjArmorRating = totalArmorRating * armorMultiplier; return((int)adjArmorRating); }
public void PlayerQuiverIsFullUnitTest() { GearHelper.EquipInitialGear(_player); _arrows.LoadPlayerQuiverWithArrows(_player); Assert.AreEqual(_player.PlayerQuiver.Quantity, _player.PlayerQuiver.MaxQuantity); Assert.AreEqual(_arrowsMaxQuantity, _arrows.Quantity); }
public void FireballSpellUnitTest() { Player player = new Player("test", PlayerClassType.Mage) { MaxManaPoints = 100, ManaPoints = 100, InCombat = true }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); Monster monster = new Monster(3, MonsterType.Demon) { HitPoints = 50, MaxHitPoints = 100, FireResistance = 0 }; MonsterBuilder.BuildMonster(monster); player.PlayerWeapon.CritMultiplier = 1; // Remove crit chance to remove "noise" in test string[] inputInfo = new[] { "spell", "fireball" }; int spellIndex = player.Spellbook.FindIndex( f => f.SpellCategory == SpellType.Fireball); PlayerHelper.SpellInfo(player, inputInfo); Assert.AreEqual("Fireball", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Mana Cost: 35", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Instant Damage: 25", OutputHelper.Display.Output[3][2]); Assert.AreEqual("Damage Over Time: 5", OutputHelper.Display.Output[4][2]); Assert.AreEqual("Fire damage over time will burn for 3 rounds.", OutputHelper.Display.Output[5][2]); OutputHelper.Display.ClearUserOutput(); string[] input = new[] { "cast", "fireball" }; string spellName = InputHelper.ParseInput(input); Assert.AreEqual("fireball", spellName); player.CastSpell(monster, spellName); Assert.AreEqual(player.MaxManaPoints - player.Spellbook[spellIndex].ManaCost, player.ManaPoints); Assert.AreEqual(25, monster.HitPoints); Assert.AreEqual(3, monster.Effects[0].MaxRound); Assert.AreEqual($"You hit the {monster.Name} for {player.Spellbook[spellIndex].Offensive.Amount} fire damage.", OutputHelper.Display.Output[0][2]); Assert.AreEqual($"The {monster.Name} bursts into flame!", OutputHelper.Display.Output[1][2]); BurningEffect burnEffect = monster.Effects[0] as BurningEffect; for (int i = 2; i < 5; i++) { burnEffect.ProcessRound(); Assert.AreEqual( $"The {monster.Name} burns for {burnEffect.FireDamageOverTime} fire damage.", OutputHelper.Display.Output[i][2]); Assert.AreEqual(i, monster.Effects[0].CurrentRound); GameHelper.RemovedExpiredEffectsAsync(monster); Thread.Sleep(1000); } Assert.AreEqual(false, monster.Effects.Any()); Assert.AreEqual(10, monster.HitPoints); }
public void CompleteQuest(Player player, string[] input) { string userInput = InputHelper.ParseInput(input); int questIndex = player.QuestLog.FindIndex( f => f.Name.ToLower().Contains(userInput)); Quest quest = player.QuestLog[questIndex]; if (questIndex != -1) { if (quest.QuestGiver == Name) { if (quest.QuestCompleted) { OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), "Congratulations on finishing " + quest.Name + "! Here's your reward."); player.Inventory.Add(quest.QuestRewardItem); OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), "You have received: "); GearHelper.StoreRainbowGearOutput(GearHelper.GetItemDetails(quest.QuestRewardItem)); player.Gold += quest.QuestRewardGold; OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), quest.QuestRewardGold + " gold coins."); player.QuestLog.RemoveAt(questIndex); } else { OutputHelper.Display.StoreUserOutput( Settings.FormatFailureOutputText(), Settings.FormatDefaultBackground(), "You haven't finished that quest yet!"); } } else { TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; OutputHelper.Display.StoreUserOutput( Settings.FormatFailureOutputText(), Settings.FormatDefaultBackground(), "I didn't give you that quest. " + textInfo.ToTitleCase(quest.QuestGiver) + " did."); } } else { OutputHelper.Display.StoreUserOutput( Settings.FormatFailureOutputText(), Settings.FormatDefaultBackground(), "What quest did you want to turn in?"); } }
public void WeaponUpgradeKitUnitTest() { Player player = new Player("test", PlayerClassType.Mage); player.Inventory.Add(new WeaponKit(KitLevel.Light, WeaponKit.WeaponKitType.Grindstone)); GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); int weaponIndex = player.Inventory.FindIndex(f => f.Name.Contains("dagger")); Weapon weapon = player.Inventory[weaponIndex] as Weapon; TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; string weaponName = textInfo.ToTitleCase(player.Inventory[weaponIndex].Name); WeaponKit weaponKit = player.Inventory.Find(item => item is WeaponKit) as WeaponKit; int kitAmount = weaponKit.KitAugmentAmount; string kitName = weaponKit.Name; string[] input = new[] { "enhance", "doesn't exist", kitName }; int weaponAmount = weapon.RegDamage; GearHelper.UseWeaponKit(player, input); const string upgradeFail = "What weapon did you want to upgrade?"; Assert.AreEqual(upgradeFail, OutputHelper.Display.Output[0][2]); Assert.IsNotEmpty(player.Inventory); input = new[] { "enhance", weaponName, "doesn't exist" }; GearHelper.UseWeaponKit(player, input); const string kitFail = "What weapon kit did you want to use?"; Assert.AreEqual(kitFail, OutputHelper.Display.Output[1][2]); Assert.IsNotEmpty(player.Inventory); input = new[] { "enhance", weaponName, kitName }; GearHelper.UseWeaponKit(player, input); string upgradeSuccess = $"You upgraded {weaponName} with a weapon kit."; Assert.AreEqual(upgradeSuccess, OutputHelper.Display.Output[2][2]); Assert.AreEqual(weaponAmount + kitAmount, weapon.RegDamage); Assert.AreEqual(0, player.Inventory.FindAll(item => item is IKit).Count); player.Inventory.Add(new WeaponKit(KitLevel.Light, WeaponKit.WeaponKitType.Bowstring)); weaponKit = player.Inventory.Find(item => item is WeaponKit) as WeaponKit; kitName = weaponKit.Name; input = new[] { "enhance", weaponName, kitName }; GearHelper.UseWeaponKit(player, input); string enhanceFail = $"You can't upgrade {weaponName} with that!"; Assert.IsNotEmpty(player.Inventory); Assert.AreEqual(enhanceFail, OutputHelper.Display.Output[3][2]); player.Inventory.Add(new Weapon(1, WeaponType.Bow)); weapon = player.Inventory.Find(item => item is Weapon && item.Name.ToLower().Contains("bow")) as Weapon; weapon.Equipped = true; weaponName = textInfo.ToTitleCase(weapon.Name); input = new[] { "enhance", weaponName, kitName }; GearHelper.UseWeaponKit(player, input); upgradeSuccess = $"You upgraded {weaponName} with a weapon kit."; Assert.AreEqual(0, player.Inventory.FindAll(item => item is IKit).Count); Assert.AreEqual(upgradeSuccess, OutputHelper.Display.Output[4][2]); }
public void PlayerQuiverIsPartiallyEmptyUnitTest() { GearHelper.EquipInitialGear(_player); _player.PlayerQuiver.MaxQuantity = _arrowsMaxQuantity; _player.PlayerQuiver.Quantity = 35; int arrowsToLoad = _player.PlayerQuiver.MaxQuantity - _player.PlayerQuiver.Quantity; _arrows.LoadPlayerQuiverWithArrows(_player); Assert.AreEqual(_player.PlayerQuiver.Quantity, _player.PlayerQuiver.MaxQuantity); Assert.AreEqual(_arrowsMaxQuantity - arrowsToLoad, _arrows.Quantity); }
public void Attack(Player player) { AttackOption attackOption = DetermineAttack(player, true); switch (attackOption.AttackCategory) { case AttackType.Physical: PhysicalAttack(player); break; case AttackType.Spell: switch (Spellbook[attackOption.AttackIndex].SpellCategory) { case SpellType.Fireball: Spellbook[attackOption.AttackIndex].CastFireOffense(this, player, attackOption.AttackIndex); break; case SpellType.Frostbolt: Spellbook[attackOption.AttackIndex].CastFrostOffense(this, player, attackOption.AttackIndex); break; case SpellType.Lightning: Spellbook[attackOption.AttackIndex].CastArcaneOffense(this, player, attackOption.AttackIndex); break; default: throw new ArgumentOutOfRangeException(); } break; case AttackType.Ability: switch (Abilities[attackOption.AttackIndex].AbilityCategory) { case Ability.PoisonBite: case Ability.TailWhip: Abilities[attackOption.AttackIndex].UseOffenseDamageAbility(this, player, attackOption.AttackIndex); break; case Ability.BloodLeech: Abilities[attackOption.AttackIndex].UseBloodLeechAbility(this, player, attackOption.AttackIndex); break; default: throw new ArgumentOutOfRangeException(); } break; default: throw new ArgumentOutOfRangeException(); } GearHelper.DecreaseArmorDurability(player); }
public void RejuvenateSpellUnitTest() { Player player = new Player("test", PlayerClassType.Mage) { MaxManaPoints = 100, ManaPoints = 100, MaxHitPoints = 100, HitPoints = 50 }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); string[] inputInfo = new[] { "spell", "rejuvenate" }; int spellIndex = player.Spellbook.FindIndex( f => f.SpellCategory == SpellType.Rejuvenate); PlayerHelper.SpellInfo(player, inputInfo); Assert.AreEqual("Rejuvenate", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Mana Cost: 25", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Heal Amount: 20", OutputHelper.Display.Output[3][2]); Assert.AreEqual("Heal Over Time: 10", OutputHelper.Display.Output[4][2]); string healInfoString = $"Heal over time will restore health for {player.Spellbook[spellIndex].Healing.HealMaxRounds} rounds."; Assert.AreEqual(healInfoString, OutputHelper.Display.Output[5][2]); OutputHelper.Display.ClearUserOutput(); string[] input = new[] { "cast", "rejuvenate" }; string spellName = InputHelper.ParseInput(input); Assert.AreEqual("rejuvenate", spellName); player.CastSpell(spellName); Assert.AreEqual(player.MaxManaPoints - player.Spellbook[spellIndex].ManaCost, player.ManaPoints); Assert.AreEqual(70, player.HitPoints); string healString = $"You heal yourself for {player.Spellbook[spellIndex].Healing.HealAmount} health."; Assert.AreEqual(healString, OutputHelper.Display.Output[0][2]); Assert.AreEqual(true, player.Effects[0] is HealingEffect); HealingEffect healEffect = player.Effects[0] as HealingEffect; for (int i = 2; i < 5; i++) { healEffect.ProcessRound(); string healAmtString = $"You have been healed for {healEffect.HealOverTimeAmount} health."; Assert.AreEqual(i, player.Effects[0].CurrentRound); Assert.AreEqual(healAmtString, OutputHelper.Display.Output[i - 1][2]); Assert.AreEqual(70 + ((i - 1) * healEffect.HealOverTimeAmount), player.HitPoints); } GameHelper.RemovedExpiredEffectsAsync(player); Thread.Sleep(1000); Assert.AreEqual(false, player.Effects.Any()); }
public void DiamondskinSpellUnitTest() { Player player = new Player("test", PlayerClassType.Mage) { MaxManaPoints = 100, ManaPoints = 100 }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); string[] inputInfo = new[] { "spell", "diamondskin" }; int spellIndex = player.Spellbook.FindIndex( f => f.SpellCategory == SpellType.Diamondskin); PlayerHelper.SpellInfo(player, inputInfo); Assert.AreEqual("Diamondskin", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Mana Cost: 25", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Augment Armor Amount: 25", OutputHelper.Display.Output[3][2]); string augmentInfoString = $"Armor will be augmented for {player.Spellbook[spellIndex].ChangeAmount.ChangeMaxRound} rounds."; Assert.AreEqual(augmentInfoString, OutputHelper.Display.Output[4][2]); string[] input = new[] { "cast", "diamondskin" }; string spellName = InputHelper.ParseInput(input); Assert.AreEqual("diamondskin", spellName); int baseArmor = GearHelper.CheckArmorRating(player); player.InCombat = true; player.CastSpell(spellName); Assert.AreEqual(player.MaxManaPoints - player.Spellbook[spellIndex].ManaCost, player.ManaPoints); string augmentString = $"You augmented your armor by {player.Spellbook[spellIndex].ChangeAmount.Amount} with {player.Spellbook[spellIndex].Name}."; Assert.AreEqual(augmentString, OutputHelper.Display.Output[5][2]); OutputHelper.Display.ClearUserOutput(); Assert.AreEqual(true, player.Effects.Any()); Assert.AreEqual(true, player.Effects[0] is ChangeArmorEffect); ChangeArmorEffect changeArmorEffect = player.Effects[0] as ChangeArmorEffect; for (int i = 2; i < 5; i++) { int augmentedArmor = GearHelper.CheckArmorRating(player); Assert.AreEqual(baseArmor + 25, augmentedArmor); changeArmorEffect.ProcessChangeArmorRound(); string augmentRoundString = $"Your armor is increased by {changeArmorEffect.ChangeArmorAmount}."; Assert.AreEqual(augmentRoundString, OutputHelper.Display.Output[i - 2][2]); } GameHelper.RemovedExpiredEffectsAsync(player); Thread.Sleep(1000); Assert.AreEqual(false, player.Effects.Any()); }
public void DisarmAbilityUnitTest() { Player player = new Player("test", PlayerClassType.Warrior) { MaxRagePoints = 100, RagePoints = 100, MaxHitPoints = 100, HitPoints = 100 }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); Monster monster = new Monster(3, MonsterType.Demon) { HitPoints = 100, MaxHitPoints = 100 }; MonsterBuilder.BuildMonster(monster); int abilityIndex = player.Abilities.FindIndex( f => f.WarAbilityCategory == WarriorAbility.Disarm); string[] inputInfo = new[] { "ability", "disarm" }; PlayerHelper.AbilityInfo(player, inputInfo); Assert.AreEqual("Disarm", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Rage Cost: 25", OutputHelper.Display.Output[2][2]); string abilityString = $"{player.Abilities[abilityIndex].Offensive.Amount}% chance to disarm opponent's weapon."; Assert.AreEqual(abilityString, OutputHelper.Display.Output[3][2]); player.Abilities[abilityIndex].Offensive.Amount = 0; // Set disarm success chance to 0% for test string[] input = new[] { "use", "disarm" }; string abilityName = InputHelper.ParseInput(input); Assert.AreEqual("disarm", abilityName); player.UseAbility(monster, input); int?rageCost = player.Abilities[abilityIndex].RageCost; Assert.AreEqual(player.MaxRagePoints - rageCost, player.RagePoints); Assert.AreEqual(true, monster.MonsterWeapon.Equipped); string disarmFailString = $"You tried to disarm {monster.Name} but failed!"; Assert.AreEqual(disarmFailString, OutputHelper.Display.Output[4][2]); player.Abilities[abilityIndex].Offensive.Amount = 100; // Set disarm success chance to 100% for test player.UseAbility(monster, input); Assert.AreEqual(player.MaxRagePoints - (rageCost * 2), player.RagePoints); Assert.AreEqual(false, monster.MonsterWeapon.Equipped); string disarmSuccessString = $"You successfully disarmed {monster.Name}!"; Assert.AreEqual(disarmSuccessString, OutputHelper.Display.Output[5][2]); }
public void PreciseShotAbilityUnitTest() { Player player = new Player("test", PlayerClassType.Archer) { MaxComboPoints = 100, ComboPoints = 100, MaxHitPoints = 100, HitPoints = 10 }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); Monster monster = new Monster(3, MonsterType.Demon) { HitPoints = 100, MaxHitPoints = 100 }; MonsterBuilder.BuildMonster(monster); foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped)) { IEquipment eItem = item as IEquipment; eItem.Equipped = false; } string[] inputInfo = new[] { "ability", "precise" }; int abilityIndex = player.Abilities.FindIndex( f => f.ArcAbilityCategory == ArcherAbility.Precise); PlayerHelper.AbilityInfo(player, inputInfo); Assert.AreEqual("Precise Shot", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Combo Cost: 40", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Instant Damage: 50", OutputHelper.Display.Output[3][2]); string[] input = new[] { "use", "precise" }; string abilityName = InputHelper.ParseInput(input); Assert.AreEqual("precise", abilityName); int arrowCount = player.PlayerQuiver.Quantity; player.UseAbility(monster, input); Assert.AreEqual(arrowCount - 1, player.PlayerQuiver.Quantity); int?comboCost = player.Abilities[abilityIndex].ComboCost; Assert.AreEqual(player.MaxComboPoints - comboCost, player.ComboPoints); int abilityDamage = player.Abilities[abilityIndex].Offensive.Amount; Assert.AreEqual(monster.HitPoints, monster.MaxHitPoints - abilityDamage); string abilitySuccessString = $"Your {player.Abilities[abilityIndex].Name} hit the {monster.Name} for {abilityDamage} physical damage."; Assert.AreEqual(abilitySuccessString, OutputHelper.Display.Output[4][2]); }
public void AmbushAbilityUnitTest() { Player player = new Player("test", PlayerClassType.Archer) { MaxComboPoints = 100, ComboPoints = 100, MaxHitPoints = 100, HitPoints = 10 }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); Monster monster = new Monster(3, MonsterType.Demon) { HitPoints = 100, MaxHitPoints = 100 }; MonsterBuilder.BuildMonster(monster); player.Abilities.Add(new PlayerAbility( "ambush", 75, 1, ArcherAbility.Ambush, 4)); string[] inputInfo = new[] { "ability", "ambush" }; PlayerHelper.AbilityInfo(player, inputInfo); Assert.AreEqual("Ambush", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Combo Cost: 75", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Instant Damage: 50", OutputHelper.Display.Output[3][2]); Assert.AreEqual("A surprise attack is launched, which initiates combat.", OutputHelper.Display.Output[4][2]); string[] input = new[] { "use", "ambush", monster.Name }; player.InCombat = true; int arrowCount = player.PlayerQuiver.Quantity; player.UseAbility(monster, input); Assert.AreEqual($"You can't ambush {monster.Name}, you're already in combat!", OutputHelper.Display.Output[5][2]); player.InCombat = false; player.UseAbility(monster, input); int index = player.Abilities.FindIndex( f => f.ArcAbilityCategory == ArcherAbility.Ambush); int abilityDamage = player.Abilities[index].Offensive.Amount; string attackString = "Your ambush hit the " + monster.Name + " for " + abilityDamage + " physical damage."; Assert.AreEqual(arrowCount - 1, player.PlayerQuiver.Quantity); Assert.AreEqual(attackString, OutputHelper.Display.Output[6][2]); Assert.AreEqual(monster.HitPoints, monster.MaxHitPoints - abilityDamage); }
public void ArmorUpgradeKitUnitTest() { Player player = new Player("test", PlayerClassType.Mage); player.Inventory.Add(new ArmorKit(KitLevel.Light, ArmorKit.ArmorKitType.Cloth)); GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); int armorIndex = player.Inventory.FindIndex(f => f.Name.Contains("cloth")); Armor armor = player.Inventory[armorIndex] as Armor; TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; string armorName = textInfo.ToTitleCase(player.Inventory[armorIndex].Name); ArmorKit armorKit = player.Inventory.Find(item => item is ArmorKit) as ArmorKit; int kitAmount = armorKit.KitAugmentAmount; string kitName = armorKit.Name; string[] input = new[] { "enhance", "doesn't exist", kitName }; int armorAmount = armor.ArmorRating; GearHelper.UseArmorKit(player, input); const string upgradeFail = "What armor did you want to upgrade?"; Assert.AreEqual(upgradeFail, OutputHelper.Display.Output[0][2]); Assert.IsNotEmpty(player.Inventory); input = new[] { "enhance", armorName, "doesn't exist" }; GearHelper.UseArmorKit(player, input); const string kitFail = "What armor kit did you want to use?"; Assert.AreEqual(kitFail, OutputHelper.Display.Output[1][2]); Assert.IsNotEmpty(player.Inventory); input = new[] { "enhance", armorName, kitName }; GearHelper.UseArmorKit(player, input); string upgradeSuccess = $"You upgraded {armorName} with an armor kit."; Assert.AreEqual(upgradeSuccess, OutputHelper.Display.Output[2][2]); Assert.AreEqual(armorAmount + kitAmount, armor.ArmorRating); Assert.AreEqual(0, player.Inventory.FindAll(item => item is IKit).Count); player.Inventory.Add(new ArmorKit(KitLevel.Light, ArmorKit.ArmorKitType.Leather)); kitName = player.Inventory.Find(item => item is ArmorKit).Name; input = new[] { "enhance", armorName, kitName }; GearHelper.UseArmorKit(player, input); string enhanceFail = $"You can't upgrade {armorName} with that!"; Assert.IsNotEmpty(player.Inventory); Assert.AreEqual(enhanceFail, OutputHelper.Display.Output[3][2]); }
public void LightningSpellUnitTest() { Player player = new Player("test", PlayerClassType.Mage) { MaxManaPoints = 100, ManaPoints = 100 }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); Monster monster = new Monster(3, MonsterType.Demon) { HitPoints = 100, MaxHitPoints = 100, ArcaneResistance = 0 }; MonsterBuilder.BuildMonster(monster); foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped)) { IEquipment eItem = item as IEquipment; eItem.Equipped = false; } string[] inputInfo = new[] { "spell", "lightning" }; int spellIndex = player.Spellbook.FindIndex( f => f.SpellCategory == SpellType.Lightning); PlayerHelper.SpellInfo(player, inputInfo); Assert.AreEqual("Lightning", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Mana Cost: 25", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Instant Damage: 35", OutputHelper.Display.Output[3][2]); string[] input = new[] { "cast", "lightning" }; string spellName = InputHelper.ParseInput(input); Assert.AreEqual("lightning", spellName); player.PlayerWeapon.Durability = 100; player.CastSpell(monster, spellName); Assert.AreEqual(player.MaxManaPoints - player.Spellbook[spellIndex].ManaCost, player.ManaPoints); int arcaneSpellDamage = player.Spellbook[spellIndex].Offensive.Amount; Assert.AreEqual(monster.HitPoints, monster.MaxHitPoints - arcaneSpellDamage); string attackSuccessString = $"You hit the {monster.Name} for {arcaneSpellDamage} arcane damage."; Assert.AreEqual(attackSuccessString, OutputHelper.Display.Output[4][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 SaveLoadGameUnitTest() { Player player = new Player("placeholder", PlayerClassType.Mage); GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); RoomHelper.Rooms = new Dictionary <Coordinate, IRoom> { { new Coordinate(1, 1, 1), new DungeonRoom(1, 1) } }; player.CanSave = true; GameHelper.SaveGame(player); Assert.AreEqual("Your game has been saved.", OutputHelper.Display.Output[0][2]); OutputHelper.Display.ClearUserOutput(); RoomHelper.Rooms = null; GameHelper.LoadGame(); player = GameHelper.LoadPlayer(); Assert.AreEqual("placeholder", player.Name); Assert.NotNull(RoomHelper.Rooms); Assert.AreEqual("Reloading your saved game.", OutputHelper.Display.Output[1][2]); }
public void MonsterResistanceUnitTest() { Player player = new Player("test", PlayerClassType.Mage) { MaxManaPoints = 100, ManaPoints = 100 }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); Monster monster = new Monster(3, MonsterType.Demon) { HitPoints = 100, MaxHitPoints = 100 }; MonsterBuilder.BuildMonster(monster); foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped)) { IEquipment eItem = item as IEquipment; eItem.Equipped = false; } Assert.AreEqual(monster.Level * 5, monster.FireResistance); Assert.AreEqual(monster.Level * 5, monster.FrostResistance); Assert.AreEqual(monster.Level * 5, monster.ArcaneResistance); int arcaneResistance = monster.ArcaneResistance; double resistanceMod = (100 - arcaneResistance) / 100.0; string[] input = new[] { "cast", "lightning" }; int spellIndex = player.Spellbook.FindIndex( f => f.SpellCategory == SpellType.Lightning); string spellName = InputHelper.ParseInput(input); player.CastSpell(monster, spellName); int reducedDamage = (int)(player.Spellbook[spellIndex].Offensive.Amount * resistanceMod); Assert.AreEqual(monster.HitPoints, monster.MaxHitPoints - reducedDamage); }
public void FrostboltSpellUnitTest() { Player player = new Player("test", PlayerClassType.Mage) { MaxManaPoints = 100, ManaPoints = 100 }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); Monster monster = new Monster(3, MonsterType.Demon) { HitPoints = 100, MaxHitPoints = 100, FrostResistance = 0 }; MonsterBuilder.BuildMonster(monster); foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped)) { IEquipment eItem = item as IEquipment; eItem.Equipped = false; } string[] inputInfo = new[] { "spell", "frostbolt" }; int spellIndex = player.Spellbook.FindIndex( f => f.SpellCategory == SpellType.Frostbolt); PlayerHelper.SpellInfo(player, inputInfo); Assert.AreEqual("Frostbolt", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Mana Cost: 25", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Instant Damage: 15", OutputHelper.Display.Output[3][2]); Assert.AreEqual("Frost damage will freeze opponent for 2 rounds.", OutputHelper.Display.Output[4][2]); Assert.AreEqual("Frozen opponents take 1.5x physical, arcane and frost damage.", OutputHelper.Display.Output[5][2]); OutputHelper.Display.ClearUserOutput(); string[] input = new[] { "cast", "frostbolt" }; string spellName = InputHelper.ParseInput(input); Assert.AreEqual("frostbolt", spellName); player.PlayerWeapon.Durability = 100; double baseDamage = player.PhysicalAttack(monster); player.CastSpell(monster, spellName); Assert.AreEqual(player.MaxManaPoints - player.Spellbook[spellIndex].ManaCost, player.ManaPoints); Assert.AreEqual(85, monster.HitPoints); Assert.AreEqual(1, monster.Effects[0].CurrentRound); Assert.AreEqual(2, monster.Effects[0].MaxRound); string attackString = $"You hit the {monster.Name} for {player.Spellbook[spellIndex].Offensive.Amount} frost damage."; Assert.AreEqual(attackString, OutputHelper.Display.Output[0][2]); string frozenString = $"The {monster.Name} is frozen. Physical, frost and arcane damage to it will be increased by 50%!"; Assert.AreEqual(frozenString, OutputHelper.Display.Output[1][2]); FrozenEffect frozenEffect = monster.Effects[0] as FrozenEffect; int monsterHitPointsBefore = monster.HitPoints; double totalBaseDamage = 0.0; double totalFrozenDamage = 0.0; double multiplier = frozenEffect.EffectMultiplier; for (int i = 2; i < 4; i++) { frozenEffect.ProcessRound(); Assert.AreEqual(i, monster.Effects[0].CurrentRound); Assert.AreEqual(frozenString, OutputHelper.Display.Output[i][2]); player.PlayerWeapon.Durability = 100; double frozenDamage = player.PhysicalAttack(monster); monster.HitPoints -= (int)frozenDamage; totalBaseDamage += baseDamage; totalFrozenDamage += frozenDamage; } GameHelper.RemovedExpiredEffectsAsync(monster); Thread.Sleep(1000); Assert.AreEqual(false, monster.Effects.Any()); int finalBaseDamageWithMod = (int)(totalBaseDamage * multiplier); int finalTotalFrozenDamage = (int)totalFrozenDamage; Assert.AreEqual(finalTotalFrozenDamage, finalBaseDamageWithMod, 14); Assert.AreEqual(monster.HitPoints, monsterHitPointsBefore - (int)totalFrozenDamage); }
public void StunShotAbilityUnitTest() { Player player = new Player("test", PlayerClassType.Archer) { MaxComboPoints = 100, ComboPoints = 100, MaxHitPoints = 100, HitPoints = 10 }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); Monster monster = new Monster(3, MonsterType.Demon) { HitPoints = 100, MaxHitPoints = 100, InCombat = true }; MonsterBuilder.BuildMonster(monster); foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped)) { IEquipment eItem = item as IEquipment; eItem.Equipped = false; } int abilityIndex = player.Abilities.FindIndex( f => f.ArcAbilityCategory == ArcherAbility.Stun); string[] inputInfo = new[] { "ability", "stun" }; PlayerHelper.AbilityInfo(player, inputInfo); Assert.AreEqual("Stun Shot", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Combo Cost: 25", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Instant Damage: 15", OutputHelper.Display.Output[3][2]); string abilityInfoString = $"Stuns opponent for {player.Abilities[abilityIndex].Stun.StunMaxRounds} rounds, preventing their attacks."; Assert.AreEqual(abilityInfoString, OutputHelper.Display.Output[4][2]); string[] input = new[] { "use", "stun" }; string abilityName = InputHelper.ParseInput(input); Assert.AreEqual("stun", abilityName); int arrowCount = player.PlayerQuiver.Quantity; player.UseAbility(monster, input); Assert.AreEqual(arrowCount - 1, player.PlayerQuiver.Quantity); int?comboCost = player.Abilities[abilityIndex].ComboCost; Assert.AreEqual(player.MaxComboPoints - comboCost, player.ComboPoints); int abilityDamage = player.Abilities[abilityIndex].Stun.DamageAmount; int abilityCurRounds = player.Abilities[abilityIndex].Stun.StunCurRounds; int abilityMaxRounds = player.Abilities[abilityIndex].Stun.StunMaxRounds; string attackSuccessString = $"You {player.Abilities[abilityIndex].Name} the {monster.Name} for {abilityDamage} physical damage."; Assert.AreEqual(attackSuccessString, OutputHelper.Display.Output[5][2]); string stunString = $"The {monster.Name} is stunned!"; Assert.AreEqual(stunString, OutputHelper.Display.Output[6][2]); Assert.AreEqual(monster.MaxHitPoints - abilityDamage, monster.HitPoints); Assert.AreEqual(true, monster.Effects[0] is StunnedEffect); Assert.AreEqual(abilityCurRounds, monster.Effects[0].CurrentRound); Assert.AreEqual(abilityMaxRounds, monster.Effects[0].MaxRound); OutputHelper.Display.ClearUserOutput(); for (int i = 2; i < 5; i++) { StunnedEffect stunnedEffect = monster.Effects[0] as StunnedEffect; stunnedEffect.ProcessRound(); string stunnedString = $"The {monster.Name} is stunned and cannot attack."; Assert.AreEqual(stunnedString, OutputHelper.Display.Output[i - 2][2]); Assert.AreEqual(i, monster.Effects[0].CurrentRound); GameHelper.RemovedExpiredEffectsAsync(monster); Thread.Sleep(1000); } Assert.AreEqual(false, monster.Effects.Any()); }
public void ImmolatingArrowAbilityUnitTest() { Player player = new Player("test", PlayerClassType.Archer) { MaxComboPoints = 100, ComboPoints = 100, MaxHitPoints = 100, HitPoints = 10, InCombat = true }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); Monster monster = new Monster(3, MonsterType.Demon) { HitPoints = 100, MaxHitPoints = 100, InCombat = true, FireResistance = 0 }; MonsterBuilder.BuildMonster(monster); player.PlayerWeapon.CritMultiplier = 1; // Remove crit chance to remove "noise" in test player.Abilities.Add(new PlayerAbility( "immolating arrow", 35, 1, ArcherAbility.ImmolatingArrow, 8)); string[] input = new[] { "use", "immolating", "arrow" }; PlayerHelper.AbilityInfo(player, input); Assert.AreEqual("Immolating Arrow", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Combo Cost: 35", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Instant Damage: 25", OutputHelper.Display.Output[3][2]); Assert.AreEqual("Damage Over Time: 5", OutputHelper.Display.Output[4][2]); Assert.AreEqual("Fire damage over time for 3 rounds.", OutputHelper.Display.Output[5][2]); int arrowCount = player.PlayerQuiver.Quantity; player.UseAbility(monster, input); Assert.AreEqual(arrowCount - 1, player.PlayerQuiver.Quantity); int index = player.Abilities.FindIndex( f => f.ArcAbilityCategory == ArcherAbility.ImmolatingArrow); Assert.AreEqual(player.ComboPoints, player.MaxComboPoints - player.Abilities[index].ComboCost); string attackString = $"Your immolating arrow hit the {monster.Name} for 25 physical damage."; Assert.AreEqual(attackString, OutputHelper.Display.Output[6][2]); Assert.AreEqual(monster.HitPoints, monster.MaxHitPoints - player.Abilities[index].Offensive.Amount); OutputHelper.Display.ClearUserOutput(); Assert.AreEqual(true, monster.Effects[0] is BurningEffect); Assert.AreEqual(3, monster.Effects[0].MaxRound); BurningEffect burnEffect = monster.Effects[0] as BurningEffect; for (int i = 0; i < 3; i++) { int baseHitPoints = monster.HitPoints; burnEffect.ProcessRound(); Assert.AreEqual(i + 2, monster.Effects[0].CurrentRound); Assert.AreEqual(monster.HitPoints, baseHitPoints - burnEffect.FireDamageOverTime); string burnString = $"The {monster.Name} burns for {burnEffect.FireDamageOverTime} fire damage."; Assert.AreEqual(burnString, OutputHelper.Display.Output[i][2]); GameHelper.RemovedExpiredEffectsAsync(monster); Thread.Sleep(1000); } Assert.AreEqual(false, monster.Effects.Any()); }
public void BandageAbilityUnitTest() { Player player = new Player("test", PlayerClassType.Warrior) { MaxRagePoints = 100, RagePoints = 100, MaxHitPoints = 100, HitPoints = 10 }; GearHelper.EquipInitialGear(player); player.Abilities.Add(new PlayerAbility( "bandage", 25, 1, WarriorAbility.Bandage, 2)); OutputHelper.Display.ClearUserOutput(); int abilityIndex = player.Abilities.FindIndex( f => f.WarAbilityCategory == WarriorAbility.Bandage); string[] inputInfo = new[] { "ability", "bandage" }; PlayerHelper.AbilityInfo(player, inputInfo); Assert.AreEqual("Bandage", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Rage Cost: 25", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Heal Amount: 25", OutputHelper.Display.Output[3][2]); Assert.AreEqual("Heal Over Time: 5", OutputHelper.Display.Output[4][2]); string healInfoStringCombat = $"Heal over time will restore health for {player.Abilities[abilityIndex].Healing.HealMaxRounds} rounds in combat."; Assert.AreEqual(healInfoStringCombat, OutputHelper.Display.Output[5][2]); string healInfoStringNonCombat = $"Heal over time will restore health {player.Abilities[abilityIndex].Healing.HealMaxRounds} times every 10 seconds."; Assert.AreEqual(healInfoStringNonCombat, OutputHelper.Display.Output[6][2]); string[] input = new[] { "use", "bandage" }; string abilityName = InputHelper.ParseInput(input); Assert.AreEqual("bandage", abilityName); int baseHitPoints = player.HitPoints; player.UseAbility(input); int?rageCost = player.Abilities[abilityIndex].RageCost; Assert.AreEqual(player.MaxRagePoints - rageCost, player.RagePoints); int healAmount = player.Abilities[abilityIndex].Healing.HealAmount; string healString = $"You heal yourself for {healAmount} health."; Assert.AreEqual(healString, OutputHelper.Display.Output[7][2]); Assert.AreEqual(true, player.Effects[0] is HealingEffect); Assert.AreEqual(baseHitPoints + healAmount, player.HitPoints); baseHitPoints = player.HitPoints; HealingEffect healEffect = player.Effects[0] as HealingEffect; OutputHelper.Display.ClearUserOutput(); for (int i = 2; i < 5; i++) { healEffect.ProcessRound(); int healOverTimeAmt = healEffect.HealOverTimeAmount; string healAmtString = $"You have been healed for {healOverTimeAmt} health."; Assert.AreEqual(i, player.Effects[0].CurrentRound); Assert.AreEqual(healAmtString, OutputHelper.Display.Output[i - 2][2]); Assert.AreEqual(baseHitPoints + ((i - 1) * healOverTimeAmt), player.HitPoints); } GameHelper.RemovedExpiredEffectsAsync(player); Thread.Sleep(1000); Assert.AreEqual(false, player.Effects.Any()); }
public void GutShotAbilityUnitTest() { Player player = new Player("test", PlayerClassType.Archer) { MaxComboPoints = 100, ComboPoints = 100, MaxHitPoints = 100, HitPoints = 10 }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); Monster monster = new Monster(3, MonsterType.Demon) { HitPoints = 100, MaxHitPoints = 100 }; MonsterBuilder.BuildMonster(monster); foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped)) { IEquipment eItem = item as IEquipment; eItem.Equipped = false; } int abilityIndex = player.Abilities.FindIndex( f => f.ArcAbilityCategory == ArcherAbility.Gut); string[] inputInfo = new[] { "ability", "gut" }; PlayerHelper.AbilityInfo(player, inputInfo); Assert.AreEqual("Gut Shot", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Combo Cost: 25", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Instant Damage: 15", OutputHelper.Display.Output[3][2]); Assert.AreEqual("Damage Over Time: 5", OutputHelper.Display.Output[4][2]); string bleedOverTimeString = $"Bleeding damage over time for {player.Abilities[abilityIndex].Offensive.AmountMaxRounds} rounds."; Assert.AreEqual(bleedOverTimeString, OutputHelper.Display.Output[5][2]); string[] input = new[] { "use", "gut" }; string abilityName = InputHelper.ParseInput(input); Assert.AreEqual("gut", abilityName); int arrowCount = player.PlayerQuiver.Quantity; player.UseAbility(monster, input); Assert.AreEqual(arrowCount - 1, player.PlayerQuiver.Quantity); int?comboCost = player.Abilities[abilityIndex].ComboCost; Assert.AreEqual(player.MaxComboPoints - comboCost, player.ComboPoints); int abilityDamage = player.Abilities[abilityIndex].Offensive.Amount; int abilityDamageOverTime = player.Abilities[abilityIndex].Offensive.AmountOverTime; int abilityCurRounds = player.Abilities[abilityIndex].Offensive.AmountCurRounds; int abilityMaxRounds = player.Abilities[abilityIndex].Offensive.AmountMaxRounds; string abilitySuccessString = $"Your {player.Abilities[abilityIndex].Name} hit the {monster.Name} for {abilityDamage} physical damage."; Assert.AreEqual(abilitySuccessString, OutputHelper.Display.Output[6][2]); string bleedString = $"The {monster.Name} is bleeding!"; Assert.AreEqual(bleedString, OutputHelper.Display.Output[7][2]); Assert.AreEqual(true, monster.Effects[0] is BleedingEffect); Assert.AreEqual(monster.MaxHitPoints - abilityDamage, monster.HitPoints); Assert.AreEqual(abilityCurRounds, monster.Effects[0].CurrentRound); Assert.AreEqual(abilityMaxRounds, monster.Effects[0].MaxRound); OutputHelper.Display.ClearUserOutput(); for (int i = 2; i < 5; i++) { BleedingEffect bleedEffect = monster.Effects[0] as BleedingEffect; bleedEffect.ProcessRound(); int bleedAmount = bleedEffect.BleedDamageOverTime; string bleedRoundString = $"The {monster.Name} bleeds for {bleedAmount} physical damage."; Assert.AreEqual(bleedRoundString, OutputHelper.Display.Output[i - 2][2]); Assert.AreEqual(i, monster.Effects[0].CurrentRound); GameHelper.RemovedExpiredEffectsAsync(monster); Thread.Sleep(1000); } Assert.AreEqual(false, monster.Effects.Any()); Assert.AreEqual(monster.MaxHitPoints - abilityDamage - (abilityDamageOverTime * abilityMaxRounds), monster.HitPoints); }
public void ShowQuest() { OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), Name); StringBuilder questBorder = new StringBuilder(); for (int i = 0; i < Settings.GetGameWidth(); i++) { questBorder.Append("="); } OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), questBorder.ToString()); for (int i = 0; i < Dialogue.Length; i += Settings.GetGameWidth()) { if (Dialogue.Length - i < Settings.GetGameWidth()) { OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), Dialogue.Substring(i, Dialogue.Length - i)); continue; } OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), Dialogue.Substring(i, Settings.GetGameWidth())); } OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), questBorder.ToString()); switch (QuestCategory) { case QuestType.KillCount: OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), $"Required Kills: {RequiredKills}"); break; case QuestType.KillMonster: OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), $"Target _Monster: {MonsterKillType}"); OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), $"Required Kills: {RequiredKills}"); break; case QuestType.ClearLevel: OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), $"Clear _Level {TargetLevel}"); break; default: throw new ArgumentOutOfRangeException(); } OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), questBorder.ToString()); OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), "Rewards: "); GearHelper.StoreRainbowGearOutput(GearHelper.GetItemDetails(QuestRewardItem)); OutputHelper.Display.StoreUserOutput( Settings.FormatGeneralInfoText(), Settings.FormatDefaultBackground(), $"{QuestRewardGold} gold coins"); }
public void BerserkAbilityUnitTest() { Player player = new Player("test", PlayerClassType.Warrior) { MaxRagePoints = 100, RagePoints = 100, InCombat = true, MaxHitPoints = 100, HitPoints = 100, DodgeChance = 0 }; GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); Monster monster = new Monster(3, MonsterType.Demon) { HitPoints = 100, MaxHitPoints = 100, InCombat = true }; MonsterBuilder.BuildMonster(monster); foreach (IItem item in monster.MonsterItems.Where(item => item is IEquipment eItem && eItem.Equipped)) { IEquipment eItem = item as IEquipment; eItem.Equipped = false; } int abilityIndex = player.Abilities.FindIndex( f => f.WarAbilityCategory == WarriorAbility.Berserk); string[] inputInfo = new[] { "ability", "berserk" }; PlayerHelper.AbilityInfo(player, inputInfo); Assert.AreEqual("Berserk", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Rage Cost: 40", OutputHelper.Display.Output[2][2]); string dmgIncreaseString = $"Damage Increase: {player.Abilities[abilityIndex].Offensive.Amount}"; Assert.AreEqual(dmgIncreaseString, OutputHelper.Display.Output[3][2]); string armDecreaseString = $"Armor Decrease: {player.Abilities[abilityIndex].ChangeAmount.Amount}"; Assert.AreEqual(armDecreaseString, OutputHelper.Display.Output[4][2]); string dmgInfoString = $"Damage increased at cost of armor decrease for {player.Abilities[abilityIndex].ChangeAmount.ChangeMaxRound} rounds"; Assert.AreEqual(dmgInfoString, OutputHelper.Display.Output[5][2]); string[] input = new[] { "use", "berserk" }; string abilityName = InputHelper.ParseInput(input); Assert.AreEqual("berserk", abilityName); int baseArmorRating = GearHelper.CheckArmorRating(player); int baseDamage = player.PhysicalAttack(monster); player.UseAbility(monster, input); int?rageCost = player.Abilities[abilityIndex].RageCost; Assert.AreEqual(player.MaxRagePoints - rageCost, player.RagePoints); Assert.AreEqual(2, player.Effects.Count); Assert.AreEqual(true, player.Effects[0] is ChangePlayerDamageEffect); Assert.AreEqual(true, player.Effects[1] is ChangeArmorEffect); ChangePlayerDamageEffect changePlayerDmgEffect = player.Effects[0] as ChangePlayerDamageEffect; ChangeArmorEffect changeArmorEffect = player.Effects[1] as ChangeArmorEffect; const string berserkString = "You go into a berserk rage!"; Assert.AreEqual(berserkString, OutputHelper.Display.Output[6][2]); for (int i = 2; i < 6; i++) { OutputHelper.Display.ClearUserOutput(); int berserkArmorAmount = player.Abilities[abilityIndex].ChangeAmount.Amount; int berserkDamageAmount = player.Abilities[abilityIndex].Offensive.Amount; int berserkArmorRating = GearHelper.CheckArmorRating(player); int berserkDamage = player.PhysicalAttack(monster); Assert.AreEqual(berserkArmorRating, baseArmorRating + berserkArmorAmount); Assert.AreEqual(berserkDamage, baseDamage + berserkDamageAmount, 5); changePlayerDmgEffect.ProcessChangePlayerDamageRound(player); string changeDmgString = $"Your damage is increased by {berserkDamageAmount}."; Assert.AreEqual(changeDmgString, OutputHelper.Display.Output[0][2]); changeArmorEffect.ProcessChangeArmorRound(); string changeArmorString = $"Your armor is decreased by {berserkArmorAmount * -1}."; Assert.AreEqual(changeArmorString, OutputHelper.Display.Output[1][2]); GameHelper.RemovedExpiredEffectsAsync(player); Thread.Sleep(1000); } Assert.AreEqual(false, player.Effects.Any()); }
public void DistanceShotAbilityUnitTest() { Player player = new Player("test", PlayerClassType.Archer) { MaxComboPoints = 100, ComboPoints = 100, MaxHitPoints = 100, HitPoints = 10 }; RoomHelper.Rooms = new Dictionary <Coordinate, IRoom> { { new Coordinate(0, 0, 0), new DungeonRoom(1, 1) }, { new Coordinate(0, 1, 0), new DungeonRoom(1, 1) }, { new Coordinate(1, 0, 0), new DungeonRoom(1, 1) } }; Coordinate roomOneCoord = new Coordinate(0, 1, 0); Coordinate roomTwoCoord = new Coordinate(1, 0, 0); RoomHelper.Rooms[roomTwoCoord].Monster = null; RoomHelper.Rooms[roomOneCoord].Monster = new Monster(3, MonsterType.Demon) { HitPoints = 100, MaxHitPoints = 100 }; Monster monster = RoomHelper.Rooms[roomOneCoord].Monster; MonsterBuilder.BuildMonster(monster); RoomHelper.SetPlayerLocation(player, 0, 0, 0); GearHelper.EquipInitialGear(player); OutputHelper.Display.ClearUserOutput(); string[] inputInfo = new[] { "ability", "distance" }; PlayerHelper.AbilityInfo(player, inputInfo); Assert.AreEqual("Distance Shot", OutputHelper.Display.Output[0][2]); Assert.AreEqual("Rank: 1", OutputHelper.Display.Output[1][2]); Assert.AreEqual("Combo Cost: 25", OutputHelper.Display.Output[2][2]); Assert.AreEqual("Instant Damage: 25", OutputHelper.Display.Output[3][2]); Assert.AreEqual("50% chance to hit monster in attack direction.", OutputHelper.Display.Output[4][2]); Assert.AreEqual("Usage example if monster is in room to north. 'use distance north'", OutputHelper.Display.Output[5][2]); string[] input = new[] { "use", "distance", "south" }; string abilityName = InputHelper.ParseInput(input); Assert.AreEqual("distance south", abilityName); int arrowCount = player.PlayerQuiver.Quantity; player.UseAbility(input); Assert.AreEqual(arrowCount, player.PlayerQuiver.Quantity); Assert.AreEqual("You can't attack in that direction!", OutputHelper.Display.Output[6][2]); Assert.AreEqual(player.MaxComboPoints, player.ComboPoints); input = new[] { "use", "distance", "east" }; player.UseAbility(input); Assert.AreEqual(arrowCount, player.PlayerQuiver.Quantity); Assert.AreEqual("There is no monster in that direction to attack!", OutputHelper.Display.Output[7][2]); Assert.AreEqual(player.MaxComboPoints, player.ComboPoints); Assert.AreEqual(player.MaxComboPoints, player.ComboPoints); int abilityIndex = player.Abilities.FindIndex( f => f.ArcAbilityCategory == ArcherAbility.Distance); int?comboCost = player.Abilities[abilityIndex].ComboCost; player.Abilities[abilityIndex].Offensive.ChanceToSucceed = 0; input = new[] { "use", "distance", "north" }; player.UseAbility(input); Assert.AreEqual(arrowCount - 1, player.PlayerQuiver.Quantity); string missString = $"You tried to shoot {monster.Name} from afar but failed!"; Assert.AreEqual(missString, OutputHelper.Display.Output[8][2]); Assert.AreEqual(player.MaxComboPoints - comboCost, player.ComboPoints); player.Abilities[abilityIndex].Offensive.ChanceToSucceed = 100; player.ComboPoints = player.MaxComboPoints; arrowCount = player.PlayerQuiver.Quantity; player.UseAbility(input); Assert.AreEqual(arrowCount - 1, player.PlayerQuiver.Quantity); int abilityDmg = player.Abilities[abilityIndex].Offensive.Amount; string shootString = $"You successfully shot {monster.Name} from afar for {abilityDmg} damage!"; Assert.AreEqual(shootString, OutputHelper.Display.Output[9][2]); Assert.AreEqual(player.MaxComboPoints - comboCost, player.ComboPoints); Assert.AreEqual(monster.MaxHitPoints - abilityDmg, monster.HitPoints); }