add intermission after judge leaves game. it looks weird, and acts a bit oddly, especially for the previous judge: they can pick a winner but it won't let them choose on the server. still I think this is better than the old way of just starting the next round immediately.
This commit is contained in:
parent
27a58856d8
commit
95fe597184
|
@ -761,10 +761,16 @@ cah.Game.prototype.reshuffle = function(deck) {
|
|||
|
||||
/**
|
||||
* Notify the player that the judge has left the game and cards are being returned to hands.
|
||||
*
|
||||
* @param {object}
|
||||
* data Event data from the server.
|
||||
*/
|
||||
cah.Game.prototype.judgeLeft = function() {
|
||||
cah.Game.prototype.judgeLeft = function(data) {
|
||||
cah.log
|
||||
.status("The judge has left the game. Cards played this round are being returned to hands.");
|
||||
cah.log.status("The next round will begin in "
|
||||
+ (data[cah.$.LongPollResponse.INTERMISSION] / 1000) + " seconds.");
|
||||
cah.log.status("(Displayed state will look weird until the next round.)");
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -125,7 +125,7 @@ cah.longpoll.EventHandlers[cah.$.LongPollEvent.GAME_BLACK_RESHUFFLE] = function(
|
|||
};
|
||||
|
||||
cah.longpoll.EventHandlers[cah.$.LongPollEvent.GAME_JUDGE_LEFT] = function(data) {
|
||||
cah.longpoll.EventHandlers.__gameEvent(data, cah.Game.prototype.judgeLeft, "", "judge left");
|
||||
cah.longpoll.EventHandlers.__gameEvent(data, cah.Game.prototype.judgeLeft, data, "judge left");
|
||||
};
|
||||
|
||||
cah.longpoll.EventHandlers[cah.$.LongPollEvent.GAME_OPTIONS_CHANGED] = function(data) {
|
||||
|
|
|
@ -200,6 +200,7 @@ public class Game {
|
|||
if (getJudge() == player && (state == GameState.PLAYING || state == GameState.JUDGING)) {
|
||||
data = getEventMap();
|
||||
data.put(LongPollResponse.EVENT, LongPollEvent.GAME_JUDGE_LEFT.toString());
|
||||
data.put(LongPollResponse.INTERMISSION, ROUND_INTERMISSION);
|
||||
broadcastToPlayers(MessageType.GAME_EVENT, data);
|
||||
synchronized (playedCards) {
|
||||
for (final Player p : playedCards.playedPlayers()) {
|
||||
|
@ -250,8 +251,17 @@ public class Game {
|
|||
if (players.size() < 3 && state != GameState.LOBBY) {
|
||||
resetState(true);
|
||||
} else if (wasJudge) {
|
||||
synchronized (nextRoundTimerLock) {
|
||||
nextRoundTimer = new Timer();
|
||||
final TimerTask task = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
startNextRound();
|
||||
}
|
||||
};
|
||||
nextRoundTimer.schedule(task, ROUND_INTERMISSION);
|
||||
}
|
||||
}
|
||||
return players.size() == 0;
|
||||
}
|
||||
}
|
||||
|
@ -627,6 +637,13 @@ public class Game {
|
|||
* state.
|
||||
*/
|
||||
private void startNextRound() {
|
||||
synchronized (nextRoundTimerLock) {
|
||||
if (nextRoundTimer != null) {
|
||||
nextRoundTimer.cancel();
|
||||
nextRoundTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (whiteDeck) {
|
||||
synchronized (playedCards) {
|
||||
for (final List<WhiteCard> cards : playedCards.cards()) {
|
||||
|
|
Loading…
Reference in New Issue