Deck builder and server startup (loading cards in background).

This commit is contained in:
marcins78@gmail.com
2011-12-07 14:02:10 +00:00
parent 0d31c4fc94
commit fa6a183606
10 changed files with 31 additions and 5 deletions

View File

@@ -25,7 +25,7 @@
7_297,3_94
7_319,1_299
7_322,1_304
11_002,1_002
11_2,1_2
11_153,4_288
11_166,1_299
11_209,1_211

View File

@@ -12,7 +12,7 @@ public class LotroCardBlueprintLibrary {
private String[] _packageNames =
new String[]{
"", ".dwarven", ".dunland", ".elven", ".gandalf", ".gollum", ".gondor", ".isengard", ".men", ".orc",
".raider", ".rohan", ".moria", ".wraith", ".sauron", ".shire", ".site"
".raider", ".rohan", ".moria", ".wraith", ".sauron", ".shire", ".site", ".uruk_hai"
};
private Map<String, LotroCardBlueprint> _blueprintMap = new HashMap<String, LotroCardBlueprint>();

View File

@@ -25,6 +25,7 @@ public class ServerManagement {
LeagueDAO leagueDao = new LeagueDAO(dbAccess, library);
DefaultCardCollection collection = new DefaultCardCollection(library);
collection.addPacks("Fellowship of the Ring - League", 12);
collection.finishedReading();
leagueDao.addLeague("Test league", "league_test", collection, 20111122, 20121123);
}

View File

@@ -127,6 +127,7 @@ public class CollectionSerializer {
final String blueprintId = _cardIds.get(i);
collection.addCards(blueprintId, _library.getLotroCardBlueprint(blueprintId), cards[i]);
}
collection.finishedReading();
return collection;
}

View File

@@ -6,11 +6,19 @@ import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
import java.util.*;
import java.util.concurrent.CountDownLatch;
public class DefaultCardCollection implements MutableCardCollection {
private Map<String, Integer> _counts = new TreeMap<String, Integer>(new CardBlueprintIdComparator());
private Map<String, LotroCardBlueprint> _cards = new TreeMap<String, LotroCardBlueprint>();
private LotroCardBlueprintLibrary _library;
private CountDownLatch _collectionReadyLatch = new CountDownLatch(1);
public void finishedReading() {
_collectionReadyLatch.countDown();
}
private static final Comparator<Item> NAME_COMPARATOR = new Comparator<Item>() {
@Override
public int compare(Item o1, Item o2) {
@@ -160,6 +168,12 @@ public class DefaultCardCollection implements MutableCardCollection {
@Override
public List<Item> getItems(String filter) {
try {
_collectionReadyLatch.await();
} catch (InterruptedException exp) {
throw new RuntimeException(exp);
}
if (filter == null)
filter = "";
String[] filterParams = filter.split(" ");

View File

@@ -47,7 +47,7 @@ public class LotroServer extends AbstractServer {
Thread thr = new Thread(
new Runnable() {
public void run() {
for (int i = 1; i <= 10; i++) {
for (int i = 1; i <= 11; i++) {
for (int j = 1; j <= 365; j++) {
String blueprintId = i + "_" + j;
try {
@@ -62,6 +62,7 @@ public class LotroServer extends AbstractServer {
}
}
}
_defaultCollection.finishedReading();
}
}
);

View File

@@ -27,7 +27,7 @@ public class LeagueService {
public MutableCardCollection getLeagueCollection(Player player, League league) {
final MutableCardCollection collectionForPlayer = _collectionDao.getCollectionForPlayer(player, league.getType());
if (collectionForPlayer == null) {
MutableCardCollection collection = new DefaultCardCollection(_library);
DefaultCardCollection collection = new DefaultCardCollection(_library);
MutableCardCollection baseCollection = league.getBaseCollection();
for (CardCollection.Item item : baseCollection.getItems(null)) {
@@ -36,6 +36,7 @@ public class LeagueService {
else
collection.addPacks(item.getBlueprintId(), item.getCount());
}
collection.finishedReading();
return collection;
}
return collectionForPlayer;

View File

@@ -22,6 +22,7 @@ public class CollectionSerializerTest {
collection.addCards("1_23*", library.getLotroCardBlueprint("1_23*"), 3);
collection.addCards("1_237T*", library.getLotroCardBlueprint("1_237T*"), 3);
collection.addPacks("Fellowship of the Ring - League", 2);
collection.finishedReading();
CollectionSerializer serializer = new CollectionSerializer(library);
@@ -47,6 +48,7 @@ public class CollectionSerializerTest {
DefaultCardCollection collection = new DefaultCardCollection(library);
collection.addPacks("Fellowship of the Ring - League", 8);
collection.finishedReading();
CollectionSerializer serializer = new CollectionSerializer(library);

View File

@@ -149,6 +149,10 @@ var GempLotrDeckBuildingUI = Class.extend({
+ "<option value='8'>08 - Siege of Gondor</option>"
+ "<option value='9'>09 - Reflections</option>"
+ "<option value='10'>10 - Mount Doom</option>"
+ "<option value='11,12,13'>War of the Ring Block</option>"
+ "<option value='11'>11 - Shadows</option>"
+ "<option value='12'>12 - Black Rider</option>"
+ "<option value='13'>13 - Bloodlines</option>"
+ "</select>");
this.fullFilterDiv.append("<input type='text' id='cardName' value='Card name'>");
this.fullFilterDiv.append("<select id='sort'>"
@@ -255,7 +259,7 @@ var GempLotrDeckBuildingUI = Class.extend({
$("#cardType").change(filterOut);
$("#keyword").change(filterOut);
$("#labelDWARVEN,#labelELVEN,#labelGANDALF,#labelGONDOR,#labelROHAN,#labelSHIRE,#labelGOLLUM,#labelDUNLAND,#labelISENGARD,#labelMORIA,#labelRAIDER,#labelSAURON,#labelWRAITH").click(filterOut);
$("#labelDWARVEN,#labelELVEN,#labelGANDALF,#labelGONDOR,#labelROHAN,#labelSHIRE,#labelGOLLUM,#labelDUNLAND,#labelISENGARD,#labelMEN,#labelMORIA,#labelORC,#labelRAIDER,#labelSAURON,#labelURUK_HAI,#labelWRAITH").click(filterOut);
$("#countSlider").slider({
value:18,

View File

@@ -80,6 +80,8 @@ var Card = Class.extend({
return (cardNo >= 117 && cardNo <= 120);
if (setNo == 10)
return (cardNo >= 117 && cardNo <= 120);
if (setNo == 11)
return (cardNo >= 227 && cardNo <= 266);
return false;
},