コード例 #1
0
 public static void ResetDisplayBoard()
 {
     CrosswordBoardMain.Instance().ResetBoard();
     CrosswordBoardPlacedWord.Instance().ResetBoard();
     CrosswordViewModel.Instance().AssignCrosswordDisplayBoard(CrosswordBoardMain.Instance().Board, CrosswordBoardPlacedWord.Instance().Board);
     CrosswordViewModel.Instance().Definitions.Clear();
 }
コード例 #2
0
        public static CrosswordBoardPlacedWord Instance()
        {
            if (_instance == null)
            {
                _instance = new CrosswordBoardPlacedWord();
            }

            return(_instance);
        }
コード例 #3
0
        public static void SetupCrosswordPuzzle(CrosswordViewModel crosswordViewModel, CrosswordBoardMain crosswordBoardMain, PlacementManager placementManager)
        {
            placementManager.PlaceAllWords();

            crosswordBoardMain.DebugWriteLineBoard(crosswordBoardMain.Board);

            crosswordViewModel.AssignCrosswordDisplayBoard(crosswordBoardMain.Board, CrosswordBoardPlacedWord.Instance().Board);

            crosswordViewModel.AssignDefinitionList(placementManager.Definitions);

            placementManager.ApplyDefinitionNumbersToDisplayBoard(placementManager.GroupedWords, crosswordViewModel.DisplayBoard);
        }
コード例 #4
0
        public MainController()
        {
            // Grid size 10, MinWordsPlaced = 12
            // Grid size 12, MinWordsPlaced = 15
            // Grid size 14, MinWordsPlaced = 21
            // Grid size 16, MinWordsPlaced = 24

            GridSize       = 12;
            MinWordsPlaced = 15;


            CrosswordBoardMain.Instance().InitializeBoard(GridSize, GridSize, Char.MinValue);
            CrosswordBoardPlacedWord.Instance().InitializeBoard(GridSize, GridSize);
            CrosswordViewModel.Instance().InitializeDisplayBoard(GridSize, GridSize);
        }
コード例 #5
0
        // Keeps trying to solve board until the _minWordsPlaced count is reached
        public void PlaceAllWords()
        {
            PlacedWords.Clear();
            _usedWords.Clear();
            _wordsPlaced = 0;
            _count       = 0;

            var solved = false;

            while (solved == false)
            {
                PlaceWords();

                if (_wordsPlaced >= MainController.MinWordsPlaced)
                {
                    solved = true;
                    break;
                }

                // Reset the board and start again if min word count in not met
                if (!solved)
                {
                    CrosswordBoardMain.Instance().ResetBoard();

                    _wordsPlaced = 0;
                    _usedWords   = new List <string>();
                    solved       = false;
                }
            }

            // Assign placed words location to each cell with a character (used for highlighting words)
            CrosswordBoardPlacedWord.Instance().AssignPlacedWords(PlacedWords);

            // Sort and find definition of placed words then apply formatting
            var SortedPlacedWords = _definitionSortingTools.SortPlacedWordsByPosition(PlacedWords);

            GroupedWords = _definitionSortingTools.GroupPlacedWords(SortedPlacedWords);

            var definitions = _definitionSortingTools.ReturnDefinitionArray(GroupedWords);

            Definitions = _definitionSortingTools.ApplyDefinitionHeadingFormatting(definitions);
        }