mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
Fixing limited: removed card lazy loading
This commit is contained in:
parent
a186cc5c33
commit
6b6f718bc4
2 changed files with 39 additions and 16 deletions
|
|
@ -77,19 +77,19 @@ public abstract class ExpansionSet implements Serializable {
|
|||
this.releaseDate = releaseDate;
|
||||
this.setType = setType;
|
||||
this.packageName = packageName;
|
||||
//this.cards = getCardClassesForPackage(packageName);
|
||||
//this.rarities = getCardsByRarity();
|
||||
this.cards = getCardClassesForPackage(packageName);
|
||||
this.rarities = getCardsByRarity();
|
||||
}
|
||||
|
||||
public List<Card> getCards() {
|
||||
if (cards == null) {
|
||||
/*if (cards == null) {
|
||||
synchronized (this) {
|
||||
if (cards == null) {
|
||||
this.cards = getCardClassesForPackage(packageName);
|
||||
this.rarities = getCardsByRarity();
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
return cards;
|
||||
}
|
||||
|
||||
|
|
@ -301,7 +301,7 @@ public abstract class ExpansionSet implements Serializable {
|
|||
private Map<Rarity, List<Card>> getCardsByRarity() {
|
||||
Map<Rarity, List<Card>> cardsByRarity = new HashMap<Rarity, List<Card>>();
|
||||
|
||||
for (Card card : cards) {
|
||||
for (Card card : getCards()) {
|
||||
if (!cardsByRarity.containsKey(card.getRarity()))
|
||||
cardsByRarity.put(card.getRarity(), new ArrayList<Card>());
|
||||
cardsByRarity.get(card.getRarity()).add(card);
|
||||
|
|
@ -426,7 +426,7 @@ public abstract class ExpansionSet implements Serializable {
|
|||
}
|
||||
|
||||
protected Card getRandom(Rarity rarity) {
|
||||
if (!rarities.containsKey(rarity))
|
||||
if (rarities.containsKey(rarity))
|
||||
return null;
|
||||
int size = rarities.get(rarity).size();
|
||||
if (size > 0) {
|
||||
|
|
@ -452,4 +452,11 @@ public abstract class ExpansionSet implements Serializable {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<Rarity, List<Card>> getRarities() {
|
||||
/*if (rarities == null) {
|
||||
this.rarities = getCardsByRarity();
|
||||
}*/
|
||||
return rarities;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue