diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/EventSerializer.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/EventSerializer.java index b0b9d11c3..7977e3386 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/EventSerializer.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/EventSerializer.java @@ -12,7 +12,7 @@ import java.util.Map; public class EventSerializer { public Node serializeEvent(Document doc, GameEvent gameEvent) { Element eventElem = doc.createElement("ge"); - eventElem.setAttribute("type", gameEvent.getType().name()); + eventElem.setAttribute("type", gameEvent.getType().getCode()); if (gameEvent.getBlueprintId() != null) eventElem.setAttribute("blueprintId", gameEvent.getBlueprintId()); if (gameEvent.getCardId() != null) diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameCommunicationChannel.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameCommunicationChannel.java index b243bc14b..a638b7fac 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameCommunicationChannel.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameCommunicationChannel.java @@ -32,7 +32,7 @@ public class GameCommunicationChannel implements GameStateListener, LongPollable List participantIds = new LinkedList(); for (String participant : participants) participantIds.add(participant); - appendEvent(new GameEvent(P).participantId(_self).allParticipantIds(participantIds)); + appendEvent(new GameEvent(PARTICIPANTS).participantId(_self).allParticipantIds(participantIds)); } @Override @@ -69,17 +69,17 @@ public class GameCommunicationChannel implements GameStateListener, LongPollable @Override public void addAssignment(PhysicalCard freePeople, Set minions) { - appendEvent(new GameEvent(AA).cardId(freePeople.getCardId()).otherCardIds(getCardIds(minions))); + appendEvent(new GameEvent(ADD_ASSIGNMENT).cardId(freePeople.getCardId()).otherCardIds(getCardIds(minions))); } @Override public void removeAssignment(PhysicalCard freePeople) { - appendEvent(new GameEvent(RA).cardId(freePeople.getCardId())); + appendEvent(new GameEvent(REMOVE_ASSIGNMENT).cardId(freePeople.getCardId())); } @Override public void startSkirmish(PhysicalCard freePeople, Set minions) { - GameEvent gameEvent = new GameEvent(SS).otherCardIds(getCardIds(minions)); + GameEvent gameEvent = new GameEvent(START_SKIRMISH).otherCardIds(getCardIds(minions)); if (freePeople != null) gameEvent.cardId(freePeople.getCardId()); appendEvent(gameEvent); @@ -87,33 +87,33 @@ public class GameCommunicationChannel implements GameStateListener, LongPollable @Override public void addToSkirmish(PhysicalCard card) { - appendEvent(new GameEvent(ATS).card(card)); + appendEvent(new GameEvent(ADD_TO_SKIRMISH).card(card)); } @Override public void removeFromSkirmish(PhysicalCard card) { - appendEvent(new GameEvent(RFS).card(card)); + appendEvent(new GameEvent(REMOVE_FROM_SKIRMISH).card(card)); } @Override public void finishSkirmish() { - appendEvent(new GameEvent(ES)); + appendEvent(new GameEvent(END_SKIRMISH)); } @Override public void setCurrentPhase(String phase) { - appendEvent(new GameEvent(GPC).phase(phase)); + appendEvent(new GameEvent(GAME_PHASE_CHANGE).phase(phase)); } @Override public void cardCreated(PhysicalCard card) { if (card.getZone().isPublic() || (card.getZone().isVisibleByOwner() && card.getOwner().equals(_self))) - appendEvent(new GameEvent(PCIP).card(card)); + appendEvent(new GameEvent(PUT_CARD_INTO_PLAY).card(card)); } @Override public void cardMoved(PhysicalCard card) { - appendEvent(new GameEvent(MCIP).card(card)); + appendEvent(new GameEvent(MOVE_CARD_IN_PLAY).card(card)); } @Override @@ -124,67 +124,67 @@ public class GameCommunicationChannel implements GameStateListener, LongPollable removedCardsVisibleByPlayer.add(card); } if (removedCardsVisibleByPlayer.size() > 0) - appendEvent(new GameEvent(RCFP).otherCardIds(getCardIds(removedCardsVisibleByPlayer)).participantId(playerPerforming)); + appendEvent(new GameEvent(REMOVE_CARD_FROM_PLAY).otherCardIds(getCardIds(removedCardsVisibleByPlayer)).participantId(playerPerforming)); } @Override public void setPlayerPosition(String participant, int position) { - appendEvent(new GameEvent(PP).participantId(participant).index(position)); + appendEvent(new GameEvent(PLAYER_POSITION).participantId(participant).index(position)); } @Override public void setTwilight(int twilightPool) { - appendEvent(new GameEvent(TP).count(twilightPool)); + appendEvent(new GameEvent(TWILIGHT_POOL_UPDATE).count(twilightPool)); } @Override public void setCurrentPlayerId(String currentPlayerId) { - appendEvent(new GameEvent(TC).participantId(currentPlayerId)); + appendEvent(new GameEvent(TURN_CHANGE).participantId(currentPlayerId)); } @Override public void addTokens(PhysicalCard card, Token token, int count) { - appendEvent(new GameEvent(AT).card(card).token(token).count(count)); + appendEvent(new GameEvent(ADD_TOKENS).card(card).token(token).count(count)); } @Override public void removeTokens(PhysicalCard card, Token token, int count) { - appendEvent(new GameEvent(RT).card(card).token(token).count(count)); + appendEvent(new GameEvent(REMOVE_TOKENS).card(card).token(token).count(count)); } @Override public void sendMessage(String message) { - appendEvent(new GameEvent(M).message(message)); + appendEvent(new GameEvent(SEND_MESSAGE).message(message)); } @Override public void setSite(PhysicalCard card) { - appendEvent(new GameEvent(PCIP).card(card).index(card.getSiteNumber())); + appendEvent(new GameEvent(PUT_CARD_INTO_PLAY).card(card).index(card.getSiteNumber())); } @Override public void sendGameStats(GameStats gameStats) { - appendEvent(new GameEvent(GS).gameStats(gameStats.makeACopy())); + appendEvent(new GameEvent(GAME_STATS).gameStats(gameStats.makeACopy())); } @Override public void cardAffectedByCard(String playerPerforming, PhysicalCard card, Collection affectedCards) { - appendEvent(new GameEvent(CAC).card(card).participantId(playerPerforming).otherCardIds(getCardIds(affectedCards))); + appendEvent(new GameEvent(CARD_AFFECTED_BY_CARD).card(card).participantId(playerPerforming).otherCardIds(getCardIds(affectedCards))); } @Override public void eventPlayed(PhysicalCard card) { - appendEvent(new GameEvent(EP).card(card)); + appendEvent(new GameEvent(SHOW_CARD_ON_SCREEN).card(card)); } @Override public void cardActivated(String playerPerforming, PhysicalCard card) { - appendEvent(new GameEvent(CA).card(card).participantId(playerPerforming)); + appendEvent(new GameEvent(FLASH_CARD_IN_PLAY).card(card).participantId(playerPerforming)); } public void decisionRequired(String playerId, AwaitingDecision decision) { if (playerId.equals(_self)) - appendEvent(new GameEvent(D).awaitingDecision(decision).participantId(playerId)); + appendEvent(new GameEvent(DECISION).awaitingDecision(decision).participantId(playerId)); } public List consumeGameEvents() { diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameEvent.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameEvent.java index 870dc3883..4267dbfc2 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameEvent.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameEvent.java @@ -1,208 +1,219 @@ -package com.gempukku.lotro.game.state; - -import com.gempukku.lotro.common.CardType; -import com.gempukku.lotro.common.Token; -import com.gempukku.lotro.common.Zone; -import com.gempukku.lotro.game.PhysicalCard; -import com.gempukku.lotro.logic.decisions.AwaitingDecision; -import com.gempukku.lotro.logic.timing.GameStats; - -import java.util.List; - -public class GameEvent { - public enum Type { - P, GPC, TC, PP, TP, - PCIP, MCIP, RCFP, - AA, RA, - SS, RFS, ATS, ES, - AT, RT, - M, W, - GS, - CAC, EP, CA, D - } - - private String _message; - private String _side; - private Type _type; - private Zone _zone; - private String _participantId; - private String _controllerId; - private List _allParticipantIds; - private Integer _index; - private String _blueprintId; - private Integer _cardId; - private Integer _targetCardId; - private String _phase; - private Integer _count; - private Token _token; - private int[] _otherCardIds; - private GameStats _gameStats; - private AwaitingDecision _awaitingDecision; - - public GameEvent(Type type) { - _type = type; - } - - public Integer getIndex() { - return _index; - } - - public GameEvent index(int index) { - _index = index; - return this; - } - - public Type getType() { - return _type; - } - - public GameStats getGameStats() { - return _gameStats; - } - - public GameEvent gameStats(GameStats gameStats) { - _gameStats = gameStats; - return this; - } - - public AwaitingDecision getAwaitingDecision() { - return _awaitingDecision; - } - - public GameEvent awaitingDecision(AwaitingDecision awaitingDecision) { - _awaitingDecision = awaitingDecision; - return this; - } - - public Zone getZone() { - return _zone; - } - - public GameEvent zone(Zone zone) { - _zone = zone; - return this; - } - - public Token getToken() { - return _token; - } - - public GameEvent token(Token token) { - _token = token; - return this; - } - - public String getMessage() { - return _message; - } - - public GameEvent message(String message) { - _message = message; - return this; - } - - public Integer getCount() { - return _count; - } - - public GameEvent count(int count) { - _count = count; - return this; - } - - public int[] getOtherCardIds() { - return _otherCardIds; - } - - public GameEvent otherCardIds(int[] otherCardIds) { - _otherCardIds = otherCardIds; - return this; - } - - public String getParticipantId() { - return _participantId; - } - - public GameEvent participantId(String participantId) { - _participantId = participantId; - return this; - } - - public List getAllParticipantIds() { - return _allParticipantIds; - } - - public GameEvent allParticipantIds(List allParticipantIds) { - _allParticipantIds = allParticipantIds; - return this; - } - - public String getSide() { - return _side; - } - - public GameEvent side(String side) { - _side = side; - return this; - } - - public String getControllerId() { - return _controllerId; - } - - public GameEvent controllerId(String controllerId) { - _controllerId = controllerId; - return this; - } - - public GameEvent card(PhysicalCard physicalCard) { - GameEvent gameEvent = cardId(physicalCard.getCardId()).blueprintId(physicalCard.getBlueprintId()).participantId(physicalCard.getOwner()).zone(physicalCard.getZone()); - if (physicalCard.getCardController() != null) - gameEvent = gameEvent.controllerId(physicalCard.getCardController()); - PhysicalCard attachedTo = physicalCard.getAttachedTo(); - if (attachedTo != null) - gameEvent = gameEvent.targetCardId(attachedTo.getCardId()); - PhysicalCard stackedOn = physicalCard.getStackedOn(); - if (stackedOn != null) - gameEvent = gameEvent.targetCardId(stackedOn.getCardId()); - if (physicalCard.getBlueprint().getCardType() == CardType.SITE && physicalCard.getZone().isInPlay()) - gameEvent = gameEvent.index(physicalCard.getSiteNumber()); - return gameEvent; - } - - public String getBlueprintId() { - return _blueprintId; - } - - public GameEvent blueprintId(String blueprintId) { - _blueprintId = blueprintId; - return this; - } - - public Integer getCardId() { - return _cardId; - } - - public GameEvent cardId(int cardId) { - _cardId = cardId; - return this; - } - - public Integer getTargetCardId() { - return _targetCardId; - } - - public GameEvent targetCardId(int targetCardId) { - _targetCardId = targetCardId; - return this; - } - - public String getPhase() { - return _phase; - } - - public GameEvent phase(String phase) { - _phase = phase; - return this; - } -} +package com.gempukku.lotro.game.state; + +import com.gempukku.lotro.common.CardType; +import com.gempukku.lotro.common.Token; +import com.gempukku.lotro.common.Zone; +import com.gempukku.lotro.game.PhysicalCard; +import com.gempukku.lotro.logic.decisions.AwaitingDecision; +import com.gempukku.lotro.logic.timing.GameStats; + +import java.util.List; + +public class GameEvent { + public enum Type { + PARTICIPANTS("P"), GAME_PHASE_CHANGE("GPC"), TURN_CHANGE("TC"), PLAYER_POSITION("PP"), + TWILIGHT_POOL_UPDATE("TP"), + PUT_CARD_INTO_PLAY("PCIP"), MOVE_CARD_IN_PLAY("MCIP"), REMOVE_CARD_FROM_PLAY("RCFP"), + ADD_ASSIGNMENT("AA"), REMOVE_ASSIGNMENT("RA"), + START_SKIRMISH("SS"), REMOVE_FROM_SKIRMISH("RFS"), ADD_TO_SKIRMISH("ATS"), END_SKIRMISH("ES"), + ADD_TOKENS("AT"), REMOVE_TOKENS("RT"), + SEND_MESSAGE("M"), SEND_WARNING("W"), + GAME_STATS("GS"), + CARD_AFFECTED_BY_CARD("CAC"), SHOW_CARD_ON_SCREEN("EP"), FLASH_CARD_IN_PLAY("CA"), DECISION("D"); + + private String code; + + private Type(String code) { + this.code = code; + } + + String getCode() { + return code; + } + } + + private String _message; + private String _side; + private Type _type; + private Zone _zone; + private String _participantId; + private String _controllerId; + private List _allParticipantIds; + private Integer _index; + private String _blueprintId; + private Integer _cardId; + private Integer _targetCardId; + private String _phase; + private Integer _count; + private Token _token; + private int[] _otherCardIds; + private GameStats _gameStats; + private AwaitingDecision _awaitingDecision; + + public GameEvent(Type type) { + _type = type; + } + + public Integer getIndex() { + return _index; + } + + public GameEvent index(int index) { + _index = index; + return this; + } + + public Type getType() { + return _type; + } + + public GameStats getGameStats() { + return _gameStats; + } + + public GameEvent gameStats(GameStats gameStats) { + _gameStats = gameStats; + return this; + } + + public AwaitingDecision getAwaitingDecision() { + return _awaitingDecision; + } + + public GameEvent awaitingDecision(AwaitingDecision awaitingDecision) { + _awaitingDecision = awaitingDecision; + return this; + } + + public Zone getZone() { + return _zone; + } + + public GameEvent zone(Zone zone) { + _zone = zone; + return this; + } + + public Token getToken() { + return _token; + } + + public GameEvent token(Token token) { + _token = token; + return this; + } + + public String getMessage() { + return _message; + } + + public GameEvent message(String message) { + _message = message; + return this; + } + + public Integer getCount() { + return _count; + } + + public GameEvent count(int count) { + _count = count; + return this; + } + + public int[] getOtherCardIds() { + return _otherCardIds; + } + + public GameEvent otherCardIds(int[] otherCardIds) { + _otherCardIds = otherCardIds; + return this; + } + + public String getParticipantId() { + return _participantId; + } + + public GameEvent participantId(String participantId) { + _participantId = participantId; + return this; + } + + public List getAllParticipantIds() { + return _allParticipantIds; + } + + public GameEvent allParticipantIds(List allParticipantIds) { + _allParticipantIds = allParticipantIds; + return this; + } + + public String getSide() { + return _side; + } + + public GameEvent side(String side) { + _side = side; + return this; + } + + public String getControllerId() { + return _controllerId; + } + + public GameEvent controllerId(String controllerId) { + _controllerId = controllerId; + return this; + } + + public GameEvent card(PhysicalCard physicalCard) { + GameEvent gameEvent = cardId(physicalCard.getCardId()).blueprintId(physicalCard.getBlueprintId()).participantId(physicalCard.getOwner()).zone(physicalCard.getZone()); + if (physicalCard.getCardController() != null) + gameEvent = gameEvent.controllerId(physicalCard.getCardController()); + PhysicalCard attachedTo = physicalCard.getAttachedTo(); + if (attachedTo != null) + gameEvent = gameEvent.targetCardId(attachedTo.getCardId()); + PhysicalCard stackedOn = physicalCard.getStackedOn(); + if (stackedOn != null) + gameEvent = gameEvent.targetCardId(stackedOn.getCardId()); + if (physicalCard.getBlueprint().getCardType() == CardType.SITE && physicalCard.getZone().isInPlay()) + gameEvent = gameEvent.index(physicalCard.getSiteNumber()); + return gameEvent; + } + + public String getBlueprintId() { + return _blueprintId; + } + + public GameEvent blueprintId(String blueprintId) { + _blueprintId = blueprintId; + return this; + } + + public Integer getCardId() { + return _cardId; + } + + public GameEvent cardId(int cardId) { + _cardId = cardId; + return this; + } + + public Integer getTargetCardId() { + return _targetCardId; + } + + public GameEvent targetCardId(int targetCardId) { + _targetCardId = targetCardId; + return this; + } + + public String getPhase() { + return _phase; + } + + public GameEvent phase(String phase) { + _phase = phase; + return this; + } +} diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/LotroGameMediator.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/LotroGameMediator.java index 072a8cb27..3d6429969 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/LotroGameMediator.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/LotroGameMediator.java @@ -385,7 +385,7 @@ public class LotroGameMediator { String warning = _userFeedback.consumeWarning(playerName); if (warning != null) - visitor.visitGameEvent(new GameEvent(GameEvent.Type.W).message(warning)); + visitor.visitGameEvent(new GameEvent(GameEvent.Type.SEND_WARNING).message(warning)); Map secondsLeft = new HashMap(); for (Map.Entry playerClock : _playerClocks.entrySet()) {