Re: Copying a SpellAbility?
How close are we to Twincast or storm? 
High Quality Resources for Collectible Card Games and Home of the CCGHQ Team
https://www.slightlymagic.net/forum/
https://www.slightlymagic.net/forum/viewtopic.php?f=52&t=2306
card.clearSpellAbility();
card.addSpellAbility(spLoseLife);
String bbCost = card.getSVar("Buyback");
if (!bbCost.equals(""))
{
SpellAbility bbLoseLife = spLoseLife.copy();
bbLoseLife.setManaCost(CardUtil.addManaCosts(card.getManaCost(), bbCost));
bbLoseLife.setDescription("Buyback " + bbCost + "(You may pay an additional " + bbCost + " as you cast this spell. If you do, put this card into your hand as it resolves.)");
bbLoseLife.setIsBuyBackAbility(true);
card.addSpellAbility(bbLoseLife);
}
static public String addManaCosts(String mc1, String mc2)
{
String tMC = new String("");
Integer cl1, cl2, tCL;
cl1 = Integer.valueOf(mc1.replaceAll("[WUBRGSX]", "").trim());
cl2 = Integer.valueOf(mc2.replaceAll("[WUBRGSX]", "").trim());
tCL = cl1 + cl2;
mc1 = mc1.replace(cl1.toString(), "").trim();
mc2 = mc2.replace(cl2.toString(), "").trim();
tMC = tCL.toString() + " " + mc1 + " " + mc2;
return tMC;
}
public abstract class SpellAbility implements Cloneable {
...
public SpellAbility copy()
{
SpellAbility clone = null;
try {
clone = (SpellAbility)this.clone();
} catch (CloneNotSupportedException e) {
System.err.println(e);
}
return clone;
}
Brush With Death
2 B
Sorcery
no text
spLoseLifeTgt:2:Drawback$YouGainLife/2:Target opponent loses 2 life and you gain 2 life.
SVar:Buyback:2 B B
card.clearSpellAbility();
card.addSpellAbility(spLoseLife);
String bbCost = card.getSVar("Buyback");
if (!bbCost.equals(""))
{
SpellAbility bbLoseLife = spLoseLife.copy();
bbLoseLife.setManaCost(CardUtil.addManaCosts(card.getManaCost(), bbCost));
bbLoseLife.setDescription("Buyback " + bbCost + "(You may pay an additional " + bbCost + " as you cast this spell. If you do, put this card into your hand as it resolves.)");
bbLoseLife.setIsBuyBackAbility(true);
if (Tgt[0] == true)
bbLoseLife.setBeforePayMana(CardFactoryUtil.input_targetPlayer(bbLoseLife));
card.addSpellAbility(bbLoseLife);
}
The buyback version of the SpellAbility needs be dealt with in the same handler as the regular version. So I didn't want to bother with a complex parser, which I guess it really doesn't need... it could have been done almost as elegantly as with a direct keyword syntax.zerker2000 wrote:Also, why Svar? I think the keyword should be placed as "Buyback X", with cycling, first cloning the spell and then putting the result in a wrapper. Or better yet, get resolveCommands[] working, and add a "Command{execute{sa.controller.draw()}}" to those.