void roll() { int timeToRoll = rng.generate(30, 40); ballPosition = ROLLING; ballStartedRolling = timer.getTimeInMillis(); timer.callBack( timeToRoll * 1000, new Runnable() { public void run() { stopRolling(); } }); }
public void placeBet(Player p, Field fields[], int value) throws NotEnoughChipsException, TooManyChipsException, TableFullException, NoMoreBetsException { if (currentChipsOnTable() + value > maxChipsOnTable) throw new TooManyChipsException(); if (!players.keySet().contains(p) && players.size() == MAX_PLAYERS) throw new TableFullException(); if (isBallRolling() && (timer.getTimeInMillis() - ballStartedRolling > CUT_OFF_TIME)) throw new NoMoreBetsException(); if (!walletService.isAvailable(p, value)) throw new NotEnoughChipsException(); walletService.adjustBalance(p, -1 * value); players.put(p, Colour.values()[players.size()]); for (Field field : fields) { if (betsByFields.get(field) == null) { betsByFields.put(field, new ArrayList<Bet>()); } betsByFields.get(field).add(new Bet(p, value, getBetType(fields))); } waitingForPlayersToComplete.add(p); }