Deckbuilding is finally working! Fixed "Tale of Gil-Galad" and "Moria Lake"
This commit is contained in:
@@ -4,6 +4,7 @@ import com.gempukku.lotro.cards.AbstractAttachable;
|
||||
import com.gempukku.lotro.cards.PlayConditions;
|
||||
import com.gempukku.lotro.cards.effects.AddUntilEndOfPhaseModifierEffect;
|
||||
import com.gempukku.lotro.cards.modifiers.StrengthModifier;
|
||||
import com.gempukku.lotro.cards.modifiers.VitalityModifier;
|
||||
import com.gempukku.lotro.common.*;
|
||||
import com.gempukku.lotro.filters.Filter;
|
||||
import com.gempukku.lotro.filters.Filters;
|
||||
@@ -11,6 +12,7 @@ import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.actions.CostToEffectAction;
|
||||
import com.gempukku.lotro.logic.effects.DiscardCardFromPlayEffect;
|
||||
import com.gempukku.lotro.logic.modifiers.Modifier;
|
||||
import com.gempukku.lotro.logic.timing.Action;
|
||||
|
||||
import java.util.LinkedList;
|
||||
@@ -51,4 +53,9 @@ public class Card1_066 extends AbstractAttachable {
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Modifier getAlwaysOnEffect(PhysicalCard self) {
|
||||
return new VitalityModifier(self, Filters.attachedTo(self), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,11 @@ public class Card1_346 extends AbstractSite {
|
||||
possibleEffects.add(new ExertCharacterEffect(frodo));
|
||||
possibleEffects.add(
|
||||
new ChooseActiveCardsEffect(fpPlayerId, "Choose two companions to exert", 2, 2, Filters.not(Filters.name("Frodo")), Filters.type(CardType.COMPANION), Filters.canExert()) {
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Exert two other companions";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cardsSelected(List<PhysicalCard> cards) {
|
||||
action.addEffect(new ExertCharacterEffect(cards.get(0)));
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.gempukku.lotro.db.DbAccess;
|
||||
import com.gempukku.lotro.db.DeckDAO;
|
||||
import com.gempukku.lotro.db.PlayerDAO;
|
||||
import com.gempukku.lotro.db.vo.Deck;
|
||||
import com.gempukku.lotro.db.vo.Player;
|
||||
import com.gempukku.lotro.game.*;
|
||||
import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||
import org.apache.log4j.Logger;
|
||||
@@ -126,30 +127,18 @@ public class LotroServer {
|
||||
}
|
||||
|
||||
public LotroDeck getParticipantDeck(String participantId) {
|
||||
Player player = _playerDao.getPlayer(participantId);
|
||||
Deck deck = _deckDao.getDeckForPlayer(player, "default");
|
||||
if (deck == null)
|
||||
return null;
|
||||
|
||||
LotroDeck lotroDeck = new LotroDeck();
|
||||
lotroDeck.setRing("1_1");
|
||||
lotroDeck.setRingBearer("1_290");
|
||||
|
||||
for (int i = 3; i <= 68; i++)
|
||||
lotroDeck.addCard("1_" + i);
|
||||
|
||||
for (int i = 0; i < 30; i++)
|
||||
lotroDeck.addCard("1_178");
|
||||
|
||||
// Sites
|
||||
lotroDeck.addSite("1_326");
|
||||
lotroDeck.addSite("1_331");
|
||||
lotroDeck.addSite("1_337");
|
||||
lotroDeck.addSite("1_346");
|
||||
lotroDeck.addSite("1_349");
|
||||
lotroDeck.addSite("1_351");
|
||||
lotroDeck.addSite("1_354");
|
||||
lotroDeck.addSite("1_356");
|
||||
lotroDeck.addSite("1_362");
|
||||
|
||||
// Minions
|
||||
for (int i = 120; i <= 162; i++)
|
||||
lotroDeck.addCard("1_" + i);
|
||||
lotroDeck.setRing(deck.getRing());
|
||||
lotroDeck.setRingBearer(deck.getRingBearer());
|
||||
for (String site : deck.getSites())
|
||||
lotroDeck.addSite(site);
|
||||
for (String card : deck.getDeck())
|
||||
lotroDeck.addCard(card);
|
||||
|
||||
return lotroDeck;
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ public class ServerResource {
|
||||
|
||||
private void createGame(String gameId) {
|
||||
LotroGameParticipant[] participants = new LotroGameParticipant[2];
|
||||
participants[0] = new LotroGameParticipant("Player1", _lotroServer.getParticipantDeck("Player1"));
|
||||
participants[1] = new LotroGameParticipant("Player2", _lotroServer.getParticipantDeck("Player2"));
|
||||
participants[0] = new LotroGameParticipant("MarcinS1", _lotroServer.getParticipantDeck("MarcinS1"));
|
||||
participants[1] = new LotroGameParticipant("MarcinS2", _lotroServer.getParticipantDeck("MarcinS2"));
|
||||
|
||||
_lotroServer.createNewGame(new DefaultLotroFormat(true), participants, gameId);
|
||||
_lotroServer.getGameById(gameId).startGame();
|
||||
|
||||
@@ -100,6 +100,12 @@
|
||||
});
|
||||
});
|
||||
|
||||
ui.setSaveDeckFunc(function(deckType, contents) {
|
||||
communication.saveDeck(deckType, contents, function(xml) {
|
||||
alert("Deck was saved");
|
||||
});
|
||||
});
|
||||
|
||||
ui.layoutUI();
|
||||
|
||||
communication.getDeck("default", function(xml) {
|
||||
|
||||
@@ -81,5 +81,18 @@ var GempLotrCommunication = Class.extend({
|
||||
error: this.failure,
|
||||
dataType: "xml"
|
||||
});
|
||||
},
|
||||
saveDeck: function(deckType, contents, callback) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: this.url + "/deck/" + deckType,
|
||||
cache: false,
|
||||
data: {
|
||||
participantId: getUrlParam("participantId"),
|
||||
deckContents: contents},
|
||||
success: callback,
|
||||
error: this.failure,
|
||||
dataType: "xml"
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -12,7 +12,13 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
specialCollectionDiv: null,
|
||||
specialCollectionGroup: null,
|
||||
loadCollectionFunc: null,
|
||||
saveDeckFunc: null,
|
||||
selectionFunc: null,
|
||||
filterDiv: null,
|
||||
drawDeckDiv: null,
|
||||
drawDeckGroup: null,
|
||||
start: 0,
|
||||
count: 18,
|
||||
|
||||
init: function() {
|
||||
var that = this;
|
||||
@@ -21,6 +27,39 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
|
||||
this.collectionDiv = $("#collectionDiv");
|
||||
|
||||
this.filterDiv = $("<div></div>");
|
||||
this.filterDiv.append("<button id='previousPage' style='float: left;'>Previous page</button>");
|
||||
this.filterDiv.append("<button id='nextPage' style='float: right;'>Previous page</button>");
|
||||
this.collectionDiv.append(this.filterDiv);
|
||||
|
||||
$("#previousPage").button({
|
||||
text: false,
|
||||
icons: {
|
||||
primary: "ui-icon-circle-triangle-w"
|
||||
}
|
||||
}).click(
|
||||
function() {
|
||||
$("#previousPage").button("option", "disabled", true);
|
||||
$("#nextPage").button("option", "disabled", true);
|
||||
that.normalCollectionDiv.html("");
|
||||
that.start -= that.count;
|
||||
that.loadCollectionFunc("default", "cardType:-SITE,THE_ONE_RING", that.start, that.count);
|
||||
});
|
||||
|
||||
$("#nextPage").button({
|
||||
text: false,
|
||||
icons: {
|
||||
primary: "ui-icon-circle-triangle-e"
|
||||
}
|
||||
}).click(
|
||||
function() {
|
||||
$("#previousPage").button("option", "disabled", true);
|
||||
$("#nextPage").button("option", "disabled", true);
|
||||
that.normalCollectionDiv.html("");
|
||||
that.start += that.count;
|
||||
that.loadCollectionFunc("default", "cardType:-SITE,THE_ONE_RING", that.start, that.count);
|
||||
});
|
||||
|
||||
this.normalCollectionDiv = $("<div></div>");
|
||||
this.normalCollectionGroup = new NormalCardGroup(null, this.normalCollectionDiv, function(card) {
|
||||
return true;
|
||||
@@ -81,6 +120,15 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
return (card.zone == "deck");
|
||||
});
|
||||
this.drawDeckGroup.maxCardHeight = 200;
|
||||
|
||||
this.bottomBarDiv = $("<div></div>");
|
||||
this.bottomBarDiv.append("<button id='saveDeck' style='float: right;'>Save deck</button>");
|
||||
this.deckDiv.append(this.bottomBarDiv);
|
||||
$("#saveDeck").button().click(
|
||||
function() {
|
||||
that.saveDeck();
|
||||
});
|
||||
|
||||
this.deckDiv.append(this.drawDeckDiv);
|
||||
|
||||
this.selectionFunc = this.addCardToDeck;
|
||||
@@ -91,7 +139,7 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
var selectedCardElem = tar.parent();
|
||||
if (event.which == 1) {
|
||||
if (event.shiftKey) {
|
||||
// that.displayCardInfo(selectedCardElem.data("card"));
|
||||
// that.displayCardInfo(selectedCardElem.data("card"));
|
||||
} else if (selectedCardElem.hasClass("cardInCollection")) {
|
||||
that.selectionFunc(selectedCardElem.data("card").blueprintId);
|
||||
} else if (selectedCardElem.hasClass("cardInDeck")) {
|
||||
@@ -103,8 +151,47 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
});
|
||||
},
|
||||
|
||||
saveDeck: function() {
|
||||
var ringBearer = $(".card", this.ringBearerDiv);
|
||||
var ring = $(".card", this.ringDiv);
|
||||
var site1 = $(".card", this.siteDivs[0]);
|
||||
var site2 = $(".card", this.siteDivs[1]);
|
||||
var site3 = $(".card", this.siteDivs[2]);
|
||||
var site4 = $(".card", this.siteDivs[3]);
|
||||
var site5 = $(".card", this.siteDivs[4]);
|
||||
var site6 = $(".card", this.siteDivs[5]);
|
||||
var site7 = $(".card", this.siteDivs[6]);
|
||||
var site8 = $(".card", this.siteDivs[7]);
|
||||
var site9 = $(".card", this.siteDivs[8]);
|
||||
|
||||
if (ringBearer.length == 0 || ring.length == 0 || site1.length == 0 || site2.length == 0 || site3.length == 0 || site4.length == 0
|
||||
|| site5.length == 0 || site6.length == 0 || site7.length == 0 || site8.length == 0 || site9.length == 0) {
|
||||
alert("To save a deck, it must have at least a Ring-Bearer, Ring and all 9 sites set");
|
||||
} else {
|
||||
var cards = new Array();
|
||||
cards.push(ringBearer.data("card").blueprintId);
|
||||
cards.push(ring.data("card").blueprintId);
|
||||
cards.push(site1.data("card").blueprintId);
|
||||
cards.push(site2.data("card").blueprintId);
|
||||
cards.push(site3.data("card").blueprintId);
|
||||
cards.push(site4.data("card").blueprintId);
|
||||
cards.push(site5.data("card").blueprintId);
|
||||
cards.push(site6.data("card").blueprintId);
|
||||
cards.push(site7.data("card").blueprintId);
|
||||
cards.push(site8.data("card").blueprintId);
|
||||
cards.push(site9.data("card").blueprintId);
|
||||
|
||||
$(".card", this.drawDeckDiv).each(
|
||||
function() {
|
||||
cards.push($(this).data("card").blueprintId);
|
||||
});
|
||||
|
||||
this.saveDeckFunc("default", "" + cards);
|
||||
}
|
||||
},
|
||||
|
||||
addCardToContainer: function(blueprintId, zone, container) {
|
||||
var card = new Card(blueprintId, zone, "deckCardId", "player");
|
||||
var card = new Card(blueprintId, zone, "deck", "player");
|
||||
var cardDiv = createCardDiv(card.imageUrl, null);
|
||||
cardDiv.data("card", card);
|
||||
container.append(cardDiv);
|
||||
@@ -114,12 +201,14 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
|
||||
showPredefinedFilter: function(filter, container) {
|
||||
this.normalCollectionDiv.hide();
|
||||
this.filterDiv.hide();
|
||||
this.specialCollectionDiv.show();
|
||||
this.loadCollectionFunc("default", filter, 0, 18);
|
||||
this.selectionFunc = function(blueprintId) {
|
||||
this.addCardToContainer(blueprintId, "special", container);
|
||||
this.specialCollectionDiv.hide();
|
||||
this.normalCollectionDiv.show();
|
||||
this.filterDiv.show();
|
||||
this.selectionFunc = this.addCardToDeck;
|
||||
};
|
||||
},
|
||||
@@ -158,11 +247,34 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
this.loadCollectionFunc = func;
|
||||
},
|
||||
|
||||
setSaveDeckFunc: function(func) {
|
||||
this.saveDeckFunc = func;
|
||||
},
|
||||
|
||||
setupDeck: function(xml) {
|
||||
this.loadCollectionFunc("default", "cardType:-SITE,THE_ONE_RING", 0, 18);
|
||||
var root = xml.documentElement;
|
||||
if (root.tagName == "deck") {
|
||||
var ringBearer = root.getElementsByTagName("ringBearer");
|
||||
if (ringBearer.length == 1) {
|
||||
this.addCardToContainer(ringBearer[0].getAttribute("blueprintId"), "deck", this.ringBearerDiv);
|
||||
this.addCardToContainer(root.getElementsByTagName("ring")[0].getAttribute("blueprintId"), "deck", this.ringDiv);
|
||||
var sites = root.getElementsByTagName("site");
|
||||
for (var i = 0; i < 9; i++)
|
||||
this.addCardToContainer(sites[i].getAttribute("blueprintId"), "deck", this.siteDivs[i]);
|
||||
|
||||
var cards = root.getElementsByTagName("card");
|
||||
for (var i = 0; i < cards.length; i++)
|
||||
this.addCardToDeck(cards[i].getAttribute("blueprintId"));
|
||||
|
||||
this.layoutUI();
|
||||
}
|
||||
|
||||
this.loadCollectionFunc("default", "cardType:-SITE,THE_ONE_RING", this.start, this.count);
|
||||
}
|
||||
},
|
||||
|
||||
displayCollection: function(xml) {
|
||||
log(xml);
|
||||
var root = xml.documentElement;
|
||||
if (root.tagName == "collection") {
|
||||
if (this.normalCollectionDiv.is(":visible"))
|
||||
@@ -187,11 +299,20 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
|
||||
this.normalCollectionGroup.layoutCards();
|
||||
this.specialCollectionGroup.layoutCards();
|
||||
|
||||
$("#previousPage").button("option", "disabled", this.start == 0);
|
||||
var cnt = parseInt(root.getAttribute("count"));
|
||||
$("#nextPage").button("option", "disabled", (this.start + this.count) >= cnt);
|
||||
}
|
||||
},
|
||||
|
||||
layoutUI: function() {
|
||||
var collectionWidth = this.collectionDiv.width();
|
||||
var collectionHeight = this.collectionDiv.height();
|
||||
|
||||
var deckWidth = this.deckDiv.width();
|
||||
var deckHeight = this.deckDiv.height();
|
||||
|
||||
var rowHeight = Math.floor(deckHeight / 5);
|
||||
var sitesWidth = Math.floor(1.5 * deckHeight / 5);
|
||||
sitesWidth = Math.min(sitesWidth, 150);
|
||||
@@ -208,14 +329,17 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
this.siteDivs[i].css({ position: "absolute", left: sitesWidth, top: rowHeight * (i - 4), width: sitesWidth, height: rowHeight });
|
||||
this.siteGroups[i].setBounds(0, 0, sitesWidth, rowHeight);
|
||||
}
|
||||
this.drawDeckDiv.css({ position: "absolute", left: sitesWidth * 2, top: 0, width: this.deckDiv.width() - sitesWidth * 2, height: deckHeight });
|
||||
this.drawDeckGroup.setBounds(0, 0, this.deckDiv.width() - sitesWidth * 2, deckHeight);
|
||||
this.drawDeckDiv.css({ position: "absolute", left: sitesWidth * 2, top: 0, width: deckWidth - sitesWidth * 2, height: deckHeight - 50 });
|
||||
this.drawDeckGroup.setBounds(0, 0, deckWidth - sitesWidth * 2, deckHeight - 50);
|
||||
|
||||
this.normalCollectionDiv.css({ position: "absolute", left: 0, top: 50, width: this.collectionDiv.width(), height: this.collectionDiv.height() - 50 })
|
||||
this.specialCollectionDiv.css({ position: "absolute", left: 0, top: 0, width: this.collectionDiv.width(), height: this.collectionDiv.height() })
|
||||
this.bottomBarDiv.css({ position: "absolute", left: sitesWidth * 2, top: deckHeight - 50, width: deckWidth - sitesWidth * 2, height: 50 });
|
||||
|
||||
this.normalCollectionGroup.setBounds(0, 0, this.collectionDiv.width(), this.collectionDiv.height() - 50);
|
||||
this.specialCollectionGroup.setBounds(0, 0, this.collectionDiv.width(), this.collectionDiv.height());
|
||||
this.normalCollectionDiv.css({ position: "absolute", left: 0, top: 50, width: collectionWidth, height: collectionHeight - 50 });
|
||||
this.filterDiv.css({ position: "absolute", left: 0, top: 0, width: collectionWidth, height: 50 });
|
||||
this.specialCollectionDiv.css({ position: "absolute", left: 0, top: 0, width: collectionWidth, height: collectionHeight });
|
||||
|
||||
this.normalCollectionGroup.setBounds(0, 0, collectionWidth, collectionHeight - 50);
|
||||
this.specialCollectionGroup.setBounds(0, 0, collectionWidth, collectionHeight);
|
||||
},
|
||||
|
||||
processError: function (xhr, ajaxOptions, thrownError) {
|
||||
|
||||
Reference in New Issue
Block a user