mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
replaced some cardFactory.getcard to CardPrinted.toForgeCard calls
still renaming set to edition streamlined challenge reward generation
This commit is contained in:
@@ -696,7 +696,7 @@ public final class CardUtil {
|
|||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public static String buildFilename(final CardPrinted card) {
|
public static String buildFilename(final CardPrinted card) {
|
||||||
final int maxIndex = card.getCard().getSetInfo(card.getEdition()).getCopiesCount();
|
final int maxIndex = card.getCard().getEditionInfo(card.getEdition()).getCopiesCount();
|
||||||
return CardUtil.buildFilename(card.getName(), card.getEdition(), card.getArtIndex(), maxIndex, false);
|
return CardUtil.buildFilename(card.getName(), card.getEdition(), card.getArtIndex(), maxIndex, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -710,7 +710,7 @@ public final class CardUtil {
|
|||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public static String buildFilename(final CardPrinted card, final String nameToUse) {
|
public static String buildFilename(final CardPrinted card, final String nameToUse) {
|
||||||
final int maxIndex = card.getCard().getSetInfo(card.getEdition()).getCopiesCount();
|
final int maxIndex = card.getCard().getEditionInfo(card.getEdition()).getCopiesCount();
|
||||||
return CardUtil.buildFilename(nameToUse, card.getEdition(), card.getArtIndex(), maxIndex, false);
|
return CardUtil.buildFilename(nameToUse, card.getEdition(), card.getArtIndex(), maxIndex, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader {
|
|||||||
System.out.println("Oh snap!");
|
System.out.println("Oh snap!");
|
||||||
}
|
}
|
||||||
if (!foundSetImage) {
|
if (!foundSetImage) {
|
||||||
final int artsCnt = c.getCard().getSetInfo(setCode3).getCopiesCount();
|
final int artsCnt = c.getCard().getEditionInfo(setCode3).getCopiesCount();
|
||||||
final String fn = CardUtil.buildIdealFilename(cardName, c.getArtIndex(), artsCnt);
|
final String fn = CardUtil.buildIdealFilename(cardName, c.getArtIndex(), artsCnt);
|
||||||
cList.add(new DownloadObject(fn, urlBase + setCode2 + "/" + Base64Coder.encodeString(fn, true),
|
cList.add(new DownloadObject(fn, urlBase + setCode2 + "/" + Base64Coder.encodeString(fn, true),
|
||||||
this.picturesPath + File.separator + setCode3));
|
this.picturesPath + File.separator + setCode3));
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ public final class CardRules {
|
|||||||
* the set code
|
* the set code
|
||||||
* @return the sets the info
|
* @return the sets the info
|
||||||
*/
|
*/
|
||||||
public CardInSet getSetInfo(final String setCode) {
|
public CardInSet getEditionInfo(final String setCode) {
|
||||||
final CardInSet result = this.setsPrinted.get(setCode);
|
final CardInSet result = this.setsPrinted.get(setCode);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ public class GameNew {
|
|||||||
Singletons.getControl().getControlMatch().getMessageControl().updateGameCount();
|
Singletons.getControl().getControlMatch().getMessageControl().updateGameCount();
|
||||||
|
|
||||||
// friendliness
|
// friendliness
|
||||||
final CardFactoryInterface c = AllZone.getCardFactory();
|
|
||||||
Card.resetUniqueNumber();
|
Card.resetUniqueNumber();
|
||||||
final boolean canRandomFoil = Constant.Runtime.RANDOM_FOIL[0]
|
final boolean canRandomFoil = Constant.Runtime.RANDOM_FOIL[0]
|
||||||
&& Constant.Runtime.getGameType().equals(GameType.Constructed);
|
&& Constant.Runtime.getGameType().equals(GameType.Constructed);
|
||||||
@@ -125,16 +124,13 @@ public class GameNew {
|
|||||||
final CardPrinted cardPrinted = stackOfCards.getKey();
|
final CardPrinted cardPrinted = stackOfCards.getKey();
|
||||||
for (int i = 0; i < stackOfCards.getValue(); i++) {
|
for (int i = 0; i < stackOfCards.getValue(); i++) {
|
||||||
|
|
||||||
final Card card = c.getCard(cardPrinted.getName(), AllZone.getHumanPlayer());
|
final Card card = cardPrinted.toForgeCard(AllZone.getHumanPlayer());
|
||||||
card.setCurSetCode(cardPrinted.getEdition());
|
final int cntVariants = cardPrinted.getCard().getEditionInfo(cardPrinted.getEdition()).getCopiesCount();
|
||||||
|
|
||||||
final int cntVariants = cardPrinted.getCard().getSetInfo(cardPrinted.getEdition()).getCopiesCount();
|
|
||||||
if (cntVariants > 1) {
|
if (cntVariants > 1) {
|
||||||
card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1);
|
card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1);
|
||||||
|
card.setImageFilename(CardUtil.buildFilename(card));
|
||||||
}
|
}
|
||||||
|
|
||||||
card.setImageFilename(CardUtil.buildFilename(card));
|
|
||||||
|
|
||||||
// Assign random foiling on approximately 1:20 cards
|
// Assign random foiling on approximately 1:20 cards
|
||||||
if (cardPrinted.isFoil() || (canRandomFoil && MyRandom.percentTrue(5))) {
|
if (cardPrinted.isFoil() || (canRandomFoil && MyRandom.percentTrue(5))) {
|
||||||
final int iFoil = MyRandom.getRandom().nextInt(9) + 1;
|
final int iFoil = MyRandom.getRandom().nextInt(9) + 1;
|
||||||
@@ -167,16 +163,13 @@ public class GameNew {
|
|||||||
final CardPrinted cardPrinted = stackOfCards.getKey();
|
final CardPrinted cardPrinted = stackOfCards.getKey();
|
||||||
for (int i = 0; i < stackOfCards.getValue(); i++) {
|
for (int i = 0; i < stackOfCards.getValue(); i++) {
|
||||||
|
|
||||||
final Card card = c.getCard(cardPrinted.getName(), AllZone.getComputerPlayer());
|
final Card card = cardPrinted.toForgeCard(AllZone.getComputerPlayer());
|
||||||
card.setCurSetCode(cardPrinted.getEdition());
|
final int cntVariants = cardPrinted.getCard().getEditionInfo(cardPrinted.getEdition()).getCopiesCount();
|
||||||
|
|
||||||
final int cntVariants = cardPrinted.getCard().getSetInfo(cardPrinted.getEdition()).getCopiesCount();
|
|
||||||
if (cntVariants > 1) {
|
if (cntVariants > 1) {
|
||||||
card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1);
|
card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1);
|
||||||
|
card.setImageFilename(CardUtil.buildFilename(card));
|
||||||
}
|
}
|
||||||
|
|
||||||
card.setImageFilename(CardUtil.buildFilename(card));
|
|
||||||
|
|
||||||
// Assign random foiling on approximately 1:20 cards
|
// Assign random foiling on approximately 1:20 cards
|
||||||
if (cardPrinted.isFoil() || (canRandomFoil && MyRandom.percentTrue(5))) {
|
if (cardPrinted.isFoil() || (canRandomFoil && MyRandom.percentTrue(5))) {
|
||||||
final int iFoil = MyRandom.getRandom().nextInt(9) + 1;
|
final int iFoil = MyRandom.getRandom().nextInt(9) + 1;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import java.util.EnumMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.card.CardRarity;
|
import forge.card.CardRarity;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.deck.DeckBase;
|
import forge.deck.DeckBase;
|
||||||
@@ -70,8 +69,7 @@ public class CustomLimited extends DeckBase {
|
|||||||
private transient ItemPoolView<CardPrinted> cardPool;
|
private transient ItemPoolView<CardPrinted> cardPool;
|
||||||
|
|
||||||
/** The Land set code. */
|
/** The Land set code. */
|
||||||
private String landSetCode = AllZone.getCardFactory().getCard("Plains", AllZone.getHumanPlayer())
|
private String landSetCode = CardDb.instance().getCard("Plains", true).getEdition();
|
||||||
.getMostRecentSet();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardUtil;
|
|
||||||
import forge.gui.game.CardDetailPanel;
|
import forge.gui.game.CardDetailPanel;
|
||||||
import forge.gui.game.CardPicturePanel;
|
import forge.gui.game.CardPicturePanel;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
@@ -217,10 +215,7 @@ public class CardListViewer {
|
|||||||
this.cache = new Card[CardListViewer.this.list.size()];
|
this.cache = new Card[CardListViewer.this.list.size()];
|
||||||
}
|
}
|
||||||
if (null == this.cache[row]) {
|
if (null == this.cache[row]) {
|
||||||
final Card card = AllZone.getCardFactory().getCard(cp.getName(), null);
|
this.cache[row] = cp.toForgeCard();
|
||||||
card.setCurSetCode(cp.getEdition());
|
|
||||||
card.setImageFilename(CardUtil.buildFilename(card));
|
|
||||||
this.cache[row] = card;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.apache.commons.lang3.ArrayUtils;
|
|||||||
import forge.AllZone;
|
import forge.AllZone;
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
|
import forge.Player;
|
||||||
import forge.card.CardRarity;
|
import forge.card.CardRarity;
|
||||||
import forge.card.CardRules;
|
import forge.card.CardRules;
|
||||||
|
|
||||||
@@ -83,7 +84,7 @@ public final class CardPrinted implements Comparable<CardPrinted>, InventoryItem
|
|||||||
* @see forge.item.InventoryItemFromSet#getSet()
|
* @see forge.item.InventoryItemFromSet#getSet()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Gets the sets the.
|
* Gets the edition code of the card.
|
||||||
*
|
*
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
@@ -274,8 +275,13 @@ public final class CardPrinted implements Comparable<CardPrinted>, InventoryItem
|
|||||||
*
|
*
|
||||||
* @return the card
|
* @return the card
|
||||||
*/
|
*/
|
||||||
public Card toForgeCard() {
|
public Card toForgeCard() {
|
||||||
final Card c = AllZone.getCardFactory().getCard(this.name, null);
|
return toForgeCard(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Card toForgeCard(Player owner) {
|
||||||
|
final Card c = AllZone.getCardFactory().getCard(this.name, owner);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
c.setCurSetCode(this.getEdition());
|
c.setCurSetCode(this.getEdition());
|
||||||
c.setRandomPicture(this.artIndex + 1);
|
c.setRandomPicture(this.artIndex + 1);
|
||||||
|
|||||||
@@ -22,14 +22,10 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.slightlymagic.maxmtg.Predicate;
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import forge.Constant;
|
|
||||||
import forge.card.CardRarity;
|
|
||||||
import forge.card.CardRules;
|
import forge.card.CardRules;
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
import forge.item.CardPrinted.Predicates;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
|
|
||||||
// The BoosterPack generates cards for the Card Pool in Quest Mode
|
// The BoosterPack generates cards for the Card Pool in Quest Mode
|
||||||
@@ -161,49 +157,16 @@ public final class BoosterUtils {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Left if only for backwards compatibility
|
public static List<CardPrinted> generateDistinctCards(final Predicate<CardPrinted> filter, final int cntNeeded) {
|
||||||
/**
|
return generateDistinctCards(CardDb.instance().getAllCards(), filter, cntNeeded);
|
||||||
* Generate cards.
|
}
|
||||||
*
|
|
||||||
* @param num
|
public static List<CardPrinted> generateDistinctCards(final Iterable<CardPrinted> source,
|
||||||
* the num
|
|
||||||
* @param rarity
|
|
||||||
* the rarity
|
|
||||||
* @param color
|
|
||||||
* the color
|
|
||||||
* @return the list
|
|
||||||
*/
|
|
||||||
public static List<CardPrinted> generateCards(final int num, final CardRarity rarity, final String color) {
|
|
||||||
final Predicate<CardPrinted> whatYouWant = BoosterUtils.getPredicateForConditions(rarity, color);
|
|
||||||
return BoosterUtils.generateDistinctCards(CardDb.instance().getAllUniqueCards(), whatYouWant, num);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate cards.
|
|
||||||
*
|
|
||||||
* @param filter
|
|
||||||
* the filter
|
|
||||||
* @param num
|
|
||||||
* the num
|
|
||||||
* @param rarity
|
|
||||||
* the rarity
|
|
||||||
* @param color
|
|
||||||
* the color
|
|
||||||
* @return the list
|
|
||||||
*/
|
|
||||||
public static List<CardPrinted> generateCards(final Predicate<CardPrinted> filter, final int num,
|
|
||||||
final CardRarity rarity, final String color) {
|
|
||||||
final Predicate<CardPrinted> whatYouWant = Predicate.and(filter,
|
|
||||||
BoosterUtils.getPredicateForConditions(rarity, color));
|
|
||||||
return BoosterUtils.generateDistinctCards(CardDb.instance().getAllUniqueCards(), whatYouWant, num);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<CardPrinted> generateDistinctCards(final Iterable<CardPrinted> source,
|
|
||||||
final Predicate<CardPrinted> filter, final int cntNeeded) {
|
final Predicate<CardPrinted> filter, final int cntNeeded) {
|
||||||
final ArrayList<CardPrinted> result = new ArrayList<CardPrinted>();
|
final ArrayList<CardPrinted> result = new ArrayList<CardPrinted>();
|
||||||
int cntMade = 0;
|
int cntMade = 0;
|
||||||
|
|
||||||
// This will prevent endless loop @ wh
|
// This will prevent endless loop @ while
|
||||||
int allowedMisses = (2 + 2) * cntNeeded; // lol, 2+2 is not magic
|
int allowedMisses = (2 + 2) * cntNeeded; // lol, 2+2 is not magic
|
||||||
// constant!
|
// constant!
|
||||||
|
|
||||||
@@ -221,85 +184,45 @@ public final class BoosterUtils {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Predicate<CardPrinted> getPredicateForConditions(final CardRarity rarity, final String color) {
|
|
||||||
Predicate<CardPrinted> rFilter;
|
|
||||||
switch (rarity) {
|
|
||||||
case Rare:
|
|
||||||
rFilter = CardPrinted.Predicates.Presets.IS_RARE_OR_MYTHIC;
|
|
||||||
break;
|
|
||||||
case Common:
|
|
||||||
rFilter = CardPrinted.Predicates.Presets.IS_COMMON;
|
|
||||||
break;
|
|
||||||
case Uncommon:
|
|
||||||
rFilter = CardPrinted.Predicates.Presets.IS_UNCOMMON;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
rFilter = Predicate.getTrue(CardPrinted.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
Predicate<CardRules> colorFilter;
|
|
||||||
if (StringUtils.isBlank(color)) {
|
|
||||||
colorFilter = Predicate.getTrue(CardRules.class);
|
|
||||||
} else {
|
|
||||||
final String col = color.toLowerCase();
|
|
||||||
if (col.startsWith("wh")) {
|
|
||||||
colorFilter = CardRules.Predicates.Presets.IS_WHITE;
|
|
||||||
} else if (col.startsWith("bla")) {
|
|
||||||
colorFilter = CardRules.Predicates.Presets.IS_BLACK;
|
|
||||||
} else if (col.startsWith("blu")) {
|
|
||||||
colorFilter = CardRules.Predicates.Presets.IS_BLUE;
|
|
||||||
} else if (col.startsWith("re")) {
|
|
||||||
colorFilter = CardRules.Predicates.Presets.IS_RED;
|
|
||||||
} else if (col.startsWith("col")) {
|
|
||||||
colorFilter = CardRules.Predicates.Presets.IS_COLORLESS;
|
|
||||||
} else if (col.startsWith("gre")) {
|
|
||||||
colorFilter = CardRules.Predicates.Presets.IS_GREEN;
|
|
||||||
} else if (col.startsWith("mul")) {
|
|
||||||
colorFilter = CardRules.Predicates.Presets.IS_MULTICOLOR;
|
|
||||||
} else {
|
|
||||||
colorFilter = Predicate.getTrue(CardRules.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Predicate.and(rFilter, colorFilter, CardPrinted.FN_GET_RULES);
|
|
||||||
}
|
|
||||||
|
|
||||||
// return List<CardPrinted> of 5 or 6 cards, one for each color and maybe an
|
|
||||||
// artifact
|
|
||||||
/**
|
/**
|
||||||
* Gets the variety.
|
* <p>
|
||||||
|
* generateCardRewardList.
|
||||||
|
* </p>
|
||||||
|
* Takes a reward list string, parses, and returns list of cards rewarded.
|
||||||
*
|
*
|
||||||
* @param in
|
* @param s
|
||||||
* the in
|
* Properties string of reward (97 multicolor rares)
|
||||||
* @return the variety
|
* @return CardList
|
||||||
*/
|
*/
|
||||||
public static List<CardPrinted> getVariety(final List<CardPrinted> in) {
|
public static List<CardPrinted> generateCardRewardList(final String s) {
|
||||||
final List<CardPrinted> out = new ArrayList<CardPrinted>();
|
final String[] temp = s.split(" ");
|
||||||
Collections.shuffle(in, MyRandom.getRandom());
|
|
||||||
|
final int qty = Integer.parseInt(temp[0]);
|
||||||
for (int i = 0; i < Constant.Color.COLORS.length; i++) {
|
// Determine rarity
|
||||||
final CardPrinted check = BoosterUtils.findCardOfColor(in, i);
|
Predicate<CardPrinted> rar = CardPrinted.Predicates.Presets.IS_UNCOMMON;
|
||||||
if (check != null) {
|
if (temp[2].equalsIgnoreCase("rare") || temp[2].equalsIgnoreCase("rares")) {
|
||||||
out.add(check);
|
rar = CardPrinted.Predicates.Presets.IS_RARE_OR_MYTHIC;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
|
||||||
} // getVariety()
|
// Determine color ("random" defaults to null color)
|
||||||
|
Predicate<CardRules> col = Predicate.getTrue(CardRules.class);
|
||||||
/**
|
if (temp[1].equalsIgnoreCase("black")) {
|
||||||
* Find card of color.
|
col = CardRules.Predicates.Presets.IS_BLACK;
|
||||||
*
|
} else if (temp[1].equalsIgnoreCase("blue")) {
|
||||||
* @param in
|
col = CardRules.Predicates.Presets.IS_BLUE;
|
||||||
* the in
|
} else if (temp[1].equalsIgnoreCase("colorless")) {
|
||||||
* @param color
|
col = CardRules.Predicates.Presets.IS_COLORLESS;
|
||||||
* the color
|
} else if (temp[1].equalsIgnoreCase("green")) {
|
||||||
* @return the card printed
|
col = CardRules.Predicates.Presets.IS_GREEN;
|
||||||
*/
|
} else if (temp[1].equalsIgnoreCase("multicolor")) {
|
||||||
private static CardPrinted findCardOfColor(final List<CardPrinted> in, final int color) {
|
col = CardRules.Predicates.Presets.IS_MULTICOLOR;
|
||||||
final Predicate<CardRules> filter = CardRules.Predicates.Presets.COLORS.get(color);
|
} else if (temp[1].equalsIgnoreCase("red")) {
|
||||||
if (null == filter) {
|
col = CardRules.Predicates.Presets.IS_RED;
|
||||||
return null;
|
} else if (temp[1].equalsIgnoreCase("white")) {
|
||||||
|
col = CardRules.Predicates.Presets.IS_WHITE;
|
||||||
}
|
}
|
||||||
return filter.first(in, CardPrinted.FN_GET_RULES);
|
|
||||||
|
return BoosterUtils.generateDistinctCards(Predicate.and(rar, col, CardPrinted.FN_GET_RULES), qty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import forge.deck.Deck;
|
|||||||
import forge.deck.io.DeckSerializer;
|
import forge.deck.io.DeckSerializer;
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
|
import forge.quest.BoosterUtils;
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
import forge.util.SectionUtil;
|
import forge.util.SectionUtil;
|
||||||
@@ -186,7 +187,7 @@ public class QuestEventManager {
|
|||||||
qc.setCreditsReward(Integer.parseInt(value));
|
qc.setCreditsReward(Integer.parseInt(value));
|
||||||
} else if (key.equalsIgnoreCase("Card Reward")) {
|
} else if (key.equalsIgnoreCase("Card Reward")) {
|
||||||
qc.setCardReward(value);
|
qc.setCardReward(value);
|
||||||
qc.setCardRewardList(QuestUtil.generateCardRewardList(value));
|
qc.setCardRewardList(BoosterUtils.generateCardRewardList(value));
|
||||||
}
|
}
|
||||||
// Human extra card list assembled here.
|
// Human extra card list assembled here.
|
||||||
else if (key.equalsIgnoreCase("HumanExtras") && !value.equals("")) {
|
else if (key.equalsIgnoreCase("HumanExtras") && !value.equals("")) {
|
||||||
@@ -213,7 +214,7 @@ public class QuestEventManager {
|
|||||||
// Card reward list assembled here.
|
// Card reward list assembled here.
|
||||||
else if (key.equalsIgnoreCase("Card Reward")) {
|
else if (key.equalsIgnoreCase("Card Reward")) {
|
||||||
qc.setCardReward(value);
|
qc.setCardReward(value);
|
||||||
qc.setCardRewardList(QuestUtil.generateCardRewardList(value));
|
qc.setCardRewardList(BoosterUtils.generateCardRewardList(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return qc;
|
return qc;
|
||||||
|
|||||||
@@ -23,11 +23,7 @@ import forge.AllZone;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardList;
|
import forge.CardList;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.Constant;
|
|
||||||
import forge.Player;
|
import forge.Player;
|
||||||
import forge.card.CardRarity;
|
|
||||||
import forge.item.CardPrinted;
|
|
||||||
import forge.quest.BoosterUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -161,47 +157,6 @@ public class QuestUtil {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* generateCardRewardList.
|
|
||||||
* </p>
|
|
||||||
* Takes a reward list string, parses, and returns list of cards rewarded.
|
|
||||||
*
|
|
||||||
* @param s
|
|
||||||
* Properties string of reward (97 multicolor rares)
|
|
||||||
* @return CardList
|
|
||||||
*/
|
|
||||||
public static List<CardPrinted> generateCardRewardList(final String s) {
|
|
||||||
final String[] temp = s.split(" ");
|
|
||||||
|
|
||||||
final int qty = Integer.parseInt(temp[0]);
|
|
||||||
// Determine rarity
|
|
||||||
CardRarity rar = CardRarity.Uncommon;
|
|
||||||
if (temp[2].equalsIgnoreCase("rare") || temp[2].equalsIgnoreCase("rares")) {
|
|
||||||
rar = CardRarity.Rare;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine color ("random" defaults to null color)
|
|
||||||
String col = null;
|
|
||||||
if (temp[1].equalsIgnoreCase("black")) {
|
|
||||||
col = Constant.Color.BLACK;
|
|
||||||
} else if (temp[1].equalsIgnoreCase("blue")) {
|
|
||||||
col = Constant.Color.BLUE;
|
|
||||||
} else if (temp[1].equalsIgnoreCase("colorless")) {
|
|
||||||
col = Constant.Color.COLORLESS;
|
|
||||||
} else if (temp[1].equalsIgnoreCase("green")) {
|
|
||||||
col = Constant.Color.GREEN;
|
|
||||||
} else if (temp[1].equalsIgnoreCase("multicolor")) {
|
|
||||||
col = "Multicolor"; // Note: No constant color for this??
|
|
||||||
} else if (temp[1].equalsIgnoreCase("red")) {
|
|
||||||
col = Constant.Color.RED;
|
|
||||||
} else if (temp[1].equalsIgnoreCase("white")) {
|
|
||||||
col = Constant.Color.WHITE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return BoosterUtils.generateCards(qty, rar, col);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* readExtraCard.
|
* readExtraCard.
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import net.slightlymagic.braids.util.lambda.Lambda1;
|
|||||||
import net.slightlymagic.maxmtg.Predicate;
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.BoosterGenerator;
|
import forge.card.BoosterGenerator;
|
||||||
import forge.card.CardRarity;
|
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
import forge.card.FormatUtils;
|
import forge.card.FormatUtils;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
@@ -104,9 +103,9 @@ public final class QuestUtilCards {
|
|||||||
final int nRare = this.qpref.getPreferenceInt(QPref.BOOSTER_RARES);
|
final int nRare = this.qpref.getPreferenceInt(QPref.BOOSTER_RARES);
|
||||||
|
|
||||||
final ArrayList<CardPrinted> newCards = new ArrayList<CardPrinted>();
|
final ArrayList<CardPrinted> newCards = new ArrayList<CardPrinted>();
|
||||||
newCards.addAll(BoosterUtils.generateCards(fSets, nCommon, CardRarity.Common, null));
|
newCards.addAll(BoosterUtils.generateDistinctCards(Predicate.and(fSets, CardPrinted.Predicates.Presets.IS_COMMON), nCommon));
|
||||||
newCards.addAll(BoosterUtils.generateCards(fSets, nUncommon, CardRarity.Uncommon, null));
|
newCards.addAll(BoosterUtils.generateDistinctCards(Predicate.and(fSets, CardPrinted.Predicates.Presets.IS_UNCOMMON), nUncommon));
|
||||||
newCards.addAll(BoosterUtils.generateCards(fSets, nRare, CardRarity.Rare, null));
|
newCards.addAll(BoosterUtils.generateDistinctCards(Predicate.and(fSets, CardPrinted.Predicates.Presets.IS_RARE_OR_MYTHIC), nRare));
|
||||||
|
|
||||||
this.addAllCards(newCards);
|
this.addAllCards(newCards);
|
||||||
return newCards;
|
return newCards;
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ import javax.swing.event.ListSelectionEvent;
|
|||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import forge.AllZone;
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardUtil;
|
|
||||||
import forge.gui.game.CardDetailPanel;
|
import forge.gui.game.CardDetailPanel;
|
||||||
import forge.gui.game.CardPicturePanel;
|
import forge.gui.game.CardPicturePanel;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
@@ -119,10 +117,7 @@ public class QuestWinLoseCardViewer extends FPanel {
|
|||||||
this.cache = new Card[QuestWinLoseCardViewer.this.list.size()];
|
this.cache = new Card[QuestWinLoseCardViewer.this.list.size()];
|
||||||
}
|
}
|
||||||
if (null == this.cache[row]) {
|
if (null == this.cache[row]) {
|
||||||
final Card card = AllZone.getCardFactory().getCard(cp.getName(), null);
|
this.cache[row] = cp.toForgeCard();
|
||||||
card.setCurSetCode(cp.getEdition());
|
|
||||||
card.setImageFilename(CardUtil.buildFilename(card));
|
|
||||||
this.cache[row] = card;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,7 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardUtil;
|
|
||||||
import forge.gui.game.CardDetailPanel;
|
import forge.gui.game.CardDetailPanel;
|
||||||
import forge.gui.game.CardPicturePanel;
|
import forge.gui.game.CardPicturePanel;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
@@ -108,10 +106,7 @@ public class CardViewer extends JPanel {
|
|||||||
this.cache = new Card[CardViewer.this.list.size()];
|
this.cache = new Card[CardViewer.this.list.size()];
|
||||||
}
|
}
|
||||||
if (null == this.cache[row]) {
|
if (null == this.cache[row]) {
|
||||||
final Card card = AllZone.getCardFactory().getCard(cp.getName(), null);
|
this.cache[row] = cp.toForgeCard();
|
||||||
card.setCurSetCode(cp.getEdition());
|
|
||||||
card.setImageFilename(CardUtil.buildFilename(card));
|
|
||||||
this.cache[row] = card;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user