Display deck/hand/discard/dead pile counts for all players.
This commit is contained in:
@@ -2,6 +2,7 @@ package com.gempukku.lotro.communication;
|
||||
|
||||
import com.gempukku.lotro.common.Phase;
|
||||
import com.gempukku.lotro.common.Token;
|
||||
import com.gempukku.lotro.common.Zone;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
|
||||
import java.util.List;
|
||||
@@ -38,4 +39,6 @@ public interface GameStateListener {
|
||||
public void sendMessage(String message);
|
||||
|
||||
public void setSite(PhysicalCard card);
|
||||
|
||||
public void setZoneSize(String playerId, Zone zone, int size);
|
||||
}
|
||||
|
||||
@@ -224,7 +224,8 @@ public class GameState {
|
||||
public void removeCardFromZone(PhysicalCard card) {
|
||||
Zone zone = card.getZone();
|
||||
|
||||
boolean b = getZoneCards(card.getOwner(), card.getBlueprint().getCardType(), zone).remove(card);
|
||||
List<PhysicalCardImpl> zoneCards = getZoneCards(card.getOwner(), card.getBlueprint().getCardType(), zone);
|
||||
boolean b = zoneCards.remove(card);
|
||||
if (!b)
|
||||
throw new RuntimeException("Card was not found in the expected zone");
|
||||
|
||||
@@ -255,11 +256,18 @@ public class GameState {
|
||||
else if (isZonePrivate(zone))
|
||||
for (GameStateListener listener : getPrivateGameStateListeners(card))
|
||||
listener.cardRemoved(card);
|
||||
|
||||
if (zone == Zone.DECK || zone == Zone.HAND || zone == Zone.DISCARD || zone == Zone.DEAD)
|
||||
for (GameStateListener listener : getAllGameStateListeners())
|
||||
listener.setZoneSize(card.getOwner(), zone, zoneCards.size());
|
||||
}
|
||||
|
||||
public void addCardToZone(PhysicalCard card, Zone zone) {
|
||||
getZoneCards(card.getOwner(), card.getBlueprint().getCardType(), zone).add((PhysicalCardImpl) card);
|
||||
List<PhysicalCardImpl> zoneCards = getZoneCards(card.getOwner(), card.getBlueprint().getCardType(), zone);
|
||||
zoneCards.add((PhysicalCardImpl) card);
|
||||
|
||||
((PhysicalCardImpl) card).setZone(zone);
|
||||
|
||||
if (zone == Zone.ADVENTURE_PATH) {
|
||||
for (GameStateListener listener : getAllGameStateListeners())
|
||||
listener.setSite(card);
|
||||
@@ -270,6 +278,9 @@ public class GameState {
|
||||
else if (isZonePrivate(zone))
|
||||
for (GameStateListener listener : getPrivateGameStateListeners(card))
|
||||
listener.cardCreated(card);
|
||||
if (zone == Zone.DECK || zone == Zone.HAND || zone == Zone.DISCARD || zone == Zone.DEAD)
|
||||
for (GameStateListener listener : getAllGameStateListeners())
|
||||
listener.setZoneSize(card.getOwner(), zone, zoneCards.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ public class GameEvent {
|
||||
ADD_ASSIGNMENT, REMOVE_ASSIGNMENT,
|
||||
START_SKIRMISH, END_SKIRMISH,
|
||||
ADD_TOKENS, REMOVE_TOKENS,
|
||||
MESSAGE, WARNING
|
||||
MESSAGE, WARNING,
|
||||
ZONE_SIZE
|
||||
}
|
||||
|
||||
private String _message;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.gempukku.lotro.game;
|
||||
|
||||
import com.gempukku.lotro.common.Phase;
|
||||
import com.gempukku.lotro.common.Token;
|
||||
import com.gempukku.lotro.common.Zone;
|
||||
import com.gempukku.lotro.communication.GameStateListener;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -109,6 +110,11 @@ public class GatheringParticipantCommunicationChannel implements GameStateListen
|
||||
_events.add(new GameEvent(PUT_CARD_IN_PLAY).card(card).index(card.getBlueprint().getSiteNumber()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZoneSize(String playerId, Zone zone, int size) {
|
||||
_events.add(new GameEvent(ZONE_SIZE).participantId(playerId).zone(zone).count(size));
|
||||
}
|
||||
|
||||
public List<GameEvent> consumeGameEvents() {
|
||||
List<GameEvent> result = _events;
|
||||
_events = new LinkedList<GameEvent>();
|
||||
|
||||
@@ -117,6 +117,7 @@ var GempLotrGameUI = Class.extend({
|
||||
this.gameStateElem.append("<b>Players:</b><br>");
|
||||
for (var i = 0; i < this.allPlayerIds.length; i++) {
|
||||
this.gameStateElem.append("<div class='player'>" + this.allPlayerIds[i] + "<div id='clock" + i + "' class='clock'></div></div>");
|
||||
this.gameStateElem.append("Deck: <div id='deck" + i + "' style='display: inline;'></div> Hand: <div id='hand" + i + "' style='display: inline;'></div> Discard: <div id='discard" + i + "' style='display: inline;'></div> Dead pile: <div id='deadPile" + i + "' style='display: inline;'></div>");
|
||||
}
|
||||
|
||||
this.gameStateElem.append("<br>");
|
||||
@@ -431,6 +432,8 @@ var GempLotrGameUI = Class.extend({
|
||||
this.removeTokens(gameEvent);
|
||||
} else if (eventType == "PLAYER_POSITION") {
|
||||
this.playerPosition(gameEvent);
|
||||
} else if (eventType == "ZONE_SIZE") {
|
||||
this.zoneSize(gameEvent);
|
||||
} else if (eventType == "MESSAGE") {
|
||||
this.message(gameEvent);
|
||||
} else if (eventType == "WARNING") {
|
||||
@@ -503,6 +506,21 @@ var GempLotrGameUI = Class.extend({
|
||||
alert("There was a problem during communication with server");
|
||||
},
|
||||
|
||||
zoneSize: function(element) {
|
||||
var playerId = element.getAttribute("participantId");
|
||||
var zone = element.getAttribute("zone");
|
||||
var count = element.getAttribute("count");
|
||||
|
||||
if (zone == "HAND")
|
||||
$("#hand" + this.getPlayerIndex(playerId)).text("" + count);
|
||||
else if (zone == "DISCARD")
|
||||
$("#discard" + this.getPlayerIndex(playerId)).text("" + count);
|
||||
else if (zone == "DEAD")
|
||||
$("#deadPile" + this.getPlayerIndex(playerId)).text("" + count);
|
||||
else if (zone == "DECK")
|
||||
$("#deck" + this.getPlayerIndex(playerId)).text("" + count);
|
||||
},
|
||||
|
||||
playerPosition: function(element) {
|
||||
var participantId = element.getAttribute("participantId");
|
||||
var position = element.getAttribute("index");
|
||||
|
||||
Reference in New Issue
Block a user