@Override public Cost getFixedCostsFromAnnouncedValue(int xValue) { TargetControlledPermanent target = new TargetControlledPermanent(xValue, xValue, filter, true); return new SacrificeTargetCost(target); }
@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { for (Cost cost : sourceAbility.getCosts()) { if (cost instanceof SacrificeTargetCost) { SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost; return sacrificeCost.getPermanents() .stream().mapToInt(p -> p.getPower().getValue()).sum(); } } return 0; }
public SacrificeTargetCost(TargetControlledPermanent target, boolean noText) { this.addTarget(target); }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (controller != null && sourcePermanent != null) { TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true); SacrificeTargetCost cost = new SacrificeTargetCost(target); if (!controller.chooseUse(Outcome.Benefit, "Do you wish to sacrifice a Forest?", source, game) || !cost.canPay(source, source.getSourceId(), source.getControllerId(), game) || !cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { sourcePermanent.sacrifice(source.getSourceId(), game); controller.damage(7, sourcePermanent.getId(), game, false, true); } else if (cost.isPaid()) { for (Permanent permanent : cost.getPermanents()) { if (filterSnow.match(permanent, game)) { game.addEffect(new GainAbilitySourceEffect(TrampleAbility.getInstance(), Duration.EndOfTurn), source); break; } } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (controller != null && sourcePermanent != null) { TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true); SacrificeTargetCost cost = new SacrificeTargetCost(target); if (!controller.chooseUse(Outcome.AIDontUseIt, "Do you wish to sacrifice an Island?", source, game) || !cost.canPay(source, source.getSourceId(), source.getControllerId(), game) || !cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { sourcePermanent.sacrifice(source.getSourceId(), game); controller.damage(6, sourcePermanent.getId(), game, false, true); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { MageObject sourceObject = source.getSourceObject(game); if (sourceObject != null) { SacrificeTargetCost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT)); for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) { cost.clearPaid(); Player player = game.getPlayer(playerId); if (player != null && cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(outcome, "Sacrifice a creature to counter " + sourceObject.getIdName() + '?', source, game)) { if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) { game.informPlayers(player.getLogName() + " sacrifices a creature to counter " + sourceObject.getIdName() + '.'); Spell spell = game.getStack().getSpell(source.getSourceId()); if (spell != null) { game.getStack().counter(spell.getId(), source.getSourceId(), game); } } } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { SacrificeTargetCost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT)); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) { game.applyEffects(); // To end effects of the sacrificed creature controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null); } return true; } return false; } }
@Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { boolean result = super.pay(ability, game, sourceId, controllerId, noMana, costToPay); if (paid && !getPermanents().isEmpty()) { Permanent sacrificedPermanen = getPermanents().get(0); Permanent sourcePermanent = game.getPermanent(sourceId); if (sourcePermanent != null && sacrificedPermanen != null) { game.getState().setValue(RAVENOUS_WAMPA_STATE_VALUE_KEY_PREFIX + sourceId + sourcePermanent.getZoneChangeCounter(game), sacrificedPermanen.getToughness().getValue()); } } return result; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { for (Cost cost : abilityToModify.getCosts()) { if (cost instanceof SacrificeTargetCost) { SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost; Filter filter = sacrificeCost.getTargets().get(0).getFilter(); filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE))); } } return true; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent minionLeshrac = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (controller != null && minionLeshrac != null) { FilterControlledPermanent filterCreature = new FilterControlledPermanent(); filterCreature.add(new CardTypePredicate(CardType.CREATURE)); filterCreature.add(AnotherPredicate.instance); TargetControlledPermanent target = new TargetControlledPermanent(filterCreature); SacrificeTargetCost cost = new SacrificeTargetCost(target); if (controller.chooseUse(Outcome.AIDontUseIt, "Do you wish to sacrifice another creature to prevent the 5 damage to you?", source, game) && cost.canPay(source, source.getSourceId(), source.getControllerId(), game) && cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { return true; } if (controller.damage(5, minionLeshrac.getId(), game, false, true) > 0) { minionLeshrac.tap(game); return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { StackObject spell = null; for(StackObject objet : game.getStack()){ if(objet instanceof Spell && objet.getSourceId().equals(source.getSourceId())){ spell = objet; } } if(spell != null){ Player controller = game.getPlayer(source.getControllerId()); if(controller != null && controller.chooseUse(Outcome.Detriment, "Sacrifice a land to not counter " + spell.getName() + '?', source, game)){ SacrificeTargetCost cost = new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledLandPermanent())); if(cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)){ game.informPlayers(controller.getLogName() + " sacrifices a land to not counter " + spell.getName() + '.'); return true; } else { game.getStack().counter(spell.getId(), source.getSourceId(), game); } } return true; } return false; }
public GlacialCrevasses(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{R}"); // Sacrifice a snow Mountain: Prevent all combat damage that would be dealt this turn. Effect effect = new PreventAllDamageByAllPermanentsEffect(Duration.EndOfTurn, true); effect.setText("Prevent all combat damage that would be dealt this turn"); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new SacrificeTargetCost(new TargetControlledPermanent(filter))); this.addAbility(ability); }
@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { for (Cost cost : sourceAbility.getCosts()) { if (cost instanceof SacrificeTargetCost) { SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost; return sacrificeCost.getPermanents().stream().mapToInt(p -> p.getToughness().getValue()).sum(); } } return 0; }
public SacrificeTargetCost(TargetControlledPermanent target) { this.addTarget(target); target.setNotTarget(true); // sacrifice is never targeted this.text = "sacrifice " + ((target.getNumberOfTargets() != 1 || (target.getTargetName().startsWith("an") || target.getTargetName().startsWith("a "))) ? (target.getMinNumberOfTargets() == target.getMaxNumberOfTargets() && target.getMinNumberOfTargets() > 1 ? CardUtil.numberToText(target.getNumberOfTargets()) + " " : "") : (target.getTargetName().startsWith("artifact") ? "an " : "a ")) + target.getTargetName(); target.setTargetName(target.getTargetName() + " (to sacrifice)"); }
public EndlessWurm(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}"); this.subtype.add(SubType.WURM); this.power = new MageInt(9); this.toughness = new MageInt(9); // Trample this.addAbility(TrampleAbility.getInstance()); // At the beginning of your upkeep, sacrifice Endless Wurm unless you sacrifice an enchantment. this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SacrificeSourceUnlessPaysEffect(new SacrificeTargetCost(new TargetControlledPermanent(filter))), TargetController.YOU, false)); }
@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { for(Cost cost : sourceAbility.getCosts()) { if(cost instanceof SacrificeTargetCost) { SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost; int totalCMC = 0; for(Permanent permanent : sacrificeCost.getPermanents()) { totalCMC += permanent.getConvertedManaCost(); } return totalCMC; } } return 0; }
public HorrorOfHorrors(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{B}{B}"); // Sacrifice a Swamp: Regenerate target black creature. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RegenerateTargetEffect(), new SacrificeTargetCost(new TargetControlledPermanent(filter1))); ability.addTarget(new TargetCreaturePermanent(filter2)); this.addAbility(ability); }
@Override public boolean apply(Game game, Ability source) { int amount = 0; for (Cost cost : source.getCosts()) { if (cost instanceof SacrificeTargetCost && !((SacrificeTargetCost) cost).getPermanents().isEmpty()) { amount = ((SacrificeTargetCost) cost).getPermanents().get(0).getPower().getValue(); break; } } if (amount > 0) { return new DamageTargetEffect(amount).apply(game, source); } return true; } }
public BloodmistInfiltrator(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}"); this.subtype.add(SubType.VAMPIRE); this.power = new MageInt(3); this.toughness = new MageInt(1); // Whenever Bloodmist Infiltrator attacks, you may sacrifice another creature. If you do, Bloodmist Infiltrator can't be blocked this turn. this.addAbility(new AttacksTriggeredAbility(new DoIfCostPaid( new CantBeBlockedSourceEffect(Duration.EndOfTurn), new SacrificeTargetCost(new TargetControlledPermanent(filter)) ), false)); }
@Override public boolean apply(Game game, Ability source) { int amount = 0; for (Cost cost : source.getCosts()) { if (cost instanceof SacrificeTargetCost && !((SacrificeTargetCost) cost).getPermanents().isEmpty()) { amount = ((SacrificeTargetCost) cost).getPermanents().get(0).getConvertedManaCost() + 1; break; } } if (amount > 0) { new AddConditionalManaOfAnyColorEffect(amount, new MetamorphosisManaBuilder()).apply(game, source); } return false; }