コード例 #1
0
ファイル: UserSelection.cs プロジェクト: kochsj/Minesweeper
        private static string MarkerMode()
        {
            bool isValid = false;

            while (true)
            {
                Console.WriteLine("================ MARKER MODE ===================");
                Console.WriteLine("Enter tile to mark with '?' (examples: 3d or 9a)");
                Console.WriteLine("Enter 'mark' again to exit marker mode.");

                string response = Console.ReadLine();

                ClearCurrentConsoleLine(Console.CursorTop, 4);


                if (response.ToLower() == "mark")
                {
                    return("n/a");
                }

                isValid = ValidateTileSelection(response);

                if (isValid == true & response.Length == 3)
                {
                    int tileID = TranslateTileChoice.Translate(response, 3);
                    MarkTile(tileID);
                }
                else
                {
                    int tileID = TranslateTileChoice.Translate(response, 2);
                    MarkTile(tileID);
                }
            }
        }
コード例 #2
0
        public static Dictionary <int, string> SquareCheckHandler(string tileChoice)
        {
            int tileToChange = 0;

            if (tileChoice.Length == 3)
            {
                tileToChange = TranslateTileChoice.Translate(tileChoice, 3);
            }
            else
            {
                tileToChange = TranslateTileChoice.Translate(tileChoice, 2);
            }

            var isBomb = CheckIfTileSelectionIsBomb(tileToChange);

            if (isBomb == true)
            {
                // end the game
                var bombTile = new Dictionary <int, string>();
                bombTile.Add(tileToChange, Tiles.BombTile());
                return(bombTile);
            }

            var adjacentTiles = CheckAdjacentTilesForBombs(tileToChange);

            return(adjacentTiles);
        }