mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
* Fixed a bug that looked at cards were sometimes not shown (fixes #266 and fixes #264). Removed unused code.
This commit is contained in:
parent
86a6e75378
commit
ac23750310
9 changed files with 40 additions and 75 deletions
|
|
@ -138,23 +138,20 @@ public class GameController implements GameCallback {
|
|||
ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.ORANGE, event.getWithTime());
|
||||
logger.debug(game.getId() + " " + event.getMessage());
|
||||
break;
|
||||
case REVEAL:
|
||||
revealCards(event.getMessage(), event.getCards());
|
||||
break;
|
||||
case ERROR:
|
||||
error(event.getMessage(), event.getException());
|
||||
break;
|
||||
case INIT_TIMER:
|
||||
final UUID initPlayerId = event.getPlayerId();
|
||||
if (initPlayerId == null) {
|
||||
throw new IllegalStateException("INIT_TIMER: playerId can't be null");
|
||||
throw new MageException("INIT_TIMER: playerId can't be null");
|
||||
}
|
||||
createPlayerTimer(event.getPlayerId(), game.getPriorityTime());
|
||||
break;
|
||||
case RESUME_TIMER:
|
||||
playerId = event.getPlayerId();
|
||||
if (playerId == null) {
|
||||
throw new IllegalStateException("RESUME_TIMER: playerId can't be null");
|
||||
throw new MageException("RESUME_TIMER: playerId can't be null");
|
||||
}
|
||||
timer = timers.get(playerId);
|
||||
if (timer == null) {
|
||||
|
|
@ -162,7 +159,7 @@ public class GameController implements GameCallback {
|
|||
if (player != null) {
|
||||
timer = createPlayerTimer(event.getPlayerId(), player.getPriorityTimeLeft());
|
||||
} else {
|
||||
throw new IllegalStateException("RESUME_TIMER: player can't be null");
|
||||
throw new MageException("RESUME_TIMER: player can't be null");
|
||||
}
|
||||
}
|
||||
timer.resume();
|
||||
|
|
@ -170,11 +167,11 @@ public class GameController implements GameCallback {
|
|||
case PAUSE_TIMER:
|
||||
playerId = event.getPlayerId();
|
||||
if (playerId == null) {
|
||||
throw new IllegalStateException("PAUSE_TIMER: playerId can't be null");
|
||||
throw new MageException("PAUSE_TIMER: playerId can't be null");
|
||||
}
|
||||
timer = timers.get(playerId);
|
||||
if (timer == null) {
|
||||
throw new IllegalStateException("PAUSE_TIMER: couldn't find timer for player: " + playerId);
|
||||
throw new MageException("PAUSE_TIMER: couldn't find timer for player: " + playerId);
|
||||
}
|
||||
timer.pause();
|
||||
break;
|
||||
|
|
@ -225,9 +222,6 @@ public class GameController implements GameCallback {
|
|||
case AMOUNT:
|
||||
amount(event.getPlayerId(), event.getMessage(), event.getMin(), event.getMax());
|
||||
break;
|
||||
case LOOK:
|
||||
lookAtCards(event.getPlayerId(), event.getMessage(), event.getCards());
|
||||
break;
|
||||
case PERSONAL_MESSAGE:
|
||||
informPersonal(event.getPlayerId(), event.getMessage());
|
||||
break;
|
||||
|
|
@ -592,21 +586,6 @@ public class GameController implements GameCallback {
|
|||
});
|
||||
}
|
||||
|
||||
private synchronized void revealCards(String name, Cards cards) throws MageException {
|
||||
for (GameSession session: gameSessions.values()) {
|
||||
session.revealCards(name, new CardsView(cards.getCards(game)));
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void lookAtCards(UUID playerId, final String name, final Cards cards) throws MageException {
|
||||
perform(playerId, new Command() {
|
||||
@Override
|
||||
public void execute(UUID playerId) {
|
||||
getGameSession(playerId).revealCards(name, new CardsView(cards.getCards(game)));
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
private void informOthers(UUID playerId) throws MageException {
|
||||
StringBuilder message = new StringBuilder();
|
||||
if (game.getStep() != null) {
|
||||
|
|
|
|||
|
|
@ -160,15 +160,6 @@ public class GameSession extends GameWatcher {
|
|||
}
|
||||
}
|
||||
|
||||
public void revealCards(final String name, final CardsView cardView) {
|
||||
if (!killed) {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null) {
|
||||
user.fireCallback(new ClientCallback("gameReveal", game.getId(), new GameClientMessage(cardView, name)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void setupTimeout() {
|
||||
if (!useTimeout) {
|
||||
return;
|
||||
|
|
@ -234,7 +225,7 @@ public class GameSession extends GameWatcher {
|
|||
list.add(new LookedAtView(entry.getKey(), entry.getValue(), game));
|
||||
}
|
||||
gameView.setLookedAt(list);
|
||||
game.getState().clearLookedAt();
|
||||
game.getState().clearLookedAt(playerId);
|
||||
|
||||
return gameView;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue