@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { for (Cost cost : sourceAbility.getCosts()) { if (cost instanceof RevealTargetFromHandCost) { return ((RevealTargetFromHandCost) cost).getNumberRevealedCards(); } } return 0; }
@Override public boolean apply(Game game, Ability source) { RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter)); if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { return false; } int xValue = -1 * cost.getNumberRevealedCards(); game.addEffect(new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn), source); return true; } }
@Override public boolean apply(Game game, Ability source) { RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter)); if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { return false; } int xValue = cost.getNumberRevealedCards(); return new DamageTargetEffect(xValue).apply(game, source); } }
@Override public boolean apply(Game game, Ability source) { RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter)); if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { return false; } int xValue = cost.getNumberRevealedCards(); game.addEffect(new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn), source); return true; } }
@Override public boolean apply(Game game, Ability source) { RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter)); if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { return false; } int xValue = -1 * cost.getNumberRevealedCards(); game.addEffect(new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn), source); return true; } }
@Override public boolean apply(Game game, Ability source) { RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter)); if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { return false; } int xValue = cost.getNumberRevealedCards(); return new DamageTargetEffect(xValue).apply(game, source); } }
@Override public boolean apply(Game game, Ability source) { RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter)); if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { return false; } int xValue = cost.getNumberRevealedCards(); return new GainLifeEffect(2 * xValue).apply(game, source); } }
@Override public boolean apply(Game game, Ability source) { RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter)); if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { return false; } int xValue = cost.getNumberRevealedCards(); return new GainLifeEffect(2 * xValue).apply(game, source); } }
@Override public boolean apply(Game game, Ability source) { RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter)); if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { return false; } int xValue = cost.getNumberRevealedCards(); game.addEffect(new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn), source); return true; } }
@Override public boolean apply(Game game, Ability source) { RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter)); if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { return false; } int xValue = cost.getNumberRevealedCards(); return new CounterUnlessPaysEffect(new GenericManaCost(xValue)).apply(game, source); } }
@Override public boolean apply(Game game, Ability source) { RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter)); if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { return false; } int xValue = cost.getNumberRevealedCards(); return new CounterUnlessPaysEffect(new GenericManaCost(xValue)).apply(game, source); } }
@Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.SPELL_CAST) { // targetId is the unique ID of the spell Spell spell = game.getState().getStack().getSpell(event.getTargetId()); // revealed a Dragon card or controlled a Dragon as you cast the spell if (spell != null) { boolean revealedOrOnBattlefield = false; for (Cost cost : spell.getSpellAbility().getCosts()) { if (cost instanceof RevealTargetFromHandCost) { revealedOrOnBattlefield = ((RevealTargetFromHandCost) cost).getNumberRevealedCards() > 0; break; } } if (!revealedOrOnBattlefield) { revealedOrOnBattlefield = game.getBattlefield().countAll(filter, spell.getControllerId(), game) > 0; } if (revealedOrOnBattlefield){ castWithDragonOnTheBattlefield.add(spell.getId()); } } } }
@Override public boolean apply(Game game, Ability source) { StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source)); if (spell != null) { Player player = game.getPlayer(spell.getControllerId()); if (player != null) { DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = game.getState().getWatcher(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class); boolean condition = watcher != null && watcher.castWithConditionTrue(source.getId()); if (!condition) { for (Cost cost: source.getCosts()) { if (cost instanceof RevealTargetFromHandCost) { condition = ((RevealTargetFromHandCost)cost).getNumberRevealedCards() > 0; } } } if (condition) { return game.getStack().counter(spell.getId(), source.getSourceId(), game); } if (!(player.chooseUse(Outcome.Benefit, "Would you like to pay {1} to prevent counter effect?", source, game) && new GenericManaCost(1).pay(source, game, spell.getSourceId(), spell.getControllerId(), false))) { return game.getStack().counter(spell.getId(), source.getSourceId(), game); } } } return true; }