use of mage.filter.common.FilterArtifactOrEnchantmentPermanent in project mage by magefree.
the class FelineSovereignTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent p = game.getPermanent(event.getSourceId());
if (damageEvent.isCombatDamage() && p != null && p.isControlledBy(this.getControllerId()) && filter.match(p, getSourceId(), getControllerId(), game) && !damagedPlayerIds.contains(event.getPlayerId())) {
damagedPlayerIds.add(event.getPlayerId());
this.getTargets().clear();
FilterArtifactOrEnchantmentPermanent filter = new FilterArtifactOrEnchantmentPermanent();
filter.add(new ControllerIdPredicate(event.getPlayerId()));
this.addTarget(new TargetPermanent(0, 1, filter, false));
return true;
}
}
if (event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_PRIORITY || (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(getSourceId()))) {
damagedPlayerIds.clear();
}
return false;
}
use of mage.filter.common.FilterArtifactOrEnchantmentPermanent in project mage by magefree.
the class DruidOfPurificationEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
FilterPermanent filter = new FilterArtifactOrEnchantmentPermanent("artifact or enchantment not controlled by " + controller.getName());
filter.add(Predicates.not(new ControllerIdPredicate(controller.getId())));
if (game.getBattlefield().count(filter, source.getControllerId(), source.getControllerId(), game) < 1) {
return false;
}
TargetPermanent target = new TargetPermanent(0, 1, filter);
target.setNotTarget(true);
Set<Permanent> permanents = new HashSet<>();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
target.clearChosen();
player.choose(Outcome.DestroyPermanent, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null) {
game.informPlayers(player.getLogName() + " has not chosen a permanent");
continue;
}
game.informPlayers(player.getLogName() + " has chosen " + permanent.getLogName());
permanents.add(permanent);
}
for (Permanent permanent : permanents) {
permanent.destroy(source, game, false);
}
return true;
}
use of mage.filter.common.FilterArtifactOrEnchantmentPermanent in project mage by magefree.
the class KappaTechWreckerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterPermanent filter = new FilterArtifactOrEnchantmentPermanent("artifact or enchantment that player controls");
filter.add(new ControllerIdPredicate(getTargetPointer().getFirst(game, source)));
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new ExileTargetEffect(), false);
ability.addTarget(new TargetPermanent(filter));
return new DoWhenCostPaid(ability, new RemoveCountersSourceCost(CounterType.DEATHTOUCH.createInstance()), "Remove a deathtouch counter?").apply(game, source);
}
Aggregations