Revert: Chat messages are now part of the game.
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
package com.gempukku.lotro.game.state;
|
||||
|
||||
import com.gempukku.lotro.common.Token;
|
||||
import com.gempukku.lotro.communication.GameStateListener;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.logic.decisions.AwaitingDecision;
|
||||
import com.gempukku.lotro.logic.timing.GameStats;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.gempukku.lotro.game.state.GameEvent.Type.*;
|
||||
|
||||
public class GatheringParticipantCommunicationChannel implements GameStateListener {
|
||||
private List<GameEvent> _events = new LinkedList<GameEvent>();
|
||||
private String _self;
|
||||
private Date _lastConsumed = new Date();
|
||||
private int _channelNumber;
|
||||
|
||||
public GatheringParticipantCommunicationChannel(String self, int channelNumber) {
|
||||
_self = self;
|
||||
_channelNumber = channelNumber;
|
||||
}
|
||||
|
||||
public int getChannelNumber() {
|
||||
return _channelNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerOrder(List<String> participants) {
|
||||
List<String> participantIds = new LinkedList<String>();
|
||||
for (String participant : participants)
|
||||
participantIds.add(participant);
|
||||
_events.add(new GameEvent(P).participantId(_self).allParticipantIds(participantIds));
|
||||
}
|
||||
|
||||
private int[] getCardIds(Collection<PhysicalCard> cards) {
|
||||
int[] result = new int[cards.size()];
|
||||
int index = 0;
|
||||
for (PhysicalCard card : cards) {
|
||||
result[index] = card.getCardId();
|
||||
index++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAssignment(PhysicalCard freePeople, Set<PhysicalCard> minions) {
|
||||
_events.add(new GameEvent(AA).cardId(freePeople.getCardId()).otherCardIds(getCardIds(minions)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAssignment(PhysicalCard freePeople) {
|
||||
_events.add(new GameEvent(RA).cardId(freePeople.getCardId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startSkirmish(PhysicalCard freePeople, Set<PhysicalCard> minions) {
|
||||
GameEvent gameEvent = new GameEvent(SS).otherCardIds(getCardIds(minions));
|
||||
if (freePeople != null)
|
||||
gameEvent.cardId(freePeople.getCardId());
|
||||
_events.add(gameEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToSkirmish(PhysicalCard card) {
|
||||
_events.add(new GameEvent(ATS).card(card));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFromSkirmish(PhysicalCard card) {
|
||||
_events.add(new GameEvent(RFS).card(card));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishSkirmish() {
|
||||
_events.add(new GameEvent(ES));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentPhase(String phase) {
|
||||
_events.add(new GameEvent(GPC).phase(phase));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cardCreated(PhysicalCard card) {
|
||||
if (card.getZone().isPublic() || (card.getZone().isVisibleByOwner() && card.getOwner().equals(_self)))
|
||||
_events.add(new GameEvent(PCIP).card(card));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cardMoved(PhysicalCard card) {
|
||||
_events.add(new GameEvent(MCIP).card(card));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cardsRemoved(String playerPerforming, Collection<PhysicalCard> cards) {
|
||||
Set<PhysicalCard> removedCardsVisibleByPlayer = new HashSet<PhysicalCard>();
|
||||
for (PhysicalCard card : cards) {
|
||||
if (card.getZone().isPublic() || (card.getZone().isVisibleByOwner() && card.getOwner().equals(_self)))
|
||||
removedCardsVisibleByPlayer.add(card);
|
||||
}
|
||||
if (removedCardsVisibleByPlayer.size() > 0)
|
||||
_events.add(new GameEvent(RCFP).otherCardIds(getCardIds(removedCardsVisibleByPlayer)).participantId(playerPerforming));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPosition(String participant, int position) {
|
||||
_events.add(new GameEvent(PP).participantId(participant).index(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTwilight(int twilightPool) {
|
||||
_events.add(new GameEvent(TP).count(twilightPool));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentPlayerId(String currentPlayerId) {
|
||||
_events.add(new GameEvent(TC).participantId(currentPlayerId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTokens(PhysicalCard card, Token token, int count) {
|
||||
_events.add(new GameEvent(AT).card(card).token(token).count(count));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTokens(PhysicalCard card, Token token, int count) {
|
||||
_events.add(new GameEvent(RT).card(card).token(token).count(count));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
_events.add(new GameEvent(M).message(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSite(PhysicalCard card) {
|
||||
_events.add(new GameEvent(PCIP).card(card).index(card.getSiteNumber()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGameStats(GameStats gameStats) {
|
||||
_events.add(new GameEvent(GS).gameStats(gameStats.makeACopy()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cardAffectedByCard(String playerPerforming, PhysicalCard card, Collection<PhysicalCard> affectedCards) {
|
||||
_events.add(new GameEvent(CAC).card(card).participantId(playerPerforming).otherCardIds(getCardIds(affectedCards)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventPlayed(PhysicalCard card) {
|
||||
_events.add(new GameEvent(EP).card(card));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cardActivated(String playerPerforming, PhysicalCard card) {
|
||||
_events.add(new GameEvent(CA).card(card).participantId(playerPerforming));
|
||||
}
|
||||
|
||||
public void decisionRequired(String playerId, AwaitingDecision decision) {
|
||||
if (playerId.equals(_self))
|
||||
_events.add(new GameEvent(D).awaitingDecision(decision).participantId(playerId));
|
||||
}
|
||||
|
||||
public List<GameEvent> consumeGameEvents() {
|
||||
List<GameEvent> result = _events;
|
||||
_events = new LinkedList<GameEvent>();
|
||||
_lastConsumed = new Date();
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean hasGameEvents() {
|
||||
return _events.size()>0;
|
||||
}
|
||||
|
||||
public Date getLastConsumed() {
|
||||
return _lastConsumed;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.gempukku.lotro.game;
|
||||
import com.gempukku.lotro.common.ApplicationConfiguration;
|
||||
import com.gempukku.lotro.game.state.EventSerializer;
|
||||
import com.gempukku.lotro.game.state.GameEvent;
|
||||
import com.gempukku.lotro.game.state.GatheringParticipantCommunicationChannel;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.gempukku.lotro.common.*;
|
||||
import com.gempukku.lotro.communication.GameStateListener;
|
||||
import com.gempukku.lotro.filters.Filters;
|
||||
import com.gempukku.lotro.game.state.GameEvent;
|
||||
import com.gempukku.lotro.game.state.GatheringParticipantCommunicationChannel;
|
||||
import com.gempukku.lotro.logic.GameUtils;
|
||||
import com.gempukku.lotro.logic.decisions.AwaitingDecision;
|
||||
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
|
||||
|
||||
Reference in New Issue
Block a user