mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- Cards with no art index specified will now have random art in every match (e.g. the line "20 Forest|7ED" provides twenty 7th Edition Forest cards each with randomized art).
- Some code reogranization related to card art randomization.
This commit is contained in:
@@ -173,6 +173,11 @@ public final class CardDb implements ICardDatabase {
|
|||||||
? ( fromLastSet ? this.uniqueCardsByName.get(splitName.get(0)) : tryGetCard(splitName.get(0), Aggregates.random(this.allCardsByName.get(splitName.get(0))).getEdition(), -1))
|
? ( fromLastSet ? this.uniqueCardsByName.get(splitName.get(0)) : tryGetCard(splitName.get(0), Aggregates.random(this.allCardsByName.get(splitName.get(0))).getEdition(), -1))
|
||||||
: tryGetCard(splitName.get(0), splitName.get(1), Integer.parseInt(splitName.get(2)));
|
: tryGetCard(splitName.get(0), splitName.get(1), Integer.parseInt(splitName.get(2)));
|
||||||
|
|
||||||
|
if (fromLastSet && null != res) {
|
||||||
|
final PaperCard res_randart = tryGetCard(res.getName(), res.getEdition(), Integer.parseInt(splitName.get(2)));
|
||||||
|
return null != res_randart && isFoil ? getFoiled(res_randart) : res_randart;
|
||||||
|
}
|
||||||
|
|
||||||
return null != res && isFoil ? getFoiled(res) : res;
|
return null != res && isFoil ? getFoiled(res) : res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,21 @@ public class CardPool extends ItemPool<PaperCard> {
|
|||||||
if ( cp == null )
|
if ( cp == null )
|
||||||
cp = StaticData.instance().getVariantCards().tryGetCard(cardName, setCode, artIndex);
|
cp = StaticData.instance().getVariantCards().tryGetCard(cardName, setCode, artIndex);
|
||||||
|
|
||||||
if ( cp != null)
|
if ( cp != null) {
|
||||||
this.add(cp, amount);
|
if (artIndex >= 0) {
|
||||||
|
this.add(cp, amount);
|
||||||
|
} else {
|
||||||
|
// random art index specified, we have to add cards one by one to randomize art for each of them
|
||||||
|
// TODO: somehow optimize this algorithm?...
|
||||||
|
for (int i = 0; i < amount; i++) {
|
||||||
|
PaperCard cp_random = StaticData.instance().getCommonCards().tryGetCard(cardName, setCode, -1);
|
||||||
|
if (cp_random == null) {
|
||||||
|
cp_random = StaticData.instance().getVariantCards().tryGetCard(cardName, setCode, -1);
|
||||||
|
}
|
||||||
|
this.add(cp_random);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
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 ));
|
||||||
}
|
}
|
||||||
@@ -81,14 +94,18 @@ public class CardPool extends ItemPool<PaperCard> {
|
|||||||
* @param cardName the card name
|
* @param cardName the card name
|
||||||
*/
|
*/
|
||||||
public void add(final String cardName, int cnt) {
|
public void add(final String cardName, int cnt) {
|
||||||
PaperCard cp = StaticData.instance().getCommonCards().tryGetCard(cardName);
|
// in order to account for art index randomization we have to add cards one by one instead of in a batch
|
||||||
if ( cp == null )
|
// TODO: somehow optimize this algorithm?...
|
||||||
cp = StaticData.instance().getVariantCards().tryGetCard(cardName);
|
for (int i = 0; i < cnt; i++) {
|
||||||
|
PaperCard cp = StaticData.instance().getCommonCards().tryGetCard(cardName);
|
||||||
if ( cp != null)
|
if ( cp == null )
|
||||||
this.add(cp, cnt);
|
cp = StaticData.instance().getVariantCards().tryGetCard(cardName);
|
||||||
else
|
|
||||||
throw new NoSuchElementException(String.format("Card %s is not supported by Forge, as it's neither a known common card nor one of casual variants' card.", cardName));
|
if ( cp != null)
|
||||||
|
this.add(cp);
|
||||||
|
else
|
||||||
|
throw new NoSuchElementException(String.format("Card %s is not supported by Forge, as it's neither a known common card nor one of casual variants' card.", cardName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -157,9 +157,7 @@ public class CEditorDraftingProcess extends ACEditorBase<PaperCard, DeckGroup> {
|
|||||||
final CardEdition landSet = IBoosterDraft.LAND_SET_CODE[0];
|
final CardEdition landSet = IBoosterDraft.LAND_SET_CODE[0];
|
||||||
final int landsCount = 20;
|
final int landsCount = 20;
|
||||||
for(String landName : MagicColor.Constant.BASIC_LANDS) {
|
for(String landName : MagicColor.Constant.BASIC_LANDS) {
|
||||||
for (int i = 0; i < landsCount; i++) {
|
deck.get(DeckSection.Sideboard).add(landName, landSet.getCode(), -1, landsCount);
|
||||||
deck.get(DeckSection.Sideboard).add(landName, landSet.getCode(), -1, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return deck;
|
return deck;
|
||||||
|
|||||||
@@ -172,9 +172,7 @@ public enum CSubmenuSealed implements ICDoc {
|
|||||||
deck.getOrCreate(DeckSection.Sideboard).addAll(humanPool);
|
deck.getOrCreate(DeckSection.Sideboard).addAll(humanPool);
|
||||||
|
|
||||||
for (final String element : MagicColor.Constant.BASIC_LANDS) {
|
for (final String element : MagicColor.Constant.BASIC_LANDS) {
|
||||||
for (int i = 0; i < 18; i++) {
|
deck.get(DeckSection.Sideboard).add(element, sd.getLandSetCode(), -1, 18);
|
||||||
deck.get(DeckSection.Sideboard).add(element, sd.getLandSetCode(), -1, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final IStorage<DeckGroup> sealedDecks = Singletons.getModel().getDecks().getSealed();
|
final IStorage<DeckGroup> sealedDecks = Singletons.getModel().getDecks().getSealed();
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ public final class QuestUtilCards {
|
|||||||
|
|
||||||
for (String landName : MagicColor.Constant.BASIC_LANDS) {
|
for (String landName : MagicColor.Constant.BASIC_LANDS) {
|
||||||
for (int i=0; i<nBasic; i++) {
|
for (int i=0; i<nBasic; i++) {
|
||||||
|
// we have to add lands one at a time here because ItemPool<PaperCard> can't handle art index
|
||||||
|
// randomization internally when adding cards in a batch (all cards end up with the same art)
|
||||||
pool.add(db.getCard(landName, landCode, -1), 1);
|
pool.add(db.getCard(landName, landCode, -1), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user