mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Some housekeeping
This commit is contained in:
@@ -601,51 +601,49 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
return sb;
|
||||
}
|
||||
|
||||
public PaperCard createUnsuportedCard(String cardName) {
|
||||
public PaperCard createUnsupportedCard(String cardName) {
|
||||
|
||||
CardRequest request = CardRequest.fromString(cardName);
|
||||
CardEdition cE = CardEdition.UNKNOWN;
|
||||
CardRarity cR = CardRarity.Unknown;
|
||||
CardEdition cardEdition = CardEdition.UNKNOWN;
|
||||
CardRarity cardRarity = CardRarity.Unknown;
|
||||
|
||||
// May iterate over editions and find out if there is any card named 'cardName' but not implemented with Forge script.
|
||||
if (StringUtils.isBlank(request.edition)) {
|
||||
for (CardEdition e : editions) {
|
||||
for (CardInSet cs : e.getCards()) {
|
||||
if (cs.name.equals(request.cardName)) {
|
||||
cE = e;
|
||||
cR = cs.rarity;
|
||||
for (CardEdition edition : editions) {
|
||||
for (CardInSet cardInSet : edition.getCards()) {
|
||||
if (cardInSet.name.equals(request.cardName)) {
|
||||
cardEdition = edition;
|
||||
cardRarity = cardInSet.rarity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cE != CardEdition.UNKNOWN) {
|
||||
if (cardEdition != CardEdition.UNKNOWN) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cardEdition = editions.get(request.edition);
|
||||
if (cardEdition != null) {
|
||||
for (CardInSet cardInSet : cardEdition.getCards()) {
|
||||
if (cardInSet.name.equals(request.cardName)) {
|
||||
cardRarity = cardInSet.rarity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
cE = editions.get(request.edition);
|
||||
if (cE != null) {
|
||||
for (CardInSet cs : cE.getCards()) {
|
||||
if (cs.name.equals(request.cardName)) {
|
||||
cR = cs.rarity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
cE = CardEdition.UNKNOWN;
|
||||
cardEdition = CardEdition.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write to log that attempt,
|
||||
if (cR == CardRarity.Unknown) {
|
||||
if (cardRarity == CardRarity.Unknown) {
|
||||
System.err.println(String.format("An unknown card found when loading Forge decks: \"%s\" Forge does not know of such a card's existence. Have you mistyped the card name?", cardName));
|
||||
}
|
||||
else {
|
||||
System.err.println(String.format("An unsupported card was requested: \"%s\" from \"%s\" set. We're sorry, but you cannot use this card yet.", request.cardName, cE.getName()));
|
||||
} else {
|
||||
System.err.println(String.format("An unsupported card was requested: \"%s\" from \"%s\" set. We're sorry, but you cannot use this card yet.", request.cardName, cardEdition.getName()));
|
||||
}
|
||||
|
||||
return new PaperCard(CardRules.getUnsupportedCardNamed(request.cardName), cE.getCode(), cR, 1);
|
||||
return new PaperCard(CardRules.getUnsupportedCardNamed(request.cardName), cardEdition.getCode(), cardRarity, 1);
|
||||
|
||||
}
|
||||
|
||||
private final Editor editor = new Editor();
|
||||
|
||||
@@ -17,23 +17,21 @@
|
||||
*/
|
||||
package forge.deck;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.StaticData;
|
||||
import forge.card.CardDb;
|
||||
import forge.item.PaperCard;
|
||||
import forge.util.ItemPool;
|
||||
import forge.util.ItemPoolSorter;
|
||||
import forge.util.MyRandom;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class CardPool extends ItemPool<PaperCard> {
|
||||
@@ -74,41 +72,42 @@ public class CardPool extends ItemPool<PaperCard> {
|
||||
|
||||
// NOTE: ART indices are "1" -based
|
||||
public void add(String cardName, String setCode, final int artIndex, final int amount) {
|
||||
PaperCard cp = StaticData.instance().getCommonCards().getCard(cardName, setCode, artIndex);
|
||||
final boolean isCommonCard = cp != null;
|
||||
|
||||
PaperCard paperCard = StaticData.instance().getCommonCards().getCard(cardName, setCode, artIndex);
|
||||
final boolean isCommonCard = paperCard != null;
|
||||
|
||||
if (!isCommonCard) {
|
||||
cp = StaticData.instance().getVariantCards().getCard(cardName, setCode);
|
||||
if (cp == null) {
|
||||
paperCard = StaticData.instance().getVariantCards().getCard(cardName, setCode);
|
||||
if (paperCard == null) {
|
||||
StaticData.instance().attemptToLoadCard(cardName, setCode);
|
||||
cp = StaticData.instance().getVariantCards().getCard(cardName, setCode);
|
||||
paperCard = StaticData.instance().getVariantCards().getCard(cardName, setCode);
|
||||
}
|
||||
}
|
||||
|
||||
int artCount = 1;
|
||||
if (cp != null ) {
|
||||
setCode = cp.getEdition();
|
||||
cardName = cp.getName();
|
||||
if (paperCard != null) {
|
||||
setCode = paperCard.getEdition();
|
||||
cardName = paperCard.getName();
|
||||
artCount = isCommonCard ? StaticData.instance().getCommonCards().getArtCount(cardName, setCode) : 1;
|
||||
}
|
||||
else {
|
||||
cp = StaticData.instance().getCommonCards().createUnsuportedCard(cardName);
|
||||
} else {
|
||||
paperCard = StaticData.instance().getCommonCards().createUnsupportedCard(cardName);
|
||||
}
|
||||
|
||||
boolean artIndexExplicitlySet = artIndex > 0 || Character.isDigit(cardName.charAt(cardName.length()-1)) && cardName.charAt(cardName.length()-2) == CardDb.NameSetSeparator;
|
||||
boolean artIndexExplicitlySet = artIndex > 0 || Character.isDigit(cardName.charAt(cardName.length() - 1)) && cardName.charAt(cardName.length() - 2) == CardDb.NameSetSeparator;
|
||||
|
||||
if (artIndexExplicitlySet || artCount <= 1) {
|
||||
// either a specific art index is specified, or there is only one art, so just add the card
|
||||
this.add(cp, amount);
|
||||
this.add(paperCard, 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)
|
||||
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);
|
||||
}
|
||||
PaperCard randomCard = StaticData.instance().getCommonCards().getCard(cardName, setCode, i);
|
||||
this.add(randomCard, cnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +143,8 @@ public class DialogChooseColors {
|
||||
left.setOpaque(false);
|
||||
left.add(new FLabel.Builder().text("Distribution").fontSize(18).build(), "gaptop 10");
|
||||
|
||||
left.add(new FTextPane("Hover over each item for a more detailed description."), "gaptop 20");
|
||||
|
||||
final JXButtonPanel poolTypePanel = new JXButtonPanel();
|
||||
final String radioConstraints = "h 25px!, gaptop 5";
|
||||
poolTypePanel.add(radBalanced, radioConstraints);
|
||||
@@ -201,9 +203,9 @@ public class DialogChooseColors {
|
||||
cbxArtifacts.setVisible(!radSurpriseMe.isSelected() && !radBoosters.isSelected());
|
||||
numberOfBoostersField.setVisible(radBoosters.isSelected());
|
||||
|
||||
radBalanced.setToolTipText("A balanced distribution will provide a roughly equal number of cards in each selected color.");
|
||||
radRandom.setToolTipText("A random distribution will be almost entirely randomly selected. This ignores any color selections.");
|
||||
radSurpriseMe.setToolTipText("This is the same as a balanced distribution, except the colors picked will be random and you will not be told what they are.");
|
||||
radBalanced.setToolTipText("A \"Balanced\" distribution will provide a roughly equal number of cards in each selected color.");
|
||||
radRandom.setToolTipText("A \"True Random\" distribution will be almost entirely randomly selected. This ignores any color selections.");
|
||||
radSurpriseMe.setToolTipText("This is the same as a \"Balanced\" distribution, except the colors picked will be random and you will not be told what they are.");
|
||||
radBoosters.setToolTipText("This ignores all color settings and instead generates a card pool out of a specified number of booster packs.");
|
||||
cbxArtifacts.setToolTipText("When selected, artifacts will be included in your pool regardless of color selections. This mimics the old card pool behavior.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user