mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
simplify ConquestAwardPool
This commit is contained in:
@@ -3,16 +3,15 @@ package forge.planarconquest;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
import forge.util.Aggregates;
|
|
||||||
|
|
||||||
public class ConquestAwardPool {
|
public class ConquestAwardPool {
|
||||||
private final BoosterPool commons, uncommons, rares, mythics;
|
public final List<PaperCard> commons, uncommons, rares, mythics;
|
||||||
|
|
||||||
public ConquestAwardPool(Iterable<PaperCard> cards) {
|
public ConquestAwardPool(Iterable<PaperCard> cards) {
|
||||||
commons = new BoosterPool();
|
commons = new ArrayList<PaperCard>();
|
||||||
uncommons = new BoosterPool();
|
uncommons = new ArrayList<PaperCard>();
|
||||||
rares = new BoosterPool();
|
rares = new ArrayList<PaperCard>();
|
||||||
mythics = new BoosterPool();
|
mythics = new ArrayList<PaperCard>();
|
||||||
|
|
||||||
for (PaperCard c : cards) {
|
for (PaperCard c : cards) {
|
||||||
switch (c.getRarity()) {
|
switch (c.getRarity()) {
|
||||||
@@ -34,41 +33,4 @@ public class ConquestAwardPool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoosterPool getCommons() {
|
|
||||||
return commons;
|
|
||||||
}
|
|
||||||
public BoosterPool getUncommons() {
|
|
||||||
return uncommons;
|
|
||||||
}
|
|
||||||
public BoosterPool getRares() {
|
|
||||||
return rares;
|
|
||||||
}
|
|
||||||
public BoosterPool getMythics() {
|
|
||||||
return mythics;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BoosterPool {
|
|
||||||
private final List<PaperCard> cards = new ArrayList<PaperCard>();
|
|
||||||
|
|
||||||
private BoosterPool() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return cards.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void add(PaperCard c) {
|
|
||||||
cards.add(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void rewardCard(List<PaperCard> rewards) {
|
|
||||||
if (isEmpty()) { return; }
|
|
||||||
|
|
||||||
int index = Aggregates.randomInt(0, cards.size() - 1);
|
|
||||||
PaperCard c = cards.get(index);
|
|
||||||
cards.remove(index);
|
|
||||||
rewards.add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -200,23 +200,19 @@ public class ConquestController {
|
|||||||
int boostersPerMythic = prefs.getPrefInt(CQPref.BOOSTERS_PER_MYTHIC);
|
int boostersPerMythic = prefs.getPrefInt(CQPref.BOOSTERS_PER_MYTHIC);
|
||||||
int raresPerBooster = prefs.getPrefInt(CQPref.BOOSTER_RARES);
|
int raresPerBooster = prefs.getPrefInt(CQPref.BOOSTER_RARES);
|
||||||
for (int i = 0; i < raresPerBooster; i++) {
|
for (int i = 0; i < raresPerBooster; i++) {
|
||||||
if (pool.getMythics().isEmpty() || Aggregates.randomInt(1, boostersPerMythic) > 1) {
|
if (!pool.mythics.isEmpty() && Aggregates.randomInt(1, boostersPerMythic) == 1)
|
||||||
pool.getRares().rewardCard(rewards);
|
rewards.add(Aggregates.removeRandom(pool.mythics));
|
||||||
}
|
else if(!pool.rares.isEmpty())
|
||||||
else {
|
rewards.add(Aggregates.removeRandom(pool.rares));
|
||||||
pool.getMythics().rewardCard(rewards);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int uncommonsPerBooster = prefs.getPrefInt(CQPref.BOOSTER_UNCOMMONS);
|
int uncommonsPerBooster = prefs.getPrefInt(CQPref.BOOSTER_UNCOMMONS);
|
||||||
for (int i = 0; i < uncommonsPerBooster; i++) {
|
for (int i = 0; i < uncommonsPerBooster && !pool.uncommons.isEmpty(); i++)
|
||||||
pool.getUncommons().rewardCard(rewards);
|
rewards.add(Aggregates.removeRandom(pool.uncommons));
|
||||||
}
|
|
||||||
|
|
||||||
int commonsPerBooster = prefs.getPrefInt(CQPref.BOOSTER_COMMONS);
|
int commonsPerBooster = prefs.getPrefInt(CQPref.BOOSTER_COMMONS);
|
||||||
for (int i = 0; i < commonsPerBooster; i++) {
|
for (int i = 0; i < commonsPerBooster && !pool.commons.isEmpty(); i++)
|
||||||
pool.getCommons().rewardCard(rewards);
|
rewards.add(Aggregates.removeRandom(pool.commons));
|
||||||
}
|
|
||||||
|
|
||||||
BoosterUtils.sort(rewards);
|
BoosterUtils.sort(rewards);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user