use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class DoomgapeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
if (controller.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) {
Permanent creature = game.getPermanent(target.getFirstTarget());
if (creature != null) {
if (creature.sacrifice(source, game)) {
controller.gainLife(creature.getToughness().getValue(), game, source);
return true;
}
}
}
}
return false;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class GriftersBladeChooseCreatureEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getPermanentEntering(source.getSourceId());
if (controller != null && mageObject != null) {
TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
if (controller.choose(this.outcome, target, source.getSourceId(), game)) {
Permanent attachToCreature = game.getPermanent(target.getFirstTarget());
if (attachToCreature != null) {
attachToCreature.addAttachment(mageObject.getId(), source, game);
}
}
return true;
}
return false;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class LethalStingCost method pay.
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(ability.getControllerId());
if (controller != null) {
Target target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
controller.chooseTarget(Outcome.UnboostCreature, target, ability, game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.addCounters(CounterType.M1M1.createInstance(), controllerId, ability, game);
game.informPlayers(controller.getLogName() + " puts a -1/-1 counter on " + permanent.getLogName());
this.paid = true;
}
}
return paid;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class PillarTombsOfAkuEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player activePlayer = game.getPlayer(game.getActivePlayerId());
if (activePlayer == null) {
return false;
}
if (activePlayer.chooseUse(Outcome.Sacrifice, "Sacrifice a creature?", source, game)) {
Cost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent());
if (cost.canPay(source, source, activePlayer.getId(), game) && cost.pay(source, game, source, activePlayer.getId(), true)) {
return true;
}
}
activePlayer.loseLife(5, game, source, false);
return new SacrificeSourceEffect().apply(game, source);
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class PromiseOfLoyaltyAttackEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = new ArrayList<>();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null || game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_CREATURE, source.getSourceId(), playerId, game) < 1) {
continue;
}
TargetPermanent target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
player.choose(outcome, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null) {
continue;
}
permanents.add(permanent);
permanent.addCounters(CounterType.VOW.createInstance(), playerId, source, game);
}
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getSourceId(), game)) {
if (permanent == null) {
continue;
}
if (permanents.contains(permanent)) {
game.addEffect(new PromiseOfLoyaltyAttackEffect().setTargetPointer(new FixedTarget(permanent, game)), source);
} else {
permanent.sacrifice(source, game);
}
}
return true;
}
Aggregations