use of mage.abilities.effects.common.DamageTargetEffect in project mage by magefree.
the class CinderSeerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter));
if (!cost.pay(source, game, source, source.getControllerId(), true)) {
return false;
}
int xValue = cost.getNumberRevealedCards();
return new DamageTargetEffect(xValue).apply(game, source);
}
use of mage.abilities.effects.common.DamageTargetEffect in project mage by magefree.
the class KeranosGodOfStormsTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!event.getPlayerId().equals(this.getControllerId())) {
return false;
}
if (!game.isActivePlayer(this.getControllerId())) {
return false;
}
CardsAmountDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) != 1) {
return false;
}
Card card = game.getCard(event.getTargetId());
Player controller = game.getPlayer(this.getControllerId());
Permanent sourcePermanent = (Permanent) getSourceObject(game);
if (card == null || controller == null || sourcePermanent == null) {
return false;
}
controller.revealCards(sourcePermanent.getIdName(), new CardsImpl(card), game);
this.getTargets().clear();
this.getEffects().clear();
if (card.isLand(game)) {
this.addEffect(new DrawCardSourceControllerEffect(1));
} else {
this.addEffect(new DamageTargetEffect(3));
this.addTarget(new TargetAnyTarget());
}
return true;
}
use of mage.abilities.effects.common.DamageTargetEffect in project mage by magefree.
the class MagmaPummelerEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
int damage = event.getAmount();
preventDamageAction(event, source, game);
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null) {
return false;
}
int beforeCounters = permanent.getCounters(game).getCount(CounterType.P1P1);
permanent.removeCounters(CounterType.P1P1.createInstance(damage), source, game);
int countersRemoved = beforeCounters - permanent.getCounters(game).getCount(CounterType.P1P1);
if (countersRemoved > 0) {
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(countersRemoved), false, "{this} deals that much damage to any target");
ability.addTarget(new TargetAnyTarget());
game.fireReflexiveTriggeredAbility(ability, source);
}
return false;
}
use of mage.abilities.effects.common.DamageTargetEffect in project mage by magefree.
the class OutcomesTest method test_FromEffects_Multi.
@Test
public void test_FromEffects_Multi() {
Ability abilityGood = new SimpleStaticAbility(new GainLifeEffect(10));
abilityGood.addEffect(new BoostSourceEffect(10, 10, Duration.EndOfTurn));
Assert.assertEquals(1 + 1, abilityGood.getEffects().getOutcomeScore(abilityGood));
Ability abilityBad = new SimpleStaticAbility(new DamageTargetEffect(10));
abilityBad.addEffect(new ExileTargetEffect());
Assert.assertEquals(-1 + -1, abilityBad.getEffects().getOutcomeScore(abilityBad));
}
use of mage.abilities.effects.common.DamageTargetEffect in project mage by magefree.
the class OutcomesTest method test_FromAbility_Single.
/**
* Special outcome from ability (AI activates only good abilities)
*/
@Test
public void test_FromAbility_Single() {
Ability abilityGood = new SimpleStaticAbility(new GainLifeEffect(10));
abilityGood.addCustomOutcome(Outcome.Detriment);
Assert.assertEquals(-1, abilityGood.getEffects().getOutcomeScore(abilityGood));
Assert.assertEquals(Outcome.Detriment, abilityGood.getEffects().getOutcome(abilityGood));
Ability abilityBad = new SimpleStaticAbility(new DamageTargetEffect(10));
abilityBad.addCustomOutcome(Outcome.Neutral);
Assert.assertEquals(1, abilityBad.getEffects().getOutcomeScore(abilityBad));
Assert.assertEquals(Outcome.Neutral, abilityBad.getEffects().getOutcome(abilityBad));
}
Aggregations