use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.
the class DevouringGreedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int numberSpirits = 0;
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
numberSpirits += ((SacrificeTargetCost) cost).getPermanents().size();
}
}
int amount = 2 + (numberSpirits * 2);
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
Player sourcePlayer = game.getPlayer(source.getControllerId());
if (targetPlayer != null && sourcePlayer != null) {
targetPlayer.loseLife(amount, game, source, false);
sourcePlayer.gainLife(amount, game, source);
return true;
}
return false;
}
use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.
the class DevouringRageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int numberSpirits = 0;
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
numberSpirits = ((SacrificeTargetCost) cost).getPermanents().size();
}
}
int amount = 3 + (numberSpirits * 3);
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null) {
ContinuousEffect effect = new BoostTargetEffect(amount, 0, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.
the class AnchorToRealityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetCardInLibrary target = new TargetCardInLibrary(filter);
controller.searchLibrary(target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
controller.shuffleLibrary(source, game);
return true;
}
int searchedManaValue = card.getManaValue();
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
controller.shuffleLibrary(source, game);
int sacrificedManaValue = 0;
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
List<Permanent> sacrificedPermanents = ((SacrificeTargetCost) cost).getPermanents();
if (sacrificedPermanents.size() > 0) {
sacrificedManaValue = sacrificedPermanents.get(0).getManaValue();
break;
}
}
}
if (searchedManaValue < sacrificedManaValue) {
controller.scry(2, source, game);
}
return true;
}
use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.
the class BrainGorgersCounterSourceEffect method apply.
@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, player.getId(), game) && player.chooseUse(outcome, "Sacrifice a creature to counter " + sourceObject.getIdName() + '?', source, game)) {
if (cost.pay(source, game, source, 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, game);
}
}
}
}
return true;
}
return false;
}
use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.
the class ArgothianWurmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
boolean costPaid = false;
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Cost cost = new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledLandPermanent()));
Player player = game.getPlayer(playerId);
if (player != null && cost.canPay(source, source, playerId, game) && player.chooseUse(Outcome.Sacrifice, "Sacrifice a land?", source, game) && cost.pay(source, game, source, playerId, true, null)) {
costPaid = true;
}
}
if (costPaid) {
super.apply(game, source);
}
return true;
}
return false;
}
Aggregations