public void TurnEngine_DetermineCriticalMissProblem_Attacker_Null_Roll_1_Should_Return_Nothing_Broke() { MockForms.Init(); // Turn off random numbers // Set random to 1, and to hit to 1 GameGlobals.SetForcedRandomNumbers(1, 1); GameGlobals.ForcedRandomValue = 1; var myTurnEngine = new TurnEngine(); var myCharacter = new Character(DefaultModels.CharacterDefault()); myCharacter.PrimaryHand = null; // Nothing in the hand, so nothing to drop... var Actual = myTurnEngine.DetermineCriticalMissProblem(myCharacter); // Should roll for 1 item, and return it... var Expected = " Luckly, nothing to drop from PrimaryHand"; // Reset GameGlobals.ToggleRandomState(); Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void TurnEngine_TurnAsAttack_Monster_Attack_DefenderList_Miss_Should_Pass() { MockForms.Init(); // Turn off random numbers GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 20); var Attacker = DefaultModels.MonsterDefault(); Attacker.Name = "Rat"; var myDefaultCharacter = new Character(DefaultModels.CharacterDefault()); myDefaultCharacter.Name = "Fighter"; myDefaultCharacter.ScaleLevel(20); var myTurnEngine = new TurnEngine(); myTurnEngine.CharacterList.Add(myDefaultCharacter); GameGlobals.ForceToHitValue = 2; // Force a miss var AttackScore = Attacker.Level + Attacker.GetAttack(); var DefenseScore = myDefaultCharacter.GetDefense() + myDefaultCharacter.Level; var Status = myTurnEngine.TurnAsAttack(Attacker, AttackScore, myDefaultCharacter, DefenseScore); var Actual = Status; bool Expected = true; // Reset GameGlobals.ToggleRandomState(); Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void BattleEngine_StartBattle_With_Six_Characters_Should_Pass() { MockForms.Init(); // Can create a new battle engine... var myBattleEngine = new BattleEngine(); var myCharacter = new Character(DefaultModels.CharacterDefault()); myBattleEngine.CharacterList.Add(myCharacter); myCharacter = new Character(DefaultModels.CharacterDefault()); myBattleEngine.CharacterList.Add(myCharacter); myCharacter = new Character(DefaultModels.CharacterDefault()); myBattleEngine.CharacterList.Add(myCharacter); myCharacter = new Character(DefaultModels.CharacterDefault()); myBattleEngine.CharacterList.Add(myCharacter); myCharacter = new Character(DefaultModels.CharacterDefault()); myBattleEngine.CharacterList.Add(myCharacter); myCharacter = new Character(DefaultModels.CharacterDefault()); myBattleEngine.CharacterList.Add(myCharacter); myBattleEngine.StartBattle(true); var Actual = myBattleEngine.GetAutoBattleState(); var Expected = true; Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void TurnEngine_DetermineCriticalMissProblem_Attacker_Sword_Roll_1_Should_Return_Sword_Broke() { MockForms.Init(); // Turn off random numbers // Set random to 1, and to hit to 1 GameGlobals.SetForcedRandomNumbers(1, 1); GameGlobals.ForcedRandomValue = 1; var myTurnEngine = new TurnEngine(); var myCharacter = new Character(DefaultModels.CharacterDefault()); var itemGuid = ItemHelper.AddItemForAttribute(AttributeEnum.Attack, ItemLocationEnum.PrimaryHand, 1000).Guid; var myItem = ItemsViewModel.Instance.GetItem(itemGuid); myCharacter.PrimaryHand = itemGuid; // Nothing in the hand, so nothing to drop... var Actual = myTurnEngine.DetermineCriticalMissProblem(myCharacter); var Expected = " Item " + myItem.Name + " from " + ItemLocationEnum.PrimaryHand + " Broke, and lost forever"; // Reset GameGlobals.ToggleRandomState(); Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public async Task ViewModel_MessageCenter_CharactersViewModel_MessageCenter_DeleteData_Should_Pass() { MockForms.Init(); // Get State of the DataStore, and set to run on the Mock var myDataStoreEnum = MasterDataStore.GetDataStoreMockFlag(); MasterDataStore.ToggleDataStore(DataStoreEnum.Mock); var myViewModel = new CharactersViewModel(); var myData = DefaultModels.CharacterDefault(); await myViewModel.AddAsync(myData); var myPage = new DeleteCharacterPage(new CharacterDetailViewModel(new Character())); MessagingCenter.Send(myPage, "DeleteData", myData); var Actual = await myViewModel.GetAsync(myData.Id); Object Expected = null; // Return state MasterDataStore.ToggleDataStore(myDataStoreEnum); // Validate the controller can stand up and has a Title Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public async Task ViewModel_CharactersViewModel_UpdateData_Bogus_Should_Skip() { MockForms.Init(); // Get State of the DataStore, and set to run on the Mock var myDataStoreEnum = MasterDataStore.GetDataStoreMockFlag(); MasterDataStore.ToggleDataStore(DataStoreEnum.Mock); var myViewModel = new CharactersViewModel(); myViewModel.ForceDataRefresh(); var myData = DefaultModels.CharacterDefault(); // Make the ID bogus... var value = "new"; myData.Id = value; var myReturn = await myViewModel.UpdateAsync(myData); var Actual = myReturn; bool Expected = false; // Return state MasterDataStore.ToggleDataStore(myDataStoreEnum); // Validate the controller can stand up and has a Title Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public async Task ViewModel_CharactersViewModel_UpdateData_Should_Pass() { MockForms.Init(); // Get State of the DataStore, and set to run on the Mock var myDataStoreEnum = MasterDataStore.GetDataStoreMockFlag(); MasterDataStore.ToggleDataStore(DataStoreEnum.Mock); var myViewModel = new CharactersViewModel(); var myData = DefaultModels.CharacterDefault(); await myViewModel.AddAsync(myData); var value = "new"; myData.Name = value; var myReturn = myViewModel.UpdateAsync(myData); var Actual = await myViewModel.GetAsync(myData.Id); string Expected = value; // Return state MasterDataStore.ToggleDataStore(myDataStoreEnum); // Validate the controller can stand up and has a Title Assert.AreEqual(Expected, Actual.Name, TestContext.CurrentContext.Test.Name); }
public void RoundEngine_RoundNextTurn_2_Characters_Should_Return_NextTurn() { MockForms.Init(); // No characters, so return should be game over... // Can create a new Round engine... var myRoundEngine = new RoundEngine(); // Add 2 monsters myRoundEngine.MonsterList.Add(new Monster(DefaultModels.MonsterDefault())); myRoundEngine.MonsterList.Add(new Monster(DefaultModels.MonsterDefault())); // Add 2 characters myRoundEngine.CharacterList.Add(new Character(DefaultModels.CharacterDefault())); myRoundEngine.CharacterList.Add(new Character(DefaultModels.CharacterDefault())); // Start myRoundEngine.StartRound(); // Do the turn... var Actual = myRoundEngine.RoundNextTurn(); // There are 2 characters, and 2 monsters, so the first turn should happen, and it is now next turn... var Expected = RoundEnum.NextTurn; Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void RoundEngine_RoundNextTurn_2Characters_1Monster_Weak_Should_Take_2_Turns() { MockForms.Init(); bool reincarnation = GameGlobals.EnableReincarnation; GameGlobals.EnableReincarnation = false; // Can create a new Round engine... var myRoundEngine = new RoundEngine(); // Start myRoundEngine.StartRound(); // Add moderate monsters // First monster myRoundEngine.MonsterList.Clear(); // start fresh, because it was loaded already with 6... var myMonsterWeak = new Monster(DefaultModels.MonsterDefault()); myMonsterWeak.ScaleLevel(5); myMonsterWeak.Attribute.CurrentHealth = 7; // need to set to enough to last 2 rounds... myRoundEngine.MonsterList.Add(myMonsterWeak); // Add weak character for first... var myCharacterWeak = new Character(DefaultModels.CharacterDefault()); myCharacterWeak.ScaleLevel(10); myRoundEngine.CharacterList.Add(myCharacterWeak); // Add strong character for second var myCharacterStrong = new Character(DefaultModels.CharacterDefault()); myCharacterStrong.ScaleLevel(20); myRoundEngine.CharacterList.Add(myCharacterStrong); // Should be Character 20, Character 10, Monster 5 // Force rolls to 18 for to hit... // Turn off random numbers GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 18); // Character, should kill the monster in the first round. // So the check for the second round will say Round over... var FirstRound = myRoundEngine.RoundNextTurn(); // Character 20 Goes var SecondRound = myRoundEngine.RoundNextTurn(); // Character 10 Goes var Actual = myRoundEngine.RoundNextTurn(); // Over... // Reset GameGlobals.ToggleRandomState(); var Expected = RoundEnum.NextTurn; Assert.AreEqual(Expected, Actual, "Status " + TestContext.CurrentContext.Test.Name); Assert.AreEqual(3, myRoundEngine.BattleScore.TurnCount, "TurnCount " + TestContext.CurrentContext.Test.Name); //Assert.AreEqual(4, myRoundEngine.BattleScore.RoundCount, "RoundCount " + TestContext.CurrentContext.Test.Name); GameGlobals.EnableReincarnation = reincarnation; }
public void TurnEngine_Turn_AttackChoice_Monster_Valid_Attacker_Valid_Defender_Alive_False_Should_Skip() { // Arrange var Attacker = DefaultModels.MonsterDefault(); var myDefaultCharacter = new Character(DefaultModels.CharacterDefault()); myDefaultCharacter.Name = "Fighter"; myDefaultCharacter.ScaleLevel(20); myDefaultCharacter.Alive = false; //dead... var myTurnEngine = new TurnEngine(); myTurnEngine.CharacterList.Add(myDefaultCharacter); object Expected = null; // Act var Actual = myTurnEngine.AttackChoice(Attacker); // Reset // Assert Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void TurnEngine_TurnAsAttack_Monster_Attack_DefenderList_CriticalMiss_Should_Pass() { // Turn off random numbers GameGlobals.SetForcedRandomNumbers(1, 20); var Attacker = DefaultModels.MonsterDefault(); Attacker.Name = "Rat"; var myDefaultCharacter = DefaultModels.CharacterDefault(); myDefaultCharacter.Name = "Fighter"; var myTurnEngine = new TurnEngine(); myTurnEngine.CharacterList.Add(myDefaultCharacter); GameGlobals.ForceToHitValue = 1; // Force a miss var AttackScore = Attacker.Level + Attacker.GetAttack(); var DefenseScore = myDefaultCharacter.GetDefense() + myDefaultCharacter.Level; var Status = myTurnEngine.TurnAsAttack(Attacker, AttackScore, myDefaultCharacter, DefenseScore); var Actual = Status; bool Expected = true; var ActualString = myTurnEngine.TurnMessage; var ActualResult = myTurnEngine.HitStatus; var ActualDamage = myTurnEngine.DamageAmount; // Reset GameGlobals.ToggleRandomState(); Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void BattleEngine_AutoBattle_With_Six_Characters_Should_Pass() { MockForms.Init(); // Can create a new battle engine... var myBattleEngine = new BattleEngine(); var myCharacter = new Character(DefaultModels.CharacterDefault()); myCharacter.Name = "Fighter 1"; myCharacter.ScaleLevel(1); myBattleEngine.CharacterList.Add(myCharacter); myCharacter = new Character(DefaultModels.CharacterDefault()); myCharacter.Name = "Fighter 2"; myCharacter.ScaleLevel(2); myBattleEngine.CharacterList.Add(myCharacter); myCharacter = new Character(DefaultModels.CharacterDefault()); myCharacter.Name = "Fighter 3"; myCharacter.ScaleLevel(3); myBattleEngine.CharacterList.Add(myCharacter); myCharacter = new Character(DefaultModels.CharacterDefault()); myCharacter.Name = "Fighter 4"; myCharacter.ScaleLevel(4); myBattleEngine.CharacterList.Add(myCharacter); myCharacter = new Character(DefaultModels.CharacterDefault()); myCharacter.Name = "Fighter 5"; myCharacter.ScaleLevel(5); myBattleEngine.CharacterList.Add(myCharacter); myCharacter = new Character(DefaultModels.CharacterDefault()); myCharacter.Name = "Fighter 6"; myCharacter.ScaleLevel(6); myBattleEngine.CharacterList.Add(myCharacter); // Turn off random numbers // For a hit on everything... GameGlobals.SetForcedRandomNumbers(1, 20); myBattleEngine.AutoBattle(); // Reset GameGlobals.ToggleRandomState(); var Actual = myBattleEngine.BattleScore; Assert.AreNotEqual(null, Actual, "Score Object " + TestContext.CurrentContext.Test.Name); Assert.AreNotEqual(0, Actual.ExperienceGainedTotal, "Experience " + TestContext.CurrentContext.Test.Name); Assert.AreNotEqual(0, Actual.RoundCount, "Round Count " + TestContext.CurrentContext.Test.Name); Assert.AreNotEqual(0, Actual.TurnCount, "Turn Count " + TestContext.CurrentContext.Test.Name); Assert.AreNotEqual(0, Actual.ScoreTotal, "Score Total " + TestContext.CurrentContext.Test.Name); Assert.AreNotEqual(string.Empty, Actual.ItemsDroppedList, "Items Dropped " + TestContext.CurrentContext.Test.Name); Assert.AreNotEqual(string.Empty, Actual.MonstersKilledList, "Monsters Killed " + TestContext.CurrentContext.Test.Name); Assert.AreNotEqual(string.Empty, Actual.CharacterAtDeathList, "Character List " + TestContext.CurrentContext.Test.Name); }
public void RoundEngine_RoundNextTurn_2Characters_1Monster_Strong_Should_Take_3_Rounds() { MockForms.Init(); // No characters, so return should be game over... // Can create a new Round engine... var myRoundEngine = new RoundEngine(); // Start myRoundEngine.StartRound(); // Add moderate monsters // First monster myRoundEngine.MonsterList.Clear(); // start fresh, because it was loaded already with 6... var myMonsterWeak = new Monster(DefaultModels.MonsterDefault()); myMonsterWeak.ScaleLevel(2); myMonsterWeak.Attribute.CurrentHealth = 20; // need to set to enough to last 4 rounds... myRoundEngine.MonsterList.Add(myMonsterWeak); // Add weak character for first... var myCharacterStrong = new Character(DefaultModels.CharacterDefault()); myCharacterStrong.ScaleLevel(10); myRoundEngine.CharacterList.Add(myCharacterStrong); // Add strong character for second myCharacterStrong = new Character(DefaultModels.CharacterDefault()); myCharacterStrong.ScaleLevel(20); myRoundEngine.CharacterList.Add(myCharacterStrong); // Should be Character 20, Character 10, Monster 5 // Force rolls to 18 for to hit... // Turn off random numbers GameGlobals.SetForcedRandomNumbers(1, 18); // Character, should kill the monster in the first round. // So the check for the second round will say Round over... var FirstRound = myRoundEngine.RoundNextTurn(); // Character 20 var SecondRound = myRoundEngine.RoundNextTurn(); // Character 10 goes var ThirdRound = myRoundEngine.RoundNextTurn(); // Monster goes var FourthRound = myRoundEngine.RoundNextTurn(); // Character 20 goes, kills monster... var Actual = myRoundEngine.RoundNextTurn(); // over... // Reset GameGlobals.ToggleRandomState(); var Expected = RoundEnum.NewRound; Assert.AreEqual(Expected, Actual, "Status " + TestContext.CurrentContext.Test.Name); Assert.AreEqual(4, myRoundEngine.BattleScore.TurnCount, "TurnCount " + TestContext.CurrentContext.Test.Name); Assert.AreEqual(1, myRoundEngine.BattleScore.RoundCount, "RoundCount " + TestContext.CurrentContext.Test.Name); }
public void TurnEngine_TurnAsAttack_Monster_Attack_Defender_Die_With_Item_Should_Drop() { MockForms.Init(); // Turn off random numbers GameGlobals.SetForcedRandomNumbers(1, 20); var Attacker = DefaultModels.MonsterDefault(); Attacker.Name = "Rat"; Attacker.ScaleLevel(20); var myDefaultCharacter = new Character(DefaultModels.CharacterDefault()); myDefaultCharacter.Name = "Fighter"; myDefaultCharacter.ScaleLevel(1); // Add Uniqueitem var myItem = new Item { Attribute = AttributeEnum.Attack, Location = ItemLocationEnum.Feet, Value = 1 }; ItemsViewModel.Instance.AddAsync(myItem).GetAwaiter().GetResult(); // Register Item to DataSet myDefaultCharacter.PrimaryHand = myItem.Guid; var myTurnEngine = new TurnEngine(); myTurnEngine.CharacterList.Add(myDefaultCharacter); // Get Score, and remember item. var BeforeItemDropList = myTurnEngine.BattleScore.ItemsDroppedList; GameGlobals.ForceToHitValue = 20; // Force a hit // Should Kill because level 20 hit on level 1 Character for Critical is more damage than health... var AttackScore = Attacker.Level + Attacker.GetAttack(); var DefenseScore = myDefaultCharacter.GetDefense() + myDefaultCharacter.Level; var Status = myTurnEngine.TurnAsAttack(Attacker, AttackScore, myDefaultCharacter, DefenseScore); // Item should drop... // Reset GameGlobals.ToggleRandomState(); // Need to get Score // See if Item is now in the score list... var AfterItemDropList = myTurnEngine.BattleScore.ItemsDroppedList; Assert.AreNotEqual(BeforeItemDropList, AfterItemDropList, TestContext.CurrentContext.Test.Name); }
public void TurnEngine_Turn_AttackChoice_Character_Valid_Attacker_Empty_Defender_Should_Pass() { var Attacker = DefaultModels.CharacterDefault(); var myTurnEngine = new TurnEngine(); myTurnEngine.MonsterList = new List <Monster>(); var Actual = myTurnEngine.AttackChoice(Attacker); object Expected = null; Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void Model_Score_AddCharacterToList_With_Valid_Should_Pass() { var myAdd = DefaultModels.CharacterDefault(); var myData = new Score(); myData.AddCharacterToList(myAdd); var Actual = myData.CharacterAtDeathList; var Expected = "Name , Description , Level : 1 , Total Experience : 0 , Speed : 1 , Defense : 1 , Attack : 1 , CurrentHealth : 1 , MaxHealth : 1 , Items : Head : None , Necklass : None , PrimaryHand : None , OffHand : None , RightFinger : None , LeftFinger : None , Feet : None , Damage : 0\n"; // Validate the controller can stand up and has a Title Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void ViewModel_CharactersViewModel_Instantiate_With_Data_Should_Pass() { MockForms.Init(); var myData = DefaultModels.CharacterDefault(); var value = "hi"; myData.Name = value; var Actual = new CharacterDetailViewModel(myData); Assert.AreEqual(value, Actual.Title, TestContext.CurrentContext.Test.Name); }
public void RoundEngine_GetAverageCharacterLevel_With_1_Character_Should_Pass() { MockForms.Init(); // Start round with one character var myRoundEngine = new RoundEngine(); myRoundEngine.CharacterList.Add(new Character(DefaultModels.CharacterDefault())); var Actual = myRoundEngine.GetAverageCharacterLevel(); var Expected = 1; Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void Model_Score_AddCharacterToList_With_Null_Add_Should_Skip() { var myAdd = DefaultModels.CharacterDefault(); var myData = new Score(); myData.AddCharacterToList(null); var Actual = myData.CharacterAtDeathList; string Expected = null; // Validate the controller can stand up and has a Title Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void TurnEngine_TakeTurn_Attack_Valid_Defender_Valid_Defender_Should_Die() { MockForms.Init(); // Turn off random numbers GameGlobals.SetForcedRandomNumbers(1, 20); var Attacker = DefaultModels.CharacterDefault(); Attacker.Name = "Fighter"; Attacker.ScaleLevel(20); var myDefaultMonster = new Monster(DefaultModels.MonsterDefault()); myDefaultMonster.Name = "Rat"; myDefaultMonster.ScaleLevel(1); // Add Uniqueitem var myItem = new Item { Attribute = AttributeEnum.Attack, Location = ItemLocationEnum.Feet, Value = 1 }; ItemsViewModel.Instance.AddAsync(myItem).GetAwaiter().GetResult(); // Register Item to DataSet myDefaultMonster.UniqueItem = myItem.Guid; var myTurnEngine = new TurnEngine(); myTurnEngine.MonsterList.Add(myDefaultMonster); // Get Score, and remember item. var BeforeItemDropList = myTurnEngine.BattleScore.ItemsDroppedList; GameGlobals.ForceToHitValue = 20; // Force a hit var BeforeMonsterList = myTurnEngine.MonsterList.Count(); // Instead of calling TurnAsAttack, call TakeTurn... var Status = myTurnEngine.TakeTurn(Attacker); var AfterMonsterList = myTurnEngine.MonsterList.Count(); // Item should drop... // Reset GameGlobals.ToggleRandomState(); Assert.AreEqual(BeforeMonsterList - 1, AfterMonsterList, TestContext.CurrentContext.Test.Name); }
public void RoundEngine_RoundNextTurn_1_Character_Should_Have_NewRound_Should_Pass() { MockForms.Init(); // Start round with one monster and character var myRoundEngine = new RoundEngine(); myRoundEngine.MonsterList.Add(new Monster(DefaultModels.MonsterDefault())); myRoundEngine.CharacterList.Add(new Character(DefaultModels.CharacterDefault())); myRoundEngine.StartRound(); var Expected = RoundEnum.NextTurn; var Actual = myRoundEngine.RoundNextTurn(); Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void ViewModel_CharactersViewModel_GetData_With_Data_Should_Pass() { MockForms.Init(); var myData = DefaultModels.CharacterDefault(); var value = "hi"; myData.Name = value; var myViewModel = new CharacterDetailViewModel(myData); var Actual = myViewModel.Data; var Expected = myData; Assert.AreEqual(Expected.Name, Actual.Name, TestContext.CurrentContext.Test.Name); }
public void TurnEngine_TurnAsAttack_Character_Attack_Defender_Die_With_Item_Should_Drop() { MockForms.Init(); // Turn off random numbers GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 20); var Attacker = DefaultModels.CharacterDefault(); Attacker.Name = "Fighter"; Attacker.ScaleLevel(20); var myDefaultMonster = new Monster(DefaultModels.MonsterDefault()); myDefaultMonster.Name = "Rat"; myDefaultMonster.ScaleLevel(1); // Add Uniqueitem var myItem = new Item { Attribute = AttributeEnum.Attack, Location = ItemLocationEnum.Feet, Value = 1 }; ItemsViewModel.Instance.AddAsync(myItem).GetAwaiter().GetResult(); // Register Item to DataSet myDefaultMonster.UniqueItem = myItem.Guid; var myTurnEngine = new TurnEngine(); myTurnEngine.MonsterList.Add(myDefaultMonster); // Get Score, and remember item. var BeforeItemDropList = myTurnEngine.BattleScore.ItemsDroppedList; GameGlobals.ForceToHitValue = 20; // Force a hit // Reset GameGlobals.ToggleRandomState(); // Need to get Score // See if Item is now in the score list... var AfterItemDropList = myTurnEngine.BattleScore.ItemsDroppedList; Assert.AreNotEqual(BeforeItemDropList, AfterItemDropList, TestContext.CurrentContext.Test.Name); }
public void TurnEngine_TurnAsAttack_Character_Attack_Null_DefenderList_Should_Skip() { // Turn off random numbers GameGlobals.SetForcedRandomNumbers(1, 20); var Attacker = DefaultModels.CharacterDefault(); var myTurnEngine = new TurnEngine(); var Status = myTurnEngine.TurnAsAttack(Attacker, 1, null, 1); var Actual = Status; bool Expected = false; // Reset GameGlobals.ToggleRandomState(); Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void TurnEngine_TurnAsAttack_Monster_Attack_Defender_CriticalHit_PowerfullHit_Should_Kill() { MockForms.Init(); // Turn off random numbers GameGlobals.SetForcedRandomNumbers(1, 20); var Attacker = DefaultModels.MonsterDefault(); Attacker.Name = "Rat"; Attacker.ScaleLevel(20); var myDefaultCharacter = new Character(DefaultModels.CharacterDefault()); myDefaultCharacter.Name = "Fighter"; myDefaultCharacter.ScaleLevel(1); var myTurnEngine = new TurnEngine(); myTurnEngine.CharacterList.Add(myDefaultCharacter); GameGlobals.ForceToHitValue = 20; // Force a hit // Should Kill because level 20 hit on level 1 Character for Critical is more damage than health... var AttackScore = Attacker.Level + Attacker.GetAttack(); var DefenseScore = myDefaultCharacter.GetDefense() + myDefaultCharacter.Level; var Status = myTurnEngine.TurnAsAttack(Attacker, AttackScore, myDefaultCharacter, DefenseScore); var Actual = Status; bool Expected = true; var ActualString = myTurnEngine.TurnMessage; var ActualResult = myTurnEngine.HitStatus; var ActualDamage = myTurnEngine.DamageAmount; var LifeStatus = myDefaultCharacter.Alive; // Reset GameGlobals.ToggleRandomState(); Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); Assert.AreEqual(false, myDefaultCharacter.Alive, TestContext.CurrentContext.Test.Name); }
public void RoundEngine_RoundNextTurn_Characters_MonstersDead_Should_Return_NewRound() { MockForms.Init(); // No characters, so return should be game over... // Can create a new Round engine... var myRoundEngine = new RoundEngine(); // Turn off random numbers GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 20); // Start myRoundEngine.StartRound(); // Clear the monster list // Add weak monsters var myMonsterWeak = new Monster(DefaultModels.MonsterDefault()); myMonsterWeak.ScaleLevel(1); myRoundEngine.MonsterList.Clear(); // start fresh, because it was loaded already with 6... myRoundEngine.MonsterList.Add(myMonsterWeak); // Add strong character var myCharacterStrong = new Character(DefaultModels.CharacterDefault()); myCharacterStrong.ScaleLevel(20); myRoundEngine.CharacterList.Add(myCharacterStrong); // Character, should kill the monster in the first round. // So the check for the second round will say Round over... var FirstRound = myRoundEngine.RoundNextTurn(); var Actual = myRoundEngine.RoundNextTurn(); var Expected = RoundEnum.NewRound; // Reset GameGlobals.ToggleRandomState(); Assert.AreEqual(RoundEnum.NextTurn, FirstRound, TestContext.CurrentContext.Test.Name); Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void RoundEngine_GetMaxCharacterLevel_With_2_Characters_Should_Pass() { MockForms.Init(); // Start round with one strong character and one default character var myRoundEngine = new RoundEngine(); var strongChar = new Character(DefaultModels.CharacterDefault()); strongChar.ScaleLevel(10); var weakChar = new Character(DefaultModels.CharacterDefault()); myRoundEngine.CharacterList.Add(strongChar); myRoundEngine.CharacterList.Add(weakChar); var Actual = myRoundEngine.GetMaxCharacterLevel(); var Expected = 10; Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void TurnEngine_Turn_AttackChoice_Monster_Valid_Attacker_Valid_Defender_Should_Pass() { var Attacker = DefaultModels.MonsterDefault(); var DefenderList = new List <Character>(); var myDefaultCharacter = new Character(DefaultModels.CharacterDefault()); myDefaultCharacter.Name = "Fighter"; myDefaultCharacter.ScaleLevel(20); var myTurnEngine = new TurnEngine(); myTurnEngine.CharacterList.Add(myDefaultCharacter); var Actual = myTurnEngine.AttackChoice(Attacker); var Expected = myDefaultCharacter; Assert.AreEqual(Expected.Guid, Actual.Guid, TestContext.CurrentContext.Test.Name); }
public void RoundEngine_RoundNextTurn_Characters_MonstersDead_Should_Return_NewRound() { MockForms.Init(); var myRoundEngine = new RoundEngine(); // Turn off random numbers GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 20); bool reincarnation = GameGlobals.EnableReincarnation; GameGlobals.EnableReincarnation = false; // Start myRoundEngine.StartRound(); // Clear the monster list // Add weak monsters var myMonsterWeak = new Monster(DefaultModels.MonsterDefault()); myMonsterWeak.ScaleLevel(1); myRoundEngine.MonsterList.Clear(); // start fresh, because it was loaded already with 6... myRoundEngine.MonsterList.Add(myMonsterWeak); // Add strong character var myCharacterStrong = new Character(DefaultModels.CharacterDefault()); myCharacterStrong.ScaleLevel(20); myRoundEngine.CharacterList.Add(myCharacterStrong); var Expected = RoundEnum.NextTurn; var Actual = myRoundEngine.RoundStateEnum; // Reset GameGlobals.ToggleRandomState(); Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); GameGlobals.EnableReincarnation = reincarnation; }