- 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:
Agetian
2014-01-14 06:02:06 +00:00
parent d234975cde
commit 666fb6b35c
5 changed files with 36 additions and 16 deletions

View File

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

View File

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

View File

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

View File

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

View File

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