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