public void TurnEngine_TurnAsAttack_Monster_Attacks_Character_Hit_Should_Pass() { // Arrange var Monster = new MonsterModel(); var MonsterPlayer = new PlayerInfoModel(Monster); Engine.MonsterList.Add(MonsterPlayer); var Character = new CharacterModel(); var CharacterPlayer = new PlayerInfoModel(Character); Engine.CharacterList.Add(CharacterPlayer); // Forece a Miss DiceHelper.EnableRandomValues(); DiceHelper.SetForcedRandomValue(20); // Act var result = Engine.TurnAsAttack(MonsterPlayer, CharacterPlayer, false); // Reset DiceHelper.DisableRandomValues(); // Assert Assert.AreEqual(true, result); }
public void RollDiceHelper_RollDice_Valid_1Time_6sided_Forced_6_Should_Pass() { // Arrange DiceHelper.EnableRandomValues(); DiceHelper.SetForcedRandomValue(6); // Act var result = DiceHelper.RollDice(1, 6); // Reset DiceHelper.DisableRandomValues(); // Assert Assert.AreEqual(6, result); }
public void AutoBattleEngine_RunAutoBattle_Default_Should_Pass() { //Arrange DiceHelper.EnableRandomValues(); DiceHelper.SetForcedRandomValue(3); //Act var result = Engine.RunAutoBattle(); //Reset DiceHelper.DisableRandomValues(); //Assert Assert.IsNotNull(result); }
public void TurnEngine_DropItems_Monster_Items_0_Random_Drop_1_Should_Return_1() { // Arrange var player = new CharacterModel(); var PlayerInfo = new PlayerInfoModel(player); DiceHelper.EnableRandomValues(); DiceHelper.SetForcedRandomValue(1); // Act var result = Engine.DropItems(PlayerInfo); // Reset DiceHelper.DisableRandomValues(); // Assert Assert.AreEqual(1, result); }
public void TurnEngine_RolltoHitTarget_Forced_1_Should_Miss() { // Arrange var AttackScore = 1; var DefenseScore = 100; DiceHelper.EnableRandomValues(); DiceHelper.SetForcedRandomValue(1); // Act Engine.CurrentAttacker = new PlayerInfoModel(); Engine.CurrentAttacker.PlayerType = PlayerTypeEnum.Character; var result = Engine.RollToHitTarget(AttackScore, DefenseScore); // Reset DiceHelper.DisableRandomValues(); // Assert Assert.AreEqual(HitStatusEnum.Miss, result); }
public void AutoBattleEngine_RunAutoBattle_Character_UsedSpecialAblity_Pass() { //Arrange var CharacterPlayerMike = new PlayerInfoModel( new CharacterModel { Speed = -1, Level = 10, CurrentHealth = 11, ExperienceTotal = 1, Name = "Mike", ListOrder = 1, }); var MonsterPlayer = new PlayerInfoModel( new CharacterModel { Speed = -1, Level = 10, CurrentHealth = 11, ExperienceTotal = 1, Name = "Monster", ListOrder = 1, }); Engine.CharacterList.Add(CharacterPlayerMike); Engine.MonsterList.Add(MonsterPlayer); Engine.UseSpecialAbility = true; //Act // Have dice rull 19 DiceHelper.EnableRandomValues(); DiceHelper.SetForcedRandomValue(19); var result = Engine.Attack(CharacterPlayerMike); //Reset DiceHelper.DisableRandomValues(); //Assert Assert.AreEqual(false, CharacterPlayerMike.ISSpecialAbilityNotUsed); }
public void TurnEngine_DropItems_Character_Items_2_Should_Return_2() { // Arrange var player = new CharacterModel { Head = ItemIndexViewModel.Instance.Dataset.FirstOrDefault().Id, Feet = ItemIndexViewModel.Instance.Dataset.FirstOrDefault().Id, }; var PlayerInfo = new PlayerInfoModel(player); DiceHelper.EnableRandomValues(); DiceHelper.SetForcedRandomValue(0); // Act var result = Engine.DropItems(PlayerInfo); // Reset DiceHelper.DisableRandomValues(); // Assert Assert.AreEqual(2, result); }
public async Task HackathonScenario_Scenario_24_Rental_Insurance_Item_Should_Break() { /* * Scenario Number: * 24 * * Description: * When the Attacker hits an opposing Person, if the random chance that a break occurs * is triggered, the Attacker's item breaks. * * Changes Required (Classes, Methods etc.) List Files, Methods, and Describe Changes: * Changed the TurnEngine.cs * * Test Algrorithm: * Set RentalInsuranceEnabled to true, chance 100% * Create an Item * Create Character and Monster * Have Character Attack Monster * Verify that Attacker has dropped the Item * * Test Conditions: * If rebound chance is * * Validation * Attacker has dropped the Item * */ //Arrange // Turn on RentalInsurance SettingsHelper.RentalInsuranceEnabled = true; // Set rental insurance chance to 100% SettingsHelper.RENTAL_INSURANCE_TEST = 1f; // Create Item var BreakingItem = new ItemModel { Name = "Breaking Item", Description = "This Item is made to break.", Range = 10, Value = 20, Damage = 20 }; await ItemIndexViewModel.Instance.CreateAsync(BreakingItem); // Create Character var CharacterPlayer = new PlayerInfoModel( new CharacterModel { BaseSpeed = 5, Level = 10, BaseHitPoints = 100, CurrentHitPoints = 100, ExperiencePoints = 100, BaseStrength = 10, Name = "Mike", Head = BreakingItem.Id }); BattleEngine.CharacterList.Add(CharacterPlayer); // Create Monster var MonsterPlayer = new PlayerInfoModel( new MonsterModel { BaseSpeed = 5, Level = 10, BaseHitPoints = 100, CurrentHitPoints = 100, ExperiencePoints = 100, BaseStrength = 10, Name = "Monster Mike" }); BattleEngine.MonsterList.Add(MonsterPlayer); DiceHelper.EnableForcedRolls(); DiceHelper.SetForcedRandomValue(18); //Act BattleEngine.TurnAsAttack(CharacterPlayer, MonsterPlayer); //Reset SettingsHelper.RentalInsuranceEnabled = false; SettingsHelper.RENTAL_INSURANCE_TEST = 0.8f; DiceHelper.DisableForcedRolls(); //Assert Assert.AreEqual(true, CharacterPlayer.Head == null); }