use of mage.target.TargetPermanent in project mage by magefree.
the class VolrathTheShapestealerCopyApplier method apply.
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
Ability ability = new SimpleActivatedAbility(new VolrathTheShapestealerEffect(), new GenericManaCost(1));
ability.addTarget(new TargetPermanent(VolrathTheShapestealer.filter));
blueprint.getAbilities().add(ability);
blueprint.removePTCDA();
blueprint.getPower().modifyBaseValue(7);
blueprint.getToughness().modifyBaseValue(5);
return true;
}
use of mage.target.TargetPermanent in project mage by magefree.
the class VonasHungerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<UUID> perms = new ArrayList<>();
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
int numTargets = (game.getBattlefield().countAll(StaticFilters.FILTER_CONTROLLED_CREATURE, player.getId(), game) + 1) / 2;
if (numTargets > 0) {
TargetPermanent target = new TargetPermanent(numTargets, numTargets, StaticFilters.FILTER_CONTROLLED_CREATURE, true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(Outcome.Sacrifice, target, source, game);
perms.addAll(target.getTargets());
}
}
}
}
for (UUID permID : perms) {
Permanent permanent = game.getPermanent(permID);
if (permanent != null) {
permanent.sacrifice(source, game);
}
}
return true;
}
use of mage.target.TargetPermanent in project mage by magefree.
the class AmassEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int xValue = amassNumber.calculate(game, source, this);
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
if (!game.getBattlefield().containsControlled(filter, source, game, 1)) {
new CreateTokenEffect(new ZombieArmyToken()).apply(game, source);
}
Target target = new TargetPermanent(filter);
target.setNotTarget(true);
if (!player.choose(outcome, target, source.getSourceId(), game)) {
return false;
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null) {
return false;
}
permanent.addCounters(CounterType.P1P1.createInstance(xValue), source.getControllerId(), source, game);
this.amassedCreatureId = permanent.getId();
return true;
}
use of mage.target.TargetPermanent in project mage by magefree.
the class AgitatorAntEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Player player : game.getState().getPlayersInRange(source.getControllerId(), game).stream().map(game::getPlayer).filter(Objects::nonNull).collect(Collectors.toList())) {
if (game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game) < 1 || !player.chooseUse(Outcome.BoostCreature, "Put two +1/+1 counters on a creature you control?", source, game)) {
continue;
}
TargetPermanent targetPermanent = new TargetControlledCreaturePermanent(0, 1);
targetPermanent.setNotTarget(true);
player.choose(Outcome.BoostCreature, targetPermanent, source.getSourceId(), game);
Permanent permanent = game.getPermanent(targetPermanent.getFirstTarget());
if (permanent == null || !permanent.addCounters(CounterType.P1P1.createInstance(2), player.getId(), source, game)) {
continue;
}
game.addEffect(new GoadTargetEffect().setTargetPointer(new FixedTarget(permanent, game)), source);
}
return true;
}
use of mage.target.TargetPermanent in project mage by magefree.
the class CausticWaspsTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.sourceId) && ((DamagedPlayerEvent) event).isCombatDamage()) {
Player player = game.getPlayer(event.getTargetId());
if (player != null) {
FilterPermanent filter = new FilterPermanent("an artifact controlled by " + player.getLogName());
filter.add(CardType.ARTIFACT.getPredicate());
filter.add(new ControllerIdPredicate(event.getTargetId()));
this.getTargets().clear();
this.addTarget(new TargetPermanent(filter));
return true;
}
}
return false;
}
Aggregations