public void NewField() //Показывает сетку { CheckLuckyCombination checkWin = new CheckLuckyCombination(); NumberVision numberVision = new NumberVision(); horizontalLine(2, 0); horizontalLine(4, 0); verticalLine(1, 2); verticalLine(1, 4); numberVision.SymInField(1, 1); numberVision.SymInField(1, 3); numberVision.SymInField(1, 5); }
public bool SwapNumAndChar(char sym) //Меняем позицию на число { int inputNumber = inputNumUser(sym); numPosition.Remove(inputNumber); numPosition.Add(inputNumber, sym); CheckLuckyCombination checkWin = new CheckLuckyCombination(); if (checkWin.WinLine(sym) == true) { return(true); } return(false); }
static void Main(string[] args) { CheckLuckyCombination checkWin = new CheckLuckyCombination(); FieldPaint paint = new FieldPaint(); NumberVision numVision = new NumberVision(); numVision.StreamInArray(); //Ввод данных игроков Console.WriteLine("Введите имя 1 игрока и нажмите Enter:"); string firstPlayerName = Console.ReadLine(); Console.WriteLine("Введите имя 2 игрока и нажмите Enter:"); string secondPlayerName = Console.ReadLine(); Console.Clear(); int count = 0; bool x = false; bool y = false; int id = 0; while (true) { paint.NewField(); Console.WriteLine($"Ходит {firstPlayerName}, введите число ячейке"); x = numVision.SwapNumAndChar('X'); count++; Console.Clear(); if (x == true) //Выход при выигрыше { id += 1; break; } if (count == 9) { break; //выход если все клеточки заняты } paint.NewField(); Console.WriteLine($"Ходит {secondPlayerName}, введите число ячейке"); y = numVision.SwapNumAndChar('O'); count++; Console.Clear(); if (y == true) //Выход при выигрыше { id += 2; break; } } if (id == 1) { Console.WriteLine($"Поздравляем, {firstPlayerName} выиграл!"); } if (id == 2) { Console.WriteLine($"Поздравляем, {secondPlayerName} выиграл!"); } if (id == 0) { Console.WriteLine("Все проиграли"); } }