nantuko84 wrote:I had the similar problems with flashback cards with targets long ago, and as far as I remember it was solved just by copying target parameters.
I've looked into your CardFactoryUtil, could you try the following (not tested, just idea):
- Code: Select all
public static SpellAbility ability_Flashback(...)
...
SpellAbility spell = sourceCard.getSpellAbility()[0];
... // at the end
flashback.setStackDescription("Flashback: " + sourceCard.getName());
flashback.setBeforePayMana(spell.getBeforePayMana());
won't it call CardFactoryUtil.input_targetCreaturePlayer(...)?
if it does, probably you'll also need to copy target in flashback.resolve()
does that make sense?
The main idea, SpellAbility.setBeforePayMana() does not have to be set if it is a
spell that doesn't need any targets. If it is an
ability, you must always call SpellAbility.setBeforePayMana(Input), the easiest way is to find a similar card in CardFactory. The specific Input for an ability depends if the ability has any targets, mana costs, or "tap cost" like
Royal Assassin. The reason (I think) that I had to have separate Input classes to pay the mana costs of spells and abilities is that spells are removed from the players hand and put into the graveyard and abilities are not. With some modifications you probably can have the same code handle spells and abilities and thus reduce the number of Input_PayaManaCost classes.
I'll tell you what I know and hopefully it will help. SpellAbility.setBeforePayMana(Input) is a horrible name for a method, sorry, a better name would be SpellAbility.chooseTargets(). I had weird ideas that
Plow Under (a very popular card at the time, 8th Edition?) would let the player put the two lands on the top of his library in any order.
SpellAbility.setBeforePayMana(Input) the argument is ran BEFORE the use pays the mana cost. Input.getMessage() is always the first method executed so you can do wierd stuff with it, see tap abilities and planeswalkers in CardFactory for messy examples. CardFactoryUtil.input_targetCreaturePlayer() is trying to implement reusable code instead of me cutting and pasting everywhere.
If a card doesn't need any targets like
Wrath of God, SpellAbility.setBeforePayMana() does not have to be set because if SpellAbility.getBeforePayMana() returns null and the program presumes that the Input should be Input_PayManaCost. (When you click on a card many methods are called Input_Main.selectCard() calls InputUtil.playAnyCard() which calls GameAction.playSpellAbility() which checks to see if SpellAbility.getBeforePayMana() returns null and presumes Input_PayManaCost).
I hope that helps.