use of mage.filter.common.FilterArtifactPermanent 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.filter.common.FilterArtifactPermanent in project mage by magefree.
the class HammerMageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterArtifactPermanent filter = new FilterArtifactPermanent();
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
permanent.destroy(source, game, false);
}
return true;
}
use of mage.filter.common.FilterArtifactPermanent in project mage by magefree.
the class BludgeonBrawlGainAbilityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterArtifactPermanent filter = new FilterArtifactPermanent("noncreature, non-Equipment artifact");
filter.add(Predicates.not(CardType.CREATURE.getPredicate()));
filter.add(Predicates.not(SubType.EQUIPMENT.getPredicate()));
Cards affectedPermanents = new CardsImpl();
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
for (Permanent permanent : permanents) {
if (permanent != null) {
permanent.addSubType(game, SubType.EQUIPMENT);
affectedPermanents.add(permanent.getId());
}
}
game.getState().setValue(source.getSourceId() + "BludgeonBrawlAffectedPermanents", affectedPermanents);
return true;
}
use of mage.filter.common.FilterArtifactPermanent in project mage by magefree.
the class ScrapMasteryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Map<UUID, Set<Card>> exiledCards = new HashMap<>();
// exile artifacts from graveyard
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
Set<Card> cards = player.getGraveyard().getCards(new FilterArtifactCard(), game);
controller.moveCards(cards, Zone.EXILED, source, game);
exiledCards.put(player.getId(), cards);
}
}
// sacrifice all artifacts
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), playerId, game)) {
permanent.sacrifice(source, game);
}
}
}
// puts all cards they exiled this way onto the battlefield
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.moveCards(exiledCards.get(playerId), Zone.BATTLEFIELD, source, game);
}
}
return true;
}
return false;
}
use of mage.filter.common.FilterArtifactPermanent in project mage by magefree.
the class EmissaryOfDespairCount method calculate.
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
if (effect.getTargetPointer().getFirst(game, sourceAbility) == null) {
return 0;
}
FilterArtifactPermanent filter = new FilterArtifactPermanent();
filter.add(new ControllerIdPredicate(effect.getTargetPointer().getFirst(game, sourceAbility)));
return game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
}
Aggregations