use of mage.filter.common.FilterArtifactPermanent in project mage by magefree.
the class StrategySchmategyffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
int numTimesToDo = 1;
if (controller != null) {
// 6 - Repeat this process two more times
while (numTimesToDo > 0) {
// ai must try to choose min
int amount = controller.rollDice(Outcome.Detriment, source, game, 6);
numTimesToDo--;
if (amount == 2) {
List<Permanent> artifactPermanents = game.getBattlefield().getActivePermanents(new FilterArtifactPermanent(), controller.getId(), game);
for (Permanent permanent : artifactPermanents) {
permanent.destroy(source, game, false);
}
} else if (amount == 3) {
List<Permanent> landPermanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LANDS, controller.getId(), game);
for (Permanent permanent : landPermanents) {
permanent.destroy(source, game, false);
}
} else if (amount == 4) {
new DamageEverythingEffect(3, new FilterCreaturePermanent()).apply(game, source);
} else if (amount == 5) {
new DiscardHandAllEffect().apply(game, source);
new DrawCardAllEffect(7).apply(game, source);
} else if (amount == 6) {
numTimesToDo += 2;
}
}
}
return false;
}
use of mage.filter.common.FilterArtifactPermanent in project mage by magefree.
the class TezzeretTheSeekerEffect3 method apply.
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), source.getControllerId(), game);
for (Permanent permanent : permanents) {
if (permanent != null) {
switch(layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
if (!permanent.isArtifact(game)) {
permanent.addCardType(game, CardType.ARTIFACT);
}
if (!permanent.isCreature(game)) {
permanent.addCardType(game, CardType.CREATURE);
}
}
break;
case PTChangingEffects_7:
if (sublayer == SubLayer.SetPT_7b) {
permanent.getPower().setValue(5);
permanent.getToughness().setValue(5);
}
}
}
}
return true;
}
use of mage.filter.common.FilterArtifactPermanent in project mage by magefree.
the class YawgmothDemonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int artifacts = game.getBattlefield().countAll(new FilterArtifactPermanent(), source.getControllerId(), game);
boolean artifactSacrificed = false;
if (artifacts > 0 && controller.chooseUse(outcome, "Sacrifice an artifact?", source, game)) {
if (new SacrificeControllerEffect(new FilterArtifactPermanent(), 1, "").apply(game, source)) {
artifactSacrificed = true;
}
}
if (!artifactSacrificed) {
Permanent sourceObject = (Permanent) source.getSourceObjectIfItStillExists(game);
if (sourceObject != null) {
sourceObject.tap(source, game);
controller.damage(2, source.getSourceId(), source, game);
}
}
return true;
}
return false;
}
use of mage.filter.common.FilterArtifactPermanent in project mage by magefree.
the class HurkylsRecallReturnToHandEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (targetPointer.getFirst(game, source) != null) {
FilterPermanent filter = new FilterArtifactPermanent();
filter.add(new OwnerIdPredicate(targetPointer.getFirst(game, source)));
return new ReturnToHandFromBattlefieldAllEffect(filter).apply(game, source);
}
return false;
}
use of mage.filter.common.FilterArtifactPermanent in project mage by magefree.
the class WardOfBonesEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
final Card card = game.getCard(event.getSourceId());
final Player opponent = game.getPlayer(event.getPlayerId());
if (card == null || opponent == null) {
return false;
}
if (card.isCreature(game) && game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, opponent.getId(), game) > game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) {
return true;
}
if (card.isArtifact(game) && game.getBattlefield().countAll(new FilterArtifactPermanent(), opponent.getId(), game) > game.getBattlefield().countAll(new FilterArtifactPermanent(), source.getControllerId(), game)) {
return true;
}
if (card.isEnchantment(game) && game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, opponent.getId(), game) > game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), game)) {
return true;
}
final int yourLands = game.getBattlefield().countAll(new FilterLandPermanent(), source.getControllerId(), game);
if (card.isLand(game) && game.getBattlefield().countAll(new FilterLandPermanent(), opponent.getId(), game) > yourLands) {
return true;
}
}
return false;
}
Aggregations