private static bool SetShips() { bool loop = true; ConsoleKeyInfo pressedKey; foreach (var ship in game.ShipsReq) { for (int i = 0; i < ship.BoatCount; i++) { PostLastAction($"Place your {ship.BoatName} of {ship.BoatLength} length"); loop = true; int sX = -1; int sY = -1; int eX = -1; int eY = -1; do { if (hasOutcome) { pressedKey = Selector(); } else { pressedKey = !game.Turn ? PLAYER1_CONTROLLER() : PLAYER2_CONTROLLER(); } //if (pressedKey.Modifiers == CTRL) //{ // if (pressedKey.Key == EXIT) // loop = false; // //if (pressedKey.Key == UNDO) // // UpdateGameState(false); // if (pressedKey.Key == SAVE) // SaveGame(); //} /*else */ if (pressedKey.Key == ENTER || pressedKey.Key == ENTER_ALT) { if (sX == -1) { sX = (Console.CursorTop - firstCellRow) / 2; sY = (Console.CursorLeft - firstCellCol) / (ROW_SEP.Length + CROSS_POINT.Length); } else if (eX == -1) { eX = (Console.CursorTop - firstCellRow) / 2; eY = (Console.CursorLeft - firstCellCol) / (ROW_SEP.Length + CROSS_POINT.Length); if ((eX == sX || eY == sY) && Math.Abs(sX - eX) + 1 + Math.Abs(sY - eY) == ship.BoatLength) { if (game.PlaceShip(sX, sY, eX, eY)) { loop = false; } else { sX = -1; sY = -1; eX = -1; eY = -1; } int row = Console.CursorTop; int col = Console.CursorLeft; Console.SetCursorPosition(0, BoardRow); DrawBoard(); Console.SetCursorPosition(col, row); } else { sX = -1; sY = -1; eX = -1; eY = -1; } } } } while (loop); } } game.Turn = !game.Turn; return(true); }