use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class AllianceOfArmsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int xSum = 0;
xSum += ManaUtil.playerPaysXGenericMana(false, "Alliance of Arms", controller, source, game);
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
if (!Objects.equals(playerId, controller.getId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
xSum += ManaUtil.playerPaysXGenericMana(false, "Alliance of Arms", player, source, game);
}
}
}
if (xSum > 0) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Effect effect = new CreateTokenTargetEffect(new SoldierToken(), xSum);
effect.setTargetPointer(new FixedTarget(playerId));
effect.apply(game, source);
}
}
// prevent undo
controller.resetStoredBookmark(game);
return true;
}
return false;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class BalduvianDeadEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
CreateTokenEffect effect = new CreateTokenEffect(new BalduvianToken());
effect.apply(game, source);
for (UUID tokenId : effect.getLastAddedTokenIds()) {
Permanent tokenPermanent = game.getPermanent(tokenId);
if (tokenPermanent != null) {
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("Sacrifice the token at the beginning of the next end step", source.getControllerId());
sacrificeEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
return true;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class BreenaTheDemagogueEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!game.getOpponents(getControllerId()).contains(event.getTargetId())) {
return false;
}
getEffects().setTargetPointer(new FixedTarget(event.getPlayerId()));
getEffects().setValue("attackedPlayer", event.getTargetId());
return true;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class BreyasApprenticeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
return false;
}
Card card = controller.getLibrary().getFromTop(game);
if (card == null) {
return false;
}
controller.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName());
game.addEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.UntilEndOfYourNextTurn).setTargetPointer(new FixedTarget(card, game)), source);
return true;
}
use of mage.target.targetpointer.FixedTarget in project mage by magefree.
the class CemeteryPucaEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent copyToCreature = game.getPermanent(source.getSourceId());
if (copyToCreature != null) {
Permanent copyFromCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (copyFromCreature != null) {
game.copyPermanent(Duration.WhileOnBattlefield, copyFromCreature, copyToCreature.getId(), source, new EmptyCopyApplier());
ContinuousEffect effect = new GainAbilityTargetEffect(new DiesCreatureTriggeredAbility(new DoIfCostPaid(new CemeteryPucaEffect(), new ManaCostsImpl("{1}")), false, StaticFilters.FILTER_PERMANENT_A_CREATURE, true), Duration.WhileOnBattlefield);
effect.setTargetPointer(new FixedTarget(copyToCreature.getId(), game));
game.addEffect(effect, source);
return true;
}
}
return false;
}
Aggregations