mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
refactor and remove some dependencies
This commit is contained in:
@@ -56,36 +56,34 @@ public class CardPool extends ItemPool<PaperCard> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: ART indices are "1" -based
|
// NOTE: ART indices are "1" -based
|
||||||
public void add(final String cardName, final String setCode, final int artIndex, final int amount) {
|
public void add(final String cardName, String setCode, final int artIndex, final int amount) {
|
||||||
PaperCard cp = StaticData.instance().getCommonCards().getCard(cardName, setCode, artIndex);
|
PaperCard cp = StaticData.instance().getCommonCards().getCard(cardName, setCode, artIndex);
|
||||||
boolean isCommonCard = cp != null;
|
boolean isCommonCard = cp != null;
|
||||||
if ( !isCommonCard ) {
|
if ( !isCommonCard ) {
|
||||||
cp = StaticData.instance().getVariantCards().getCard(cardName, setCode);
|
cp = StaticData.instance().getVariantCards().getCard(cardName, setCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int artCount = isCommonCard
|
if (cp == null )
|
||||||
? StaticData.instance().getCommonCards().getArtCount(cardName, setCode) : 1;
|
|
||||||
|
|
||||||
if ( cp != null) {
|
|
||||||
if (artIndex >= 0 || artCount <= 1) {
|
|
||||||
// either a specific art index is specified, or there is only one art, so just add the card
|
|
||||||
this.add(cp, amount);
|
|
||||||
} else {
|
|
||||||
// random art index specified, make sure we get different groups of cards with different art
|
|
||||||
int[] artGroups = MyRandom.splitIntoRandomGroups(amount, artCount);
|
|
||||||
for (int i = 1; i <= artGroups.length; i++) {
|
|
||||||
int cnt = artGroups[i-1];
|
|
||||||
if (cnt <= 0)
|
|
||||||
continue;
|
|
||||||
PaperCard cp_random = isCommonCard
|
|
||||||
? StaticData.instance().getCommonCards().getCard(cardName, setCode, i)
|
|
||||||
: StaticData.instance().getVariantCards().getCard(cardName, setCode, i);
|
|
||||||
this.add(cp_random, cnt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new RuntimeException(String.format("Card %s from %s is not supported by Forge, as it's neither a known common card nor one of casual variants' card.", cardName, setCode ));
|
throw new RuntimeException(String.format("Card %s from %s is not supported by Forge, as it's neither a known common card nor one of casual variants' card.", cardName, setCode ));
|
||||||
|
|
||||||
|
setCode = cp.getEdition();
|
||||||
|
int artCount = isCommonCard ? StaticData.instance().getCommonCards().getArtCount(cardName, setCode) : 1;
|
||||||
|
|
||||||
|
if (artIndex >= 0 || artCount <= 1) {
|
||||||
|
// either a specific art index is specified, or there is only one art, so just add the card
|
||||||
|
this.add(cp, amount);
|
||||||
|
} else {
|
||||||
|
// random art index specified, make sure we get different groups of cards with different art
|
||||||
|
int[] artGroups = MyRandom.splitIntoRandomGroups(amount, artCount);
|
||||||
|
for (int i = 1; i <= artGroups.length; i++) {
|
||||||
|
int cnt = artGroups[i-1];
|
||||||
|
if (cnt <= 0)
|
||||||
|
continue;
|
||||||
|
PaperCard cp_random = isCommonCard
|
||||||
|
? StaticData.instance().getCommonCards().getCard(cardName, setCode, i)
|
||||||
|
: StaticData.instance().getVariantCards().getCard(cardName, setCode, i);
|
||||||
|
this.add(cp_random, cnt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class MyRandom {
|
|||||||
int[] groups = new int[numGroups];
|
int[] groups = new int[numGroups];
|
||||||
|
|
||||||
for (int i = 0; i < value; i++) {
|
for (int i = 0; i < value; i++) {
|
||||||
groups[MyRandom.getRandom().nextInt(numGroups)]++;
|
groups[random.nextInt(numGroups)]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups;
|
return groups;
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import forge.limited.BoosterDraft;
|
|||||||
import forge.limited.IBoosterDraft;
|
import forge.limited.IBoosterDraft;
|
||||||
import forge.properties.ForgePreferences.FPref;
|
import forge.properties.ForgePreferences.FPref;
|
||||||
import forge.util.ItemPool;
|
import forge.util.ItemPool;
|
||||||
import forge.util.MyRandom;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the deck editor UI as necessary draft selection mode.
|
* Updates the deck editor UI as necessary draft selection mode.
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import forge.limited.SealedCardPoolGenerator;
|
|||||||
import forge.limited.SealedDeckBuilder;
|
import forge.limited.SealedDeckBuilder;
|
||||||
import forge.properties.ForgePreferences.FPref;
|
import forge.properties.ForgePreferences.FPref;
|
||||||
import forge.util.ItemPool;
|
import forge.util.ItemPool;
|
||||||
import forge.util.MyRandom;
|
|
||||||
import forge.util.storage.IStorage;
|
import forge.util.storage.IStorage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user