From 90e20ea0c4d91f9f2cc5b56dbab3e71126318d3e Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Wed, 5 Oct 2011 19:25:35 +0000 Subject: [PATCH] Fixing taking control of the sites, and site text for triggers. --- .../spotting/SimpleLotroCardBlueprint.java | 5 +++ .../spotting/SimplePhysicalCard.java | 5 +++ .../gempukku/lotro/game/state/GameState.java | 36 +++++++++++-------- .../actions/DefaultActionsEnvironment.java | 8 ++--- .../com/gempukku/lotro/game/LotroServer.java | 20 ++++++++++- .../gempukku/lotro/server/ServerResource.java | 4 +-- .../gemp-lotr-web/src/main/webapp/hall.html | 6 ++-- .../src/main/webapp/js/gameUi.js | 10 ++++++ .../src/main/webapp/js/hallUi.js | 4 +-- .../src/main/webapp/js/jCardGroup.js | 27 +++++++++----- 10 files changed, 91 insertions(+), 34 deletions(-) diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/modifiers/spotting/SimpleLotroCardBlueprint.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/modifiers/spotting/SimpleLotroCardBlueprint.java index e671d7b67..4d5f50583 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/modifiers/spotting/SimpleLotroCardBlueprint.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/modifiers/spotting/SimpleLotroCardBlueprint.java @@ -69,6 +69,11 @@ public class SimpleLotroCardBlueprint implements LotroCardBlueprint { return null; } + @Override + public List getPhaseActionsFromStacked(String playerId, LotroGame game, PhysicalCard self) { + return null; + } + @Override public Action getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) { return null; diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/modifiers/spotting/SimplePhysicalCard.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/modifiers/spotting/SimplePhysicalCard.java index cbe556b83..3e044582f 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/modifiers/spotting/SimplePhysicalCard.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/modifiers/spotting/SimplePhysicalCard.java @@ -41,6 +41,11 @@ public class SimplePhysicalCard implements PhysicalCard { return null; } + @Override + public String getCardController() { + return null; + } + @Override public PhysicalCard getStackedOn() { return null; diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameState.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameState.java index 37e9093ba..09ed09790 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameState.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/GameState.java @@ -362,6 +362,28 @@ public class GameState { 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) { if (physicalCardVisitor.visitPhysicalCard(getCurrentSite())) return true; @@ -393,20 +415,6 @@ public class GameState { 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) { return _allCards.get(cardId); } diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/actions/DefaultActionsEnvironment.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/actions/DefaultActionsEnvironment.java index fcc7d73ed..76a4af25b 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/actions/DefaultActionsEnvironment.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/actions/DefaultActionsEnvironment.java @@ -74,7 +74,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment { public List getRequiredBeforeTriggers(Effect effect) { GatherRequiredBeforeTriggers gatherActions = new GatherRequiredBeforeTriggers(effect); - _lotroGame.getGameState().iterateActiveCards(gatherActions); + _lotroGame.getGameState().iterateActiveTextCards(gatherActions); List gatheredActions = gatherActions.getActions(); @@ -91,7 +91,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment { public List getOptionalBeforeTriggers(String playerId, Effect effect) { GatherOptionalBeforeTriggers gatherActions = new GatherOptionalBeforeTriggers(playerId, effect); - _lotroGame.getGameState().iterateActiveCards(playerId, gatherActions); + _lotroGame.getGameState().iterateActiveTextCards(playerId, gatherActions); return gatherActions.getActions(); } @@ -109,7 +109,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment { public List getRequiredAfterTriggers(EffectResult[] effectResults) { GatherRequiredAfterTriggers gatherActions = new GatherRequiredAfterTriggers(effectResults); - _lotroGame.getGameState().iterateActiveCards(gatherActions); + _lotroGame.getGameState().iterateActiveTextCards(gatherActions); List gatheredActions = gatherActions.getActions(); @@ -128,7 +128,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment { public List getOptionalAfterTriggers(String playerId, EffectResult[] effectResults) { GatherOptionalAfterTriggers gatherActions = new GatherOptionalAfterTriggers(playerId, effectResults); - _lotroGame.getGameState().iterateActiveCards(playerId, gatherActions); + _lotroGame.getGameState().iterateActiveTextCards(playerId, gatherActions); return gatherActions.getActions(); } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/LotroServer.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/LotroServer.java index 4ad0f79e1..74974ca49 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/LotroServer.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/LotroServer.java @@ -33,7 +33,7 @@ public class LotroServer extends AbstractServer { private DefaultCardCollection _defaultCollection; private ChatServer _chatServer; - public LotroServer(DbAccess dbAccess, LotroCardBlueprintLibrary library, ChatServer chatServer) { + public LotroServer(DbAccess dbAccess, LotroCardBlueprintLibrary library, ChatServer chatServer, boolean test) { _lotroCardBlueprintLibrary = library; _chatServer = chatServer; _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); _deckDao = new DeckDAO(dbAccess); } diff --git a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/ServerResource.java b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/ServerResource.java index 7a49fdd03..cfe8005b6 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/ServerResource.java +++ b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/ServerResource.java @@ -61,7 +61,7 @@ public class ServerResource { _chatServer = new ChatServer(); _chatServer.startServer(); - _lotroServer = new LotroServer(dbAccess, _library, _chatServer); + _lotroServer = new LotroServer(dbAccess, _library, _chatServer, _test); _lotroServer.startServer(); _collectionDao = new CollectionDAO(dbAccess, _library, _lotroServer.getDefaultCollection()); @@ -721,7 +721,7 @@ public class ServerResource { if (gameEvent.getIndex() != null) eventElem.setAttribute("index", gameEvent.getIndex().toString()); if (gameEvent.getControllerId() != null) - eventElem.setAttribute("controllerId", gameEvent.getParticipantId()); + eventElem.setAttribute("controllerId", gameEvent.getControllerId()); if (gameEvent.getParticipantId() != null) eventElem.setAttribute("participantId", gameEvent.getParticipantId()); if (gameEvent.getAllParticipantIds() != null) { diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/hall.html b/gemp-lotr/gemp-lotr-web/src/main/webapp/hall.html index 2fed33665..d329bb52a 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/hall.html +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/hall.html @@ -14,14 +14,14 @@ .tableFormatName { text-align: center; - font-style: oblique; - font-size: 120%; + font-weight: bold; + font-size: 100%; } .tableStatus { text-align: center; font-style: italic; - font-size: 120%; + font-size: 100%; } .tablePlayer { diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js index 04e155d02..57ee79c2d 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js @@ -725,6 +725,10 @@ var GempLotrGameUI = Class.extend({ var cardId = element.getAttribute("cardId"); var zone = element.getAttribute("zone"); var targetCardId = element.getAttribute("targetCardId"); + var controllerId = element.getAttribute("controllerId"); + + if (controllerId != null) + participantId = controllerId; var card; if (zone == "ADVENTURE_PATH") @@ -750,6 +754,11 @@ var GempLotrGameUI = Class.extend({ var cardId = element.getAttribute("cardId"); var zone = element.getAttribute("zone"); 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 $(".card").each( @@ -770,6 +779,7 @@ var GempLotrGameUI = Class.extend({ var cardData = card.data("card"); // move to new zone cardData.zone = zone; + cardData.owner = participantId; if (targetCardId != null) { // attach to new card if it's attached diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/hallUi.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/hallUi.js index 6c10f0238..811cc537e 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/hallUi.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/hallUi.js @@ -151,10 +151,10 @@ var GempLotrHallUI = Class.extend({ createTableDiv: function(id, gameId, status, formatName, players, waiting) { var tableDiv = $("
"); - 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("
" + formatName + "
"); tableDiv.append("
" + status + "
"); - tableDiv.append("Players:
"); + tableDiv.append("
"); for (var i = 0; i < players.length; i++) tableDiv.append("
" + players[i] + "
"); diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js index 3da6a2330..3515fb56f 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js @@ -105,7 +105,7 @@ var AdvPathCardGroup = CardGroup.extend({ function(first, second) { return (first.data("card").siteNumber - second.data("card").siteNumber); } - ); + ); var cardCount = cardsToLayout.length; var totalHeight = 0; @@ -183,7 +183,10 @@ var NormalCardGroup = CardGroup.extend({ for (var cardId in cardsToLayout) { var cardData = cardsToLayout[cardId].data("card"); 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; } var widthWithoutPadding = this.width - (this.padding * (cardsToLayout.length - 1)); @@ -203,7 +206,10 @@ var NormalCardGroup = CardGroup.extend({ for (var cardId in cardsToLayout) { var cardData = cardsToLayout[cardId].data("card"); 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; if (totalWidth > this.width) { row++; @@ -230,8 +236,9 @@ var NormalCardGroup = CardGroup.extend({ var cardWidth = cardData.getWidthForHeight(height); for (var i = 0; i < cardData.attachedCards.length; i++) { - this.layoutCard(cardData.attachedCards[i], this.x + x, this.y + y, cardWidth, height, index); - x += Math.floor(cardWidth * 0.2); + var attachedCardWidth = cardData.attachedCards[i].data("card").getWidthForHeight(height); + this.layoutCard(cardData.attachedCards[i], this.x + x, this.y + y, attachedCardWidth, height, index); + x += Math.floor(attachedCardWidth * 0.2); 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 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) { row++; x = 0; @@ -263,8 +273,9 @@ var NormalCardGroup = CardGroup.extend({ } for (var i = 0; i < cardData.attachedCards.length; i++) { - this.layoutCard(cardData.attachedCards[i], this.x + x, this.y + y, cardWidth, rowHeight, index); - x += Math.floor(cardWidth * 0.2); + var attachedCardWidth = cardData.attachedCards[i].data("card").getWidthForHeight(this.height); + this.layoutCard(cardData.attachedCards[i], this.x + x, this.y + y, attachedCardWidth, rowHeight, index); + x += Math.floor(attachedCardWidth * 0.2); index++; } this.layoutCard(cardElem, this.x + x, this.y + y, cardWidth, rowHeight, index);