use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class FrontierWarmongerTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Set<UUID> opponents = game.getOpponents(this.getControllerId());
Predicate<UUID> predicate = uuid -> opponents.contains(game.getCombat().getDefendingPlayerId(uuid, game));
if (game.getCombat().getAttackers().stream().noneMatch(predicate)) {
return false;
}
List<Permanent> permanents = game.getCombat().getAttackers().stream().filter(predicate).map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList());
this.getEffects().setTargetPointer(new FixedTargets(permanents, game));
return true;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class LoyalApprenticeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Token token = new ThopterColorlessToken();
token.putOntoBattlefield(1, game, source, source.getControllerId());
game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList()), game)), source);
return true;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class SigardasVanguardEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetPermanent target = new TargetCreaturesWithDifferentPowers();
player.choose(outcome, target, source.getSourceId(), game);
if (target.getTargets().isEmpty()) {
return false;
}
game.addEffect(new GainAbilityTargetEffect(DoubleStrikeAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(new CardsImpl(target.getTargets()), game)), source);
return true;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class SleepEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player != null) {
List<Permanent> doNotUntapNextUntapStep = new ArrayList<>();
for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) {
creature.tap(source, game);
doNotUntapNextUntapStep.add(creature);
}
if (!doNotUntapNextUntapStep.isEmpty()) {
ContinuousEffect effect = new DontUntapInControllersNextUntapStepTargetEffect("", player.getId());
effect.setText("those creatures don't untap during that player's next untap step");
effect.setTargetPointer(new FixedTargets(doNotUntapNextUntapStep, game));
game.addEffect(effect, source);
}
return true;
}
return false;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class SporeCloudEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
List<Permanent> doNotUntapNextUntapStep = new ArrayList<>();
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
doNotUntapNextUntapStep.add(permanent);
}
if (!doNotUntapNextUntapStep.isEmpty()) {
ContinuousEffect effect = new DontUntapInControllersNextUntapStepTargetEffect("This creature");
effect.setTargetPointer(new FixedTargets(doNotUntapNextUntapStep, game));
game.addEffect(effect, source);
}
return true;
}
return false;
}
Aggregations