use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class PhantomSteedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
ExileZone exileZone = game.getState().getExile().getExileZone(CardUtil.getExileZoneId(game, source));
if (exileZone == null || exileZone.isEmpty()) {
return false;
}
for (Card card : exileZone.getCards(game)) {
EmptyToken token = new EmptyToken();
CardUtil.copyTo(token).from(card, game);
token.addSubType(SubType.ILLUSION);
token.putOntoBattlefield(1, game, source, source.getControllerId(), true, true);
List<Permanent> permanents = token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList());
game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(new ExileTargetEffect("Sacrifice that token at end of combat").setTargetPointer(new FixedTargets(permanents, game))), source);
}
return true;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class RebellionOfTheFlamekinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Token token = new ElementalShamanToken("LRW");
token.putOntoBattlefield(1, game, source, source.getControllerId());
List<Permanent> permanents = token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList());
if (!permanents.isEmpty() && (boolean) this.getValue("clash")) {
game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(permanents, game)), source);
}
return true;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class SigardianZealotEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = source.getSourcePermanentOrLKI(game);
if (player == null || permanent == null) {
return false;
}
int power = permanent.getPower().getValue();
if (power == 0) {
return false;
}
TargetPermanent target = new TargetCreaturesWithDifferentPowers();
player.choose(outcome, target, source.getSourceId(), game);
Cards cards = new CardsImpl(target.getTargets());
if (cards.isEmpty()) {
return false;
}
game.addEffect(new BoostTargetEffect(power, power).setTargetPointer(new FixedTargets(cards, game)), source);
game.addEffect(new GainAbilityTargetEffect(VigilanceAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(cards, game)), source);
return true;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class WakeTheDeadReturnFromGraveyardToBattlefieldTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cards = new CardsImpl(getTargetPointer().getTargets(game, source));
controller.moveCards(cards, Zone.BATTLEFIELD, source, game);
List<Permanent> toSacrifice = new ArrayList<>(cards.size());
for (UUID targetId : cards) {
Permanent creature = game.getPermanent(targetId);
if (creature != null) {
toSacrifice.add(creature);
}
}
Effect effect = new SacrificeTargetEffect("Sacrifice those creatures at the beginning of the next end step", source.getControllerId());
effect.setTargetPointer(new FixedTargets(toSacrifice, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class MyriadEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && sourceObject != null) {
UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(source.getSourceId(), game);
if (defendingPlayerId == null) {
Logger.getLogger(MyriadEffect.class).error("defending player == null source: " + sourceObject.getName() + " attacking: " + (sourceObject.isAttacking() ? "Y" : "N"));
return false;
}
List<Permanent> tokens = new ArrayList<>();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
if (!playerId.equals(defendingPlayerId) && controller.hasOpponent(playerId, game)) {
Player opponent = game.getPlayer(playerId);
if (opponent != null && controller.chooseUse(Outcome.PutCreatureInPlay, "Put a copy of " + sourceObject.getIdName() + " onto battlefield attacking " + opponent.getName() + '?', source, game)) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(controller.getId(), null, false, 1, true, true, playerId);
effect.setTargetPointer(new FixedTarget(sourceObject, game));
effect.apply(game, source);
tokens.addAll(effect.getAddedPermanents());
}
}
}
if (!tokens.isEmpty()) {
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTargets(tokens, game));
game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), source);
}
return true;
}
return false;
}
Aggregations