@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; } }
public RevealTargetFromHandCost(TargetCardInHand target) { this.addTarget(target); this.text = (target.getNumberOfTargets() == 0 ? "You may reveal " : "Reveal ") + target.getTargetName(); this.revealedCards = new ArrayList<>(); }
@Override public RevealTargetFromHandCost copy() { return new RevealTargetFromHandCost(this); } }
@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 = (RevealTargetFromHandCost) source.getCosts().get(0); Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); if (cost != null && creature != null && controller != null) { List<Card> revealedCards = cost.getRevealedCards(); if (!revealedCards.isEmpty()) { Card card = revealedCards.iterator().next(); if (card != null && card.getPower().getValue() >= creature.getPower().getValue()) { controller.moveCards(creature, Zone.EXILED, source, game); } } return true; } return false; }
@Override public Cost getFixedCostsFromAnnouncedValue(int xValue) { return new RevealTargetFromHandCost(new TargetCardInHand(0, xValue, filter)); }
@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) { 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); } }
public FortifiedVillage(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.LAND},""); // As Fortified Village enters the battlefield, you may reveal a Forest or Plains card from your hand. If you don't, Fortified Village enters the battlefield tapped. this.addAbility(new AsEntersBattlefieldAbility(new TapSourceUnlessPaysEffect(new RevealTargetFromHandCost(new TargetCardInHand(filter))), "you may reveal a Forest or Plains card from your hand. If you don't, {this} enters the battlefield tapped")); // {T}: Add {G} or {W}. this.addAbility(new GreenManaAbility()); this.addAbility(new WhiteManaAbility()); }
@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; }
@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; } }
public SecludedGlen(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.LAND},""); // As Secluded Glen enters the battlefield, you may reveal a Faerie card from your hand. If you don't, Secluded Glen enters the battlefield tapped. this.addAbility(new AsEntersBattlefieldAbility(new TapSourceUnlessPaysEffect(new RevealTargetFromHandCost(new TargetCardInHand(filter))), "you may reveal a Faerie card from your hand. If you don't, {this} enters the battlefield tapped")); // {tap}: Add {U} or {B}. this.addAbility(new BlueManaAbility()); this.addAbility(new BlackManaAbility()); }
@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; } }
public WanderwineHub(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.LAND},""); // As Wanderwine Hub enters the battlefield, you may reveal a Merfolk card from your hand. If you don't, Wanderwine Hub enters the battlefield tapped. this.addAbility(new AsEntersBattlefieldAbility(new TapSourceUnlessPaysEffect(new RevealTargetFromHandCost(new TargetCardInHand(filter))), "you may reveal a Merfolk card from your hand. If you don't, {this} enters the battlefield tapped")); // {tap}: Add {W} or {U}. this.addAbility(new WhiteManaAbility()); this.addAbility(new BlueManaAbility()); }
@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); } }
public GiltLeafPalace(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.LAND},""); // As Gilt-Leaf Palace enters the battlefield, you may reveal an Elf card from your hand. If you don't, Gilt-Leaf Palace enters the battlefield tapped. this.addAbility(new AsEntersBattlefieldAbility(new TapSourceUnlessPaysEffect(new RevealTargetFromHandCost(new TargetCardInHand(filter))), "you may reveal a Elf card from your hand. If you don't, {this} enters the battlefield tapped")); // {tap}: Add {B} or {G}. this.addAbility(new BlackManaAbility()); this.addAbility(new GreenManaAbility()); }
@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); } }
public GameTrail(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.LAND},""); // As Game Trail enters the battlefield, you may reveal a Mountain or Forest card from your hand. If you don't, Game Trail enters the battlefield tapped. this.addAbility(new AsEntersBattlefieldAbility(new TapSourceUnlessPaysEffect(new RevealTargetFromHandCost(new TargetCardInHand(filter))), "you may reveal a Mountain or Forest card from your hand. If you don't, {this} enters the battlefield tapped")); // {T}: Add {R} or {G}. this.addAbility(new RedManaAbility()); this.addAbility(new GreenManaAbility()); }
@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); } }
public ChokedEstuary(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.LAND},""); // As Choked Estuary enters the battlefield, you may reveal an Island or Swamp card from your hand. If you don't, Choked Estuary enters the battlefield tapped. this.addAbility(new AsEntersBattlefieldAbility(new TapSourceUnlessPaysEffect(new RevealTargetFromHandCost(new TargetCardInHand(filter))), "you may reveal an Island or Swamp card from your hand. If you don't, {this} enters the battlefield tapped")); // {T}: Add {U} or {B}. this.addAbility(new BlueManaAbility()); this.addAbility(new BlackManaAbility()); }