mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Merge branch 'dungeon' into 'master'
Add Dungeon to EditionSectionWithCollectorNumbers See merge request core-developers/forge!5099
This commit is contained in:
@@ -138,7 +138,7 @@ public class CardStorageReader {
|
||||
final CardRules.Reader rulesReader = new CardRules.Reader();
|
||||
|
||||
final List<CardRules> result = new ArrayList<>();
|
||||
for(int i = from; i < to; i++) {
|
||||
for (int i = from; i < to; i++) {
|
||||
final ZipEntry ze = files.get(i);
|
||||
// if (ze.getName().endsWith(CardStorageReader.CARD_FILE_DOT_EXTENSION)) // already filtered!
|
||||
result.add(this.loadCard(rulesReader, ze));
|
||||
@@ -315,11 +315,11 @@ public class CardStorageReader {
|
||||
final List<Future<List<CardRules>>> parts = executor.invokeAll(tasks);
|
||||
executor.shutdown();
|
||||
cdl.await();
|
||||
for(final Future<List<CardRules>> pp : parts) {
|
||||
for (final Future<List<CardRules>> pp : parts) {
|
||||
result.addAll(pp.get());
|
||||
}
|
||||
} else {
|
||||
for(final Callable<List<CardRules>> c : tasks) {
|
||||
for (final Callable<List<CardRules>> c : tasks) {
|
||||
result.addAll(c.call());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +322,6 @@ public class StaticData {
|
||||
}
|
||||
|
||||
public PaperCard getCardByEditionDate(PaperCard card, Date editionDate) {
|
||||
|
||||
PaperCard c = this.getCommonCards().getCardFromEdition(card.getName(), editionDate, CardDb.SetPreference.LatestCoreExp, card.getArtIndex());
|
||||
|
||||
if (null != c) {
|
||||
@@ -346,7 +345,6 @@ public class StaticData {
|
||||
}
|
||||
|
||||
public PaperCard getCardFromLatestorEarliest(PaperCard card) {
|
||||
|
||||
PaperCard c = this.getCommonCards().getCardFromEdition(card.getName(), null, CardDb.SetPreference.Latest, card.getArtIndex());
|
||||
|
||||
if (null != c && c.hasImage()) {
|
||||
@@ -376,7 +374,6 @@ public class StaticData {
|
||||
}
|
||||
|
||||
public PaperCard getCardFromEarliestCoreExp(PaperCard card) {
|
||||
|
||||
PaperCard c = this.getCommonCards().getCardFromEdition(card.getName(), null, CardDb.SetPreference.EarliestCoreExp, card.getArtIndex());
|
||||
|
||||
if (null != c && c.hasImage()) {
|
||||
|
||||
@@ -212,16 +212,14 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
CardRules cr = rulesByName.get(cis.name);
|
||||
if (cr != null) {
|
||||
addSetCard(e, cis, cr);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
missingCards.add(cis.name);
|
||||
}
|
||||
}
|
||||
if (isCoreExpSet && logMissingPerEdition) {
|
||||
if (missingCards.isEmpty()) {
|
||||
System.out.println(" ... 100% ");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
int missing = (e.getAllCardsInSet().size() - missingCards.size()) * 10000 / e.getAllCardsInSet().size();
|
||||
System.out.printf(" ... %.2f%% (%s missing: %s)%n", missing * 0.01f, Lang.nounWithAmount(missingCards.size(), "card"), StringUtils.join(missingCards, " | "));
|
||||
}
|
||||
@@ -245,7 +243,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
if (!contains(cr.getName())) {
|
||||
if (upcomingSet != null) {
|
||||
addCard(new PaperCard(cr, upcomingSet.getCode(), CardRarity.Unknown, 1));
|
||||
} else if(enableUnknownCards) {
|
||||
} else if (enableUnknownCards) {
|
||||
System.err.println("The card " + cr.getName() + " was not assigned to any set. Adding it to UNKNOWN set... to fix see res/editions/ folder. ");
|
||||
addCard(new PaperCard(cr, CardEdition.UNKNOWN.getCode(), CardRarity.Special, 1));
|
||||
}
|
||||
@@ -505,17 +503,16 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
if (pc.hasImage()) {
|
||||
return pc;
|
||||
}
|
||||
else {
|
||||
if (firstWithoutImage == null) {
|
||||
firstWithoutImage = pc; //ensure first without image returns if none have image
|
||||
}
|
||||
if (cardsListReadOnly) { //ensure we don't modify a cached collection
|
||||
cards = new ArrayList<>(cards);
|
||||
cardsListReadOnly = false;
|
||||
}
|
||||
cards.remove(randomIndex); //remove card from collection and try another random card
|
||||
sz--;
|
||||
if (firstWithoutImage == null) {
|
||||
firstWithoutImage = pc; //ensure first without image returns if none have image
|
||||
}
|
||||
if (cardsListReadOnly) { //ensure we don't modify a cached collection
|
||||
cards = new ArrayList<>(cards);
|
||||
cardsListReadOnly = false;
|
||||
}
|
||||
cards.remove(randomIndex); //remove card from collection and try another random card
|
||||
sz--;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,8 @@ public final class CardEdition implements Comparable<CardEdition> {
|
||||
BUY_A_BOX("buy a box"),
|
||||
PROMO("promo"),
|
||||
BUNDLE("bundle"),
|
||||
BOX_TOPPER("box topper");
|
||||
BOX_TOPPER("box topper"),
|
||||
DUNGEONS("dungeons");
|
||||
|
||||
private final String name;
|
||||
|
||||
@@ -216,11 +217,11 @@ public final class CardEdition implements Comparable<CardEdition> {
|
||||
try {
|
||||
collNr = Integer.parseInt(onlyNumeric);
|
||||
} catch (NumberFormatException exon) {
|
||||
collNr = 0; // this is the case of ONLY-letters collector numbers
|
||||
collNr = 0; // this is the case of ONLY-letters collector numbers
|
||||
}
|
||||
if ((collNr > 0) && (sortableCollNr.startsWith(onlyNumeric))) // e.g. 12a, 37+, 2018f,
|
||||
sortableCollNr = String.format("%05d", collNr) + nonNumeric;
|
||||
else // e.g. WS6, S1
|
||||
else // e.g. WS6, S1
|
||||
sortableCollNr = nonNumeric + String.format("%05d", collNr);
|
||||
}
|
||||
return sortableCollNr;
|
||||
@@ -459,11 +460,11 @@ public final class CardEdition implements Comparable<CardEdition> {
|
||||
Map<String, Integer> cardToIndex = new HashMap<>();
|
||||
|
||||
List<PrintSheet> sheets = Lists.newArrayList();
|
||||
for(String sectionName : cardMap.keySet()) {
|
||||
for (String sectionName : cardMap.keySet()) {
|
||||
PrintSheet sheet = new PrintSheet(String.format("%s %s", this.getCode(), sectionName));
|
||||
|
||||
List<CardInSet> cards = cardMap.get(sectionName);
|
||||
for(CardInSet card : cards) {
|
||||
for (CardInSet card : cards) {
|
||||
int index = 1;
|
||||
if (cardToIndex.containsKey(card.name)) {
|
||||
index = cardToIndex.get(card.name);
|
||||
@@ -478,7 +479,7 @@ public final class CardEdition implements Comparable<CardEdition> {
|
||||
sheets.add(sheet);
|
||||
}
|
||||
|
||||
for(String sheetName : customPrintSheetsToParse.keySet()) {
|
||||
for (String sheetName : customPrintSheetsToParse.keySet()) {
|
||||
List<String> sheetToParse = customPrintSheetsToParse.get(sheetName);
|
||||
CardPool sheetPool = CardPool.fromCardList(sheetToParse);
|
||||
PrintSheet sheet = new PrintSheet(String.format("%s %s", this.getCode(), sheetName), sheetPool);
|
||||
@@ -561,7 +562,7 @@ public final class CardEdition implements Comparable<CardEdition> {
|
||||
|
||||
// parse tokens section
|
||||
if (contents.containsKey("tokens")) {
|
||||
for(String line : contents.get("tokens")) {
|
||||
for (String line : contents.get("tokens")) {
|
||||
if (StringUtils.isBlank(line))
|
||||
continue;
|
||||
|
||||
@@ -589,11 +590,11 @@ public final class CardEdition implements Comparable<CardEdition> {
|
||||
res.mciCode = res.code2.toLowerCase();
|
||||
}
|
||||
res.scryfallCode = section.get("ScryfallCode");
|
||||
if (res.scryfallCode == null){
|
||||
if (res.scryfallCode == null) {
|
||||
res.scryfallCode = res.code;
|
||||
}
|
||||
res.cardsLanguage = section.get("CardLang");
|
||||
if (res.cardsLanguage == null){
|
||||
if (res.cardsLanguage == null) {
|
||||
res.cardsLanguage = "en";
|
||||
}
|
||||
|
||||
@@ -619,7 +620,7 @@ public final class CardEdition implements Comparable<CardEdition> {
|
||||
res.borderColor = BorderColor.valueOf(section.get("border", "Black").toUpperCase(Locale.ENGLISH));
|
||||
Type enumType = Type.UNKNOWN;
|
||||
if (this.isCustomEditions){
|
||||
enumType = Type.CUSTOM_SET; // Forcing ThirdParty Edition Type to avoid inconsistencies
|
||||
enumType = Type.CUSTOM_SET; // Forcing ThirdParty Edition Type to avoid inconsistencies
|
||||
} else {
|
||||
String type = section.get("type");
|
||||
if (null != type && !type.isEmpty()) {
|
||||
@@ -636,7 +637,7 @@ public final class CardEdition implements Comparable<CardEdition> {
|
||||
res.prerelease = section.get("Prerelease", null);
|
||||
res.boosterBoxCount = Integer.parseInt(section.get("BoosterBox", enumType.getBoosterBoxDefault()));
|
||||
|
||||
switch(section.get("foil", "newstyle").toLowerCase()) {
|
||||
switch (section.get("foil", "newstyle").toLowerCase()) {
|
||||
case "notsupported":
|
||||
res.foilType = FoilType.NOT_SUPPORTED;
|
||||
break;
|
||||
@@ -769,7 +770,7 @@ public final class CardEdition implements Comparable<CardEdition> {
|
||||
@Override
|
||||
public Map<String, SealedProduct.Template> readAll() {
|
||||
Map<String, SealedProduct.Template> map = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
for(CardEdition ce : Collection.this) {
|
||||
for (CardEdition ce : Collection.this) {
|
||||
List<String> boosterTypes = Lists.newArrayList(ce.getAvailableBoosterTypes());
|
||||
for (String type : boosterTypes) {
|
||||
String setAffix = type.equals("Draft") ? "" : type;
|
||||
@@ -799,18 +800,18 @@ public final class CardEdition implements Comparable<CardEdition> {
|
||||
|
||||
for (Entry<PaperCard, Integer> k : cards) {
|
||||
PaperCard cp = StaticData.instance().getCommonCards().getCardFromEdition(k.getKey().getName(), strictness);
|
||||
if( cp == null && strictness == SetPreference.EarliestCoreExp) {
|
||||
if (cp == null && strictness == SetPreference.EarliestCoreExp) {
|
||||
strictness = SetPreference.Earliest; // card is not found in core and expansions only (probably something CMD or C13)
|
||||
cp = StaticData.instance().getCommonCards().getCardFromEdition(k.getKey().getName(), strictness);
|
||||
}
|
||||
if ( cp == null )
|
||||
if (cp == null)
|
||||
cp = k.getKey(); // it's unlikely, this code will ever run
|
||||
|
||||
minEditions.add(cp.getEdition());
|
||||
}
|
||||
|
||||
for(CardEdition ed : getOrderedEditions()) {
|
||||
if(minEditions.contains(ed.getCode()))
|
||||
for (CardEdition ed : getOrderedEditions()) {
|
||||
if (minEditions.contains(ed.getCode()))
|
||||
return ed;
|
||||
}
|
||||
return UNKNOWN;
|
||||
|
||||
@@ -513,14 +513,14 @@ public final class CardRules implements ICardCharacteristics {
|
||||
case 'S':
|
||||
if ("S".equals(key)) {
|
||||
this.faces[this.curFace].addStaticAbility(value);
|
||||
} else if ( "SVar".equals(key) ) {
|
||||
if ( null == value ) throw new IllegalArgumentException("SVar has no variable name");
|
||||
} else if ("SVar".equals(key)) {
|
||||
if (null == value) throw new IllegalArgumentException("SVar has no variable name");
|
||||
|
||||
colonPos = value.indexOf(':');
|
||||
String variable = colonPos > 0 ? value.substring(0, colonPos) : value;
|
||||
value = colonPos > 0 ? value.substring(1+colonPos) : null;
|
||||
|
||||
if ( "Picture".equals(variable) ) {
|
||||
if ("Picture".equals(variable)) {
|
||||
this.pictureUrl[this.curFace] = value;
|
||||
} else
|
||||
this.faces[curFace].addSVar(variable, value);
|
||||
|
||||
@@ -451,8 +451,7 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
|
||||
if (calculatedType == null) {
|
||||
if (subtypes.isEmpty()) {
|
||||
calculatedType = StringUtils.join(getTypesBeforeDash(), ' ');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
calculatedType = StringUtils.join(getTypesBeforeDash(), ' ') + " - " + StringUtils.join(subtypes, " ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public final class MagicColor {
|
||||
}
|
||||
|
||||
public static String toShortString(final byte color) {
|
||||
switch (color){
|
||||
switch (color) {
|
||||
case WHITE: return "W";
|
||||
case BLUE: return "U";
|
||||
case BLACK: return "B";
|
||||
@@ -95,7 +95,7 @@ public final class MagicColor {
|
||||
}
|
||||
|
||||
public static String toLongString(final byte color) {
|
||||
switch (color){
|
||||
switch (color) {
|
||||
case WHITE: return Constant.WHITE;
|
||||
case BLUE: return Constant.BLUE;
|
||||
case BLACK: return Constant.BLACK;
|
||||
|
||||
@@ -29,8 +29,8 @@ public class PrintSheet {
|
||||
public static final IStorage<PrintSheet> initializePrintSheets(File sheetsFile, CardEdition.Collection editions) {
|
||||
IStorage<PrintSheet> sheets = new StorageExtendable<>("Special print runs", new PrintSheet.Reader(sheetsFile));
|
||||
|
||||
for(CardEdition edition : editions) {
|
||||
for(PrintSheet ps : edition.getPrintSheetsBySection()) {
|
||||
for (CardEdition edition : editions) {
|
||||
for (PrintSheet ps : edition.getPrintSheetsBySection()) {
|
||||
sheets.add(ps.name, ps);
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class PrintSheet {
|
||||
}
|
||||
|
||||
public void addAll(Iterable<PaperCard> cards, int weight) {
|
||||
for(PaperCard card : cards)
|
||||
for (PaperCard card : cards)
|
||||
cardsWithWeights.add(card, weight);
|
||||
}
|
||||
|
||||
@@ -78,15 +78,15 @@ public class PrintSheet {
|
||||
private PaperCard fetchRoulette(int start, int roulette, Collection<PaperCard> toSkip) {
|
||||
int sum = start;
|
||||
boolean isSecondRun = start > 0;
|
||||
for(Entry<PaperCard, Integer> cc : cardsWithWeights ) {
|
||||
for (Entry<PaperCard, Integer> cc : cardsWithWeights ) {
|
||||
sum += cc.getValue();
|
||||
if( sum > roulette ) {
|
||||
if( toSkip != null && toSkip.contains(cc.getKey()))
|
||||
if (sum > roulette) {
|
||||
if (toSkip != null && toSkip.contains(cc.getKey()))
|
||||
continue;
|
||||
return cc.getKey();
|
||||
}
|
||||
}
|
||||
if( isSecondRun )
|
||||
if (isSecondRun)
|
||||
throw new IllegalStateException("Print sheet does not have enough unique cards");
|
||||
|
||||
return fetchRoulette(sum + 1, roulette, toSkip); // start over from beginning, in case last cards were to skip
|
||||
@@ -94,8 +94,8 @@ public class PrintSheet {
|
||||
|
||||
public List<PaperCard> all() {
|
||||
List<PaperCard> result = new ArrayList<>();
|
||||
for(Entry<PaperCard, Integer> kv : cardsWithWeights) {
|
||||
for(int i = 0; i < kv.getValue(); i++) {
|
||||
for (Entry<PaperCard, Integer> kv : cardsWithWeights) {
|
||||
for (int i = 0; i < kv.getValue(); i++) {
|
||||
result.add(kv.getKey());
|
||||
}
|
||||
}
|
||||
@@ -106,26 +106,26 @@ public class PrintSheet {
|
||||
List<PaperCard> result = new ArrayList<>();
|
||||
|
||||
int totalWeight = cardsWithWeights.countAll();
|
||||
if( totalWeight == 0) {
|
||||
if (totalWeight == 0) {
|
||||
System.err.println("No cards were found on sheet " + name);
|
||||
return result;
|
||||
}
|
||||
|
||||
// If they ask for 40 unique basic lands (to make a fatpack) out of 20 distinct possible, add the whole print run N times.
|
||||
int uniqueCards = cardsWithWeights.countDistinct();
|
||||
while ( number >= uniqueCards ) {
|
||||
for(Entry<PaperCard, Integer> kv : cardsWithWeights) {
|
||||
while (number >= uniqueCards) {
|
||||
for (Entry<PaperCard, Integer> kv : cardsWithWeights) {
|
||||
result.add(kv.getKey());
|
||||
}
|
||||
number -= uniqueCards;
|
||||
}
|
||||
|
||||
List<PaperCard> uniques = wantUnique ? new ArrayList<>() : null;
|
||||
for(int iC = 0; iC < number; iC++) {
|
||||
for (int iC = 0; iC < number; iC++) {
|
||||
int index = MyRandom.getRandom().nextInt(totalWeight);
|
||||
PaperCard toAdd = fetchRoulette(0, index, wantUnique ? uniques : null);
|
||||
result.add(toAdd);
|
||||
if( wantUnique )
|
||||
if (wantUnique)
|
||||
uniques.add(toAdd);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -244,7 +244,7 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
||||
CardPool pool = CardPool.fromCardList(cardsInSection);
|
||||
// I used to store planes and schemes under sideboard header, so this will assign them to a correct section
|
||||
IPaperCard sample = pool.get(0);
|
||||
if (sample != null && ( sample.getRules().getType().isPlane() || sample.getRules().getType().isPhenomenon())) {
|
||||
if (sample != null && (sample.getRules().getType().isPlane() || sample.getRules().getType().isPhenomenon())) {
|
||||
sec = DeckSection.Planes;
|
||||
}
|
||||
if (sample != null && sample.getRules().getType().isScheme()) {
|
||||
@@ -263,13 +263,13 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
||||
Date dateWithAllCards = StaticData.instance().getEditions().getEarliestDateWithAllCards(getAllCardsInASinglePool());
|
||||
String artOption = StaticData.instance().getPrefferedArtOption();
|
||||
|
||||
for(Entry<DeckSection, CardPool> p : parts.entrySet()) {
|
||||
if( p.getKey() == DeckSection.Planes || p.getKey() == DeckSection.Schemes || p.getKey() == DeckSection.Avatar)
|
||||
for (Entry<DeckSection, CardPool> p : parts.entrySet()) {
|
||||
if (p.getKey() == DeckSection.Planes || p.getKey() == DeckSection.Schemes || p.getKey() == DeckSection.Avatar)
|
||||
continue;
|
||||
|
||||
CardPool newPool = new CardPool();
|
||||
|
||||
for(Entry<PaperCard, Integer> cp : p.getValue()){
|
||||
for (Entry<PaperCard, Integer> cp : p.getValue()) {
|
||||
PaperCard card = cp.getKey();
|
||||
int count = cp.getValue();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user