private void StartRandomizing(int pokeNumber) { _teamSize = pokeNumber; var levelValidatorResult = LevelValidator.IsLevelValid(tbLevel.Text); if (levelValidatorResult == LevelValidatorResult.OK) { _pokemonList.Clear(); _enemyPokemonList.Clear(); int level = Convert.ToInt32(tbLevel.Text); for (int i = 0; i < pokeNumber; i++) { _pokemonList.Add(PokemonFactory.CreatePokemon(level)); _enemyPokemonList.Add(PokemonFactory.CreatePokemon(level)); } PrepareImages(); } else if (levelValidatorResult == LevelValidatorResult.InvalidFormat) { MessageBox.Show("Incorrect level format (Only numbers)"); } else if (levelValidatorResult == LevelValidatorResult.NotInRange) { MessageBox.Show("Level must be higher than 0 or 100 and less"); } }
void Start() { textPlayer = GetComponent <TextAnimatorPlayer>(); levelValidator = GameObject.FindObjectOfType <LevelValidator>(); if (inDialogueMode) { dialogueByLine = dialogue.Split('\n'); return; } speechByLine = speech.Split('\n'); ShowNamePlate(); }
public void Should_Return_All_Levels() { var fakeContext = new FakeContext("GetAllLevels"); fakeContext.FillWith <Level>(); using (var context = new MainContext(fakeContext.FakeOptions)) { var levelCountIndDb = context.Level.Count(); var repository = new LevelRepository(context); var validator = new LevelValidator(); var service = new LevelService(repository, validator); Assert.Equal(levelCountIndDb, service.GetAll().Count()); repository.Dispose(); } }
public void CreatLevel() { string[] data = LevelReader.GetInputData(); Level level = LevelBinder.CreateLevel(data); if (LevelValidator.IsValid(level)) { LevelsInfo.Add(level); LevelSaver.Save(level, pathToFile); Console.WriteLine("Level created and saved.."); // remove CW from BL Thread.Sleep(3000); } else { Console.WriteLine("level info is wrong");// remove CW from BL } }
public async Task <Item> CreateSword([FromBody] NewSword sword, Guid playerId) { DateTime localDate = DateTime.UtcNow; int ownerLvl = await repo.GetPlayerLevel(playerId); Sword new_sword = new Sword(); LevelValidator validator = new LevelValidator(); new_sword.Id = Guid.NewGuid(); new_sword.OwnerLevel = ownerLvl; new_sword.Level = 1; new_sword.SwordType = sword.SwordType; validator.ValidateAndThrow(new_sword); await repo.CreateSword(playerId, new_sword); return(new_sword); }
public async Task <Item> CreateSword([FromBody] Sword sword, Guid playerId) { DateTime localDate = DateTime.UtcNow; Sword new_sword = new Sword(); LevelValidator validator = new LevelValidator(); new_sword.Name = sword.Name; new_sword.Id = Guid.NewGuid(); new_sword.Level = sword.Level; new_sword.Type = sword.Type; new_sword.CreationTime = localDate; validator.ValidateAndThrow(new_sword); await _irepository.CreateItem(playerId, new_sword); return(new_sword); }
public void Should_Update_Existing_Level(int id) { var fakeContext = new FakeContext("UpdateLevel"); fakeContext.FillWith <Level>(); using (var context = new MainContext(fakeContext.FakeOptions)) { var repository = new LevelRepository(context); var validator = new LevelValidator(); var service = new LevelService(repository, validator); var curretLevel = service.GetById(id); curretLevel.Name = "Testing"; service.Update(curretLevel); Assert.Equal("Testing", service.GetById(id).Name); repository.Dispose(); } }
public void Should_Return_Right_Level_When_Find_By_Id(int id) { var fakeContext = new FakeContext("LevelById"); fakeContext.FillWith <Level>(); using (var context = new MainContext(fakeContext.FakeOptions)) { var expected = fakeContext.GetFakeData <Level>().Find(x => x.Id == id); var repository = new LevelRepository(context); var validator = new LevelValidator(); var service = new LevelService(repository, validator); var actual = service.GetById(id); Assert.Equal(expected, actual, new LevelIdComparer()); repository.Dispose(); } }
public void Should_Delete_Level() { var fakeContext = new FakeContext("DeleteLevel"); fakeContext.FillWith <Level>(); using (var context = new MainContext(fakeContext.FakeOptions)) { var repository = new LevelRepository(context); var validator = new LevelValidator(); var service = new LevelService(repository, validator); var currentCount = context.Level.Count(); Assert.NotEqual(0, currentCount); service.Delete(1); Assert.NotEqual(currentCount, context.Level.Count()); repository.Dispose(); } }
public void Should_Create_Correct_LevelDTO_Object(int id) { var fakeContext = new FakeContext("LevelDTOTest"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions)) { var repository = new LevelRepository(context); var validator = new LevelValidator(); var service = new LevelService(repository, validator); var mockMapper = new MapperConfiguration(cfg => { cfg.AddProfile <AutoMapperProfile>();; }); var mapper = mockMapper.CreateMapper(); var testLevel = service.GetById(id); var levelDTO = mapper.Map <Level, LevelDTO>(testLevel); Assert.IsType <LevelDTO>(levelDTO); Assert.Equal(testLevel.Name, levelDTO.Name); } }
bool RunOneLevelTrial() { FindNetworkManager(); ValidLevels thisLevel = new ValidLevels(); LevelValidator lv = new LevelValidator(); levelTesterState_s bestWinState = lv.PathfindLevel_BreadthFirst(); if (bestWinState.numStepsToReach == -1) { return false; } else { thisLevel.numClicks = bestWinState.numStepsToReach; // set number of clicks } thisLevel.level = networkMgr.GetNumPeople(); // set how many people on this level if (thisLevel.level == 3) { thisLevel.difficulty = Difficulty.VeryEasy; } // set difficulty from number of clicks and level else if (thisLevel.level == 4 && thisLevel.numClicks < 3) { thisLevel.difficulty = Difficulty.VeryEasy; } else if (thisLevel.level == 4 && thisLevel.numClicks >= 3) { thisLevel.difficulty = Difficulty.Easy; } else if (thisLevel.level == 5 && thisLevel.numClicks < 4) { thisLevel.difficulty = Difficulty.Easy; } else if (thisLevel.level == 5 && thisLevel.numClicks >= 4) { thisLevel.difficulty = Difficulty.Medium; } else if (thisLevel.level == 6 && thisLevel.numClicks < 3) { return false; } // this level is too easy else if (thisLevel.level == 6 && thisLevel.numClicks < 5) { thisLevel.difficulty = Difficulty.Medium; } else if (thisLevel.level == 6 && thisLevel.numClicks >= 5) { thisLevel.difficulty = Difficulty.Hard; } else if (thisLevel.level == 7 && thisLevel.numClicks < 3) { return false; } // this level is too easy else if (thisLevel.level == 7 && thisLevel.numClicks < 5) { thisLevel.difficulty = Difficulty.Medium; } else if (thisLevel.level == 7 && thisLevel.numClicks >= 5) { thisLevel.difficulty = Difficulty.Hard; } else if (thisLevel.level == 8 && thisLevel.numClicks < 3) { return false; } // this level is too easy else if (thisLevel.level == 8 && thisLevel.numClicks < 5) { thisLevel.difficulty = Difficulty.Medium; } else if (thisLevel.level == 8 && thisLevel.numClicks >= 5) { thisLevel.difficulty = Difficulty.Hard; } else { Debug.LogException(new System.Exception("Level and number of clicks wasn't handled by levelTester class (" + thisLevel.level + ", " + thisLevel.numClicks + ")")); } thisLevel.seed = networkMgr.usedSeed; // set used seed thisLevel.path = bestWinState.pathOfActions; if (lv.CheckIfLevelCanBeOneClick(bestWinState)) { thisLevel.oneClick = true; } // find a person for the cantTouch special level bool foundCantClickPerson = false; for (int i = 0; i < bestWinState.pathOfActions.trail.Count; i++) { int personToExclude = bestWinState.pathOfActions.trail[i].Key; networkMgr.ReloadStartingState(); LevelValidator lv2 = new LevelValidator(); levelTesterState_s bestWinState2 = lv2.PathfindLevel_BreadthFirst(personToExclude); if (bestWinState2.numStepsToReach != -1) { foundCantClickPerson = true; thisLevel.cantTouch = personToExclude; //print (bestWinState.numStepsToReach + ":" + bestWinState2.numStepsToReach); thisLevel.cantTouchPath = bestWinState2.pathOfActions; } } if (!foundCantClickPerson) { thisLevel.cantTouch = -1; } if (thisLevel.difficulty != Difficulty.Impossible) { lv.levelList.Add(thisLevel); if (fp == null) { fp = new ValidSeedListFileParse(); } fp.SerializeALevel(thisLevel); } return true; }
bool RunOneLevelTrial() { FindNetworkManager(); ValidLevels thisLevel = new ValidLevels(); LevelValidator lv = new LevelValidator(); levelTesterState_s bestWinState = lv.PathfindLevel_BreadthFirst(); if (bestWinState.numStepsToReach == -1) { return(false); } else { thisLevel.numClicks = bestWinState.numStepsToReach; // set number of clicks } thisLevel.level = networkMgr.GetNumPeople(); // set how many people on this level if (thisLevel.level == 3) { thisLevel.difficulty = Difficulty.VeryEasy; } // set difficulty from number of clicks and level else if (thisLevel.level == 4 && thisLevel.numClicks < 3) { thisLevel.difficulty = Difficulty.VeryEasy; } else if (thisLevel.level == 4 && thisLevel.numClicks >= 3) { thisLevel.difficulty = Difficulty.Easy; } else if (thisLevel.level == 5 && thisLevel.numClicks < 4) { thisLevel.difficulty = Difficulty.Easy; } else if (thisLevel.level == 5 && thisLevel.numClicks >= 4) { thisLevel.difficulty = Difficulty.Medium; } else if (thisLevel.level == 6 && thisLevel.numClicks < 3) { return(false); } // this level is too easy else if (thisLevel.level == 6 && thisLevel.numClicks < 5) { thisLevel.difficulty = Difficulty.Medium; } else if (thisLevel.level == 6 && thisLevel.numClicks >= 5) { thisLevel.difficulty = Difficulty.Hard; } else if (thisLevel.level == 7 && thisLevel.numClicks < 3) { return(false); } // this level is too easy else if (thisLevel.level == 7 && thisLevel.numClicks < 5) { thisLevel.difficulty = Difficulty.Medium; } else if (thisLevel.level == 7 && thisLevel.numClicks >= 5) { thisLevel.difficulty = Difficulty.Hard; } else if (thisLevel.level == 8 && thisLevel.numClicks < 3) { return(false); } // this level is too easy else if (thisLevel.level == 8 && thisLevel.numClicks < 5) { thisLevel.difficulty = Difficulty.Medium; } else if (thisLevel.level == 8 && thisLevel.numClicks >= 5) { thisLevel.difficulty = Difficulty.Hard; } else { Debug.LogException(new System.Exception("Level and number of clicks wasn't handled by levelTester class (" + thisLevel.level + ", " + thisLevel.numClicks + ")")); } thisLevel.seed = networkMgr.usedSeed; // set used seed thisLevel.path = bestWinState.pathOfActions; if (lv.CheckIfLevelCanBeOneClick(bestWinState)) { thisLevel.oneClick = true; } // find a person for the cantTouch special level bool foundCantClickPerson = false; for (int i = 0; i < bestWinState.pathOfActions.trail.Count; i++) { int personToExclude = bestWinState.pathOfActions.trail[i].Key; networkMgr.ReloadStartingState(); LevelValidator lv2 = new LevelValidator(); levelTesterState_s bestWinState2 = lv2.PathfindLevel_BreadthFirst(personToExclude); if (bestWinState2.numStepsToReach != -1) { foundCantClickPerson = true; thisLevel.cantTouch = personToExclude; //print (bestWinState.numStepsToReach + ":" + bestWinState2.numStepsToReach); thisLevel.cantTouchPath = bestWinState2.pathOfActions; } } if (!foundCantClickPerson) { thisLevel.cantTouch = -1; } if (thisLevel.difficulty != Difficulty.Impossible) { lv.levelList.Add(thisLevel); if (fp == null) { fp = new ValidSeedListFileParse(); } fp.SerializeALevel(thisLevel); } return(true); }