Search in sources :

Example 1 with TargetCreaturePermanentAmount

use of mage.target.common.TargetCreaturePermanentAmount in project mage by magefree.

the class TargetPriorityTest method test_targetAmount_BadCase.

@Test
public void test_targetAmount_BadCase() {
    // choose targets as enters battlefield (e.g. can't be canceled)
    SpellAbility spell = new SpellAbility(new ManaCostsImpl("R"), "damage 3", Zone.HAND);
    Ability ability = new EntersBattlefieldTriggeredAbility(new DamageMultiEffect(3));
    ability.addTarget(new TargetCreaturePermanentAmount(3));
    addCustomCardWithSpell(playerA, spell, ability, CardType.ENCHANTMENT);
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
    // 
    // 1/1
    addCard(Zone.BATTLEFIELD, playerA, "Memnite", 3);
    // 2/2
    addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 3);
    // 2/2 with ability
    addCard(Zone.BATTLEFIELD, playerA, "Ashcoat Bear", 3);
    // 4/3
    addCard(Zone.BATTLEFIELD, playerA, "Golden Bear", 3);
    // 4/4 with ability
    addCard(Zone.BATTLEFIELD, playerA, "Battering Sliver", 3);
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "damage 3");
    // must damage x3 Balduvian Bears by -1 to keep alive
    checkDamage("pt after", 1, PhaseStep.BEGIN_COMBAT, playerA, "Balduvian Bears", 1);
    // showBattlefield("after", 1, PhaseStep.BEGIN_COMBAT, playerA);
    setStopAt(1, PhaseStep.BEGIN_COMBAT);
    execute();
    assertAllCommandsUsed();
    assertPermanentCount(playerA, "damage 3", 1);
    assertPermanentCount(playerA, "Memnite", 3);
    assertPermanentCount(playerA, "Balduvian Bears", 3);
    assertPermanentCount(playerA, "Ashcoat Bear", 3);
    assertPermanentCount(playerA, "Golden Bear", 3);
    assertPermanentCount(playerA, "Battering Sliver", 3);
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) SpellAbility(mage.abilities.SpellAbility) Ability(mage.abilities.Ability) TargetCreaturePermanentAmount(mage.target.common.TargetCreaturePermanentAmount) DamageMultiEffect(mage.abilities.effects.common.DamageMultiEffect) SpellAbility(mage.abilities.SpellAbility) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Test(org.junit.Test)

Example 2 with TargetCreaturePermanentAmount

use of mage.target.common.TargetCreaturePermanentAmount in project mage by magefree.

the class YannikScavengingSentinelEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (player == null || sourcePermanent == null || game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 1) {
        return false;
    }
    TargetPermanent target = new TargetPermanent(filter);
    target.setNotTarget(true);
    player.choose(outcome, target, source.getSourceId(), game);
    Permanent permanent = game.getPermanent(target.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    int power = permanent.getPower().getValue();
    new ExileTargetEffect(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()), permanent.getIdName()).setTargetPointer(new FixedTarget(permanent, game)).apply(game, source);
    game.addDelayedTriggeredAbility(new OnLeaveReturnExiledToBattlefieldAbility(), source);
    if (game.getState().getZone(permanent.getId()) != Zone.BATTLEFIELD) {
        ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DistributeCountersEffect(CounterType.P1P1, power, false, ""), false, "distribute X +1/+1 counters among any number of target creatures, " + "where X is the exiled creature's power");
        ability.addTarget(new TargetCreaturePermanentAmount(power));
        game.fireReflexiveTriggeredAbility(ability, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetCreaturePermanentAmount(mage.target.common.TargetCreaturePermanentAmount) FilterPermanent(mage.filter.FilterPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TargetPermanent(mage.target.TargetPermanent) DistributeCountersEffect(mage.abilities.effects.common.counter.DistributeCountersEffect) OnLeaveReturnExiledToBattlefieldAbility(mage.abilities.common.delayed.OnLeaveReturnExiledToBattlefieldAbility) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 3 with TargetCreaturePermanentAmount

use of mage.target.common.TargetCreaturePermanentAmount in project mage by magefree.

the class RavenousGigantotheriumEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!super.checkTrigger(event, game)) {
        return false;
    }
    Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
    if (permanent == null) {
        return false;
    }
    int power = Math.max(permanent.getPower().getValue(), 0);
    this.getEffects().clear();
    this.addEffect(new DamageMultiEffect(power));
    this.addEffect(new RavenousGigantotheriumEffect());
    this.getTargets().clear();
    if (power < 1) {
        return true;
    }
    this.addTarget(new TargetCreaturePermanentAmount(power));
    return true;
}
Also used : TargetCreaturePermanentAmount(mage.target.common.TargetCreaturePermanentAmount) Permanent(mage.game.permanent.Permanent) DamageMultiEffect(mage.abilities.effects.common.DamageMultiEffect)

