use of mage.filter.common.FilterControlledCreaturePermanent in project mage by magefree.
the class ArchfiendOfDepravityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
if (opponent != null) {
List<Permanent> creaturesToSacrifice = new ArrayList<>();
TargetControlledPermanent target = new TargetControlledPermanent(0, 2, new FilterControlledCreaturePermanent("creatures to keep"), true);
if (opponent.chooseTarget(outcome, target, source, game)) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), opponent.getId(), source.getSourceId(), game)) {
if (permanent != null && !target.getTargets().contains(permanent.getId())) {
creaturesToSacrifice.add(permanent);
}
}
}
for (Permanent creature : creaturesToSacrifice) {
creature.sacrifice(source, game);
}
return true;
}
return false;
}
use of mage.filter.common.FilterControlledCreaturePermanent in project mage by magefree.
the class CopperhornScoutUntapEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
List<Permanent> creatures = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
for (Permanent creature : creatures) {
if (!creature.getId().equals(source.getSourceId())) {
creature.untap(game);
}
}
return true;
}
use of mage.filter.common.FilterControlledCreaturePermanent in project mage by magefree.
the class AngelicSkirmisherEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (controller != null && sourcePermanent != null) {
Choice abilityChoice = new ChoiceImpl(true);
Set<String> abilityChoices = new HashSet<>(3);
abilityChoice.setMessage("Choose ability for your creatures");
abilityChoices.add("First strike");
abilityChoices.add("Vigilance");
abilityChoices.add("Lifelink");
abilityChoice.setChoices(abilityChoices);
if (controller.choose(outcome, abilityChoice, game)) {
Ability ability = null;
switch(abilityChoice.getChoice()) {
case "First strike":
ability = FirstStrikeAbility.getInstance();
break;
case "Vigilance":
ability = VigilanceAbility.getInstance();
break;
case "Lifelink":
ability = LifelinkAbility.getInstance();
break;
default:
break;
}
if (ability != null) {
GainAbilityControlledEffect effect = new GainAbilityControlledEffect(ability, Duration.EndOfTurn, new FilterControlledCreaturePermanent());
game.addEffect(effect, source);
game.informPlayers(sourcePermanent.getName() + ": " + controller.getLogName() + " has chosen " + abilityChoice.getChoice().toLowerCase(Locale.ENGLISH));
return true;
}
}
}
return false;
}
use of mage.filter.common.FilterControlledCreaturePermanent in project mage by magefree.
the class BattletideAlchemistEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
boolean result = false;
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(event.getTargetId());
if (controller != null && targetPlayer != null) {
int numberOfClericsControlled = new PermanentsOnBattlefieldCount(new FilterControlledCreaturePermanent(SubType.CLERIC, "Clerics")).calculate(game, source, this);
int toPrevent = Math.min(numberOfClericsControlled, event.getAmount());
if (toPrevent > 0 && controller.chooseUse(Outcome.PreventDamage, "Prevent " + toPrevent + " damage to " + targetPlayer.getName() + '?', source, game)) {
GameEvent preventEvent = new PreventDamageEvent(event.getTargetId(), source.getSourceId(), source, source.getControllerId(), toPrevent, ((DamageEvent) event).isCombatDamage());
if (!game.replaceEvent(preventEvent)) {
if (event.getAmount() >= toPrevent) {
event.setAmount(event.getAmount() - toPrevent);
} else {
event.setAmount(0);
result = true;
}
game.informPlayers("Battletide Alchemist prevented " + toPrevent + " damage to " + targetPlayer.getName());
game.fireEvent(new PreventedDamageEvent(event.getTargetId(), source.getSourceId(), source, source.getControllerId(), toPrevent));
}
}
}
return result;
}
use of mage.filter.common.FilterControlledCreaturePermanent in project mage by magefree.
the class BroodBirthingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("Eldrazi Spawn");
filter.add(SubType.ELDRAZI.getPredicate());
filter.add(SubType.SPAWN.getPredicate());
EldraziSpawnToken token = new EldraziSpawnToken();
int count = game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0 ? 3 : 1;
token.putOntoBattlefield(count, game, source, source.getControllerId());
return true;
}
Aggregations