use of mage.filter.FilterPermanent in project mage by magefree.
the class VisionCharmEffect method init.
@Override
public void init(Ability source, Game game) {
super.init(source, game);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Choice choice = new ChoiceLandType();
if (!controller.choose(outcome, choice, game)) {
discard();
return;
}
targetLandType = choice.getChoice();
choice = new ChoiceBasicLandType();
if (!controller.choose(outcome, choice, game)) {
discard();
return;
}
targetBasicLandType = SubType.byDescription(choice.getChoice());
if (targetLandType == null || targetBasicLandType == null) {
this.discard();
return;
}
} else {
this.discard();
return;
}
FilterPermanent filter = new FilterLandPermanent();
filter.add(SubType.byDescription(targetLandType).getPredicate());
if (this.affectedObjectsSet) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
affectedObjectList.add(new MageObjectReference(permanent, game));
}
}
}
use of mage.filter.FilterPermanent in project mage by magefree.
the class SimpleGameTest method testSimple.
@Test
public void testSimple() {
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerB, "Forest");
addCard(Zone.BATTLEFIELD, playerC, "Forest");
addCard(Zone.BATTLEFIELD, playerD, "Forest");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertLife(playerC, 20);
assertLife(playerD, 20);
FilterPermanent filterPermanent = new FilterLandPermanent();
filterPermanent.add(SubType.FOREST.getPredicate());
List<Permanent> forestCards = currentGame.getBattlefield().getAllActivePermanents(filterPermanent, currentGame);
Assert.assertEquals(4, forestCards.size());
}
use of mage.filter.FilterPermanent in project mage by magefree.
the class ExchangeControlTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Set<UUID> toDelete = new HashSet<>();
for (Map.Entry<UUID, Integer> entry : zoneChangeCounter.entrySet()) {
Permanent permanent = game.getPermanent(entry.getKey());
if (permanent == null || permanent.getZoneChangeCounter(game) != entry.getValue()) {
// controll effect cease if the same permanent is no longer on the battlefield
toDelete.add(entry.getKey());
continue;
}
permanent.changeControllerId(lockedControllers.get(permanent.getId()), game, source);
permanent.getAbilities().setControllerId(lockedControllers.get(permanent.getId()));
if (destroyAttachedAuras) {
FilterPermanent filter = new FilterPermanent();
filter.add(SubType.AURA.getPredicate());
for (UUID attachmentId : new HashSet<>(permanent.getAttachments())) {
Permanent attachment = game.getPermanent(attachmentId);
if (filter.match(attachment, game)) {
attachment.destroy(source, game, false);
}
}
}
}
if (!toDelete.isEmpty()) {
for (UUID uuid : toDelete) {
zoneChangeCounter.remove(uuid);
}
if (zoneChangeCounter.isEmpty()) {
discard();
return false;
}
}
return true;
}
use of mage.filter.FilterPermanent in project mage by magefree.
the class ArcbondEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int damage = (Integer) this.getValue("damage");
UUID sourceId = (UUID) this.getValue("sourceId");
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && damage > 0 && sourceId != null) {
Permanent targetObject = game.getPermanentOrLKIBattlefield(sourceId);
if (targetObject != null) {
game.informPlayers(sourceObject.getLogName() + ": " + targetObject.getLogName() + " deals " + damage + " damage to each other creature and each player");
}
FilterPermanent filter = new FilterCreaturePermanent("each other creature");
filter.add(Predicates.not(new PermanentIdPredicate(sourceId)));
return new DamageEverythingEffect(StaticValue.get(damage), filter, sourceId).apply(game, source);
}
return false;
}
use of mage.filter.FilterPermanent in project mage by magefree.
the class BlastZoneEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
int xValue = permanent.getCounters(game).getCount(CounterType.CHARGE);
FilterPermanent filter = new FilterNonlandPermanent();
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, xValue));
return new DestroyAllEffect(filter).apply(game, source);
}
Aggregations