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))
|
||||
: 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,21 @@ public class CardPool extends ItemPool<PaperCard> {
|
||||
if ( cp == null )
|
||||
cp = StaticData.instance().getVariantCards().tryGetCard(cardName, setCode, artIndex);
|
||||
|
||||
if ( cp != null)
|
||||
if ( cp != null) {
|
||||
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
|
||||
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,15 +94,19 @@ public class CardPool extends ItemPool<PaperCard> {
|
||||
* @param cardName the card name
|
||||
*/
|
||||
public void add(final String cardName, int cnt) {
|
||||
// in order to account for art index randomization we have to add cards one by one instead of in a batch
|
||||
// TODO: somehow optimize this algorithm?...
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
PaperCard cp = StaticData.instance().getCommonCards().tryGetCard(cardName);
|
||||
if ( cp == null )
|
||||
cp = StaticData.instance().getVariantCards().tryGetCard(cardName);
|
||||
|
||||
if ( cp != null)
|
||||
this.add(cp, cnt);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns n-th card from this DeckSection. LINEAR time. No fixed order between changes
|
||||
|
||||
@@ -157,9 +157,7 @@ public class CEditorDraftingProcess extends ACEditorBase<PaperCard, DeckGroup> {
|
||||
final CardEdition landSet = IBoosterDraft.LAND_SET_CODE[0];
|
||||
final int landsCount = 20;
|
||||
for(String landName : MagicColor.Constant.BASIC_LANDS) {
|
||||
for (int i = 0; i < landsCount; i++) {
|
||||
deck.get(DeckSection.Sideboard).add(landName, landSet.getCode(), -1, 1);
|
||||
}
|
||||
deck.get(DeckSection.Sideboard).add(landName, landSet.getCode(), -1, landsCount);
|
||||
}
|
||||
|
||||
return deck;
|
||||
|
||||
@@ -172,9 +172,7 @@ public enum CSubmenuSealed implements ICDoc {
|
||||
deck.getOrCreate(DeckSection.Sideboard).addAll(humanPool);
|
||||
|
||||
for (final String element : MagicColor.Constant.BASIC_LANDS) {
|
||||
for (int i = 0; i < 18; i++) {
|
||||
deck.get(DeckSection.Sideboard).add(element, sd.getLandSetCode(), -1, 1);
|
||||
}
|
||||
deck.get(DeckSection.Sideboard).add(element, sd.getLandSetCode(), -1, 18);
|
||||
}
|
||||
|
||||
final IStorage<DeckGroup> sealedDecks = Singletons.getModel().getDecks().getSealed();
|
||||
|
||||
@@ -126,6 +126,8 @@ public final class QuestUtilCards {
|
||||
|
||||
for (String landName : MagicColor.Constant.BASIC_LANDS) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user