use of mage.target.TargetPermanent in project mage by magefree.
the class GoblinVandalTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent sourcePermanent = game.getPermanent(getSourceId());
if (sourcePermanent.isAttacking()) {
for (CombatGroup combatGroup : game.getCombat().getGroups()) {
if (combatGroup.getBlockers().isEmpty() && combatGroup.getAttackers().contains(getSourceId())) {
UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(getSourceId(), game);
FilterPermanent filter = new FilterArtifactPermanent();
filter.add(new ControllerIdPredicate(defendingPlayerId));
Target target = new TargetPermanent(filter);
this.addTarget(target);
return true;
}
}
}
return false;
}
use of mage.target.TargetPermanent in project mage by magefree.
the class GoblinWarCryRestrictionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player == null) {
return false;
}
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control");
filter.add(new ControllerIdPredicate(player.getId()));
Target target = new TargetPermanent(1, 1, filter, true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
while (!target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game) && player.canRespond()) {
player.chooseTarget(Outcome.DestroyPermanent, target, source, game);
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
game.informPlayers(player.getLogName() + " has chosen " + permanent.getLogName() + " as their only creature able to block this turn");
}
}
game.addEffect(new GoblinWarCryRestrictionEffect(target.getFirstTarget()), source);
return true;
}
use of mage.target.TargetPermanent in project mage by magefree.
the class GuildSummitEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int tappedAmount = 0;
Player you = game.getPlayer(source.getControllerId());
TargetPermanent target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), game)) {
for (UUID creatureId : target.getTargets()) {
Permanent creature = game.getPermanent(creatureId);
if (creature != null) {
creature.tap(source, game);
tappedAmount++;
}
}
}
if (tappedAmount > 0) {
you.drawCards(tappedAmount, source, game);
return true;
}
return false;
}
use of mage.target.TargetPermanent 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.TargetPermanent in project mage by magefree.
the class NecriteTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (super.checkTrigger(event, game)) {
UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(getSourceId(), game);
FilterPermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(defendingPlayerId));
Target target = new TargetPermanent(filter);
this.getTargets().clear();
this.addTarget(target);
return true;
}
return false;
}
Aggregations