use of mage.abilities.effects.Effect in project mage by magefree.
the class TrostaniSelesnyasVoiceEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && permanent.isCreature(game) && permanent.isControlledBy(this.controllerId) && !Objects.equals(event.getTargetId(), this.getSourceId())) {
Effect effect = this.getEffects().get(0);
// life is determined during resolution so it has to be retrieved there (e.g. Giant Growth before resolution)
effect.setValue("lifeSource", event.getTargetId());
effect.setValue("zoneChangeCounter", permanent.getZoneChangeCounter(game));
return true;
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class WaylayEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Token token = new WaylayToken();
token.putOntoBattlefield(3, game, source, source.getControllerId());
List<Permanent> toExile = new ArrayList<>();
for (UUID tokenId : token.getLastAddedTokenIds()) {
Permanent tokenPermanent = game.getPermanent(tokenId);
if (tokenPermanent != null) {
toExile.add(tokenPermanent);
}
}
Effect effect = new ExileTargetEffect();
effect.setTargetPointer(new FixedTargets(toExile, game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextCleanupDelayedTriggeredAbility(effect), source);
return true;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class WolfOfDevilsBreachDiscardCostCardConvertedManaCount method calculate.
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (Effect sourceEffect : sourceAbility.getEffects()) {
if (sourceEffect instanceof DoIfCostPaid) {
Cost doCosts = ((DoIfCostPaid) sourceEffect).getCost();
if (doCosts instanceof Costs) {
Costs costs = (Costs) doCosts;
for (Object cost : costs) {
if (cost instanceof DiscardCardCost) {
DiscardCardCost discardCost = (DiscardCardCost) cost;
int cmc = 0;
for (Card card : discardCost.getCards()) {
cmc += card.getManaValue();
}
return cmc;
}
}
}
}
}
return 0;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class DealsDamageToACreatureAllTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent == null || !permanent.isCreature(game)) {
return false;
}
if (combatDamageOnly && !((DamagedEvent) event).isCombatDamage()) {
return false;
}
permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
if (!filterPermanent.match(permanent, getSourceId(), getControllerId(), game)) {
return false;
}
for (Effect effect : this.getEffects()) {
effect.setValue("damage", event.getAmount());
effect.setValue("sourceId", event.getSourceId());
switch(setTargetPointer) {
case PLAYER:
effect.setTargetPointer(new FixedTarget(permanent.getControllerId()));
break;
case PERMANENT:
effect.setTargetPointer(new FixedTarget(permanent, game));
break;
case PERMANENT_TARGET:
Permanent permanent_target = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (permanent_target != null) {
effect.setTargetPointer(new FixedTarget(permanent_target, game));
}
break;
}
}
return true;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class DealsDamageToOpponentTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.sourceId) && game.getOpponents(this.getControllerId()).contains(event.getTargetId())) {
if (onlyCombat && event instanceof DamagedPlayerEvent) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
if (!damageEvent.isCombatDamage()) {
return false;
}
}
if (setTargetPointer) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
effect.setValue("damage", event.getAmount());
}
}
return true;
}
return false;
}
Aggregations