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