forked from External/mage
Dauthi Voidwalker - correct code for #8141 and same cards (see comments in fd719ad287);
This commit is contained in:
parent
affd33c23b
commit
a3ca9fc03a
8 changed files with 142 additions and 88 deletions
|
|
@ -11,12 +11,16 @@ import mage.abilities.condition.Condition;
|
|||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.costs.mana.*;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.asthought.CanPlayCardControllerEffect;
|
||||
import mage.abilities.effects.common.asthought.YouMaySpendManaAsAnyColorToCastTargetEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
||||
import mage.abilities.hint.Hint;
|
||||
import mage.abilities.hint.HintUtils;
|
||||
import mage.cards.*;
|
||||
import mage.constants.*;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.CardState;
|
||||
|
|
@ -1371,4 +1375,32 @@ public final class CardUtil {
|
|||
return stream.filter(clazz::isInstance).map(clazz::cast);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move card or permanent to dest zone and add counter to it
|
||||
*
|
||||
* @param game
|
||||
* @param source
|
||||
* @param controller
|
||||
* @param card can be card or permanent
|
||||
* @param toZone
|
||||
* @param counter
|
||||
*/
|
||||
public static boolean moveCardWithCounter(Game game, Ability source, Player controller, Card card, Zone toZone, Counter counter) {
|
||||
if (toZone == Zone.BATTLEFIELD) {
|
||||
throw new IllegalArgumentException("Wrong code usage - method doesn't support moving to battlefield zone");
|
||||
}
|
||||
|
||||
// move to zone
|
||||
if (!controller.moveCards(card, toZone, source, game)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// add counter
|
||||
// after move it's a new object (not a permanent), so must work with main card
|
||||
Effect effect = new AddCountersTargetEffect(counter);
|
||||
effect.setTargetPointer(new FixedTarget(card.getMainCard(), game));
|
||||
effect.apply(game, source);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue