use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class MogisGodOfSlaughterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId());
if (player == null) {
return false;
}
if (game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, game.getActivePlayerId(), game) == 0) {
return player.damage(2, source.getSourceId(), source, game) > 0;
}
TargetPermanent target = new TargetControlledCreaturePermanent(1);
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), player.getId(), game) && player.chooseUse(Outcome.Detriment, "Sacrifice a creature to prevent 2 damage?", source, game) && player.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null && permanent.sacrifice(source, game)) {
return true;
}
}
return player.damage(2, source.getSourceId(), source, game) > 0;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class StonehewerGiantEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
FilterCard filter = new FilterCard("Equipment");
filter.add(SubType.EQUIPMENT.getPredicate());
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (controller.searchLibrary(target, source, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
Permanent equipment = game.getPermanent(card.getId());
Target targetCreature = new TargetControlledCreaturePermanent();
targetCreature.setNotTarget(true);
if (equipment != null && controller.choose(Outcome.BoostCreature, targetCreature, source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(targetCreature.getFirstTarget());
permanent.addAttachment(equipment.getId(), source, game);
}
}
}
controller.shuffleLibrary(source, game);
return true;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class AgitatorAntEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Player player : game.getState().getPlayersInRange(source.getControllerId(), game).stream().map(game::getPlayer).filter(Objects::nonNull).collect(Collectors.toList())) {
if (game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game) < 1 || !player.chooseUse(Outcome.BoostCreature, "Put two +1/+1 counters on a creature you control?", source, game)) {
continue;
}
TargetPermanent targetPermanent = new TargetControlledCreaturePermanent(0, 1);
targetPermanent.setNotTarget(true);
player.choose(Outcome.BoostCreature, targetPermanent, source.getSourceId(), game);
Permanent permanent = game.getPermanent(targetPermanent.getFirstTarget());
if (permanent == null || !permanent.addCounters(CounterType.P1P1.createInstance(2), player.getId(), source, game)) {
continue;
}
game.addEffect(new GoadTargetEffect().setTargetPointer(new FixedTarget(permanent, game)), source);
}
return true;
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class BloodCurdleEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Target target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
if (!player.choose(outcome, target, source.getSourceId(), game)) {
return false;
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null) {
return false;
}
return permanent.addCounters(CounterType.MENACE.createInstance(), source.getControllerId(), source, game);
}
use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.
the class HuntedNightmareEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player == null || game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game) == 0) {
return false;
}
Target target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
player.choose(outcome, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
return permanent != null && permanent.addCounters(CounterType.DEATHTOUCH.createInstance(), player.getId(), source, game);
}
Aggregations