mirror of
https://github.com/correl/mage.git
synced 2025-04-01 19:07:57 -09: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
Mage.Server/src/main/java/mage/server/game
Mage/src/mage
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -137,7 +137,6 @@ public interface Game extends MageItem, Serializable {
|
|||
void fireSelectTargetEvent(UUID playerId, String message, List<TriggeredAbility> abilities);
|
||||
void fireSelectTargetEvent(UUID playerId, String message, List<Permanent> perms, boolean required);
|
||||
void fireSelectEvent(UUID playerId, String message);
|
||||
void fireLookAtCardsEvent(UUID playerId, String message, Cards cards);
|
||||
void firePriorityEvent(UUID playerId);
|
||||
void firePlayManaEvent(UUID playerId, String message);
|
||||
void firePlayXManaEvent(UUID playerId, String message);
|
||||
|
|
|
@ -1481,14 +1481,6 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
playerQueryEventSource.target(playerId, message, perms, required);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireLookAtCardsEvent(UUID playerId, String message, Cards cards) {
|
||||
if (simulation) {
|
||||
return;
|
||||
}
|
||||
playerQueryEventSource.target(playerId, message, cards);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireGetAmountEvent(UUID playerId, String message, int min, int max) {
|
||||
if (simulation) {
|
||||
|
@ -1518,7 +1510,6 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
if (simulation) {
|
||||
return;
|
||||
}
|
||||
// state.addMessage(message);
|
||||
fireInformEvent(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,21 +29,35 @@
|
|||
package mage.game;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import mage.constants.Zone;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.*;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.AbilitiesImpl;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.DelayedTriggeredAbilities;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.SpecialActions;
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.abilities.TriggeredAbilities;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.ContinuousEffects;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.choices.Choice;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.combat.Combat;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.command.Command;
|
||||
import mage.game.command.CommandObject;
|
||||
import mage.game.command.Emblem;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Battlefield;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -59,7 +73,6 @@ import mage.util.Copyable;
|
|||
import mage.watchers.Watcher;
|
||||
import mage.watchers.Watchers;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -86,7 +99,6 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
private int turnNum = 1;
|
||||
private boolean gameOver;
|
||||
private boolean paused;
|
||||
// private List<String> messages = new ArrayList<String>();
|
||||
private ContinuousEffects effects;
|
||||
private TriggeredAbilities triggers;
|
||||
private List<TriggeredAbility> triggered = new ArrayList<TriggeredAbility>();
|
||||
|
@ -310,15 +322,15 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
|
||||
public LookedAt getLookedAt(UUID playerId) {
|
||||
if (lookedAt.get(playerId) == null) {
|
||||
LookedAt l = new LookedAt();
|
||||
lookedAt.put(playerId, l);
|
||||
return l;
|
||||
LookedAt lookedAtCards = new LookedAt();
|
||||
lookedAt.put(playerId, lookedAtCards);
|
||||
return lookedAtCards;
|
||||
}
|
||||
return lookedAt.get(playerId);
|
||||
}
|
||||
|
||||
public void clearLookedAt() {
|
||||
lookedAt.clear();
|
||||
public void clearLookedAt(UUID playerId) {
|
||||
lookedAt.remove(playerId);
|
||||
}
|
||||
|
||||
public Turn getTurn() {
|
||||
|
|
|
@ -28,6 +28,12 @@
|
|||
|
||||
package mage.game.events;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.EventObject;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
|
@ -35,9 +41,6 @@ import mage.cards.Card;
|
|||
import mage.cards.Cards;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -45,7 +48,7 @@ import java.util.*;
|
|||
public class PlayerQueryEvent extends EventObject implements ExternalEvent, Serializable {
|
||||
|
||||
public enum QueryType {
|
||||
ASK, CHOOSE, CHOOSE_ABILITY, CHOOSE_MODE, PICK_TARGET, PICK_ABILITY, SELECT, PLAY_MANA, PLAY_X_MANA, AMOUNT, LOOK, PICK_CARD, CONSTRUCT, CHOOSE_PILE, PERSONAL_MESSAGE
|
||||
ASK, CHOOSE, CHOOSE_ABILITY, CHOOSE_MODE, PICK_TARGET, PICK_ABILITY, SELECT, PLAY_MANA, PLAY_X_MANA, AMOUNT, PICK_CARD, CONSTRUCT, CHOOSE_PILE, PERSONAL_MESSAGE
|
||||
}
|
||||
|
||||
private String message;
|
||||
|
@ -191,10 +194,6 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.AMOUNT, min, max, false);
|
||||
}
|
||||
|
||||
public static PlayerQueryEvent lookEvent(UUID playerId, String message, Cards cards) {
|
||||
return new PlayerQueryEvent(playerId, message, null, null, null, cards, QueryType.LOOK, 0, 0, false);
|
||||
}
|
||||
|
||||
public static PlayerQueryEvent pickCard(UUID playerId, String message, List<Card> booster, int time) {
|
||||
return new PlayerQueryEvent(playerId, message, booster, QueryType.PICK_CARD, time);
|
||||
}
|
||||
|
|
|
@ -82,10 +82,6 @@ public class PlayerQueryEventSource implements EventSource<PlayerQueryEvent>, Se
|
|||
dispatcher.fireEvent(PlayerQueryEvent.targetEvent(playerId, message, cards, required, options));
|
||||
}
|
||||
|
||||
public void target(UUID playerId, String message, Cards cards) {
|
||||
dispatcher.fireEvent(PlayerQueryEvent.lookEvent(playerId, message, cards));
|
||||
}
|
||||
|
||||
public void target(UUID playerId, String message, List<TriggeredAbility> abilities) {
|
||||
dispatcher.fireEvent(PlayerQueryEvent.targetEvent(playerId, message, abilities));
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
|
||||
package mage.game.events;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.EventObject;
|
||||
import java.util.UUID;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.Game;
|
||||
|
@ -35,10 +38,6 @@ import mage.game.draft.Draft;
|
|||
import mage.game.match.MatchOptions;
|
||||
import mage.game.tournament.TournamentPairing;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.EventObject;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
|
@ -977,13 +977,12 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
@Override
|
||||
public void revealCards(String name, Cards cards, Game game) {
|
||||
game.getState().getRevealed().add(name, cards);
|
||||
// game.fireRevealCardsEvent(this.name + " revealed", cards);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lookAtCards(String name, Cards cards, Game game) {
|
||||
game.getState().getLookedAt(this.playerId).add(name, cards);
|
||||
game.fireLookAtCardsEvent(playerId, this.name + " looking at", cards);
|
||||
game.fireUpdatePlayersEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue