Adding player tokens on sites.

This commit is contained in:
marcins78@gmail.com
2011-09-16 10:36:03 +00:00
parent 1d51c1d67f
commit 10cc7571f6
7 changed files with 67 additions and 9 deletions

View File

@@ -36,4 +36,6 @@ public interface GameStateListener {
public void removeTokens(PhysicalCard card, Token token, int count);
public void sendMessage(String message);
public void setSite(PhysicalCard card);
}

View File

@@ -280,12 +280,17 @@ public class GameState {
public void addCardToZone(PhysicalCard card, Zone zone) {
getZoneCards(card.getOwner(), card.getBlueprint().getCardType(), zone).add((PhysicalCardImpl) card);
((PhysicalCardImpl) card).setZone(zone);
if (isZonePublic(zone))
if (zone == Zone.ADVENTURE_PATH) {
for (GameStateListener listener : getAllGameStateListeners())
listener.cardCreated(card);
else if (isZonePrivate(zone))
for (GameStateListener listener : getPrivateGameStateListeners(card))
listener.cardCreated(card);
listener.setSite(card);
} else {
if (isZonePublic(zone))
for (GameStateListener listener : getAllGameStateListeners())
listener.cardCreated(card);
else if (isZonePrivate(zone))
for (GameStateListener listener : getPrivateGameStateListeners(card))
listener.cardCreated(card);
}
}
private void removeAllTokens(PhysicalCard card) {

View File

@@ -104,6 +104,11 @@ public class GatheringParticipantCommunicationChannel implements GameStateListen
_events.add(new GameEvent(MESSAGE).message(message));
}
@Override
public void setSite(PhysicalCard card) {
_events.add(new GameEvent(PUT_CARD_IN_PLAY).card(card).index(card.getBlueprint().getSiteNumber()));
}
public List<GameEvent> consumeGameEvents() {
List<GameEvent> result = _events;
_events = new LinkedList<GameEvent>();

View File

@@ -8,6 +8,7 @@ var GempLotrGameUI = Class.extend({
selfPlayerId: null,
currentPlayerId: null,
allPlayerIds: null,
playerPositions: null,
cardActionDialog: null,
smallDialog: null,
gameStateElem: null,
@@ -395,6 +396,8 @@ var GempLotrGameUI = Class.extend({
this.addTokens(gameEvent);
} else if (eventType == "REMOVE_TOKENS") {
this.removeTokens(gameEvent);
} else if (eventType == "PLAYER_POSITION") {
this.playerPosition(gameEvent);
} else if (eventType == "MESSAGE") {
this.message(gameEvent);
} else if (eventType == "WARNING") {
@@ -438,6 +441,21 @@ var GempLotrGameUI = Class.extend({
alert("There was a problem during communication with server");
},
playerPosition: function(element) {
var participantId = element.getAttribute("participantId");
var position = element.getAttribute("index");
if (this.playerPositions == null)
this.playerPositions = new Array();
var index = -1;
for (var i = 0; i < this.allPlayerIds.length; i++)
if (this.allPlayerIds[i] == participantId)
this.playerPositions[i] = position;
this.advPathGroup.setPositions(this.playerPositions);
},
addTokens: function(element) {
var cardId = element.getAttribute("cardId");
var zone = element.getAttribute("zone");
@@ -540,7 +558,11 @@ var GempLotrGameUI = Class.extend({
// TODO finish off the other zones (DISCARD, DEAD)
if (zone != "DISCARD" && zone != "DEAD") {
var card = new Card(blueprintId, zone, cardId, participantId);
var card;
if (zone == "ADVENTURE_PATH")
card = new Card(blueprintId, zone, cardId, participantId, element.getAttribute("index"));
else
card = new Card(blueprintId, zone, cardId, participantId);
var cardDiv = this.createCardDiv(card);
$("#main").append(cardDiv);

View File

@@ -71,6 +71,8 @@ var CardGroup = Class.extend({
});
var AdvPathCardGroup = CardGroup.extend({
positions: null,
init: function(container) {
this._super(container,
function(card) {
@@ -78,6 +80,10 @@ var AdvPathCardGroup = CardGroup.extend({
});
},
setPositions: function(positions) {
this.positions = positions;
},
layoutCards: function() {
var cardsToLayout = new Array();
var that = this;
@@ -88,6 +94,12 @@ var AdvPathCardGroup = CardGroup.extend({
}
});
cardsToLayout.sort(
function(first, second) {
return (first.data("card").siteNumber - second.data("card").siteNumber);
}
);
var cardCount = cardsToLayout.length;
var totalHeight = 0;
@@ -103,6 +115,12 @@ var AdvPathCardGroup = CardGroup.extend({
var cardElem = cardsToLayout[cardId];
var cardData = cardsToLayout[cardId].data("card");
var cardHeight = (cardElem.data("card").getHeightForWidth(this.width));
cardData.tokens = {};
for (var i = 0; this.positions.length; i++)
if (this.positions[i] == cardData.siteNumber)
cardData.tokens["" + (i + 1)] = 1;
this.layoutCard(cardElem, x, y, this.width, cardHeight, index);
for (var i = 0; i < cardData.attachedCards.length; i++) {

View File

@@ -8,13 +8,16 @@ var Card = Class.extend({
zone: null,
cardId: null,
owner: null,
siteNumber: null,
attachedCards: null,
init: function(blueprintId, zone, cardId, owner) {
init: function(blueprintId, zone, cardId, owner, siteNumber) {
this.blueprintId = blueprintId;
this.zone = zone;
this.cardId = cardId;
this.owner = owner;
if (siteNumber)
this.siteNumber = parseInt(siteNumber);
this.attachedCards = new Array();
if (blueprintId == "rules") {
this.imageUrl = "/gemp-lotr/images/rules.png";

View File

@@ -1,11 +1,13 @@
TO DO:
Before release:
15. Add join game screen, where players can choose to play and get paired automatically when a pair becomes available.
18. Add display of site where player is on adventure path.
21. Scale wounds, burdens, other tokens with the card size.
22. If skirmish is in progress, the total strength of each side should be displayed.
16. Add an option to view an ongoing game.
20. Display "chess-clock" for each player.
20. Display clock.
Next priority:
16. Add an option to view an ongoing game.
13. Add dead/discard pile displays.
14. Add hand/deck card count displays.
19. Add filtering cards to deck-builder.
@@ -14,6 +16,7 @@ TO DO:
23. Add ghost cards attached to cards they are affecting in case of things (non-possessions) affecting only one card
(like skirmish strength bonuses, etc)
Optional:
4. Modify the Blueprint hierarchy to return possible return objects (PlayEventAction), TriggeredAction, etc. Use
final methods were possible to avoid implementation errors on new cards added.
10. Add active/all cards switch to the user interface.