public void RoundEngine_StartRound_Zero_Monsters_Should_Create_6() { // Arrange MockForms.Init(); // Clear the datastore... var myMonsterViewModel = MonstersViewModel.Instance; myMonsterViewModel.ForceDataRefresh(); myMonsterViewModel.Dataset.Add(new Monster()); var ListCount = myMonsterViewModel.Dataset.Count; myMonsterViewModel.Dataset.Clear(); MockDataStore.Instance.DeleteTables(); // Remove the data from Mock as well... // Can create a new Round engine... var myRoundEngine = new RoundEngine(); var Expected = GameGlobals.MaxNumberPartyPlayers; // Act myRoundEngine.StartRound(); var Actual = myRoundEngine.MonsterList.Count; // Reset // Restore the datastore MockDataStore.Instance.InitializeDatabaseNewTables(); // Assert Assert.AreEqual(Expected, Actual, "Monster List" + TestContext.CurrentContext.Test.Name); Assert.AreNotEqual(Expected, ListCount, "View Model " + TestContext.CurrentContext.Test.Name); }
public async Task RoundEngine_GetBetterItems_Valid_Feet_Parent_Should_Pass() { // Arrange RoundEngine test = new RoundEngine(); test.EngineSettings.CharacterList.Clear(); ItemModel item = ItemIndexViewModel.Instance.GetDefaultItem(ItemLocationEnum.Feet); test.EngineSettings.ItemPool.Clear(); item.Value = 1; CharacterModel testCharacter = new CharacterModel { CharacterTypeEnum = CharacterTypeEnum.Parent, Feet = item.Id, }; test.EngineSettings.CharacterList.Add(new PlayerInfoModel(testCharacter)); // Act await test.GetBetterItems(); // Reset ItemIndexViewModel.Instance.Dataset.Clear(); await ItemIndexViewModel.Instance.LoadDefaultDataAsync(); // Assert Assert.IsTrue(true); //Assert.IsTrue(test.EngineSettings.ItemPool.FirstOrDefault().Value > 1); }
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 RoundEngine_GetNextPlayerInList_3Player_CurrentPlayer_3_Should_Return_1st() { MockForms.Init(); // Can create a new Round engine... var myRoundEngine = new RoundEngine(); myRoundEngine.StartRound(); myRoundEngine.PlayerList.Clear(); var myFirst = new PlayerInfo(); myRoundEngine.PlayerList.Add(myFirst); var mySecond = new PlayerInfo(); myRoundEngine.PlayerList.Add(mySecond); var myThird = new PlayerInfo(); myRoundEngine.PlayerList.Add(myThird); myRoundEngine.PlayerCurrent = myThird; var Actual = myRoundEngine.GetNextPlayerInList(); var Expected = myFirst; Assert.AreEqual(Expected.Guid, Actual.Guid, TestContext.CurrentContext.Test.Name); }
public void Setup() { Referee = new RefereeModel(); Referee.Monsters = new List <DungeonFighterModel>(); Referee.Characters = new List <DungeonFighterModel>(); Engine = new RoundEngine(Referee, 9); }
public void RoundEngine_StartRound_Zero_Monsters_Should_Create_6() { MockForms.Init(); // Clear the datastore... var myMonsterViewModel = MonstersViewModel.Instance; var canExecute = myMonsterViewModel.LoadDataCommand.CanExecute(null); myMonsterViewModel.LoadDataCommand.Execute(null); myMonsterViewModel.Dataset.Add(new Monster()); var ListCount = myMonsterViewModel.Dataset.Count; myMonsterViewModel.Dataset.Clear(); MockDataStore.Instance.DeleteTables(); // Remove the data from Mock as well... // Can create a new Round engine... var myRoundEngine = new RoundEngine(); myRoundEngine.StartRound(); var Actual = myRoundEngine.MonsterList.Count; var Expected = 6; // Restore the datastore MockDataStore.Instance.InitializeDatabaseNewTables(); Assert.AreEqual(Expected, Actual, "Monster List" + TestContext.CurrentContext.Test.Name); Assert.AreNotEqual(Expected, ListCount, "View Model " + TestContext.CurrentContext.Test.Name); }
public async Task RoundEngine_GetAmazonSameBattleDeliveryItems_Valid_Default_Should_Pass() { // Arrange RoundEngine test = new RoundEngine(); test.EngineSettings.CharacterList.Clear(); //ItemModel item = ItemIndexViewModel.Instance.GetDefaultItem(ItemLocationEnum.Feet); test.EngineSettings.ItemPool.Clear(); //item.Value = 1; CharacterModel testCharacter = new CharacterModel { CharacterTypeEnum = CharacterTypeEnum.Student, Head = null, Necklace = null, PrimaryHand = null, RightFinger = null, LeftFinger = null, Feet = null, }; test.EngineSettings.CharacterList.Add(new PlayerInfoModel(testCharacter)); // Act await test.GetAmazonSameBattleDeliveryItems(); // Reset ItemIndexViewModel.Instance.Dataset.Clear(); await ItemIndexViewModel.Instance.LoadDefaultDataAsync(); // Assert Assert.IsTrue(true); //Assert.IsTrue(test.EngineSettings.ItemPool.FirstOrDefault().Value > 1); }
public void RoundEngine_Instantiate_Should_Pass() { MockForms.Init(); var Actual = new RoundEngine(); Assert.AreNotEqual(null, Actual, 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 RoundEngine_NewRound_AddMonstersToRound_6_Monsters_Should_Pass() { MockForms.Init(); var myRoundEngine = new RoundEngine(); myRoundEngine.NewRound(); var Expected = 6; var Actual = myRoundEngine.MonsterList.Count; Assert.AreEqual(Expected, Actual, 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 RoundEngine_RoundNextTurn_NoCharacters_GameOver_Should_Pass() { MockForms.Init(); var myRoundEngine = new RoundEngine(); myRoundEngine.StartRound(); var Actual = myRoundEngine.RoundNextTurn(); var Expected = RoundEnum.GameOver; Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void RoundEngine_StartRound_Should_Pass() { MockForms.Init(); // Can create a new Round engine... var myRoundEngine = new RoundEngine(); myRoundEngine.StartRound(); var Actual = myRoundEngine.BattleScore.RoundCount; var Expected = 1; Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void RoundEngine_Valid_Turn_Set_Should_Pass() { // Arrange // Act var result = new RoundEngine(); result.Turn = new TurnEngine(); // Reset // Assert Assert.IsNotNull(result.Turn); }
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 RoundEngine_RoundNextTurn_No_Characters_Should_Return_GameOver() { MockForms.Init(); // No characters, so return should be game over... // Can create a new Round engine... var myRoundEngine = new RoundEngine(); myRoundEngine.StartRound(); var Actual = myRoundEngine.RoundNextTurn(); var Expected = RoundEnum.GameOver; Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void RoundEngine_GetNextPlayerInList_Null_PlayerList_CurrentPlayer_Valid_Should_Skip() { MockForms.Init(); // Can create a new Round engine... var myRoundEngine = new RoundEngine(); myRoundEngine.StartRound(); myRoundEngine.PlayerCurrent = new PlayerInfo(); myRoundEngine.PlayerList.Clear(); var Actual = myRoundEngine.GetNextPlayerInList(); object Expected = null; Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }
public void RoundEngine_DropedItemOutput_Valid_Default_Should_Pass() { // Arrange List <ItemModel> items = new List <ItemModel>(); items.AddRange(ItemIndexViewModel.Instance.GetLocationItems(ItemLocationEnum.Head)); // Act RoundEngine test = new RoundEngine(); //Engine.EngineSettings.ItemPool.Add() test.DropedItemOutput("Head", items); // Reset // Assert Assert.IsTrue(true); }
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 int[] Play() { var finalScores = new int[_players.Count()]; //Inform about other players for (int seatIndex = 0; seatIndex < _players.Count(); seatIndex++) { _players[seatIndex].GameStart(_players.Count(), _rounds, seatIndex); } for (int roundNumber = 0; roundNumber < _rounds; roundNumber++) { var scores = new RoundEngine(_players).PlayRound(); for (int i = 0; i < _players.Count(); i++) { finalScores[i] += scores[i]; } } return(finalScores); }
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_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; }
public void RoundEngine_GetWhatIsNeededForEmptyLocation_Valid_Feet_Should_Pass() { // Arrange RoundEngine test = new RoundEngine(); test.EngineSettings.CharacterList.Clear(); CharacterModel testCharacter = new CharacterModel { CharacterTypeEnum = CharacterTypeEnum.Student, Feet = null, }; test.EngineSettings.CharacterList.Add(new PlayerInfoModel(testCharacter)); // Act int result = test.GetWhatIsNeededForEmptyLocation(ItemLocationEnum.Feet); // Reset // Assert Assert.AreEqual(1, result); }
public void RoundEngine_GetNextPlayerInList_1Player_CurrentPlayer_Null_Should_ReturnFirst() { MockForms.Init(); // Can create a new Round engine... var myRoundEngine = new RoundEngine(); myRoundEngine.StartRound(); myRoundEngine.PlayerList.Clear(); var myFirst = new PlayerInfo(); myRoundEngine.PlayerList.Add(myFirst); myRoundEngine.PlayerCurrent = null; var Actual = myRoundEngine.GetNextPlayerInList(); var Expected = myFirst; Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name); }