Esempio n. 1
0
        private static void RecordPlayerShot(PlayerInfoModel activePlayer, PlayerInfoModel opponent)
        {
            bool   isValidShot = false;
            string row         = "";
            int    column      = 0;

            do
            {
                string shot = AskForShot(activePlayer); // Asks for shot (Syntax example : B2)

                bool isSyntaxOk = GameLogic.ValidateSyntax(shot);

                if (isSyntaxOk == false)
                {
                    Color("DarkRed");
                    Console.WriteLine("Invalid syntax. Use e.g. 'B2'. Try again.");
                    Color("White");
                    continue;
                }

                (row, column) = GameLogic.SplitShotIntoRowAndColumn(shot);       // Determine row and column (split)

                isValidShot = GameLogic.ValidateShot(activePlayer, row, column); // Determine if valid shot or not
                if (isValidShot == false)
                {
                    Color("DarkRed");
                    Console.WriteLine("You already placed a shot here. Try again.");
                    Color("White");
                }
            } while (isValidShot == false);                                    // Go to beginning, if not valid shot

            bool isAHit = GameLogic.IdentifyShotResult(opponent, row, column); // Determine result - hit or miss

            if (isAHit == true)
            {
                DisplayHitMessage();
            }
            else
            {
                DisplayMissMessage();
            }

            GameLogic.AdjustShotGridStatus(activePlayer, row, column, isAHit);
            //GameLogic.MarkShotResult(activePlayer, row, column, IsAHit); // Record results
        }