use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.
the class RescueFromTheUnderworldReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
DelayedTriggeredAbility delayedAbility = ability.copy();
delayedAbility.getTargets().addAll(source.getTargets());
for (Effect effect : delayedAbility.getEffects()) {
effect.getTargetPointer().init(game, source);
}
// add the sacrificed creature as target
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacCost = (SacrificeTargetCost) cost;
TargetCardInGraveyard target = new TargetCardInGraveyard();
for (Permanent permanent : sacCost.getPermanents()) {
target.add(permanent.getId(), game);
delayedAbility.getTargets().add(target);
}
}
}
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.
the class FalkenrathAristocratEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
Permanent sacrificedCreature = ((SacrificeTargetCost) cost).getPermanents().get(0);
Permanent sourceCreature = game.getPermanent(source.getSourceId());
if (sacrificedCreature.hasSubtype(SubType.HUMAN, game) && sourceCreature != null) {
sourceCreature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
break;
}
}
}
return true;
}
use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.
the class SacrificedWasCondition method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
UUID targetId = cost.getTargets().getFirstTarget();
Permanent permanent = game.getPermanentOrLKIBattlefield(targetId);
if (filter.match(permanent, game)) {
return true;
}
}
}
return false;
}
use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.
the class PrimeSpeakerVannifarEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sacrificedPermanent = null;
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost;
if (!sacrificeCost.getPermanents().isEmpty()) {
sacrificedPermanent = sacrificeCost.getPermanents().get(0);
}
break;
}
}
Player controller = game.getPlayer(source.getControllerId());
if (sacrificedPermanent == null || controller == null) {
return false;
}
int newConvertedCost = sacrificedPermanent.getManaValue() + 1;
FilterCard filter = new FilterCard("creature card with mana value " + newConvertedCost);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, newConvertedCost));
filter.add(CardType.CREATURE.getPredicate());
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (controller.searchLibrary(target, source, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
controller.shuffleLibrary(source, game);
return true;
}
use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.
the class ScourgeOfNelTothPlayEffect method applies.
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
if (sourceId.equals(source.getSourceId()) && source.isControlledBy(affectedControllerId)) {
if (game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
Player player = game.getPlayer(affectedControllerId);
if (player != null) {
// can sometimes be cast with base mana cost from grave????
Costs<Cost> costs = new CostsImpl<>();
costs.add(new SacrificeTargetCost(new TargetControlledCreaturePermanent(2)));
player.setCastSourceIdWithAlternateMana(sourceId, new ManaCostsImpl<>("{B}{B}"), costs);
return true;
}
}
}
return false;
}
Aggregations