/** * Pays out all players any accrued coins and records all player minutes and coin awards to this * game's activity log, potentially recalculating its payout factor as a result. */ protected void flushAllPlayers() { int totalSecs = 0, totalTasks = 0, totalAward = 0; // pay out flow to all players, total up our coin awards and play time for (Player player : _players.values()) { final int playerSecs = player.timeAccrued + player.getPlayTime(now()); totalSecs += playerSecs; totalTasks += player.tasksCompleted; if (player.coinsAccrued > 0) { final UserAction action = UserAction.playedGame( player.playerObject.getMemberId(), _content.game.name, _gameId, playerSecs); _gameReg.awardCoins(_gameId, action, player.coinsAccrued); totalAward += player.coinsAccrued; } player.reset(); } // if we actually awarded coins or accrued time, update our game metrics if (totalAward > 0 || totalSecs > 0) { final int totalMins = Math.round(totalSecs / 60f); _gameReg.updateGameMetrics( _content.metrics, GameGameRegistry.MetricType.AVRG, totalMins, totalTasks, totalAward); } }
/** * Resets the game * * @param difficulty Which difficulty it should be reset to. */ public void reset(Difficulty difficulty) { bulletManager.clearAllBullets(); enemyManager.clearAllEnemies(); pickupManager.clearAllPickups(); enemySpawner = new EnemySpawner(new RandomWaveList(difficulty)); enemySpawner.addPropertyChangeListener(enemyManager); player.reset(); player.giveWeapon(new BasicWeapon(bulletManager)); }
@Override public void update(GameManager manager) { if (manager.allPlayersReady()) { for (Player players : manager.players.values()) { players.reset(); } manager.newGame(); manager.state = GameManagerState.WAIT_FOR_PLAYER_READY; } }
public void reset() // resets game prior to a new round { myDeck = new ScumDeck(); myDeck.clear(); for (Player p : players) // resets all the players p.reset(); for (int x = 0; x < numberOfDecks; x++) { ScumDeck temp = new ScumDeck(); for (ScumCard c : temp.getDeck()) myDeck.add(c); // creates a new deck } myDeck.shuffle(); // shuffles the deck deal(); // deals out the deck evenly as possible clearDiscard(); // clears the discard pile lastMove.clear(); done = false; // the game has started }
/** * Pays accumulated coins to the supplied player and potentially recalculates our payout factor if * this player's payout consumes the last of our coin budget. */ protected void payoutPlayer(final Player player, boolean flushing) { final int memberId = player.playerObject.getMemberId(); final int playerSecs = player.timeAccrued + player.getPlayTime(now()); final int playerMins = Math.round(playerSecs / 60f); if (!flushing) { // TODO: Get this into EventLogDelegate, or write a AVRG-specific one? if (player.playerObject.visitorInfo == null) { log.warning("No VisitorInfo for AVRG player!", "gameId", _gameId, "memberId", memberId); } _eventLog.avrgLeft( memberId, _gameId, playerSecs, _plmgr.getPlaceObject().occupantInfo.size(), player.playerObject.getVisitorId()); } // if they accrued any coins (and are not a guest), do the actual coin awarding if (player.coinsAccrued > 0) { final UserAction action = UserAction.playedGame(memberId, _content.game.name, _gameId, playerSecs); _gameReg.awardCoins(_gameId, action, player.coinsAccrued); } // note time played and coins awarded for coin payout factor calculation purposes if (playerMins > 0 || player.coinsAccrued > 0) { _gameReg.updateGameMetrics( _content.metrics, GameGameRegistry.MetricType.AVRG, playerMins, player.tasksCompleted, player.coinsAccrued); } // reset their accumulated coins and whatnot player.reset(); }
public void resetGame() { System.out.println("xxx_ResetGame_xxx"); winer.reset(); server.reset(); reciever.reset(); }