public boolean startGame() { if (gamestarted == false) { gamestarted = true; // start the game // tell all the distant players to start playing (from ClientSocketAnalyser) game = new OnlineGame(props, players, listeners); game.addGameListener(this); game.setStartingPlayer(Math.abs(random.nextInt() % (players.size()))); game.start(); return true; } else { return false; } }
public void onCreate() { Log.v("CheckService", "starting service"); ogame = new OnlineGame(); super.onCreate(); SharedPreferences settings = getSharedPreferences(Backgammon.PREFS_NAME, 0); String string = settings.getString("onlineGame", ""); ogame.loadFromFile(string); updateTime = settings.getInt("updateTime", 1); Log.v("CheckService", "updateTime: " + updateTime); if (Backgammon.UPDATE_TIMES[updateTime] == 0) { stopservice(); Log.v("CheckService", "updating turned off"); } else { url = OnlineGame.REQURL + "checkgames.php" + ogame.generateParameters(); // updateTime = update; userAgent = OnlineGame.USERAGENT; ns = Context.NOTIFICATION_SERVICE; mNotificationManager = (NotificationManager) getSystemService(ns); startservice(); } }
public void removePlayer(String un) { int n = players.size(); Player p; for (int i = 0; i < n; i++) { p = (Player) players.get(i); if (p.getName().equals(un)) { players.remove(i); if (game != null) game.makeHimQuit(p); break; } } }