mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
CardDb & CardRules & Card & CardFactory: use MeldPair to get the Backside from the Secondary
if CardFactory use StaticData to get the other card
This commit is contained in:
@@ -177,8 +177,10 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
|
||||
if (paperCard.getRules().getSplitType() == CardSplitType.None) { return; }
|
||||
|
||||
//allow looking up card by the name of other faces
|
||||
allCardsByName.put(paperCard.getRules().getOtherPart().getName(), paperCard);
|
||||
if (paperCard.getRules().getOtherPart() != null) {
|
||||
//allow looking up card by the name of other faces
|
||||
allCardsByName.put(paperCard.getRules().getOtherPart().getName(), paperCard);
|
||||
}
|
||||
if (paperCard.getRules().getSplitType() == CardSplitType.Split) {
|
||||
//also include main part for split cards
|
||||
allCardsByName.put(paperCard.getRules().getMainPart().getName(), paperCard);
|
||||
@@ -218,6 +220,15 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
return false;
|
||||
}
|
||||
|
||||
public CardRules getRules(String cardname) {
|
||||
CardRules result = rulesByName.get(cardname);
|
||||
if (result != null) {
|
||||
return result;
|
||||
} else {
|
||||
return CardRules.getUnsupportedCardNamed(cardname);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaperCard getCard(String cardName) {
|
||||
CardRequest request = CardRequest.fromString(cardName);
|
||||
|
||||
@@ -38,12 +38,14 @@ public final class CardRules implements ICardCharacteristics {
|
||||
private ICardFace otherPart;
|
||||
private CardAiHints aiHints;
|
||||
private ColorSet colorIdentity;
|
||||
private String meldWith;
|
||||
|
||||
private CardRules(ICardFace[] faces, CardSplitType altMode, CardAiHints cah) {
|
||||
splitType = altMode;
|
||||
mainPart = faces[0];
|
||||
otherPart = faces[1];
|
||||
aiHints = cah;
|
||||
meldWith = "";
|
||||
|
||||
//calculate color identity
|
||||
byte colMask = calculateColorIdentity(mainPart);
|
||||
@@ -63,6 +65,7 @@ public final class CardRules implements ICardCharacteristics {
|
||||
otherPart = newRules.otherPart;
|
||||
aiHints = newRules.aiHints;
|
||||
colorIdentity = newRules.colorIdentity;
|
||||
meldWith = newRules.meldWith;
|
||||
}
|
||||
|
||||
private static byte calculateColorIdentity(final ICardFace face) {
|
||||
@@ -195,6 +198,10 @@ public final class CardRules implements ICardCharacteristics {
|
||||
return mainPart.getOracleText().contains("can be your commander");
|
||||
}
|
||||
|
||||
public String getMeldWith() {
|
||||
return meldWith;
|
||||
}
|
||||
|
||||
// public Set<String> getSets() { return this.setsPrinted.keySet(); }
|
||||
// public CardInSet getEditionInfo(final String setCode) {
|
||||
// final CardInSet result = this.setsPrinted.get(setCode);
|
||||
@@ -242,6 +249,7 @@ public final class CardRules implements ICardCharacteristics {
|
||||
private String[] pictureUrl = new String[] { null, null };
|
||||
private int curFace = 0;
|
||||
private CardSplitType altMode = CardSplitType.None;
|
||||
private String meldWith = "";
|
||||
private String handLife = null;
|
||||
|
||||
// fields to build CardAiHints
|
||||
@@ -281,6 +289,7 @@ public final class CardRules implements ICardCharacteristics {
|
||||
faces[0].assignMissingFields();
|
||||
if (null != faces[1]) faces[1].assignMissingFields();
|
||||
final CardRules result = new CardRules(faces, altMode, cah);
|
||||
result.meldWith = this.meldWith;
|
||||
result.setDlUrls(pictureUrl);
|
||||
if (StringUtils.isNotBlank(handLife))
|
||||
result.setVanguardProperties(handLife);
|
||||
@@ -362,6 +371,8 @@ public final class CardRules implements ICardCharacteristics {
|
||||
if ("ManaCost".equals(key)) {
|
||||
this.faces[this.curFace].setManaCost("no cost".equals(value) ? ManaCost.NO_COST
|
||||
: new ManaCost(new ManaCostParser(value)));
|
||||
} else if ("MeldPair".equals(key)) {
|
||||
this.meldWith = value;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user