예제 #1
0
        private CrozzleGrid NextRecursive(CrozzleGrid aGrid)
        {
            if (aGrid.Counter == 0 && aGrid.Next == false)
            {
                return aGrid;
            }
            else
            {
                aGrid.MoreWords();
            }

            return NextRecursive(aGrid);
        }
예제 #2
0
        private CrozzleGrid Recursive(CrozzleGrid aGrid)
        {
            if(aGrid.Counter == 0)
            {
                return aGrid;
            }
            else
            {
                aGrid.AddWord();
            }

            return Recursive(aGrid);
        }
예제 #3
0
        public string DisplayGrid(CrozzleGrid game)
        {
            char[,] grid = game.Grid;
            string crozzleDisplay = "";
            string style          = "<style> table, td { border: 1px solid black; border-collapse: collapse; } td { width:24px; height:18px; text-align: center; } </style>";

            style += @"<style>
                       .empty { background-color: #777777; }
                       .nonempty { background-color: white; }
                       .border { background-color: black; }
                       </style>";

            crozzleDisplay += @"<!DOCTYPE html><html><head>";
            crozzleDisplay += style;
            crozzleDisplay += @"</head><body>";
            crozzleDisplay += @"<table>";

            for (int i = 0; i < grid.GetLength(0); i++)
            {
                crozzleDisplay += @"<tr>";

                for (int j = 0; j < grid.GetLength(1); j++)
                {
                    if (grid[i, j] == '*')
                    {
                        crozzleDisplay += @"<td hidden class=""border""></td>";
                    }
                    else if (grid[i, j] == '\0')
                    {
                        crozzleDisplay += @"<td class=""empty""></td>";
                    }
                    else
                    {
                        crozzleDisplay += @"<td class=""nonempty"">" + grid[i, j] + @"</td>";
                    }
                }
                crozzleDisplay += @"</tr>";
            }
            crozzleDisplay += @"</table>";

            //crozzleHTML += @"<p>Score = " + game.Score + @"</p>";

            //if (game.Counter == 0)
            //{
            //    crozzleHTML += @"<p>Cannot add any more words.</p>";
            //}

            crozzleDisplay += @"</body></html>";

            return(crozzleDisplay);
        }
예제 #4
0
        private void OpenCrozzle(WordList wList)
        {

            CrozzleGrid aGrid = new CrozzleGrid(wList);
            aGrid.AddFirstWord();
            aGrid.AddWord();

            Recursive(aGrid);
            aGrid.MoreWords();
            NextRecursive(aGrid);
            aGrid.GetScore();
            

            string result = aGrid.DisplayGrid(aGrid);

            wbGameGrid.DocumentText = result;
            lblScore.Text = "Score: " + aGrid.Score;
        }