mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
removed extra parameters from spell and payMana constructors
pre-reqs to make payCost in spellAility not null and final
This commit is contained in:
@@ -19,7 +19,9 @@ public class SpellApiBased extends Spell {
|
||||
private final SpellAbilityAi ai;
|
||||
|
||||
public SpellApiBased(ApiType api0, Card sourceCard, Cost abCost, Target tgt, Map<String, String> params0) {
|
||||
super(sourceCard, abCost, tgt);
|
||||
super(sourceCard, abCost);
|
||||
this.setTarget(tgt);
|
||||
|
||||
params = params0;
|
||||
api = api0;
|
||||
effect = api.getSpellEffect();
|
||||
|
||||
@@ -255,7 +255,7 @@ public class CardFactorySorceries {
|
||||
* library.
|
||||
*/
|
||||
|
||||
return new Spell(card, new Cost("U U", false), null) {
|
||||
return new Spell(card, new Cost("U U", false)) {
|
||||
private static final long serialVersionUID = -8497142072380944393L;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -162,7 +162,7 @@ public class CardFactoryUtil {
|
||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||
*/
|
||||
public static SpellAbility abilityMorphDown(final Card sourceCard) {
|
||||
final Spell morphDown = new Spell(sourceCard, new Cost(ManaCost.THREE, false), null) {
|
||||
final Spell morphDown = new Spell(sourceCard, new Cost(ManaCost.THREE, false)) {
|
||||
private static final long serialVersionUID = -1438810964807867610L;
|
||||
|
||||
@Override
|
||||
@@ -2596,9 +2596,7 @@ public class CardFactoryUtil {
|
||||
if (!card.getSVar("FullCost").equals("")) {
|
||||
final SpellAbility sa1 = card.getFirstSpellAbility();
|
||||
if (sa1 != null && sa1.isSpell()) {
|
||||
final String altCost = card.getSVar("FullCost");
|
||||
final Cost abCost = new Cost(altCost, sa1.isAbility());
|
||||
sa1.setPayCosts(abCost);
|
||||
sa1.setPayCosts(new Cost(card.getSVar("FullCost"), sa1.isAbility()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3136,10 +3134,9 @@ public class CardFactoryUtil {
|
||||
*/
|
||||
private static SpellAbility makeEvokeSpell(final Card card, final String evokeKeyword) {
|
||||
final String[] k = evokeKeyword.split(":");
|
||||
final String evokedCost = k[1];
|
||||
ManaCost manaCost = new ManaCost(new ManaCostParser(evokedCost));
|
||||
final Cost evokedCost = new Cost(k[1], false);
|
||||
|
||||
final SpellAbility evokedSpell = new Spell(card, new Cost(manaCost, false), null) {
|
||||
final SpellAbility evokedSpell = new Spell(card, evokedCost) {
|
||||
private static final long serialVersionUID = -1598664196463358630L;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -97,7 +97,9 @@ public class Cost {
|
||||
return ManaCost.ZERO;
|
||||
}
|
||||
|
||||
private Cost() {}
|
||||
private Cost(int colorlessmana) {
|
||||
costParts.add(new CostPartMana(ManaCost.get(colorlessmana), null, false));
|
||||
}
|
||||
|
||||
// Parsing Strings
|
||||
|
||||
@@ -373,11 +375,9 @@ public class Cost {
|
||||
}
|
||||
|
||||
public final Cost copyWithNoMana() {
|
||||
Cost toRet = new Cost();
|
||||
Cost toRet = new Cost(0);
|
||||
for(CostPart cp : this.costParts) {
|
||||
if ( cp instanceof CostPartMana )
|
||||
toRet.costParts.add(new CostPartMana(ManaCost.ZERO, null, false));
|
||||
else
|
||||
if (!(cp instanceof CostPartMana))
|
||||
toRet.costParts.add(cp);
|
||||
}
|
||||
return toRet;
|
||||
@@ -686,4 +686,6 @@ public class Cost {
|
||||
card.setSVar("ChosenX", Integer.toString(chosenX));
|
||||
return chosenX;
|
||||
}
|
||||
|
||||
public static final Cost Zero = new Cost(0);
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public class CostPartMana extends CostPart {
|
||||
|
||||
|
||||
if (!toPay.isPaid()) {
|
||||
InputPayment inpPayment = new InputPayManaOfCostPayment(game, toPay, ability);
|
||||
InputPayment inpPayment = new InputPayManaOfCostPayment(toPay, ability);
|
||||
FThreads.setInputAndWait(inpPayment);
|
||||
if(!inpPayment.isPaid())
|
||||
return false;
|
||||
|
||||
@@ -551,10 +551,9 @@ public class ManaPool {
|
||||
* a boolean.
|
||||
*/
|
||||
public final void clearManaPaid(final SpellAbility ability, final boolean refund) {
|
||||
final List<SpellAbility> abilitiesUsedToPay = ability.getPayingManaAbilities();
|
||||
final List<Mana> manaPaid = ability.getPayingMana();
|
||||
|
||||
abilitiesUsedToPay.clear();
|
||||
ability.getPayingManaAbilities().clear();
|
||||
// move non-undoable paying mana back to floating
|
||||
if (refund) {
|
||||
if (ability.getSourceCard() != null) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import forge.card.ability.effects.ChangeZoneEffect;
|
||||
import forge.card.ability.effects.ManaEffect;
|
||||
import forge.card.ability.effects.ManaReflectedEffect;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.game.player.AIPlayer;
|
||||
|
||||
/**
|
||||
@@ -90,8 +91,9 @@ public final class AbilitySub extends SpellAbility implements java.io.Serializab
|
||||
}
|
||||
|
||||
public AbilitySub(ApiType api0, final Card ca, final Target tgt, Map<String, String> params0) {
|
||||
super(ca);
|
||||
super(ca, Cost.Zero);
|
||||
this.setTarget(tgt);
|
||||
|
||||
api = api0;
|
||||
params = params0;
|
||||
ai = api.getAi();
|
||||
|
||||
@@ -57,32 +57,15 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
|
||||
* a {@link forge.Card} object.
|
||||
*/
|
||||
public Spell(final Card sourceCard) {
|
||||
super(sourceCard);
|
||||
this(sourceCard, new Cost(sourceCard.getManaCost(), false));
|
||||
}
|
||||
public Spell(final Card sourceCard, final Cost abCost) {
|
||||
super(sourceCard, abCost);
|
||||
|
||||
this.setPayCosts(new Cost(sourceCard.getManaCost(), false));
|
||||
this.setStackDescription(sourceCard.getSpellText());
|
||||
this.getRestrictions().setZone(ZoneType.Hand);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for Spell.
|
||||
* </p>
|
||||
*
|
||||
* @param sourceCard
|
||||
* a {@link forge.Card} object.
|
||||
* @param abCost
|
||||
* a {@link forge.card.cost.Cost} object.
|
||||
* @param abTgt
|
||||
* a {@link forge.card.spellability.Target} object.
|
||||
*/
|
||||
public Spell(final Card sourceCard, final Cost abCost, final Target abTgt) {
|
||||
this(sourceCard);
|
||||
|
||||
this.setPayCosts(abCost);
|
||||
this.setTarget(abTgt);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean canPlay() {
|
||||
|
||||
@@ -66,24 +66,7 @@ public class SpellPermanent extends Spell {
|
||||
* a {@link forge.Card} object.
|
||||
*/
|
||||
public SpellPermanent(final Card sourceCard) {
|
||||
// Add Costs for all SpellPermanents
|
||||
this(sourceCard, new Cost(sourceCard.getManaCost(), false), null);
|
||||
} // Spell_Permanent()
|
||||
|
||||
/**
|
||||
* Instantiates a new spell_ permanent.
|
||||
*
|
||||
* @param sourceCard
|
||||
* the source card
|
||||
* @param cost
|
||||
* the cost
|
||||
* @param tgt
|
||||
* the tgt
|
||||
* @param setDesc
|
||||
* the set desc
|
||||
*/
|
||||
public SpellPermanent(final Card sourceCard, final Cost cost, final Target tgt) {
|
||||
super(sourceCard, cost, tgt);
|
||||
super(sourceCard, new Cost(sourceCard.getManaCost(), false));
|
||||
|
||||
if (sourceCard.isCreature()) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package forge.control.input;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.mana.ManaCostBeingPaid;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -62,15 +63,10 @@ public class InputPayManaExecuteCommands extends InputPayManaBase {
|
||||
* a {@link forge.Command} object.
|
||||
*/
|
||||
public InputPayManaExecuteCommands(final Player p, final String prompt, final ManaCost manaCost2) {
|
||||
super(new SpellAbility(null) {
|
||||
@Override
|
||||
public void resolve() {}
|
||||
|
||||
@Override
|
||||
public Player getActivatingPlayer() { return p; }
|
||||
|
||||
@Override
|
||||
public boolean canPlay() { return false; }
|
||||
super(new SpellAbility(null, Cost.Zero) {
|
||||
@Override public void resolve() {}
|
||||
@Override public Player getActivatingPlayer() { return p; }
|
||||
@Override public boolean canPlay() { return false; }
|
||||
});
|
||||
this.originalManaCost = manaCost2;
|
||||
this.phyLifeToLose = 0;
|
||||
|
||||
@@ -4,13 +4,12 @@ import forge.Card;
|
||||
import forge.Singletons;
|
||||
import forge.card.mana.ManaCostBeingPaid;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.view.ButtonUtil;
|
||||
|
||||
public class InputPayManaOfCostPayment extends InputPayManaBase {
|
||||
|
||||
public InputPayManaOfCostPayment(final GameState game, ManaCostBeingPaid cost, SpellAbility spellAbility) {
|
||||
public InputPayManaOfCostPayment(ManaCostBeingPaid cost, SpellAbility spellAbility) {
|
||||
super(spellAbility);
|
||||
manaCost = cost;
|
||||
}
|
||||
|
||||
@@ -1159,8 +1159,7 @@ public final class GameActionUtil {
|
||||
|
||||
// there is a flashback cost (and not the cards cost)
|
||||
if (!keyword.equals("Flashback")) {
|
||||
final Cost fbCost = new Cost(keyword.substring(10), false);
|
||||
flashback.setPayCosts(fbCost);
|
||||
flashback.setPayCosts(new Cost(keyword.substring(10), false));
|
||||
}
|
||||
alternatives.add(flashback);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user