mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
cardfactory - no longer instanced. some methods moved here from CardFactoryUtil
This commit is contained in:
@@ -7,7 +7,7 @@ import forge.card.ability.effects.ChangeZoneAllEffect;
|
||||
import forge.card.ability.effects.ChangeZoneEffect;
|
||||
import forge.card.ability.effects.ManaEffect;
|
||||
import forge.card.ability.effects.ManaReflectedEffect;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
import forge.card.spellability.AbilityManaPart;
|
||||
@@ -50,7 +50,7 @@ public class AbilityApiBased extends AbilityActivated {
|
||||
public AbilityActivated getCopy() {
|
||||
Target tgt = getTarget() == null ? null : new Target(getTarget());
|
||||
AbilityActivated res = new AbilityApiBased(api, getSourceCard(), getPayCosts(), tgt, params);
|
||||
CardFactoryUtil.copySpellAbility(this, res);
|
||||
CardFactory.copySpellAbility(this, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
@@ -122,7 +123,7 @@ public class CloneEffect extends SpellAbilityEffect {
|
||||
stateToCopy = cardToCopy.getCurState();
|
||||
}
|
||||
|
||||
CardFactoryUtil.copyState(cardToCopy, stateToCopy, tgtCard);
|
||||
CardFactory.copyState(cardToCopy, stateToCopy, tgtCard);
|
||||
// must call this before addAbilityFactoryAbilities so cloned added abilities are handled correctly
|
||||
addExtraCharacteristics(tgtCard, sa, origSVars);
|
||||
CardFactoryUtil.addAbilityFactoryAbilities(tgtCard);
|
||||
@@ -140,7 +141,7 @@ public class CloneEffect extends SpellAbilityEffect {
|
||||
tgtCard.addAlternateState(CardCharacteristicName.Flipped);
|
||||
tgtCard.setState(CardCharacteristicName.Flipped);
|
||||
}
|
||||
CardFactoryUtil.copyState(cardToCopy, CardCharacteristicName.Flipped, tgtCard);
|
||||
CardFactory.copyState(cardToCopy, CardCharacteristicName.Flipped, tgtCard);
|
||||
addExtraCharacteristics(tgtCard, sa, origSVars);
|
||||
CardFactoryUtil.addAbilityFactoryAbilities(tgtCard);
|
||||
for (int i = 0; i < tgtCard.getStaticAbilityStrings().size(); i++) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.spellability.Ability;
|
||||
@@ -82,7 +83,7 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
|
||||
if (!c.isToken() || c.isCopiedToken()) {
|
||||
// copy creature and put it onto the battlefield
|
||||
|
||||
copy = Singletons.getModel().getCardFactory().getCard(CardDb.getCard(c), sa.getActivatingPlayer());
|
||||
copy = CardFactory.getCard(CardDb.getCard(c), sa.getActivatingPlayer());
|
||||
|
||||
// when copying something stolen:
|
||||
copy.addController(controller);
|
||||
@@ -90,7 +91,7 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
|
||||
copy.setToken(true);
|
||||
copy.setCopiedToken(true);
|
||||
} else { // isToken()
|
||||
copy = CardFactoryUtil.copyStats(c);
|
||||
copy = CardFactory.copyStats(c);
|
||||
|
||||
copy.setName(c.getName());
|
||||
copy.setImageFilename(c.getImageFilename());
|
||||
|
||||
@@ -5,9 +5,9 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.SpellAbilityEffect;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.player.Player;
|
||||
import forge.gui.GuiChoose;
|
||||
@@ -99,7 +99,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
||||
for (final SpellAbility chosenSAcopy : chosenSAs) {
|
||||
chosenSAcopy.setActivatingPlayer(controller);
|
||||
for (int i = 0; i < amount; i++) {
|
||||
Singletons.getModel().getCardFactory().copySpellontoStack(card, chosenSAcopy.getSourceCard(), chosenSAcopy, true);
|
||||
CardFactory.copySpellontoStack(card, chosenSAcopy.getSourceCard(), chosenSAcopy, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
||||
|
||||
chosenSA.setActivatingPlayer(controller);
|
||||
for (int i = 0; i < amount; i++) {
|
||||
Singletons.getModel().getCardFactory().copySpellontoStack(card, chosenSA.getSourceCard(), chosenSA, true);
|
||||
CardFactory.copySpellontoStack(card, chosenSA.getSourceCard(), chosenSA, true);
|
||||
}
|
||||
}
|
||||
} // end resolve
|
||||
|
||||
@@ -150,7 +150,7 @@ public class PlayEffect extends SpellAbilityEffect {
|
||||
source.clearRemembered();
|
||||
}
|
||||
if (sa.hasParam("CopyCard")) {
|
||||
tgtCard = Singletons.getModel().getCardFactory().getCard(CardDb.getCard(tgtCard), sa.getActivatingPlayer());
|
||||
tgtCard = CardDb.getCard(tgtCard).toForgeCard(sa.getActivatingPlayer());
|
||||
// when copying something stolen:
|
||||
tgtCard.addController(sa.getActivatingPlayer());
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package forge.card.cardfactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -28,10 +27,10 @@ import forge.CardCharacteristicName;
|
||||
import forge.CardColor;
|
||||
import forge.CardUtil;
|
||||
import forge.Color;
|
||||
import forge.card.CardCharacteristics;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.ICardFace;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.replacement.ReplacementHandler;
|
||||
@@ -41,13 +40,9 @@ import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.SpellPermanent;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.card.trigger.TriggerHandler;
|
||||
import forge.error.BugReporter;
|
||||
import forge.game.player.Player;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.item.CardDb;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -68,33 +63,6 @@ import forge.properties.NewConstants;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class CardFactory {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for CardFactory.
|
||||
* </p>
|
||||
*
|
||||
* @param file
|
||||
* a {@link java.io.File} object.
|
||||
*/
|
||||
private final CardStorageReader reader;
|
||||
|
||||
public CardFactory(final File file) {
|
||||
|
||||
GuiUtils.checkEDT("CardFactory$constructor", false);
|
||||
reader = new CardStorageReader(ForgeProps.getFile(NewConstants.CARDSFOLDER), true);
|
||||
try {
|
||||
// this fills in our map of card names to Card instances.
|
||||
final List<CardRules> listCardRules = reader.loadCards();
|
||||
CardDb.setup(listCardRules.iterator());
|
||||
|
||||
} catch (final Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
}
|
||||
|
||||
} // constructor
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* copyCard.
|
||||
@@ -104,15 +72,15 @@ public class CardFactory {
|
||||
* a {@link forge.Card} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
public final Card copyCard(final Card in) {
|
||||
public final static Card copyCard(final Card in) {
|
||||
final CardCharacteristicName curState = in.getCurState();
|
||||
if (in.isInAlternateState()) {
|
||||
in.setState(CardCharacteristicName.Original);
|
||||
}
|
||||
final Card out = this.getCard(CardDb.getCard(in), in.getOwner());
|
||||
final Card out = getCard(CardDb.getCard(in), in.getOwner());
|
||||
out.setUniqueNumber(in.getUniqueNumber());
|
||||
|
||||
CardFactoryUtil.copyCharacteristics(in, out);
|
||||
CardFactory.copyCharacteristics(in, out);
|
||||
if (in.hasAlternateState()) {
|
||||
for (final CardCharacteristicName state : in.getStates()) {
|
||||
in.setState(state);
|
||||
@@ -120,7 +88,7 @@ public class CardFactory {
|
||||
out.addAlternateState(state);
|
||||
}
|
||||
out.setState(state);
|
||||
CardFactoryUtil.copyCharacteristics(in, out);
|
||||
CardFactory.copyCharacteristics(in, out);
|
||||
}
|
||||
in.setState(curState);
|
||||
out.setState(curState);
|
||||
@@ -157,7 +125,7 @@ public class CardFactory {
|
||||
* @param bCopyDetails
|
||||
* a boolean.
|
||||
*/
|
||||
public final void copySpellontoStack(final Card source, final Card original, final SpellAbility sa,
|
||||
public final static void copySpellontoStack(final Card source, final Card original, final SpellAbility sa,
|
||||
final boolean bCopyDetails) {
|
||||
//Player originalController = original.getController();
|
||||
Player controller = sa.getActivatingPlayer();
|
||||
@@ -243,7 +211,7 @@ public class CardFactory {
|
||||
* @return a {@link forge.Card} instance, owned by owner; or the special
|
||||
* blankCard
|
||||
*/
|
||||
public final Card getCard(final IPaperCard cp, final Player owner) {
|
||||
public final static Card getCard(final IPaperCard cp, final Player owner) {
|
||||
|
||||
//System.out.println(cardName);
|
||||
CardRules cardRules = cp.getRules();
|
||||
@@ -438,4 +406,110 @@ public class CardFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Copies stats like power, toughness, etc.
|
||||
* </p>
|
||||
*
|
||||
* @param sim
|
||||
* a {@link java.lang.Object} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
public static Card copyStats(final Card sim) {
|
||||
final Card c = new Card();
|
||||
|
||||
c.setFlipCard(sim.isFlipCard());
|
||||
c.setDoubleFaced(sim.isDoubleFaced());
|
||||
c.setCurSetCode(sim.getCurSetCode());
|
||||
|
||||
final CardCharacteristicName origState = sim.getCurState();
|
||||
for (final CardCharacteristicName state : sim.getStates()) {
|
||||
c.addAlternateState(state);
|
||||
c.setState(state);
|
||||
sim.setState(state);
|
||||
CardFactory.copyCharacteristics(sim, c);
|
||||
}
|
||||
|
||||
sim.setState(origState);
|
||||
c.setState(origState);
|
||||
c.setRules(sim.getRules());
|
||||
|
||||
return c;
|
||||
} // copyStats()
|
||||
|
||||
/**
|
||||
* Copy characteristics.
|
||||
*
|
||||
* @param from
|
||||
* the from
|
||||
* @param to
|
||||
* the to
|
||||
*/
|
||||
private static void copyCharacteristics(final Card from, final Card to) {
|
||||
to.setBaseAttack(from.getBaseAttack());
|
||||
to.setBaseDefense(from.getBaseDefense());
|
||||
to.setBaseLoyalty(from.getBaseLoyalty());
|
||||
to.setBaseAttackString(from.getBaseAttackString());
|
||||
to.setBaseDefenseString(from.getBaseDefenseString());
|
||||
to.setIntrinsicKeyword(from.getIntrinsicKeyword());
|
||||
to.setName(from.getName());
|
||||
to.setType(from.getCharacteristics().getType());
|
||||
to.setText(from.getSpellText());
|
||||
to.setManaCost(from.getManaCost());
|
||||
to.setColor(from.getColor());
|
||||
to.setSVars(from.getSVars());
|
||||
to.setIntrinsicAbilities(from.getIntrinsicAbilities());
|
||||
|
||||
to.setImageFilename(from.getImageFilename());
|
||||
to.setTriggers(from.getTriggers());
|
||||
to.setReplacementEffects(from.getReplacementEffects());
|
||||
to.setStaticAbilityStrings(from.getStaticAbilityStrings());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy characteristics.
|
||||
*
|
||||
* @param from
|
||||
* the from
|
||||
* @param stateToCopy
|
||||
* the state to copy
|
||||
* @param to
|
||||
* the to
|
||||
*/
|
||||
public static void copyState(final Card from, final CardCharacteristicName stateToCopy, final Card to) {
|
||||
|
||||
// copy characteristics not associated with a state
|
||||
to.setBaseLoyalty(from.getBaseLoyalty());
|
||||
to.setBaseAttackString(from.getBaseAttackString());
|
||||
to.setBaseDefenseString(from.getBaseDefenseString());
|
||||
to.setText(from.getSpellText());
|
||||
|
||||
// get CardCharacteristics for desired state
|
||||
CardCharacteristics characteristics = from.getState(stateToCopy);
|
||||
to.getCharacteristics().copy(characteristics);
|
||||
// handle triggers and replacement effect through Card class interface
|
||||
to.setTriggers(characteristics.getTriggers());
|
||||
to.setReplacementEffects(characteristics.getReplacementEffects());
|
||||
}
|
||||
|
||||
public static void copySpellAbility(SpellAbility from, SpellAbility to) {
|
||||
to.setDescription(from.getDescription());
|
||||
to.setStackDescription(from.getDescription());
|
||||
|
||||
if (from.getSubAbility() != null) {
|
||||
to.setSubAbility(from.getSubAbility().getCopy());
|
||||
}
|
||||
if (from.getRestrictions() != null) {
|
||||
to.setRestrictions(from.getRestrictions());
|
||||
}
|
||||
if (from.getConditions() != null) {
|
||||
to.setConditions(from.getConditions());
|
||||
}
|
||||
|
||||
for (String sVar : from.getSVars()) {
|
||||
to.setSVar(sVar, from.getSVar(sVar));
|
||||
}
|
||||
}
|
||||
|
||||
} // end class AbstractCardFactory
|
||||
|
||||
@@ -49,7 +49,7 @@ class CardFactoryArtifacts {
|
||||
public AbilityActivated getCopy() {
|
||||
AbilityActivated res = new AbilityGrindstone(getSourceCard(),
|
||||
getPayCosts(), getTarget() == null ? null : new Target(getTarget()));
|
||||
CardFactoryUtil.copySpellAbility(this, res);
|
||||
CardFactory.copySpellAbility(this, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ class CardFactoryArtifacts {
|
||||
public AbilityActivated getCopy() {
|
||||
AbilityActivated res = new AbilityScrollRack(getSourceCard(),
|
||||
getPayCosts(), getTarget() == null ? null : new Target(getTarget()));
|
||||
CardFactoryUtil.copySpellAbility(this, res);
|
||||
CardFactory.copySpellAbility(this, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ class CardFactoryArtifacts {
|
||||
public AbilityActivated getCopy() {
|
||||
AbilityActivated res = new AbilityTemporalAperture(getSourceCard(),
|
||||
getPayCosts(), getTarget() == null ? null : new Target(getTarget()));
|
||||
CardFactoryUtil.copySpellAbility(this, res);
|
||||
CardFactory.copySpellAbility(this, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ import forge.Constant;
|
||||
import forge.CounterType;
|
||||
import forge.GameEntity;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardCharacteristics;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
@@ -148,7 +147,7 @@ public class CardFactoryUtil {
|
||||
public AbilityActivated getCopy() {
|
||||
AbilityActivated res = new AbilityUnearth(getSourceCard(),
|
||||
getPayCosts(), getTarget() == null ? null : new Target(getTarget()));
|
||||
CardFactoryUtil.copySpellAbility(this, res);
|
||||
CardFactory.copySpellAbility(this, res);
|
||||
final SpellAbilityRestriction restrict = new SpellAbilityRestriction();
|
||||
restrict.setZone(ZoneType.Graveyard);
|
||||
restrict.setSorcerySpeed(true);
|
||||
@@ -361,7 +360,7 @@ public class CardFactoryUtil {
|
||||
public AbilityActivated getCopy() {
|
||||
AbilityActivated res = new AbilityTransmute(getSourceCard(),
|
||||
getPayCosts(), getTarget() == null ? null : new Target(getTarget()));
|
||||
CardFactoryUtil.copySpellAbility(this, res);
|
||||
CardFactory.copySpellAbility(this, res);
|
||||
res.getRestrictions().setZone(ZoneType.Hand);
|
||||
return res;
|
||||
}
|
||||
@@ -2490,7 +2489,7 @@ public class CardFactoryUtil {
|
||||
|
||||
final int multiplier = controller.getTokenDoublersMagnitude();
|
||||
for (int i = 0; i < multiplier; i++) {
|
||||
Card temp = CardFactoryUtil.copyStats(c);
|
||||
Card temp = CardFactory.copyStats(c);
|
||||
|
||||
for (final String kw : intrinsicKeywords) {
|
||||
temp.addIntrinsicKeyword(kw);
|
||||
@@ -2671,112 +2670,6 @@ public class CardFactoryUtil {
|
||||
|| (c == CounterType.TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Copies stats like power, toughness, etc.
|
||||
* </p>
|
||||
*
|
||||
* @param sim
|
||||
* a {@link java.lang.Object} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
public static Card copyStats(final Card sim) {
|
||||
final Card c = new Card();
|
||||
|
||||
c.setFlipCard(sim.isFlipCard());
|
||||
c.setDoubleFaced(sim.isDoubleFaced());
|
||||
c.setCurSetCode(sim.getCurSetCode());
|
||||
|
||||
final CardCharacteristicName origState = sim.getCurState();
|
||||
for (final CardCharacteristicName state : sim.getStates()) {
|
||||
c.addAlternateState(state);
|
||||
c.setState(state);
|
||||
sim.setState(state);
|
||||
CardFactoryUtil.copyCharacteristics(sim, c);
|
||||
}
|
||||
|
||||
sim.setState(origState);
|
||||
c.setState(origState);
|
||||
c.setRules(sim.getRules());
|
||||
|
||||
return c;
|
||||
} // copyStats()
|
||||
|
||||
/**
|
||||
* Copy characteristics.
|
||||
*
|
||||
* @param from
|
||||
* the from
|
||||
* @param to
|
||||
* the to
|
||||
*/
|
||||
public static void copyCharacteristics(final Card from, final Card to) {
|
||||
to.setBaseAttack(from.getBaseAttack());
|
||||
to.setBaseDefense(from.getBaseDefense());
|
||||
to.setBaseLoyalty(from.getBaseLoyalty());
|
||||
to.setBaseAttackString(from.getBaseAttackString());
|
||||
to.setBaseDefenseString(from.getBaseDefenseString());
|
||||
to.setIntrinsicKeyword(from.getIntrinsicKeyword());
|
||||
to.setName(from.getName());
|
||||
to.setType(from.getCharacteristics().getType());
|
||||
to.setText(from.getSpellText());
|
||||
to.setManaCost(from.getManaCost());
|
||||
to.setColor(from.getColor());
|
||||
to.setSVars(from.getSVars());
|
||||
to.setIntrinsicAbilities(from.getIntrinsicAbilities());
|
||||
|
||||
to.setImageFilename(from.getImageFilename());
|
||||
to.setTriggers(from.getTriggers());
|
||||
to.setReplacementEffects(from.getReplacementEffects());
|
||||
to.setStaticAbilityStrings(from.getStaticAbilityStrings());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy characteristics.
|
||||
*
|
||||
* @param from
|
||||
* the from
|
||||
* @param stateToCopy
|
||||
* the state to copy
|
||||
* @param to
|
||||
* the to
|
||||
*/
|
||||
public static void copyState(final Card from, final CardCharacteristicName stateToCopy, final Card to) {
|
||||
|
||||
// copy characteristics not associated with a state
|
||||
to.setBaseLoyalty(from.getBaseLoyalty());
|
||||
to.setBaseAttackString(from.getBaseAttackString());
|
||||
to.setBaseDefenseString(from.getBaseDefenseString());
|
||||
to.setText(from.getSpellText());
|
||||
|
||||
// get CardCharacteristics for desired state
|
||||
CardCharacteristics characteristics = from.getState(stateToCopy);
|
||||
to.getCharacteristics().copy(characteristics);
|
||||
// handle triggers and replacement effect through Card class interface
|
||||
to.setTriggers(characteristics.getTriggers());
|
||||
to.setReplacementEffects(characteristics.getReplacementEffects());
|
||||
}
|
||||
|
||||
public static void copySpellAbility(SpellAbility from, SpellAbility to) {
|
||||
to.setDescription(from.getDescription());
|
||||
to.setStackDescription(from.getDescription());
|
||||
|
||||
if (from.getSubAbility() != null) {
|
||||
to.setSubAbility(from.getSubAbility().getCopy());
|
||||
}
|
||||
if (from.getRestrictions() != null) {
|
||||
to.setRestrictions(from.getRestrictions());
|
||||
}
|
||||
if (from.getConditions() != null) {
|
||||
to.setConditions(from.getConditions());
|
||||
}
|
||||
|
||||
for (String sVar : from.getSVars()) {
|
||||
to.setSVar(sVar, from.getSVar(sVar));
|
||||
}
|
||||
}
|
||||
|
||||
public static void correctAbilityChainSourceCard(final SpellAbility sa, final Card card) {
|
||||
|
||||
sa.setSourceCard(card);
|
||||
|
||||
@@ -28,7 +28,7 @@ import forge.card.ability.effects.ChangeZoneAllEffect;
|
||||
import forge.card.ability.effects.ChangeZoneEffect;
|
||||
import forge.card.ability.effects.ManaEffect;
|
||||
import forge.card.ability.effects.ManaReflectedEffect;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
import forge.game.player.AIPlayer;
|
||||
|
||||
/**
|
||||
@@ -109,7 +109,7 @@ public final class AbilitySub extends SpellAbility implements java.io.Serializab
|
||||
public AbilitySub getCopy() {
|
||||
Target t = getTarget() == null ? null : new Target(getTarget());
|
||||
AbilitySub res = new AbilitySub(api, getSourceCard(), t, params);
|
||||
CardFactoryUtil.copySpellAbility(this, res);
|
||||
CardFactory.copySpellAbility(this, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import forge.GameEntity;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.CardType;
|
||||
import forge.card.ability.effects.AttachEffect;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
@@ -157,7 +158,7 @@ public class GameAction {
|
||||
if (zoneFrom.is(ZoneType.Battlefield)) {
|
||||
c.setFlipStaus(false);
|
||||
}
|
||||
copied = forge.Singletons.getModel().getCardFactory().copyCard(c);
|
||||
copied = CardFactory.copyCard(c);
|
||||
copied.setUnearthed(c.isUnearthed());
|
||||
copied.setTapped(false);
|
||||
for (final Trigger trigger : copied.getTriggers()) {
|
||||
@@ -669,7 +670,7 @@ public class GameAction {
|
||||
if (p != null && p.is(ZoneType.Battlefield)) {
|
||||
lastKnownInfo = CardUtil.getLKICopy(c);
|
||||
c.clearCounters(); // remove all counters
|
||||
library.add(forge.Singletons.getModel().getCardFactory().copyCard(c), libPosition);
|
||||
library.add(CardFactory.copyCard(c), libPosition);
|
||||
} else {
|
||||
c.clearCounters(); // remove all counters
|
||||
library.add(c, libPosition);
|
||||
|
||||
@@ -33,6 +33,7 @@ import forge.CardPredicates.Presets;
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.mana.ManaCostBeingPaid;
|
||||
import forge.card.mana.ManaCostParser;
|
||||
@@ -609,7 +610,7 @@ public class MagicStack extends MyObservable {
|
||||
@Override
|
||||
public void execute() {
|
||||
for (int i = 0; i < sp.getSourceCard().getReplicateMagnitude(); i++) {
|
||||
Singletons.getModel().getCardFactory().copySpellontoStack(sp.getSourceCard(), sp.getSourceCard(), sp, false);
|
||||
CardFactory.copySpellontoStack(sp.getSourceCard(), sp.getSourceCard(), sp, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -507,7 +507,7 @@ public final class GuiDisplayUtil {
|
||||
for (final String element : data) {
|
||||
final String[] cardinfo = element.trim().split("\\|");
|
||||
|
||||
final Card c = Singletons.getModel().getCardFactory().getCard(CardDb.instance().getCard(cardinfo[0]), player);
|
||||
final Card c = CardDb.instance().getCard(cardinfo[0]).toForgeCard(player);
|
||||
|
||||
boolean hasSetCurSet = false;
|
||||
for (final String info : cardinfo) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import forge.Command;
|
||||
import forge.Constant;
|
||||
import forge.Constant.Preferences;
|
||||
import forge.Singletons;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.control.input.Input;
|
||||
@@ -301,7 +302,7 @@ public class CField implements ICDoc {
|
||||
faceDown.setName("Face Down");
|
||||
choices2.add(faceDown);
|
||||
} else {
|
||||
final Card faceDown = Singletons.getModel().getCardFactory().copyCard(crd);
|
||||
final Card faceDown = CardFactory.copyCard(crd);
|
||||
faceDown.setState(CardCharacteristicName.Original);
|
||||
choices2.add(faceDown);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ package forge.item;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
@@ -81,7 +80,7 @@ public final class CardDb {
|
||||
* @param list
|
||||
* the new up
|
||||
*/
|
||||
public static void setup(final Iterator<CardRules> list) {
|
||||
public static void setup(final Iterable<CardRules> list) {
|
||||
if (CardDb.commonCards != null) {
|
||||
throw new RuntimeException("CardDb has already been initialized, don't do it twice please");
|
||||
}
|
||||
@@ -426,9 +425,9 @@ public final class CardDb {
|
||||
uniqueSpecialCards.put(cardName, lastAdded);
|
||||
}
|
||||
|
||||
CardSorter(final Iterator<CardRules> parser) {
|
||||
while (parser.hasNext()) {
|
||||
this.addNewCard(parser.next());
|
||||
CardSorter(final Iterable<CardRules> parser) {
|
||||
for (CardRules cr : parser) {
|
||||
this.addNewCard(cr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import forge.CardUtil;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
import forge.game.player.Player;
|
||||
|
||||
|
||||
@@ -295,7 +296,7 @@ public final class CardPrinted implements Comparable<IPaperCard>, InventoryItemF
|
||||
*/
|
||||
@Override
|
||||
public Card toForgeCard(Player owner) {
|
||||
final Card c = Singletons.getModel().getCardFactory().getCard(this, owner);
|
||||
final Card c = CardFactory.getCard(this, owner);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package forge.item;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
import forge.game.player.Player;
|
||||
|
||||
public class CardToken implements InventoryItemFromSet, IPaperCard {
|
||||
@@ -40,7 +40,7 @@ public class CardToken implements InventoryItemFromSet, IPaperCard {
|
||||
|
||||
@Override
|
||||
public Card toForgeCard(Player owner) {
|
||||
final Card c = Singletons.getModel().getCardFactory().getCard(this, owner);
|
||||
final Card c = CardFactory.getCard(this, owner);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,9 @@ import forge.card.CardBlock;
|
||||
import forge.card.EditionCollection;
|
||||
import forge.card.FatPackData;
|
||||
import forge.card.FormatCollection;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
import forge.card.cardfactory.CardStorageReader;
|
||||
import forge.deck.CardCollections;
|
||||
import forge.error.BugReporter;
|
||||
import forge.error.ExceptionHandler;
|
||||
import forge.game.GameState;
|
||||
import forge.game.GameType;
|
||||
@@ -41,6 +42,8 @@ import forge.game.MatchController;
|
||||
import forge.game.limited.GauntletMini;
|
||||
import forge.game.player.LobbyPlayer;
|
||||
import forge.gauntlet.GauntletData;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.item.CardDb;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.properties.ForgeProps;
|
||||
@@ -81,7 +84,6 @@ public enum FModel {
|
||||
private GauntletData gauntletData;
|
||||
private GauntletMini gauntlet;
|
||||
|
||||
private final CardFactory cardFactory;
|
||||
private final QuestController quest;
|
||||
private final CardCollections decks;
|
||||
|
||||
@@ -154,7 +156,16 @@ public enum FModel {
|
||||
this.loadDynamicGamedata();
|
||||
|
||||
// Loads all cards (using progress bar).
|
||||
this.cardFactory = new CardFactory(ForgeProps.getFile(NewConstants.CARDSFOLDER));
|
||||
GuiUtils.checkEDT("CardFactory$constructor", false);
|
||||
final CardStorageReader reader = new CardStorageReader(ForgeProps.getFile(NewConstants.CARDSFOLDER), true);
|
||||
try {
|
||||
// this fills in our map of card names to Card instances.
|
||||
CardDb.setup(reader.loadCards());
|
||||
|
||||
} catch (final Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
}
|
||||
|
||||
this.decks = new CardCollections(ForgeProps.getFile(NewConstants.NEW_DECKS));
|
||||
this.quest = new QuestController();
|
||||
}
|
||||
@@ -412,14 +423,6 @@ public enum FModel {
|
||||
return gameState;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @return
|
||||
*/
|
||||
public CardFactory getCardFactory() {
|
||||
return cardFactory;
|
||||
}
|
||||
|
||||
public GauntletMini getGauntletMini() {
|
||||
|
||||
if (gauntlet == null) {
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.List;
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.quest.data.GameFormatQuest;
|
||||
import forge.util.FileSection;
|
||||
import forge.util.storage.StorageReaderFile;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user