use of mage.abilities.effects.Effect in project mage by magefree.
the class ExtraplanarLensTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
// need only info about permanent
Permanent landTappedForMana = ((TappedForManaEvent) event).getPermanent();
Permanent extraplanarLens = game.getPermanent(getSourceId());
if (extraplanarLens != null && landTappedForMana != null && !extraplanarLens.getImprinted().isEmpty()) {
Card imprinted = game.getCard(extraplanarLens.getImprinted().get(0));
if (imprinted != null && game.getState().getZone(imprinted.getId()) == Zone.EXILED) {
if (landTappedForMana.getName().equals(imprinted.getName()) && landTappedForMana.isLand(game)) {
ManaEvent mEvent = (ManaEvent) event;
for (Effect effect : getEffects()) {
effect.setValue("mana", mEvent.getMana());
effect.setValue("tappedPermanent", landTappedForMana);
}
getEffects().get(0).setTargetPointer(new FixedTarget(landTappedForMana.getId()));
return true;
}
}
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class HarshJusticeEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player controller = game.getPlayer(this.getControllerId());
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent damagePermanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
if (controller != null && damagePermanent != null) {
if (damageEvent.isCombatDamage() && controller.getId().equals(damageEvent.getTargetId()) && filter.match(damagePermanent, game)) {
for (Effect effect : this.getEffects()) {
effect.setValue("damage", damageEvent.getAmount());
effect.setValue("sourceId", damageEvent.getSourceId());
}
return true;
}
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class KillerInstinctEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
if (player == null || sourceObject == null) {
return false;
}
Library library = player.getLibrary();
if (library == null || !library.hasCards()) {
return false;
}
Card card = library.getFromTop(game);
if (card == null) {
return false;
}
player.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
if (card.isCreature(game) && player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
FixedTarget ft = new FixedTarget(permanent, game);
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(ft);
game.addEffect(effect, source);
Effect sacrificeEffect = new SacrificeTargetEffect("Sacrifice it at the beginning of the next end step", source.getControllerId());
sacrificeEffect.setTargetPointer(ft);
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
}
return true;
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class MarkOfSakikoTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (((DamagedEvent) event).isCombatDamage()) {
if (event.getSourceId().equals(getSourceId())) {
this.getEffects().clear();
Effect effect = new AddManaToManaPoolTargetControllerEffect(Mana.GreenMana(event.getAmount()), "that player", true);
effect.setTargetPointer(new FixedTarget(getControllerId()));
effect.setText("add that much {G}. Until end of turn, you don't lose this mana as steps and phases end");
this.addEffect(effect);
return true;
}
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class MindWhipEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controllerOfEnchantedCreature = game.getPlayer(targetPointer.getFirst(game, source));
Permanent mindWhip = game.getPermanent(source.getSourceId());
if (controllerOfEnchantedCreature != null && mindWhip != null) {
Permanent enchantedCreature = game.getPermanent(mindWhip.getAttachedTo());
if (enchantedCreature != null) {
Effect effect = new DamageTargetEffect(2);
effect.setTargetPointer(new FixedTarget(controllerOfEnchantedCreature.getId()));
effect.apply(game, source);
enchantedCreature.tap(source, game);
return true;
}
}
return false;
}
Aggregations