Check if exists a target to counter in Stack before counter

This commit is contained in:
Alexsandro 2017-03-06 19:06:37 -03:00
parent d98e43ded2
commit 3c5bd9acce

View file

@ -126,7 +126,8 @@ class SpellstutterSpriteCounterTargetEffect extends OneShotEffect {
*/
int numberFaeries = game.getState().getBattlefield().countAll(SpellstutterSprite.filter, source.getControllerId(), game);
StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget());
if (stackObject.getConvertedManaCost() <= numberFaeries) {
// If do'nt have any spell targeted
if (stackObject != null && stackObject.getConvertedManaCost() <= numberFaeries) {
if (game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game)) {
return true;
}
@ -134,6 +135,21 @@ class SpellstutterSpriteCounterTargetEffect extends OneShotEffect {
return false;
}
// @Override
// public boolean apply(Game game, Ability source) {
// Player controller = game.getPlayer(source.getControllerId());
// MageObject sourceObject = source.getSourceObject(game);
// if (controller != null && sourceObject != null) {
// Spell spell = game.getStack().getSpell(getTargetPointer().getFirst(game, source));
// if (spell != null) {
// UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
// return controller.moveCardsToExile(spell, source, game, true, exileId, sourceObject.getIdName());
// }
// return true;
// }
// return false;
// }
@Override
public String getText(Mode mode) {
return "counter target spell with converted mana cost X or less, where X is the number of Faeries you control";