|
|
@ -19,11 +19,15 @@ public class TicTacToeGame extends JPanel { |
|
|
|
public cell[] field; |
|
|
|
public int playerID = 1; |
|
|
|
public int turns = 0; |
|
|
|
public Scoreboard scoreboard; |
|
|
|
|
|
|
|
public TicTacToeGame() { |
|
|
|
this.setSize(width, height); |
|
|
|
setLayout(null); |
|
|
|
initField(); |
|
|
|
scoreboard = new Scoreboard(maxPlayers); |
|
|
|
scoreboard.setBounds(200, 100, 200, 50); |
|
|
|
add(scoreboard); |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
@ -74,12 +78,14 @@ public class TicTacToeGame extends JPanel { |
|
|
|
public void endTurn() { |
|
|
|
if(checkPlayfield() != 0) { |
|
|
|
JOptionPane.showMessageDialog(getParent(),"Player: " + playerID + " Wins!"); |
|
|
|
scoreboard.addPoint(playerID); |
|
|
|
resetGame(); |
|
|
|
} |
|
|
|
|
|
|
|
turns++; |
|
|
|
if(turns >= playFieldSize) { |
|
|
|
JOptionPane.showMessageDialog(getParent(),"Draw!"); |
|
|
|
scoreboard.addPoint(playerID); |
|
|
|
resetGame(); |
|
|
|
} |
|
|
|
|
|
|
|