Merge branch 'dungeon' into 'master'

Add Dungeon to EditionSectionWithCollectorNumbers

See merge request core-developers/forge!5099
This commit is contained in:
Michael Kamensky
2021-07-24 05:17:57 +00:00
22 changed files with 74 additions and 94 deletions

View File

@@ -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());
}
}

View File

@@ -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()) {

View File

@@ -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--;
}
}
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -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, " ");
}
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();

View File

@@ -545,7 +545,7 @@ public class GameAction {
if (fromBattlefield && !zoneFrom.getPlayer().equals(zoneTo.getPlayer())) {
final Map<AbilityKey, Object> runParams2 = AbilityKey.mapFromCard(lastKnownInfo);
runParams2.put(AbilityKey.OriginalController, zoneFrom.getPlayer());
if(params != null) {
if (params != null) {
runParams2.putAll(params);
}
game.getTriggerHandler().runTrigger(TriggerType.ChangesController, runParams2, false);

View File

@@ -73,8 +73,7 @@ public class DamageAllEffect extends DamageBaseEffect {
CardCollectionView list;
if (sa.hasParam("ValidCards")) {
list = game.getCardsIn(ZoneType.Battlefield);
}
else {
} else {
list = CardCollection.EMPTY;
}

View File

@@ -19,7 +19,7 @@ public enum AttackRestrictionType {
public Predicate<Card> getPredicate(final Card attacker) {
switch (this) {
case NEED_GREATER_POWER:
return CardPredicates.hasGreaterPowerThan(attacker.getNetPower());
return CardPredicates.hasGreaterPowerThan(attacker.getNetPower());
case NEED_BLACK_OR_GREEN:
return Predicates.and(
CardPredicates.isColor((byte) (MagicColor.BLACK | MagicColor.GREEN)),

View File

@@ -36,8 +36,7 @@ public class ManaConversionMatrix {
rowIdx = rowIdx < 0 ? identityMatrix.length - 1 : rowIdx;
if (additive) {
colorConversionMatrix[rowIdx] |= replacementColor;
}
else {
} else {
colorRestrictionMatrix[rowIdx] &= replacementColor;
}
}

View File

@@ -258,8 +258,7 @@ public class ManaCostBeingPaid {
ManaCostShard shard;
if (StringUtils.isEmpty(xColor)) {
shard = ManaCostShard.GENERIC;
}
else {
} else {
shard = ManaCostShard.parseNonGeneric(xColor);
}
increaseShard(shard, xCost, true);

View File

@@ -137,18 +137,15 @@ public class ManaPool extends ManaConversionMatrix implements Iterable<Mana> {
if (convertToColorless) {
convertManaColor(b, (byte)ManaAtom.COLORLESS);
cm.addAll(pMana);
}
else {
} else {
cleared.addAll(cm);
cm.clear();
floatingMana.putAll(b, pMana);
}
}
else {
} else {
if (convertToColorless) {
convertManaColor(b, (byte)ManaAtom.COLORLESS);
}
else {
} else {
cleared.addAll(cm);
cm.clear();
}
@@ -261,8 +258,7 @@ public class ManaPool extends ManaConversionMatrix implements Iterable<Mana> {
if (poolLane != null && poolLane.contains(mana)) {
removeFloating.add(mana);
}
else {
} else {
manaNotAccountedFor = true;
break;
}
@@ -319,7 +315,7 @@ public class ManaPool extends ManaConversionMatrix implements Iterable<Mana> {
// TODO Debug this for Paying Gonti,
byte line = getPossibleColorUses(color);
for(byte outColor : ManaAtom.MANATYPES) {
for (byte outColor : ManaAtom.MANATYPES) {
if ((line & outColor) != 0 && shard.canBePaidWithManaOfColor(outColor)) {
return true;
}

View File

@@ -63,7 +63,7 @@ public class MulliganService {
boolean allKept;
do {
allKept = true;
for(AbstractMulligan mulligan : mulligans) {
for (AbstractMulligan mulligan : mulligans) {
if (mulligan.hasKept()) {
continue;
}
@@ -85,7 +85,7 @@ public class MulliganService {
}
} while (!allKept);
for(AbstractMulligan mulligan : mulligans) {
for (AbstractMulligan mulligan : mulligans) {
mulligan.afterMulligan();
}
}

View File

@@ -136,7 +136,7 @@ public class RegisteredPlayer {
}
if (appliedVariants.contains(GameType.Vanguard) || appliedVariants.contains(GameType.MomirBasic)
|| appliedVariants.contains(GameType.MoJhoSto)) { //fix the crash, if somehow the avatar is null, get it directly from the deck
start.setVanguardAvatars(vanguardAvatar == null ? deck.get(DeckSection.Avatar).toFlatList():vanguardAvatar.toFlatList());
start.setVanguardAvatars(vanguardAvatar == null ? deck.get(DeckSection.Avatar).toFlatList() : vanguardAvatar.toFlatList());
}
return start;
}
@@ -167,7 +167,7 @@ public class RegisteredPlayer {
private void setVanguardAvatars(List<PaperCard> vanguardAvatars0) {
vanguardAvatars = vanguardAvatars0;
if (vanguardAvatars == null) { return; }
for(PaperCard avatar: vanguardAvatars){
for (PaperCard avatar: vanguardAvatars) {
setStartingLife(getStartingLife() + avatar.getRules().getLife());
setStartingHand(getStartingHand() + avatar.getRules().getHand());
}

View File

@@ -163,7 +163,6 @@ public class StaticAbilityCantBeCast {
return false;
}
if (stAb.hasParam("AffectedZone") && !card.isInZone(ZoneType.smartValueOf(stAb.getParam("AffectedZone")))) {
return false;
}

View File

@@ -48,11 +48,7 @@ public class StaticAbilityCastWithFlash {
return false;
}
public static boolean commonParts(final StaticAbility stAb, final SpellAbility sa, final Card card, final Player activator) {
if (!stAb.matchesValidParam("ValidCard", card)) {
return false;
}

View File

@@ -535,14 +535,12 @@ public abstract class Trigger extends TriggerReplacementBase {
return this.numberTurnActivations;
}
public void triggerRun()
{
public void triggerRun() {
this.numberTurnActivations++;
}
// Resets the state stored each turn for per-turn and per-instance restriction
public void resetTurnState()
{
public void resetTurnState() {
this.numberTurnActivations = 0;
}

View File

@@ -335,7 +335,7 @@ public class TriggerHandler {
waitingTriggers.clear();
}
public void resetTurnTriggerState() {
public void resetTurnTriggerState() {
for(final Trigger t : activeTriggers) {
t.resetTurnState();
}

View File

@@ -839,7 +839,7 @@ public class VLobby implements ILobbyView {
}
private boolean isPlayerAI(final int playernum) {
if(playernum < activePlayersNum){
if (playernum < activePlayersNum) {
return playerPanels.get(playernum).isAi();
}
return true;