Example 4 with TargetCreaturePermanentAmount

use of mage.target.common.TargetCreaturePermanentAmount in project mage by magefree.

the class NumaJoragaChieftainEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    ManaCosts cost = new ManaCostsImpl("{X}{X}");
    if (!player.chooseUse(Outcome.BoostCreature, "Pay " + cost.getText() + "?", source, game)) {
        return false;
    }
    int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
    cost.add(new GenericManaCost(2 * costX));
    if (!cost.pay(source, game, source, source.getControllerId(), false, null)) {
        return false;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DistributeCountersEffect(CounterType.P1P1, costX, false, ""), false, "distribute " + costX + " +1/+1 counters among any number of target Elves");
    ability.addTarget(new TargetCreaturePermanentAmount(costX, filter));
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) TargetCreaturePermanentAmount(mage.target.common.TargetCreaturePermanentAmount) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DistributeCountersEffect(mage.abilities.effects.common.counter.DistributeCountersEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 5 with TargetCreaturePermanentAmount

use of mage.target.common.TargetCreaturePermanentAmount in project mage by magefree.

the class TargetPriorityTest method test_targetAmount_Performance.

@Test
// do not enable it in production, only for devs
@Ignore
public void test_targetAmount_Performance() {
    int cardsMultiplier = 3;
    Ability ability = new SimpleActivatedAbility(Zone.ALL, new DamageMultiEffect(3), new ManaCostsImpl("R"));
    ability.addTarget(new TargetCreaturePermanentAmount(3));
    addCustomCardWithAbility("damage 3", playerA, ability);
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
    // 
    // 1/1
    addCard(Zone.BATTLEFIELD, playerB, "Memnite", 1 * cardsMultiplier);
    // 2/2
    addCard(Zone.BATTLEFIELD, playerB, "Balduvian Bears", 1 * cardsMultiplier);
    // 2/2 with ability
    addCard(Zone.BATTLEFIELD, playerB, "Ashcoat Bear", 1 * cardsMultiplier);
    // 4/3
    addCard(Zone.BATTLEFIELD, playerB, "Golden Bear", 1 * cardsMultiplier);
    // 4/4 with ability
    addCard(Zone.BATTLEFIELD, playerB, "Battering Sliver", 1 * cardsMultiplier);
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{R}: ");
    setStopAt(1, PhaseStep.BEGIN_COMBAT);
    execute();
    assertAllCommandsUsed();
    assertPermanentCount(playerB, "Memnite", 1 * cardsMultiplier);
    assertPermanentCount(playerB, "Balduvian Bears", 1 * cardsMultiplier);
    assertPermanentCount(playerB, "Ashcoat Bear", 1 * cardsMultiplier);
    assertPermanentCount(playerB, "Golden Bear", 1 * cardsMultiplier - 1);
    assertPermanentCount(playerB, "Battering Sliver", 1 * cardsMultiplier);
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) SpellAbility(mage.abilities.SpellAbility) Ability(mage.abilities.Ability) TargetCreaturePermanentAmount(mage.target.common.TargetCreaturePermanentAmount) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) DamageMultiEffect(mage.abilities.effects.common.DamageMultiEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

TargetCreaturePermanentAmount (mage.target.common.TargetCreaturePermanentAmount)7 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)4 DamageMultiEffect (mage.abilities.effects.common.DamageMultiEffect)4 Ability (mage.abilities.Ability)3 SpellAbility (mage.abilities.SpellAbility)3 EntersBattlefieldTriggeredAbility (mage.abilities.common.EntersBattlefieldTriggeredAbility)3 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)3 Permanent (mage.game.permanent.Permanent)3 Player (mage.players.Player)3 Test (org.junit.Test)3 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)2 DistributeCountersEffect (mage.abilities.effects.common.counter.DistributeCountersEffect)2 FilterPermanent (mage.filter.FilterPermanent)2 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)2 UUID (java.util.UUID)1 OnLeaveReturnExiledToBattlefieldAbility (mage.abilities.common.delayed.OnLeaveReturnExiledToBattlefieldAbility)1 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)1 ManaCosts (mage.abilities.costs.mana.ManaCosts)1 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)1 TargetAmount (mage.target.TargetAmount)1