Visually separated Free People and Shadow cards in deck builder.
This commit is contained in:
@@ -1,21 +1,34 @@
|
||||
package com.gempukku.lotro.game;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface CardCollection {
|
||||
public Map<String, Integer> getAll();
|
||||
|
||||
public Map<String, Item> getItems(String filter);
|
||||
public List<Item> getItems(String filter);
|
||||
|
||||
public static class Item {
|
||||
public enum Type {PACK, CARD}
|
||||
public enum Type {
|
||||
PACK, CARD
|
||||
}
|
||||
|
||||
private Type _type;
|
||||
private int _count;
|
||||
private String _blueprintId;
|
||||
private LotroCardBlueprint _cardBlueprint;
|
||||
|
||||
public Item(Type type, int count) {
|
||||
public Item(Type type, int count, String blueprintId) {
|
||||
_type = type;
|
||||
_count = count;
|
||||
_blueprintId = blueprintId;
|
||||
}
|
||||
|
||||
public Item(Type type, int count, String blueprintId, LotroCardBlueprint cardBlueprint) {
|
||||
_type = type;
|
||||
_count = count;
|
||||
_blueprintId = blueprintId;
|
||||
_cardBlueprint = cardBlueprint;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
@@ -25,5 +38,13 @@ public interface CardCollection {
|
||||
public int getCount() {
|
||||
return _count;
|
||||
}
|
||||
|
||||
public String getBlueprintId() {
|
||||
return _blueprintId;
|
||||
}
|
||||
|
||||
public LotroCardBlueprint getCardBlueprint() {
|
||||
return _cardBlueprint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import com.gempukku.lotro.common.Keyword;
|
||||
import java.util.*;
|
||||
|
||||
public class DefaultCardCollection implements MutableCardCollection {
|
||||
private Map<String, Integer> _counts = new TreeMap<String, Integer>();
|
||||
private Map<String, LotroCardBlueprint> _cards = new TreeMap<String, LotroCardBlueprint>(new CardBlueprintIdComparator());
|
||||
private Map<String, Integer> _counts = new TreeMap<String, Integer>(new CardBlueprintIdComparator());
|
||||
private Map<String, LotroCardBlueprint> _cards = new TreeMap<String, LotroCardBlueprint>();
|
||||
|
||||
@Override
|
||||
public void addCards(String blueprintId, LotroCardBlueprint blueprint, int count) {
|
||||
@@ -29,7 +29,7 @@ public class DefaultCardCollection implements MutableCardCollection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Item> getItems(String filter) {
|
||||
public List<Item> getItems(String filter) {
|
||||
if (filter == null)
|
||||
filter = "";
|
||||
String[] filterParams = filter.split(" ");
|
||||
@@ -39,7 +39,7 @@ public class DefaultCardCollection implements MutableCardCollection {
|
||||
List<Keyword> keywords = getEnumFilter(Keyword.values(), Keyword.class, "keyword", Collections.<Keyword>emptyList(), filterParams);
|
||||
Integer siteNumber = getSiteNumber(filterParams);
|
||||
|
||||
Map<String, Item> result = new LinkedHashMap<String, Item>();
|
||||
List<Item> result = new ArrayList<Item>();
|
||||
|
||||
for (Map.Entry<String, Integer> itemCount : _counts.entrySet()) {
|
||||
String blueprintId = itemCount.getKey();
|
||||
@@ -47,13 +47,13 @@ public class DefaultCardCollection implements MutableCardCollection {
|
||||
|
||||
final LotroCardBlueprint blueprint = _cards.get(blueprintId);
|
||||
if (blueprint == null)
|
||||
result.put(blueprintId, new Item(Item.Type.PACK, count));
|
||||
result.add(new Item(Item.Type.PACK, count, blueprintId));
|
||||
else {
|
||||
if (cardTypes == null || cardTypes.contains(blueprint.getCardType()))
|
||||
if (cultures == null || cultures.contains(blueprint.getCulture()))
|
||||
if (containsAllKeywords(blueprint, keywords))
|
||||
if (siteNumber == null || blueprint.getSiteNumber() == siteNumber.intValue())
|
||||
result.put(blueprintId, new Item(Item.Type.CARD, count));
|
||||
result.add(new Item(Item.Type.CARD, count, blueprintId, blueprint));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -43,6 +43,8 @@ public class ServerResource {
|
||||
private static final Logger _logger = Logger.getLogger(ServerResource.class);
|
||||
private boolean _test = System.getProperty("test") != null;
|
||||
|
||||
private LotroCardBlueprintLibrary _library;
|
||||
|
||||
private HallServer _hallServer;
|
||||
private LotroServer _lotroServer;
|
||||
private ChatServer _chatServer;
|
||||
@@ -53,17 +55,17 @@ public class ServerResource {
|
||||
|
||||
try {
|
||||
DbAccess dbAccess = new DbAccess();
|
||||
LotroCardBlueprintLibrary library = new LotroCardBlueprintLibrary();
|
||||
_library = new LotroCardBlueprintLibrary();
|
||||
|
||||
CollectionDAO collectionDao = new CollectionDAO(dbAccess, library);
|
||||
CollectionDAO collectionDao = new CollectionDAO(dbAccess, _library);
|
||||
|
||||
_chatServer = new ChatServer();
|
||||
_chatServer.startServer();
|
||||
|
||||
_lotroServer = new LotroServer(dbAccess, library, _chatServer);
|
||||
_lotroServer = new LotroServer(dbAccess, _library, _chatServer);
|
||||
_lotroServer.startServer();
|
||||
|
||||
_leagueService = new LeagueService(dbAccess, collectionDao, library);
|
||||
_leagueService = new LeagueService(dbAccess, collectionDao, _library);
|
||||
|
||||
_hallServer = new HallServer(_lotroServer, _chatServer, _leagueService, _test);
|
||||
_hallServer.startServer();
|
||||
@@ -267,6 +269,7 @@ public class ServerResource {
|
||||
}
|
||||
for (String s : deck.getAdventureCards()) {
|
||||
Element card = doc.createElement("card");
|
||||
card.setAttribute("side", _library.getLotroCardBlueprint(s).getSide().toString());
|
||||
card.setAttribute("blueprintId", s);
|
||||
deckElem.appendChild(card);
|
||||
}
|
||||
@@ -367,7 +370,7 @@ public class ServerResource {
|
||||
sendError(Response.Status.NOT_FOUND);
|
||||
|
||||
CardCollection collection = _lotroServer.getDefaultCollection();
|
||||
Map<String, CardCollection.Item> filteredResult = collection.getItems(filter);
|
||||
List<CardCollection.Item> filteredResult = collection.getItems(filter);
|
||||
|
||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||
@@ -379,14 +382,14 @@ public class ServerResource {
|
||||
doc.appendChild(collectionElem);
|
||||
|
||||
int index = 0;
|
||||
for (Map.Entry<String, CardCollection.Item> collectionEntry : filteredResult.entrySet()) {
|
||||
for (CardCollection.Item item : filteredResult) {
|
||||
if (index >= start && index < start + count) {
|
||||
String blueprintId = collectionEntry.getKey();
|
||||
CardCollection.Item item = collectionEntry.getValue();
|
||||
String blueprintId = item.getBlueprintId();
|
||||
if (item.getType() == CardCollection.Item.Type.CARD) {
|
||||
Element card = doc.createElement("card");
|
||||
card.setAttribute("count", String.valueOf(item.getCount()));
|
||||
card.setAttribute("blueprintId", blueprintId);
|
||||
card.setAttribute("side", item.getCardBlueprint().getSide().toString());
|
||||
collectionElem.appendChild(card);
|
||||
} else {
|
||||
Element pack = doc.createElement("pack");
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<pre style="font-size:80%">
|
||||
24 Sept. 2011
|
||||
- Visually separated Free People and Shadow cards in deck builder.
|
||||
|
||||
23 Sept. 2011
|
||||
- If an action or effect has play card from non-deck zone as an effect or a cost, you have to have a playable card of
|
||||
type in that zone before you start playing the action or effect. If you use an action or effect of that type, you HAVE
|
||||
|
||||
@@ -18,7 +18,8 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
pageDiv: null,
|
||||
filterDiv: null,
|
||||
drawDeckDiv: null,
|
||||
drawDeckGroup: null,
|
||||
fpDeckGroup: null,
|
||||
shadowDeckGroup: null,
|
||||
start: 0,
|
||||
count: 18,
|
||||
filter: null,
|
||||
@@ -169,10 +170,14 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
}
|
||||
|
||||
this.drawDeckDiv = $("<div></div>");
|
||||
this.drawDeckGroup = new NormalCardGroup(this.drawDeckDiv, function(card) {
|
||||
return (card.zone == "deck");
|
||||
this.fpDeckGroup = new NormalCardGroup(this.drawDeckDiv, function(card) {
|
||||
return (card.zone == "FREE_PEOPLE");
|
||||
});
|
||||
this.drawDeckGroup.maxCardHeight = 200;
|
||||
this.fpDeckGroup.maxCardHeight = 200;
|
||||
this.shadowDeckGroup = new NormalCardGroup(this.drawDeckDiv, function(card) {
|
||||
return (card.zone == "SHADOW");
|
||||
});
|
||||
this.shadowDeckGroup.maxCardHeight = 200;
|
||||
|
||||
this.bottomBarDiv = $("<div></div>");
|
||||
this.bottomBarDiv.append("<button id='saveDeck' style='float: right;'>Save deck</button>");
|
||||
@@ -197,7 +202,7 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
if (event.shiftKey) {
|
||||
that.displayCardInfo(selectedCardElem.data("card"));
|
||||
} else if (selectedCardElem.hasClass("cardInCollection")) {
|
||||
that.selectionFunc(selectedCardElem.data("card").blueprintId);
|
||||
that.selectionFunc(selectedCardElem.data("card").blueprintId, selectedCardElem.data("card").zone);
|
||||
that.updateDeckStats();
|
||||
} else if (selectedCardElem.hasClass("cardInDeck")) {
|
||||
that.removeCardFromDeck(selectedCardElem);
|
||||
@@ -342,7 +347,7 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
return "cardType:-SITE,THE_ONE_RING";
|
||||
},
|
||||
|
||||
addCardToDeck: function(blueprintId) {
|
||||
addCardToDeck: function(blueprintId, side) {
|
||||
var that = this;
|
||||
var added = false;
|
||||
$(".card.cardInDeck", this.drawDeckDiv).each(
|
||||
@@ -356,7 +361,7 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
}
|
||||
});
|
||||
if (!added) {
|
||||
var div = this.addCardToContainer(blueprintId, "deck", this.drawDeckDiv)
|
||||
var div = this.addCardToContainer(blueprintId, side, this.drawDeckDiv)
|
||||
div.addClass("cardInDeck");
|
||||
}
|
||||
},
|
||||
@@ -401,7 +406,7 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
|
||||
var cards = root.getElementsByTagName("card");
|
||||
for (var i = 0; i < cards.length; i++)
|
||||
this.addCardToDeck(cards[i].getAttribute("blueprintId"));
|
||||
this.addCardToDeck(cards[i].getAttribute("blueprintId"), cards[i].getAttribute("side"));
|
||||
|
||||
this.layoutUI();
|
||||
}
|
||||
@@ -427,7 +432,7 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
var cardElem = cards[i];
|
||||
var blueprintId = cardElem.getAttribute("blueprintId");
|
||||
var count = cardElem.getAttribute("count");
|
||||
var card = new Card(blueprintId, "collection", "collection" + i, "player");
|
||||
var card = new Card(blueprintId, cardElem.getAttribute("side"), "collection" + i, "player");
|
||||
var cardDiv = createCardDiv(card.imageUrl, null, card.isFoil());
|
||||
cardDiv.data("card", card);
|
||||
cardDiv.addClass("cardInCollection");
|
||||
@@ -472,7 +477,8 @@ var GempLotrDeckBuildingUI = Class.extend({
|
||||
this.siteGroups[i].setBounds(0, 0, sitesWidth, rowHeight);
|
||||
}
|
||||
this.drawDeckDiv.css({ position: "absolute", left: padding * 3 + sitesWidth * 2, top: padding, width: deckWidth - (sitesWidth + padding) * 2 - padding, height: deckHeight - 2 * padding - 50 });
|
||||
this.drawDeckGroup.setBounds(0, 0, deckWidth - (sitesWidth + padding) * 2 - padding, deckHeight - 2 * padding - 50);
|
||||
this.fpDeckGroup.setBounds(0, 0, deckWidth - (sitesWidth + padding) * 2 - padding, (deckHeight - 2 * padding - 50) / 2);
|
||||
this.shadowDeckGroup.setBounds(0, (deckHeight - 2 * padding - 50) / 2, deckWidth - (sitesWidth + padding) * 2 - padding, (deckHeight - 2 * padding - 50) / 2);
|
||||
|
||||
this.bottomBarDiv.css({ position: "absolute", left: padding * 3 + sitesWidth * 2, top: deckHeight - 50, width: deckWidth - (sitesWidth + padding) * 2 - padding, height: 50 });
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ var cardScale = 357 / 497;
|
||||
var Card = Class.extend({
|
||||
blueprintId: null,
|
||||
foil: null,
|
||||
tengwar: null,
|
||||
horizontal: null,
|
||||
imageUrl: null,
|
||||
zone: null,
|
||||
@@ -13,13 +14,16 @@ var Card = Class.extend({
|
||||
attachedCards: null,
|
||||
|
||||
init: function(blueprintId, zone, cardId, owner, siteNumber) {
|
||||
this.blueprintId = blueprintId;
|
||||
|
||||
var len = blueprintId.length;
|
||||
this.foil = blueprintId.substring(len - 1, len) == "*";
|
||||
|
||||
if (this.foil)
|
||||
blueprintId = blueprintId.substring(0, len - 1);
|
||||
|
||||
this.blueprintId = blueprintId;
|
||||
len = blueprintId.length;
|
||||
this.tengwar = blueprintId.substring(len - 1, len) == "T";
|
||||
if (this.tengwar)
|
||||
blueprintId = blueprintId.substring(0, len - 1);
|
||||
|
||||
this.zone = zone;
|
||||
this.cardId = cardId;
|
||||
@@ -45,6 +49,10 @@ var Card = Class.extend({
|
||||
}
|
||||
},
|
||||
|
||||
isTengwar: function() {
|
||||
return this.tengwar;
|
||||
},
|
||||
|
||||
isFoil: function() {
|
||||
return this.foil;
|
||||
},
|
||||
@@ -70,11 +78,11 @@ var Card = Class.extend({
|
||||
setNoStr = setNo;
|
||||
|
||||
if (cardNo < 10)
|
||||
return "http://lotrtcgdb.com/images/LOTR" + setNoStr + "00" + cardNo + ".jpg";
|
||||
return "http://lotrtcgdb.com/images/LOTR" + setNoStr + "00" + cardNo + (this.isTengwar() ? "T" : "") + ".jpg";
|
||||
else if (cardNo < 100)
|
||||
return "http://lotrtcgdb.com/images/LOTR" + setNoStr + "0" + cardNo + ".jpg";
|
||||
return "http://lotrtcgdb.com/images/LOTR" + setNoStr + "0" + cardNo + (this.isTengwar() ? "T" : "") + ".jpg";
|
||||
else
|
||||
return "http://lotrtcgdb.com/images/LOTR" + setNoStr + "" + cardNo + ".jpg";
|
||||
return "http://lotrtcgdb.com/images/LOTR" + setNoStr + "" + cardNo + (this.isTengwar() ? "T" : "") + ".jpg";
|
||||
},
|
||||
|
||||
getHeightForWidth: function(width) {
|
||||
|
||||
Reference in New Issue
Block a user