private void ExecuteTestAction() { _canvasContainer.ClearCanvas(CanvasType.Result); NetworkTester networkTester = new NetworkTester(_network); var inputData = PreaperNetworkInput(CanvasType.Test); GameMark gameMark = networkTester.Test(inputData); if (gameMark == GameMark.Circle) { _painterCommand = new DrawCircleCommand(_pen); _canvasContainer.DrawOnCanvas(CanvasType.Result, _painterCommand); GameInfo("Circle"); } if (gameMark == GameMark.Cross) { _painterCommand = new DrawCrossCommand(_pen, _crossDesignator); _canvasContainer.DrawOnCanvas(CanvasType.Result, _painterCommand); GameInfo("Cross"); } else { GameInfo("Blank"); } UpdateCanvasView(CanvasType.Result); }
public ComputerPlayer(GameUtil gameUtil, List<CanvasType> canvasTypes) { _gameUtil = gameUtil; _canvasTypes = canvasTypes; _state = new int[9]; _computerMark = GameMark.Cross; }
public void Mark(GameMark mark, int x, int y) { try { _client.Mark(mark, x, y); } catch (Exception e) { Trace.TraceError("Error: {0}", e.Message); } }
public void SetTurn(GameMark symbol) { _turnMark = symbol; if (_playerMark == symbol) { lblYourTurn.Show(); } else { lblYourTurn.Hide(); } }
private void NextTurn() { switch (Turn) { case GameMark.X: Turn = GameMark.O; return; case GameMark.O: Turn = GameMark.X; return; } }
public void SetComputerMark(GameMark humanMark) { switch (humanMark) { case GameMark.Cross: _computerPlayer.ComputerMark = GameMark.Circle; break; default: _computerPlayer.ComputerMark = GameMark.Cross; break; } }
public static GameState ToState(this GameMark mark) { switch (mark) { case GameMark.X: return(GameState.WinX); case GameMark.O: return(GameState.WinO); default: throw new ArgumentOutOfRangeException($"Unexpect value {mark}"); } }
public void Next() { switch (_currentMark) { case GameMark.X: _currentMark = GameMark.O; break; case GameMark.O: _currentMark = GameMark.X; break; } GameEvent?.Invoke(this, EventArgs.Empty); }
public IPainterCommand GetPainter(GameMark gameMark) { switch (gameMark) { case GameMark.Cross: return(new DrawCrossCommand(_pen, _crossDesignator)); case GameMark.Circle: return(new DrawCircleCommand(_pen)); case GameMark.Blank: default: return(new NullObjectCommand()); } }
public void Mark(GameMark playerMark, int x, int y) { if (playerMark != _turn) { _callback[playerMark]?.Progress("It isn't your turn"); return; } if (_board.Mark(_turn, x, y)) { foreach (var cb in _callback.Values) { cb.UpdateBoard(_board); cb.Winner(_board.Winner()); } NextTurn(); } }
private void NextTurn() { if (_turn == GameMark.X) { _turn = GameMark.O; } else if (_turn == GameMark.O) { _turn = GameMark.X; } else if (_board.Winner() != GameMark.None) { _turn = GameMark.None; } foreach (var cb in _callback.Values) { cb.SetTurn(_turn); } }
public void Winner(GameMark winMark) { _winner = winMark; string message; switch (_winner) { case GameMark.X: MessageBox.Show("Player X Wins!"); break; case GameMark.O: MessageBox.Show("Player O Wins!"); break; case GameMark.Draw: MessageBox.Show("The Game is a Draw. Play again?"); break; } }
public void SetPlayerMark(GameMark mark) { _playerMark = mark; string strMark = ""; switch (mark) { case GameMark.X: strMark = "X"; break; case GameMark.O: strMark = "O"; break; default: strMark = "Error"; break; } lblYourSymbol.Text = "You are: " + strMark; }
public GameSession() { _gameField = new GameField(); _currentMark = GameMark.X; }
public void Restart() { _board.Clear(); Turn = GameMark.X; }
public void UpdateBoard(CanvasType canvasType, GameMark gameMark) { _board[canvasType] = gameMark; }
public bool Mark(GameMark symbol, int x, int y) { switch (x) { case 1: switch (y) { case 1: if (_topLeft == GameMark.None) { _topLeft = symbol; return(true); } return(false); case 2: if (_midLeft == GameMark.None) { _midLeft = symbol; return(true); } return(false); case 3: if (_bottomLeft == GameMark.None) { _bottomLeft = symbol; return(true); } return(false); } return(false); case 2: switch (y) { case 1: if (_topMid == GameMark.None) { _topMid = symbol; return(true); } return(false); case 2: if (_midMid == GameMark.None) { _midMid = symbol; return(true); } return(false); case 3: if (_bottomMid == GameMark.None) { _bottomMid = symbol; return(true); } return(false); } return(false); case 3: switch (y) { case 1: if (_topRight == GameMark.None) { _topRight = symbol; return(true); } return(false); case 2: if (_midRight == GameMark.None) { _midRight = symbol; return(true); } return(false); case 3: if (_bottomRight == GameMark.None) { _bottomRight = symbol; return(true); } return(false); } return(false); default: return(false); } }
public void Clear() { _topLeft = _topMid = _topRight = _midLeft = _midMid = _midRight = _bottomLeft = _bottomMid = _bottomRight = GameMark.None; }
public static char MarkToChar(GameMark mark) { return(mark == GameMark.X ? 'X' : mark == GameMark.O ? 'O' : ' '); }
public void Restart() { _gameField = new GameField(); _currentMark = GameMark.X; GameRestarted?.Invoke(this, EventArgs.Empty); }
public void UpdateBoard(CanvasType canvasType, GameMark gameMark) { _gameBoard.UpdateBoard(canvasType, gameMark); }