static void Main(string[] args) { KingSurvival game = new KingSurvival(); int hodoveNaCarq = 0; bool isKingsTurn = true; while (true) //dokato igrata ne svyrshi - vyrti cikyla { if (game.KingWon()) { Console.WriteLine("King won in {0} turns", hodoveNaCarq); break; } else if (game.KingLost()) { Console.WriteLine("King lost in {0} turns", hodoveNaCarq); break; } else { Console.WriteLine(); game.PrintBoard(); if (isKingsTurn) { bool kingMoved = false; while (!kingMoved) { Console.Write("King's turn: "); string command = Console.ReadLine(); kingMoved = game.MoveKingIfPossible(command); if (!kingMoved) { Console.WriteLine("Illegal move!"); } } isKingsTurn = false; hodoveNaCarq++; } else { bool pawnMoved = false; while (!pawnMoved) { Console.Write("Pawns' turn: "); string command = Console.ReadLine(); pawnMoved = game.MovePawnIfPossible(command); if (!pawnMoved) { Console.WriteLine("Illegal move!"); } } isKingsTurn = true; } } } }
static void Main(string[] args) { KingSurvival game = new KingSurvival(); int hodoveNaCarq = 0; bool isKingsTurn = true; while (true) //dokato igrata ne svyrshi - vyrti cikyla { if (game.KingWon()) { Console.WriteLine("King won in {0} turns", hodoveNaCarq);break; } else if (game.KingLost()) { Console.WriteLine("King lost in {0} turns", hodoveNaCarq); break; } else { Console.WriteLine(); game.PrintBoard(); if (isKingsTurn) { bool kingMoved = false; while (!kingMoved) { Console.Write("King's turn: "); string command = Console.ReadLine(); kingMoved = game.MoveKingIfPossible(command); if (!kingMoved) { Console.WriteLine("Illegal move!"); } } isKingsTurn = false; hodoveNaCarq++; } else { bool pawnMoved = false; while (!pawnMoved) { Console.Write("Pawns' turn: "); string command = Console.ReadLine(); pawnMoved = game.MovePawnIfPossible(command); if (!pawnMoved) { Console.WriteLine("Illegal move!"); } } isKingsTurn = true; } } } }