Added Christmas The One Ring promo.

This commit is contained in:
marcins78@gmail.com
2012-12-22 01:06:05 +00:00
parent 53f29ef1b1
commit 978224345b
6 changed files with 83 additions and 60 deletions

View File

@@ -225,4 +225,6 @@
18_146,18_96
18_147,18_97
18_148,18_102
18_149,18_133
18_149,18_133
# Gemp-LotR promos
gl_theOneRing,1_2

View File

@@ -10,58 +10,69 @@ import java.util.List;
import java.util.Map;
public class CollectionSerializer {
private List<String> _packIds = new ArrayList<String>();
private List<String> _cardIds = new ArrayList<String>();
private List<String> _doubleByteCountItems = new ArrayList<String>();
private List<String> _singleByteCountItems = new ArrayList<String>();
public CollectionSerializer() {
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(CollectionSerializer.class.getResourceAsStream("/packs.txt"), "UTF-8"));
try {
String line;
while ((line = bufferedReader.readLine()) != null)
_packIds.add(line);
} finally {
bufferedReader.close();
}
fillDoubleByteItems();
loadSet("1");
loadSet("2");
loadSet("3");
loadSet("0");
loadSet("4");
loadSet("5");
loadSet("6");
loadSet("7");
loadSet("8");
loadSet("9");
loadSet("10");
loadSet("11");
loadSet("12");
loadSet("13");
loadSet("14");
loadSet("15");
loadSet("16");
loadSet("17");
loadSet("18");
loadSet("19");
fillSingleByteItems();
} catch (IOException exp) {
throw new RuntimeException("Problem loading collection data", exp);
}
}
private void loadSet(String setNo) throws IOException {
BufferedReader cardReader = new BufferedReader(new InputStreamReader(CollectionSerializer.class.getResourceAsStream("/set" + setNo + "-rarity.txt"), "UTF-8"));
private void fillSingleByteItems() throws IOException {
loadSet("1");
loadSet("2");
loadSet("3");
loadSet("0");
loadSet("4");
loadSet("5");
loadSet("6");
loadSet("7");
loadSet("8");
loadSet("9");
loadSet("10");
loadSet("11");
loadSet("12");
loadSet("13");
loadSet("14");
loadSet("15");
loadSet("16");
loadSet("17");
loadSet("18");
loadSet("19");
_singleByteCountItems.add("gl_theOneRing");
_singleByteCountItems.add("gl_theOneRing*");
}
private void fillDoubleByteItems() throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(CollectionSerializer.class.getResourceAsStream("/packs.txt"), "UTF-8"));
try {
String line;
while ((line = bufferedReader.readLine()) != null)
_doubleByteCountItems.add(line);
} finally {
bufferedReader.close();
}
}
private void loadSet(String setId) throws IOException {
BufferedReader cardReader = new BufferedReader(new InputStreamReader(CollectionSerializer.class.getResourceAsStream("/set" + setId + "-rarity.txt"), "UTF-8"));
try {
String line;
while ((line = cardReader.readLine()) != null) {
if (!line.substring(0, setNo.length()).equals(setNo))
if (!line.substring(0, setId.length()).equals(setId))
throw new IllegalStateException("Seems the rarity is for some other set");
// Normal
_cardIds.add(translateToBlueprintId(line));
_singleByteCountItems.add(translateToBlueprintId(line));
// Foil
_cardIds.add(translateToBlueprintId(line) + "*");
_singleByteCountItems.add(translateToBlueprintId(line) + "*");
}
} finally {
cardReader.close();
@@ -91,24 +102,25 @@ public class CollectionSerializer {
int currency = collection.getCurrency();
printInt(outputStream, currency, 3);
byte packTypes = (byte) _packIds.size();
byte packTypes = (byte) _doubleByteCountItems.size();
outputStream.write(packTypes);
final Map<String, CardCollection.Item> collectionCounts = collection.getAll();
for (String packId : _packIds) {
final CardCollection.Item count = collectionCounts.get(packId);
for (String itemId : _doubleByteCountItems) {
final CardCollection.Item count = collectionCounts.get(itemId);
if (count == null) {
printInt(outputStream, 0, 2);
} else {
printInt(outputStream, count.getCount(), 2);
int itemCount = Math.min((int) Math.pow(255, 2), count.getCount());
printInt(outputStream, itemCount, 2);
}
}
int cardBytes = _cardIds.size();
int cardBytes = _singleByteCountItems.size();
printInt(outputStream, cardBytes, 2);
for (String cardId : _cardIds) {
final CardCollection.Item count = collectionCounts.get(cardId);
for (String itemId : _singleByteCountItems) {
final CardCollection.Item count = collectionCounts.get(itemId);
if (count == null)
outputStream.write(0);
else {
@@ -145,7 +157,7 @@ public class CollectionSerializer {
throw new IllegalStateException("Under-read the packs information");
for (int i = 0; i < packs.length; i++)
if (packs[i] > 0)
collection.addItem(_packIds.get(i), packs[i]);
collection.addItem(_doubleByteCountItems.get(i), packs[i]);
int cardBytes = convertToInt(inputStream.read(), inputStream.read());
byte[] cards = new byte[cardBytes];
@@ -154,7 +166,7 @@ public class CollectionSerializer {
throw new IllegalArgumentException("Under-read the cards information");
for (int i = 0; i < cards.length; i++)
if (cards[i] > 0) {
final String blueprintId = _cardIds.get(i);
final String blueprintId = _singleByteCountItems.get(i);
collection.addItem(blueprintId, cards[i]);
}
@@ -179,7 +191,7 @@ public class CollectionSerializer {
throw new IllegalStateException("Under-read the packs information");
for (int i = 0; i < packs.length; i++)
if (packs[i] > 0)
collection.addItem(_packIds.get(i), packs[i]);
collection.addItem(_doubleByteCountItems.get(i), packs[i]);
int cardBytes = convertToInt(inputStream.read(), inputStream.read());
byte[] cards = new byte[cardBytes];
@@ -188,7 +200,7 @@ public class CollectionSerializer {
throw new IllegalArgumentException("Under-read the cards information");
for (int i = 0; i < cards.length; i++)
if (cards[i] > 0) {
final String blueprintId = _cardIds.get(i);
final String blueprintId = _singleByteCountItems.get(i);
collection.addItem(blueprintId, cards[i]);
}
@@ -215,7 +227,7 @@ public class CollectionSerializer {
for (int i = 0; i < packTypes; i++) {
int count = convertToInt(packs[i * 2], packs[i * 2 + 1]);
if (count > 0)
collection.addItem(_packIds.get(i), count);
collection.addItem(_doubleByteCountItems.get(i), count);
}
int cardBytes = convertToInt(inputStream.read(), inputStream.read());
@@ -225,7 +237,7 @@ public class CollectionSerializer {
throw new IllegalArgumentException("Under-read the cards information");
for (int i = 0; i < cards.length; i++)
if (cards[i] > 0) {
final String blueprintId = _cardIds.get(i);
final String blueprintId = _singleByteCountItems.get(i);
collection.addItem(blueprintId, cards[i]);
}
@@ -233,17 +245,16 @@ public class CollectionSerializer {
}
private MutableCardCollection deserializeCollectionVer3(BufferedInputStream inputStream) throws IOException {
DefaultCardCollection collection = new DefaultCardCollection();
int byte1 = inputStream.read();
int byte2 = inputStream.read();
int byte3 = inputStream.read();
int currency = convertToInt(byte1, byte2, byte3);
int packTypes = inputStream.read();
DefaultCardCollection collection = new DefaultCardCollection();
collection.addCurrency(currency);
int packTypes = convertToInt(inputStream.read());
byte[] packs = new byte[packTypes * 2];
int read = inputStream.read(packs);
@@ -252,7 +263,7 @@ public class CollectionSerializer {
for (int i = 0; i < packTypes; i++) {
int count = convertToInt(packs[i * 2], packs[i * 2 + 1]);
if (count > 0)
collection.addItem(_packIds.get(i), count);
collection.addItem(_doubleByteCountItems.get(i), count);
}
int cardBytes = convertToInt(inputStream.read(), inputStream.read());
@@ -263,7 +274,7 @@ public class CollectionSerializer {
for (int i = 0; i < cards.length; i++) {
int count = convertToInt(cards[i]);
if (count>0) {
final String blueprintId = _cardIds.get(i);
final String blueprintId = _singleByteCountItems.get(i);
collection.addItem(blueprintId, count);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 KiB

View File

@@ -503,7 +503,7 @@ var GempLotrDeckBuildingUI = Class.extend({
this.infoDialog.html("");
this.infoDialog.html("<div style='scroll: auto'></div>");
this.infoDialog.append(createFullCardDiv(card.imageUrl, card.foil, card.horizontal, card.isPack()));
if (!card.isPack())
if (card.hasWikiInfo())
this.infoDialog.append("<div><a href='" + card.getWikiLink() + "' target='_blank'>Wiki</a></div>");
var windowWidth = $(window).width();
var windowHeight = $(window).height();

View File

@@ -6,7 +6,9 @@ var fixedImages = {
"15_205":"http://lotrtcgwiki.com/images/LOTR15060E.jpg",
"15_206":"http://lotrtcgwiki.com/images/LOTR15060G.jpg",
// Holidays Gandalf
"15_207":"http://lotrtcgwiki.com/images/LOTR15029H.jpg"
"15_207":"http://lotrtcgwiki.com/images/LOTR15029H.jpg",
// Gemp-LotR promos
"gl_theOneRing":"/gemp-lotr/images/cards/gl_theOneRing.png"
};
var packBlueprints = {
@@ -122,6 +124,7 @@ var Card = Class.extend({
blueprintId:null,
foil:null,
tengwar:null,
hasWiki: null,
horizontal:null,
imageUrl:null,
zone:null,
@@ -146,6 +149,9 @@ var Card = Class.extend({
if (this.tengwar)
bareBlueprint = bareBlueprint.substring(0, len - 1);
this.hasWiki = fixedImages[imageBlueprint] == null
&& packBlueprints[imageBlueprint] == null;
this.zone = zone;
this.cardId = cardId;
this.owner = owner;
@@ -268,6 +274,10 @@ var Card = Class.extend({
return "http://lotrtcgwiki.com/wiki/" + imageUrl.substr(afterLastSlash, countAfterLastSlash);
},
hasWikiInfo: function() {
return this.hasWiki;
},
formatSetNo:function (setNo) {
var setNoStr;
if (setNo < 10)

View File

@@ -186,7 +186,7 @@ var GempLotrMerchantUI = Class.extend({
this.infoDialog.html("");
this.infoDialog.html("<div style='scroll: auto'></div>");
this.infoDialog.append(createFullCardDiv(card.imageUrl, card.foil, card.horizontal, card.isPack()));
if (!card.isPack())
if (card.hasWikiInfo())
this.infoDialog.append("<div><a href='" + card.getWikiLink() + "' target='_blank'>Wiki</a></div>");
var windowWidth = $(window).width();
var windowHeight = $(window).height();
@@ -301,7 +301,7 @@ var GempLotrMerchantUI = Class.extend({
this.questionDialog.html("<div style='scroll: auto'></div>");
var floatCardDiv = $("<div style='float: left;'></div>");
floatCardDiv.append(createFullCardDiv(card.imageUrl, card.foil, card.horizontal, card.isPack()));
if (!card.isPack())
if (card.hasWikiInfo())
floatCardDiv.append("<div><a href='" + card.getWikiLink() + "' target='_blank'>Wiki</a></div>");
this.questionDialog.append(floatCardDiv);
var questionDiv = $("<div id='cardEffects'>" + text + "</div>");