private void play(Position clicked) { disableBoard(); List <Position> posFilp = Board.play(clicked, board); projection[clicked.row, clicked.column].BackColor = getColor(player); foreach (Position p in posFilp) { projection[p.row, p.column].BackColor = getColor(player); } Board.pieces nextPlayer = Board.getCurrentPlayer(board); if (player == nextPlayer) { MessageBox.Show("skip the turn"); } player = nextPlayer; if (player == Board.pieces.blank) { finish(); } else { int[] score = Board.count(board); num1.Text = string.Format("{0:D}", score[0]); num2.Text = string.Format("{0:D}", score[1]); enableBoard(); turnAI(); } }
public Color getColor(Board.pieces player) { if (player == Board.pieces.one) { return(Color.LightPink); } else if (player == Board.pieces.two) { return(Color.LightGreen); } else { return(Color.White); } }
public void finish()//游戏结束 { player = Board.pieces.blank; int one, two; int[] temp = Board.count(board); one = temp[0]; two = temp[1]; num1.Text = string.Format("{0:D}", one); num2.Text = string.Format("{0:D}", two); if (one > two) { MessageBox.Show("player one win"); } else if (one < two) { MessageBox.Show("player two win"); } else { MessageBox.Show("0"); } }