public void Execute(int wight, int height, int minWordsForGrid) { List<Word> wordsForGame = words.GetAll(); Grid<char> grid = new Grid<char>((uint)wight, (uint)height); GridWithLetters gridWithLetters; wordsForGame = shuffleWordsService.Shuffle(wordsForGame); if (minWordsForGrid < wordsForGame.Count) { int toremover = wordsForGame.Count - minWordsForGrid; wordsForGame.RemoveRange(minWordsForGrid, toremover); } gridWithLetters = addWordsService.AddWords(grid, wordsForGame); gridWithLetters = fillGridService.FillGrid(gridWithLetters); gameService.SetNewGame(gridWithLetters); if (haveGameActive) OnGameReset?.Invoke(); Logger.Log("-- New Game --"); haveGameActive = true; }
public void Add_Word_Successfully_In_Zero_Position() { // Given var grid = new Grid <char>(10, 10); wordsRepository.Add(new Word("Uno")); ramdomPositionGenerator.SetMaxPosition(new Position(10, 10)); ramdomPositionGenerator.SetReturnPosition(new Position(0, 0)); // When var result = addWordsService.AddWords(grid, wordsRepository.GetAll()); // Then PrintGrid.Print(result); Assert.IsTrue(result.GetLeterInPosition(0, 0) == 'U'); Assert.IsTrue(result.GetLeterInPosition(1, 0) == 'n'); Assert.IsTrue(result.GetLeterInPosition(2, 0) == 'o'); }
public async Task <Unit> Handle(WriteShortestPathToFileCommand request, CancellationToken cancellationToken) { var words = (await _wordsRepository.GetAll()) .ToList(); _logger.LogDebug($"Find {words.Count} words"); var start = new Word(request.Start); var end = new Word(request.End); _logger.LogDebug($"Build tree node"); var wordsTree = _treeNodeBuilder.BuildTree(start, end, words); _logger.LogDebug($"search shortest path"); var shortestPath = await _searchWordsPath .GetShortestPath(start, end, wordsTree); _logger.LogDebug($"write file output"); _documentListWriter.WriteText(shortestPath); return(Unit.Value); }