Fixing taking control of the sites, and site text for triggers.

This commit is contained in:
marcins78@gmail.com
2011-10-05 19:25:35 +00:00
parent 32d886d991
commit 90e20ea0c4
10 changed files with 91 additions and 34 deletions

View File

@@ -69,6 +69,11 @@ public class SimpleLotroCardBlueprint implements LotroCardBlueprint {
return null; return null;
} }
@Override
public List<? extends Action> getPhaseActionsFromStacked(String playerId, LotroGame game, PhysicalCard self) {
return null;
}
@Override @Override
public Action getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) { public Action getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
return null; return null;

View File

@@ -41,6 +41,11 @@ public class SimplePhysicalCard implements PhysicalCard {
return null; return null;
} }
@Override
public String getCardController() {
return null;
}
@Override @Override
public PhysicalCard getStackedOn() { public PhysicalCard getStackedOn() {
return null; return null;

View File

@@ -362,6 +362,28 @@ public class GameState {
return false; return false;
} }
public boolean iterateActiveTextCards(PhysicalCardVisitor physicalCardVisitor) {
for (PhysicalCardImpl physicalCard : _inPlay) {
if (physicalCard.getBlueprint().getCardType() != CardType.SITE || getCurrentSite() == physicalCard)
if (isCardInPlayActive(physicalCard))
if (physicalCardVisitor.visitPhysicalCard(physicalCard))
return true;
}
return false;
}
public boolean iterateActiveTextCards(String player, PhysicalCardVisitor physicalCardVisitor) {
physicalCardVisitor.visitPhysicalCard(getCurrentSite());
for (PhysicalCardImpl physicalCard : _inPlay) {
if (physicalCard.getBlueprint().getCardType() != CardType.SITE && physicalCard.getOwner().equals(player) && isCardInPlayActive(physicalCard))
if (physicalCardVisitor.visitPhysicalCard(physicalCard))
return true;
}
return false;
}
public boolean iterateActivableCards(String player, PhysicalCardVisitor physicalCardVisitor) { public boolean iterateActivableCards(String player, PhysicalCardVisitor physicalCardVisitor) {
if (physicalCardVisitor.visitPhysicalCard(getCurrentSite())) if (physicalCardVisitor.visitPhysicalCard(getCurrentSite()))
return true; return true;
@@ -393,20 +415,6 @@ public class GameState {
return false; return false;
} }
public boolean iterateActiveCards(String player, PhysicalCardVisitor physicalCardVisitor) {
for (int i = 1; i <= 9; i++) {
PhysicalCard site = getSite(i);
if (site != null)
physicalCardVisitor.visitPhysicalCard(site);
}
for (PhysicalCardImpl physicalCard : _inPlay) {
if (physicalCard.getOwner().equals(player) && isCardInPlayActive(physicalCard))
if (physicalCardVisitor.visitPhysicalCard(physicalCard))
return true;
}
return false;
}
public PhysicalCard findCardById(int cardId) { public PhysicalCard findCardById(int cardId) {
return _allCards.get(cardId); return _allCards.get(cardId);
} }

View File

@@ -74,7 +74,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
public List<Action> getRequiredBeforeTriggers(Effect effect) { public List<Action> getRequiredBeforeTriggers(Effect effect) {
GatherRequiredBeforeTriggers gatherActions = new GatherRequiredBeforeTriggers(effect); GatherRequiredBeforeTriggers gatherActions = new GatherRequiredBeforeTriggers(effect);
_lotroGame.getGameState().iterateActiveCards(gatherActions); _lotroGame.getGameState().iterateActiveTextCards(gatherActions);
List<Action> gatheredActions = gatherActions.getActions(); List<Action> gatheredActions = gatherActions.getActions();
@@ -91,7 +91,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
public List<Action> getOptionalBeforeTriggers(String playerId, Effect effect) { public List<Action> getOptionalBeforeTriggers(String playerId, Effect effect) {
GatherOptionalBeforeTriggers gatherActions = new GatherOptionalBeforeTriggers(playerId, effect); GatherOptionalBeforeTriggers gatherActions = new GatherOptionalBeforeTriggers(playerId, effect);
_lotroGame.getGameState().iterateActiveCards(playerId, gatherActions); _lotroGame.getGameState().iterateActiveTextCards(playerId, gatherActions);
return gatherActions.getActions(); return gatherActions.getActions();
} }
@@ -109,7 +109,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
public List<Action> getRequiredAfterTriggers(EffectResult[] effectResults) { public List<Action> getRequiredAfterTriggers(EffectResult[] effectResults) {
GatherRequiredAfterTriggers gatherActions = new GatherRequiredAfterTriggers(effectResults); GatherRequiredAfterTriggers gatherActions = new GatherRequiredAfterTriggers(effectResults);
_lotroGame.getGameState().iterateActiveCards(gatherActions); _lotroGame.getGameState().iterateActiveTextCards(gatherActions);
List<Action> gatheredActions = gatherActions.getActions(); List<Action> gatheredActions = gatherActions.getActions();
@@ -128,7 +128,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
public List<Action> getOptionalAfterTriggers(String playerId, EffectResult[] effectResults) { public List<Action> getOptionalAfterTriggers(String playerId, EffectResult[] effectResults) {
GatherOptionalAfterTriggers gatherActions = new GatherOptionalAfterTriggers(playerId, effectResults); GatherOptionalAfterTriggers gatherActions = new GatherOptionalAfterTriggers(playerId, effectResults);
_lotroGame.getGameState().iterateActiveCards(playerId, gatherActions); _lotroGame.getGameState().iterateActiveTextCards(playerId, gatherActions);
return gatherActions.getActions(); return gatherActions.getActions();
} }

View File

@@ -33,7 +33,7 @@ public class LotroServer extends AbstractServer {
private DefaultCardCollection _defaultCollection; private DefaultCardCollection _defaultCollection;
private ChatServer _chatServer; private ChatServer _chatServer;
public LotroServer(DbAccess dbAccess, LotroCardBlueprintLibrary library, ChatServer chatServer) { public LotroServer(DbAccess dbAccess, LotroCardBlueprintLibrary library, ChatServer chatServer, boolean test) {
_lotroCardBlueprintLibrary = library; _lotroCardBlueprintLibrary = library;
_chatServer = chatServer; _chatServer = chatServer;
_defaultCollection = new DefaultCardCollection(); _defaultCollection = new DefaultCardCollection();
@@ -53,6 +53,24 @@ public class LotroServer extends AbstractServer {
} }
} }
if (test) {
for (int i = 4; i <= 4; i++) {
for (int j = 1; j <= 365; j++) {
String blueprintId = i + "_" + j;
try {
LotroCardBlueprint cardBlueprint = _lotroCardBlueprintLibrary.getLotroCardBlueprint(blueprintId);
CardType cardType = cardBlueprint.getCardType();
if (cardType == CardType.SITE || cardType == CardType.THE_ONE_RING)
_defaultCollection.addCards(blueprintId, cardBlueprint, 1);
else
_defaultCollection.addCards(blueprintId, cardBlueprint, 4);
} catch (IllegalArgumentException exp) {
}
}
}
}
_playerDao = new PlayerDAO(dbAccess); _playerDao = new PlayerDAO(dbAccess);
_deckDao = new DeckDAO(dbAccess); _deckDao = new DeckDAO(dbAccess);
} }

View File

@@ -61,7 +61,7 @@ public class ServerResource {
_chatServer = new ChatServer(); _chatServer = new ChatServer();
_chatServer.startServer(); _chatServer.startServer();
_lotroServer = new LotroServer(dbAccess, _library, _chatServer); _lotroServer = new LotroServer(dbAccess, _library, _chatServer, _test);
_lotroServer.startServer(); _lotroServer.startServer();
_collectionDao = new CollectionDAO(dbAccess, _library, _lotroServer.getDefaultCollection()); _collectionDao = new CollectionDAO(dbAccess, _library, _lotroServer.getDefaultCollection());
@@ -721,7 +721,7 @@ public class ServerResource {
if (gameEvent.getIndex() != null) if (gameEvent.getIndex() != null)
eventElem.setAttribute("index", gameEvent.getIndex().toString()); eventElem.setAttribute("index", gameEvent.getIndex().toString());
if (gameEvent.getControllerId() != null) if (gameEvent.getControllerId() != null)
eventElem.setAttribute("controllerId", gameEvent.getParticipantId()); eventElem.setAttribute("controllerId", gameEvent.getControllerId());
if (gameEvent.getParticipantId() != null) if (gameEvent.getParticipantId() != null)
eventElem.setAttribute("participantId", gameEvent.getParticipantId()); eventElem.setAttribute("participantId", gameEvent.getParticipantId());
if (gameEvent.getAllParticipantIds() != null) { if (gameEvent.getAllParticipantIds() != null) {

View File

@@ -14,14 +14,14 @@
.tableFormatName { .tableFormatName {
text-align: center; text-align: center;
font-style: oblique; font-weight: bold;
font-size: 120%; font-size: 100%;
} }
.tableStatus { .tableStatus {
text-align: center; text-align: center;
font-style: italic; font-style: italic;
font-size: 120%; font-size: 100%;
} }
.tablePlayer { .tablePlayer {

View File

@@ -725,6 +725,10 @@ var GempLotrGameUI = Class.extend({
var cardId = element.getAttribute("cardId"); var cardId = element.getAttribute("cardId");
var zone = element.getAttribute("zone"); var zone = element.getAttribute("zone");
var targetCardId = element.getAttribute("targetCardId"); var targetCardId = element.getAttribute("targetCardId");
var controllerId = element.getAttribute("controllerId");
if (controllerId != null)
participantId = controllerId;
var card; var card;
if (zone == "ADVENTURE_PATH") if (zone == "ADVENTURE_PATH")
@@ -750,6 +754,11 @@ var GempLotrGameUI = Class.extend({
var cardId = element.getAttribute("cardId"); var cardId = element.getAttribute("cardId");
var zone = element.getAttribute("zone"); var zone = element.getAttribute("zone");
var targetCardId = element.getAttribute("targetCardId"); var targetCardId = element.getAttribute("targetCardId");
var participantId = element.getAttribute("participantId");
var controllerId = element.getAttribute("controllerId");
if (controllerId != null)
participantId = controllerId;
// Remove from where it was already attached // Remove from where it was already attached
$(".card").each( $(".card").each(
@@ -770,6 +779,7 @@ var GempLotrGameUI = Class.extend({
var cardData = card.data("card"); var cardData = card.data("card");
// move to new zone // move to new zone
cardData.zone = zone; cardData.zone = zone;
cardData.owner = participantId;
if (targetCardId != null) { if (targetCardId != null) {
// attach to new card if it's attached // attach to new card if it's attached

View File

@@ -151,10 +151,10 @@ var GempLotrHallUI = Class.extend({
createTableDiv: function(id, gameId, status, formatName, players, waiting) { createTableDiv: function(id, gameId, status, formatName, players, waiting) {
var tableDiv = $("<div></div>"); var tableDiv = $("<div></div>");
tableDiv.css({ display: "inline-block", width: "120px", height: "120px", margin: "5px", "background-color": "#333300", color: "#ffffff"}); tableDiv.css({ display: "inline-table", width: "120px", height: "120px", margin: "5px", "background-color": "#333300", color: "#ffffff"});
tableDiv.append("<div class='tableFormatName'>" + formatName + "</div>"); tableDiv.append("<div class='tableFormatName'>" + formatName + "</div>");
tableDiv.append("<div class='tableStatus'>" + status + "</div>"); tableDiv.append("<div class='tableStatus'>" + status + "</div>");
tableDiv.append("Players:<br/>"); tableDiv.append("<hr/>");
for (var i = 0; i < players.length; i++) for (var i = 0; i < players.length; i++)
tableDiv.append("<div class='tablePlayer'>" + players[i] + "</div>"); tableDiv.append("<div class='tablePlayer'>" + players[i] + "</div>");

View File

@@ -105,7 +105,7 @@ var AdvPathCardGroup = CardGroup.extend({
function(first, second) { function(first, second) {
return (first.data("card").siteNumber - second.data("card").siteNumber); return (first.data("card").siteNumber - second.data("card").siteNumber);
} }
); );
var cardCount = cardsToLayout.length; var cardCount = cardsToLayout.length;
var totalHeight = 0; var totalHeight = 0;
@@ -183,7 +183,10 @@ var NormalCardGroup = CardGroup.extend({
for (var cardId in cardsToLayout) { for (var cardId in cardsToLayout) {
var cardData = cardsToLayout[cardId].data("card"); var cardData = cardsToLayout[cardId].data("card");
var cardWidth = cardData.getWidthForHeight(this.height); var cardWidth = cardData.getWidthForHeight(this.height);
var cardWidthWithAttachments = cardWidth + Math.floor(cardWidth * 0.2) * cardData.attachedCards.length; var attachmentWidths = 0;
for (var i = 0; i < cardData.attachedCards.length; i++)
attachmentWidths += cardData.attachedCards[i].data("card").getWidthForHeight(this.height) * 0.2;
var cardWidthWithAttachments = cardWidth + attachmentWidths;
totalWidth += cardWidthWithAttachments; totalWidth += cardWidthWithAttachments;
} }
var widthWithoutPadding = this.width - (this.padding * (cardsToLayout.length - 1)); var widthWithoutPadding = this.width - (this.padding * (cardsToLayout.length - 1));
@@ -203,7 +206,10 @@ var NormalCardGroup = CardGroup.extend({
for (var cardId in cardsToLayout) { for (var cardId in cardsToLayout) {
var cardData = cardsToLayout[cardId].data("card"); var cardData = cardsToLayout[cardId].data("card");
var cardWidth = cardData.getWidthForHeight(rowHeight); var cardWidth = cardData.getWidthForHeight(rowHeight);
var cardWidthWithAttachments = cardWidth + Math.floor(cardWidth * 0.2) * cardData.attachedCards.length; var attachmentWidths = 0;
for (var i = 0; i < cardData.attachedCards.length; i++)
attachmentWidths += cardData.attachedCards[i].data("card").getWidthForHeight(this.height) * 0.2;
var cardWidthWithAttachments = cardWidth + attachmentWidths;
totalWidth += cardWidthWithAttachments; totalWidth += cardWidthWithAttachments;
if (totalWidth > this.width) { if (totalWidth > this.width) {
row++; row++;
@@ -230,8 +236,9 @@ var NormalCardGroup = CardGroup.extend({
var cardWidth = cardData.getWidthForHeight(height); var cardWidth = cardData.getWidthForHeight(height);
for (var i = 0; i < cardData.attachedCards.length; i++) { for (var i = 0; i < cardData.attachedCards.length; i++) {
this.layoutCard(cardData.attachedCards[i], this.x + x, this.y + y, cardWidth, height, index); var attachedCardWidth = cardData.attachedCards[i].data("card").getWidthForHeight(height);
x += Math.floor(cardWidth * 0.2); this.layoutCard(cardData.attachedCards[i], this.x + x, this.y + y, attachedCardWidth, height, index);
x += Math.floor(attachedCardWidth * 0.2);
index++; index++;
} }
this.layoutCard(cardElem, this.x + x, this.y + y, cardWidth, height, index); this.layoutCard(cardElem, this.x + x, this.y + y, cardWidth, height, index);
@@ -255,7 +262,10 @@ var NormalCardGroup = CardGroup.extend({
var cardData = cardsToLayout[cardId].data("card"); var cardData = cardsToLayout[cardId].data("card");
var cardWidth = cardData.getWidthForHeight(rowHeight); var cardWidth = cardData.getWidthForHeight(rowHeight);
var cardWidthWithAttachments = cardWidth + Math.floor(cardWidth * 0.2) * cardData.attachedCards.length; var attachmentWidths = 0;
for (var i = 0; i < cardData.attachedCards.length; i++)
attachmentWidths += cardData.attachedCards[i].data("card").getWidthForHeight(this.height) * 0.2;
var cardWidthWithAttachments = cardWidth + attachmentWidths;
if (x + cardWidthWithAttachments > this.width) { if (x + cardWidthWithAttachments > this.width) {
row++; row++;
x = 0; x = 0;
@@ -263,8 +273,9 @@ var NormalCardGroup = CardGroup.extend({
} }
for (var i = 0; i < cardData.attachedCards.length; i++) { for (var i = 0; i < cardData.attachedCards.length; i++) {
this.layoutCard(cardData.attachedCards[i], this.x + x, this.y + y, cardWidth, rowHeight, index); var attachedCardWidth = cardData.attachedCards[i].data("card").getWidthForHeight(this.height);
x += Math.floor(cardWidth * 0.2); this.layoutCard(cardData.attachedCards[i], this.x + x, this.y + y, attachedCardWidth, rowHeight, index);
x += Math.floor(attachedCardWidth * 0.2);
index++; index++;
} }
this.layoutCard(cardElem, this.x + x, this.y + y, cardWidth, rowHeight, index); this.layoutCard(cardElem, this.x + x, this.y + y, cardWidth, rowHeight, index);