use of mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility in project mage by magefree.
the class GazeOfTheGorgonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (!source.getTargets().isEmpty() && source.getFirstTarget() != null) {
MageObjectReference mor = new MageObjectReference(source.getFirstTarget(), game);
AtTheEndOfCombatDelayedTriggeredAbility delayedAbility = new AtTheEndOfCombatDelayedTriggeredAbility(new GazeOfTheGorgonEffect(mor));
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
use of mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility in project mage by magefree.
the class ArrogantBloodlordEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
AtTheEndOfCombatDelayedTriggeredAbility delayedAbility = new AtTheEndOfCombatDelayedTriggeredAbility(new DestroyTargetEffect());
delayedAbility.getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game));
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
use of mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility in project mage by magefree.
the class MirrorMockeryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
// In the case that the enchantment is blinked
Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (enchantment == null) {
// It was not blinked, use the standard method
enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
}
if (enchantment == null) {
return false;
}
Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo());
if (enchanted != null) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect();
effect.setTargetPointer(new FixedTarget(enchanted, game));
effect.apply(game, source);
for (Permanent addedToken : effect.getAddedPermanents()) {
if (addedToken != null) {
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), source);
}
}
return true;
}
return false;
}
use of mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility in project mage by magefree.
the class MirrorMatchEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID attackerId : game.getCombat().getAttackers()) {
Permanent attacker = game.getPermanent(attackerId);
if (attacker != null && source.isControlledBy(game.getCombat().getDefendingPlayerId(attackerId, game))) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, false);
effect.setTargetPointer(new FixedTarget(attacker, game));
effect.apply(game, source);
CombatGroup group = game.getCombat().findGroup(attacker.getId());
boolean isCreature = false;
if (group != null) {
for (Permanent addedToken : effect.getAddedPermanents()) {
if (addedToken.isCreature(game)) {
group.addBlockerToGroup(addedToken.getId(), attackerId, game);
isCreature = true;
}
}
ExileTargetEffect exileEffect = new ExileTargetEffect("Exile those tokens at end of combat");
exileEffect.setTargetPointer(new FixedTargets(effect.getAddedPermanents(), game));
game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), source);
if (isCreature) {
group.pickBlockerOrder(attacker.getControllerId(), game);
}
}
}
}
return true;
}
return false;
}
use of mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility in project mage by magefree.
the class VenomousBreathEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (!source.getTargets().isEmpty() && source.getFirstTarget() != null) {
MageObjectReference mor = new MageObjectReference(source.getFirstTarget(), game);
AtTheEndOfCombatDelayedTriggeredAbility delayedAbility = new AtTheEndOfCombatDelayedTriggeredAbility(new VenomousBreathEffect(mor));
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
Aggregations