From f058e380044a5b8d37c2cad753e673f595732d27 Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Sat, 23 Nov 2013 00:03:51 +0000 Subject: [PATCH] CardRules.reinitializeFromScript --- .../forge/card/CardCharacteristicName.java | 2 ++ .../src/main/java/forge/card/CardRules.java | 33 +++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/forge-core/src/main/java/forge/card/CardCharacteristicName.java b/forge-core/src/main/java/forge/card/CardCharacteristicName.java index 81571df0f32..92148724514 100644 --- a/forge-core/src/main/java/forge/card/CardCharacteristicName.java +++ b/forge-core/src/main/java/forge/card/CardCharacteristicName.java @@ -1,5 +1,7 @@ package forge.card; +import org.apache.commons.lang3.StringUtils; + /** * TODO: Write javadoc for this type. * diff --git a/forge-core/src/main/java/forge/card/CardRules.java b/forge-core/src/main/java/forge/card/CardRules.java index 9925aa2efa8..4218fc0dc57 100644 --- a/forge-core/src/main/java/forge/card/CardRules.java +++ b/forge-core/src/main/java/forge/card/CardRules.java @@ -34,13 +34,10 @@ import forge.card.mana.ManaCostShard; * @version $Id: CardRules.java 9708 2011-08-09 19:34:12Z jendave $ */ public final class CardRules implements ICardCharacteristics { - private final CardSplitType splitType; - private final ICardFace mainPart; - private final ICardFace otherPart; - //private final Map setsPrinted = new TreeMap(String.CASE_INSENSITIVE_ORDER); - + private CardSplitType splitType; + private ICardFace mainPart; + private ICardFace otherPart; private CardAiHints aiHints; - private ColorSet colorIdentity = null; private CardRules(ICardFace[] faces, CardSplitType altMode, CardAiHints cah) { @@ -49,18 +46,6 @@ public final class CardRules implements ICardCharacteristics { otherPart = faces[1]; aiHints = cah; - //System.out.print(faces[0].getName()); - -// for (Entry cs : sets.entrySet()) { -// if( CardRulesReader.editions.get(cs.getKey()) != null ) -// setsPrinted.put(cs.getKey(), cs.getValue()); -// } -// -// if ( setsPrinted.isEmpty() ) { -// System.err.println(getName() + " was not assigned any set."); -// setsPrinted.put(CardEdition.UNKNOWN.getCode(), new CardInSet(CardRarity.Common, 1) ); -// } -// //Calculate Color Identity byte colMask = calculateColorIdentity(mainPart); @@ -70,6 +55,18 @@ public final class CardRules implements ICardCharacteristics { } colorIdentity = ColorSet.fromMask(colMask); } + + public void reinitializeFromScript(Iterable script) { + CardRules newRules = fromScript(script); + if(!newRules.getName().equals(this.getName())) + throw new UnsupportedOperationException("You cannot rename the card using the same CardRules object"); + + splitType = newRules.splitType; + mainPart = newRules.mainPart; + otherPart = newRules.otherPart; + aiHints = newRules.aiHints; + colorIdentity = newRules.colorIdentity; + } private byte calculateColorIdentity(ICardFace face) {