@Override public Battlefield getBattlefield() { return state.getBattlefield(); }
@Override public void init(Ability source, Game game) { super.init(source, game); Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (player != null) { for (Permanent perm : game.getState().getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) { affectedObjectList.add(new MageObjectReference(perm, game)); } } }
@Override public void init(Ability source, Game game) { super.init(source, game); if (this.affectedObjectsSet) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { for (Permanent perm :game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { affectedObjectList.add(new MageObjectReference(perm, game)); } } } }
@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { int count = 0; Permanent enchantment = game.getPermanent(sourceAbility.getSourceId()); for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(filter, sourceAbility.getControllerId(), game)) { if (!permanent.getId().equals(enchantment.getAttachedTo())) { count += permanent.getCounters(game).getCount(CounterType.P1P1); } } return count; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int destroyedCreature = 0; for (Permanent creature : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) { if (creature.destroy(source.getSourceId(), game, true)) { destroyedCreature++; } } if (destroyedCreature > 0) { controller.drawCards(destroyedCreature, game); } return true; } return false; } }
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_LANDS, player.getId(), source.getSourceId(), game)) { switch (layer) { case AbilityAddingRemovingEffects_6: permanent.getAbilities().removeIf(ability -> ability.getAbilityType() != AbilityType.MANA); break; } } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent perm = game.getPermanent(source.getSourceId()); if (perm != null) { for (Permanent creature :game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)){ for (Ability ability: creature.getAbilities()) { if (ability instanceof ActivatedAbility) { perm.addAbility(ability, source.getSourceId(), game); } } } } return true; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); int enchantmentsDestoyed = 0; for (Permanent permanent: game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_ENCHANTMENT_PERMANENT, source.getControllerId(), source.getSourceId(), game)) { if (permanent.destroy(source.getSourceId(), game, false)) { enchantmentsDestoyed++; } } if(enchantmentsDestoyed > 0 && controller != null) { controller.gainLife(enchantmentsDestoyed * 2, game, source); } return false; } }
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE_GOBLINS, source.getControllerId(), source.getSourceId(), game)) { switch (layer) { case TypeChangingEffects_4: if (!permanent.hasSubtype(SubType.ZOMBIE, game)) { permanent.getSubtype(game).add(SubType.ZOMBIE); } break; case ColorChangingEffects_5: permanent.getColor(game).setColor(ObjectColor.BLACK); break; } } return true; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { for(Permanent permanent: game.getState().getBattlefield().getAllActivePermanents(filter , controller.getId(), game)) { permanent.addCounters(CounterType.P1P1.createInstance(), source, game); game.informPlayers(sourceObject.getName() + ": Put a +1/+1 counter on " + permanent.getLogName()); } } return true; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int destroyedCreature = 0; for (Permanent creature : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) { if (creature.destroy(source.getSourceId(), game, false)) { destroyedCreature++; } } game.applyEffects(); if (destroyedCreature > 0) { controller.gainLife(destroyedCreature, game, source); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) { permanent.addCounters(CounterType.P1P1.createInstance(), source, game); game.informPlayers(sourceObject.getName() + ": Put a +1/+1 counter on " + permanent.getLogName()); } } return true; } }
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (player != null) { for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) { if (affectedObjectList.contains(new MageObjectReference(permanent, game))) { switch (layer) { case AbilityAddingRemovingEffects_6: permanent.removeAllAbilities(source.getSourceId(), game); break; case PTChangingEffects_7: if (sublayer == SubLayer.SetPT_7b) { permanent.getPower().setValue(0); permanent.getToughness().setValue(2); } } } } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { for(Permanent permanent: game.getState().getBattlefield().getAllActivePermanents(filter , controller.getId(), game)) { permanent.addCounters(CounterType.P1P1.createInstance(), source, game); game.informPlayers(sourceObject.getName() + ": Put a +1/+1 counter on " + permanent.getLogName()); } } return true; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(game.getActivePlayerId()); FilterArtifactPermanent filter = new FilterArtifactPermanent("artifacts you control"); filter.add(new ControllerIdPredicate(game.getActivePlayerId())); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (player != null && sourcePermanent != null && !sourcePermanent.isTapped()) { player.getManaPool().addMana(Mana.ColorlessMana( game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game). size()), game, source, false); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int destroyedPermanents = 0; for (Permanent permanent: game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { if (permanent.destroy(source.getSourceId(), game, false)) { ++destroyedPermanents; } } game.applyEffects(); // needed in case a destroyed permanent did prevent life gain if (destroyedPermanents > 0) { controller.gainLife(2 * destroyedPermanents, game, source); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { for (Permanent artifact : game.getState().getBattlefield().getActivePermanents(new FilterArtifactPermanent(), controller.getId(), game)) { Player artifactController = game.getPlayer(artifact.getControllerId()); int cmc = artifact.getConvertedManaCost(); if (artifact.destroy(source.getSourceId(), game, true)) { if(artifactController != null) { artifactController.gainLife(cmc, game, source); } } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); if (targetCreature != null && targetCreature.getPower().getValue() > 0) { for (Permanent creature : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { if (!creature.getId().equals(targetCreature.getId())) { creature.damage(targetCreature.getPower().getValue(), targetCreature.getId(), game, false, true); } } for (UUID opponentId : game.getOpponents(source.getControllerId())) { Player opponent = game.getPlayer(opponentId); if (opponent != null) { opponent.damage(targetCreature.getPower().getValue(), targetCreature.getId(), game, false, true); } } } return true; } }
@Override public boolean apply(Game game, Ability source) { Permanent target = game.getPermanent(source.getFirstTarget()); Player player = game.getPlayer(target.getControllerId()); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && player != null) { player.moveCards(target, Zone.HAND, source, game); game.applyEffects(); FilterPermanent zombieFilter = new FilterPermanent(); zombieFilter.add(new SubtypePredicate(SubType.ZOMBIE)); if (game.getState().getBattlefield().countAll(zombieFilter, controller.getId(), game) > 0) { player.discard(1, false, source, game); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { // Destroy all other enchantments for (Permanent permanent : game.getBattlefield().getActivePermanents(opponentEnchantmentsFilter, source.getControllerId(), source.getSourceId(), game)) { permanent.destroy(source.getSourceId(), game, false); } // Then if you control an untapped land, destroy all own enchantments Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { if (game.getState().getBattlefield().countAll(untappedLandFilter, controller.getId(), game) > 0) { for (Permanent permanent : game.getBattlefield().getActivePermanents(controlledEnchantmentsFilter, source.getControllerId(), source.getSourceId(), game)) { permanent.destroy(source.getSourceId(), game, false); } } } return true; } }