private static void Move(string command) { try { int x = Int32.Parse(command[0].ToString()); int y = Int32.Parse(command[1].ToString()); CellContent content = (_currentUser == UserType.UserFirst) ? CellContent.Cross : CellContent.Zero; CellDto cell = new CellDto(x, y, content); CellView cellView = new CellView(cell); cells[y][x] = cellView; for (int i = 0; i < cells.Length; i++) { string res = ""; string symbol; CellView[] row = cells[i]; for (int j = 0; j < row.Count(); j++) { CellContent cellContent = row[j].CellType; symbol = "-"; if (cellContent == CellContent.Cross) { symbol = "X"; } if (cellContent == CellContent.Zero) { symbol = "0"; } res += symbol; } Console.WriteLine(res); } Console.WriteLine("************************** - ход совершен"); _currentUser = (_currentUser == UserType.UserSecond) ? UserType.UserFirst : UserType.UserSecond; } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private static void StartNewGame(UserType user) { if (model != null && model.GameStatus == GameStatuses.Game) { Utils.Log("Введена не корректная последовательность команд, игра не начата"); return; } _currentUser = (user == UserType.UserFirst) ? UserType.UserSecond : UserType.UserFirst; cells = new CellView[rowsCount][]; for (int row = 0; row < rowsCount; row++) { cells[row] = new CellView[colsCount]; for (int column = 0; column < colsCount; column++) { cells[row][column] = new CellView(row, column, CellContent.Empty); } } model = new Model.ModelTicTacToe(3, 3, user, 3); //model.ChangeStatusEvent += OnChangeGameStatus; }