Fixing taking control of the sites, and site text for triggers.
This commit is contained in:
@@ -69,6 +69,11 @@ public class SimpleLotroCardBlueprint implements LotroCardBlueprint {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Action> getPhaseActionsFromStacked(String playerId, LotroGame game, PhysicalCard self) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
|
||||
return null;
|
||||
|
||||
@@ -41,6 +41,11 @@ public class SimplePhysicalCard implements PhysicalCard {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCardController() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhysicalCard getStackedOn() {
|
||||
return null;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
|
||||
public List<Action> getRequiredBeforeTriggers(Effect effect) {
|
||||
GatherRequiredBeforeTriggers gatherActions = new GatherRequiredBeforeTriggers(effect);
|
||||
|
||||
_lotroGame.getGameState().iterateActiveCards(gatherActions);
|
||||
_lotroGame.getGameState().iterateActiveTextCards(gatherActions);
|
||||
|
||||
List<Action> gatheredActions = gatherActions.getActions();
|
||||
|
||||
@@ -91,7 +91,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
|
||||
public List<Action> 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<Action> getRequiredAfterTriggers(EffectResult[] effectResults) {
|
||||
GatherRequiredAfterTriggers gatherActions = new GatherRequiredAfterTriggers(effectResults);
|
||||
|
||||
_lotroGame.getGameState().iterateActiveCards(gatherActions);
|
||||
_lotroGame.getGameState().iterateActiveTextCards(gatherActions);
|
||||
|
||||
List<Action> gatheredActions = gatherActions.getActions();
|
||||
|
||||
@@ -128,7 +128,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
|
||||
public List<Action> getOptionalAfterTriggers(String playerId, EffectResult[] effectResults) {
|
||||
GatherOptionalAfterTriggers gatherActions = new GatherOptionalAfterTriggers(playerId, effectResults);
|
||||
|
||||
_lotroGame.getGameState().iterateActiveCards(playerId, gatherActions);
|
||||
_lotroGame.getGameState().iterateActiveTextCards(playerId, gatherActions);
|
||||
|
||||
return gatherActions.getActions();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -151,10 +151,10 @@ var GempLotrHallUI = Class.extend({
|
||||
|
||||
createTableDiv: function(id, gameId, status, formatName, players, waiting) {
|
||||
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='tableStatus'>" + status + "</div>");
|
||||
tableDiv.append("Players:<br/>");
|
||||
tableDiv.append("<hr/>");
|
||||
for (var i = 0; i < players.length; i++)
|
||||
tableDiv.append("<div class='tablePlayer'>" + players[i] + "</div>");
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user