public void TurnEngine_TurnAsAttack_Monster_Attacks_Character_Hit_Should_Pass() { // Arrange Engine.MaxNumberCharacters = 1; var Character = new CharacterModel(); Engine.CharacterList.Add(Character); Engine.MaxNumberMonsters = 1; var Monster = new MonsterModel(); Engine.MonsterList.Add(Monster); Engine.MakeEntityList(); // Force a Hit DiceHelper.DisableRandomValues(); DiceHelper.SetForcedDiceRollValue(20); // Act var result = Engine.TurnAsAttack( Engine.EntityList.First(a => a.Id == Monster.Id), Engine.EntityList.First(a => a.Id == Character.Id)); // Reset DiceHelper.EnableRandomValues(); // Assert Assert.AreEqual(true, result); }
public void TurnEngine_DropItems_Character_Items_2_Should_Return_2() { // Arrange var Character = new CharacterModel { HeadItem = ItemIndexViewModel.Instance.Dataset.FirstOrDefault().Id, FeetItem = ItemIndexViewModel.Instance.Dataset.FirstOrDefault().Id, Id = "me" }; Engine.CharacterList.Clear(); Engine.CharacterList.Add(Character); Engine.MakeEntityList(); DiceHelper.DisableRandomValues(); DiceHelper.SetForcedDiceRollValue(0); // Act var result = Engine.DropItems(Engine.EntityList .Where(a => a.Id == "me").FirstOrDefault()); // Reset DiceHelper.EnableRandomValues(); Engine.StartBattle(false); // Assert Assert.AreEqual(2, result); }
public async Task AutoBattleEngine_RunAutoBattle_GameOver_Round_1_Should_Pass() { /* * * 1 Character, Speed slowest, only 1 HP * * 6 Monsters * * Should end in the first round * */ //Arrange // Add Characters Engine.MaxNumberCharacters = 1; var CharacterPlayer = new CharacterModel { Speed = -1, // Will go last... Level = 10, CurrentHealth = 1, TotalExperience = 1, }; Engine.CharacterList.Add(CharacterPlayer); // Add Monsters Engine.MaxNumberMonsters = 6; // set dice to always hit DiceHelper.DisableRandomValues(); DiceHelper.SetForcedDiceRollValue(20); //Act var result = await Engine.RunAutoBattle(); //Reset DiceHelper.DisableRandomValues(); Engine.MonsterList.Clear(); Engine.CharacterList.Clear(); Engine.EntityList.Clear(); //Assert Assert.AreEqual(true, result); }
public void CharacterModel_Default_GetAttackValue_Should_Pass() { // Arrange var data = new CharacterModel(); // Act DiceHelper.ForceConstantRoll = true; DiceHelper.SetForcedDiceRollValue(1); var result = data.GetAttackValue(); // roll + level // Reset DiceHelper.ForceConstantRoll = false; // Assert Assert.AreEqual(2, result); }
public void ItemModel_ScaleLevel_ForcedVaue_Should_Pass() { // Arrange var data = new ItemModel(); DiceHelper.DisableRandomValues(); DiceHelper.SetForcedDiceRollValue(1); // Act var result = data.ScaleLevel(1); // Reset DiceHelper.DisableRandomValues(); // Assert Assert.AreEqual(1, result); }
public void TurnEngine_RolltoHitTarget_Forced_20_Should_Hit() { // Arrange var AttackScore = 1; var DefenseScore = 100; DiceHelper.DisableRandomValues(); DiceHelper.SetForcedDiceRollValue(20); // Act var result = Engine.RollToHitTarget(AttackScore, DefenseScore); // Reset DiceHelper.EnableRandomValues(); // Assert Assert.AreEqual(HitStatusEnum.Hit, result); }
public void TurnEngine_DropItems_Character_Items_0_Random_Drop_Should_Return_0() { // Arrange var Character = new CharacterModel(); Character.Id = "me"; Engine.CharacterList.Clear(); Engine.CharacterList.Add(Character); Engine.MakeEntityList(); DiceHelper.DisableRandomValues(); DiceHelper.SetForcedDiceRollValue(1); // Act var result = Engine.DropItems(Engine.EntityList .Where(a => a.Id == "me").FirstOrDefault()); // Reset DiceHelper.EnableRandomValues(); Engine.StartBattle(false); // Assert Assert.AreEqual(0, result); }
public async Task AutoBattleEngine_RunAutoBattle_InValid_Trun_Loop_Should_Fail() { /* * Test infinate turn. * * Monsters overpower Characters game never ends * * 1 Character * Speed low * Hit weak * Health low * * 6 Monsters * Speed High * Hit strong * Health High * * Rolls for always Miss * * Should never end * * Inifinite Loop Check should stop the game * */ //Arrange // Add Characters Engine.MaxNumberCharacters = 1; var CharacterPlayer = new CharacterModel { Speed = 1, Level = 1, MaxHealth = 1, CurrentHealth = 1, }; Engine.CharacterList.Add(CharacterPlayer); // Add Monsters Engine.MaxNumberMonsters = 6; // Controll Rolls, Always Miss DiceHelper.DisableRandomValues(); DiceHelper.SetForcedDiceRollValue(1); //Act var result = await Engine.RunAutoBattle(); //Reset DiceHelper.EnableRandomValues(); Engine.CharacterList.Clear(); Engine.MonsterList.Clear(); Engine.EntityList.Clear(); //Assert Assert.AreEqual(false, result); Assert.AreEqual(true, Engine.Score.TurnCount > Engine.MaxTurnCount); Assert.AreEqual(true, Engine.Score.RoundCount < Engine.MaxRoundCount); }