Beispiel #1
0
        public static Pos ReadMove(string input)
        {
            if (input.Contains("X") || input.Contains("x"))
            {
                Console.WriteLine("\n Termination character X retrieved, ending game!");
                Environment.Exit(0);
            }

            var cord = new Pos();

            foreach (var character in input)
            {
                if (char.IsLetter(character))
                {
                    cord.X = Pos.ConvertLetter(character);
                }

                if (char.IsDigit(character))
                {
                    var str = character.ToString();
                    cord.Y = int.Parse(str);
                }
            }

            return(cord);
        }
Beispiel #2
0
        public char LoadSaveGame(string saveGame)
        {
            var player = Constants.Black;
            var move   = new Pos();

            foreach (var character in saveGame)
            {
                if (char.IsLetter(character))
                {
                    move.X = Pos.ConvertLetter(character);
                }
                else if (char.IsDigit(character))
                {
                    move.Y = Pos.ConvertFromAsciiDigit(character);
                }
                else
                {
                    MakeMove(move, player);
                    PlacePiece(move, player);

                    player = GetOtherPlayer(player);
                }
            }

            return(player);
        }
Beispiel #3
0
        public static char LoadGameLog(char[] board, string gameLogLine)
        {
            var player = Constants.Black;
            var coord  = new Pos();

            foreach (var character in gameLogLine)
            {
                if (char.IsLetter(character))
                {
                    coord.X = Pos.ConvertLetter(character);
                }
                else if (char.IsDigit(character))
                {
                    coord.Y = Pos.ConvertDigit(character);
                }
                else
                {
                    InputHandler.MakeMove(board, coord, player);
                    InputHandler.PlacePiece(board, coord, player);

                    player = player == Constants.Black ? Constants.White : Constants.Black;
                }
            }

            return(player);
        }