private void Form1_MouseDown(object sender, MouseEventArgs e) { // game.CheckWinner(); pis piece = game.PlaceAPis(e.X, e.Y); if (piece != null) { this.Controls.Add(piece); //game.CheckWinner(); //每次增加一棋,就檢查有沒有人贏 //game.CheckWinner(); if (game.Winner == PisType_Enum.BLACK) { MessageBox.Show("黑色大成功"); Controls.Clear(); game.RestartGame(); } else if (game.Winner == PisType_Enum.WHITE) { MessageBox.Show("白色大成功"); Controls.Clear(); game.RestartGame(); } } }
public pis PlaceAPis(int x, int y) //Method Board 的 PlaceAPis { // return board.PlaceAPis(x, y); pis piece = board.PlaceAPis(x, y, currentPlayer_Enum); if (piece != null) { //檢查是否現在下棋的人獲勝 CheckWinner(); //交換使用者 if (currentPlayer_Enum == PisType_Enum.BLACK) { currentPlayer_Enum = PisType_Enum.WHITE; } else { currentPlayer_Enum = PisType_Enum.BLACK; } return(piece); } return(null); }