import java.io.*; import java.awt.Color; class WaitThread extends java.lang.Thread { mancala board; WaitThread(mancala board) { super("WaitThread"); setPriority(getPriority()-1); this.board = board; } public void run() { String s, words[]; while(true) { if(!board.reading && board.readReady()) { words = board.explode(s = board.readLine(), " "); if(words[0].equals("?") && words[1].equalsIgnoreCase("PLAY")) { MsgBox mb = new MsgBox(words[2]+" wants to play. Accept?","Game Request",MsgBox.YES+MsgBox.NO); mb.show(); if(mb.result.equalsIgnoreCase("Yes")) board.sendLine("+ Game accepted."); else board.sendLine("- Game rejected."); } if(words[1].equalsIgnoreCase("RULESET")) { if(!words[2].equalsIgnoreCase("Midgard")) board.sendLine("- I only know how to play Midgard Rules."); else board.sendLine("+ Midgard Rules!"); board.leftOk = words[3].equals("1"); } if(s.equalsIgnoreCase("! PLAY")) { board.sendLine("+ Cool!"); board.inGame = true; board.led.setOn(true); board.userButton.setEnabled(false); board.userButton.setVisible(false); // board.resignButton.setEnabled(true); board.resignButton.setVisible(true); board.serverThread = new GameThread(board); board.serverThread.start(); stop(); } } else { try { sleep(500); } catch(Exception e) { System.err.println("Exception "+e);return; } } } } }