Search in sources :

Example 1 with ContinuousEffectsList

use of mage.abilities.effects.ContinuousEffectsList in project mage by magefree.

the class CloneTest method testCopyNightmare.

// copy Nightmare test, check that the P/T setting effect ends
// if the clone leaves battlefield
@Test
public void testCopyNightmare() {
    addCard(Zone.BATTLEFIELD, playerA, "Island", 5);
    addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
    addCard(Zone.BATTLEFIELD, playerB, "Swamp", 6);
    addCard(Zone.BATTLEFIELD, playerB, "Forest", 1);
    // Target creature you control gets +1/+1 and gains hexproof until end of turn. (It can't be the target of spells or abilities your opponents control.)
    addCard(Zone.HAND, playerB, "Ranger's Guile");
    addCard(Zone.HAND, playerA, "Clone");
    // Return target nonland permanent to its owner's hand.
    addCard(Zone.HAND, playerA, "Disperse");
    addCard(Zone.BATTLEFIELD, playerB, "Nightmare", 1);
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Clone");
    setChoice(playerA, "Nightmare");
    castSpell(1, PhaseStep.BEGIN_COMBAT, playerB, "Ranger's Guile", "Nightmare");
    castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Disperse", "Nightmare");
    setStopAt(2, PhaseStep.UPKEEP);
    execute();
    assertPermanentCount(playerB, "Nightmare", 1);
    assertPowerToughness(playerB, "Nightmare", 6, 6);
    assertPermanentCount(playerA, "Nightmare", 0);
    assertHandCount(playerA, "Disperse", 0);
    FilterCard filter = new FilterCard();
    filter.add(new NamePredicate("Clone"));
    Card card = playerA.getHand().getCards(filter, currentGame).iterator().next();
    if (card != null) {
        Assert.assertEquals("Power has to be 0 because copy from nightmare P/T ability may no longer be applied", 0, card.getPower().getValue());
    }
    Logger.getLogger(CloneTest.class).debug("EXISTING CONTINUOUS EFFECTS:");
    for (ContinuousEffectsList effectsList : currentGame.getContinuousEffects().allEffectsLists) {
        for (Object anEffectsList : effectsList) {
            ContinuousEffect effect = (ContinuousEffect) anEffectsList;
            Logger.getLogger(CloneTest.class).debug("- " + effect.toString());
        }
    }
}
Also used : FilterCard(mage.filter.FilterCard) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) ContinuousEffectsList(mage.abilities.effects.ContinuousEffectsList) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card) Test(org.junit.Test)

Example 2 with ContinuousEffectsList

use of mage.abilities.effects.ContinuousEffectsList in project mage by magefree.

the class TraceUtil method traceCombat.

private static void traceCombat(Game game, Permanent attacker, Permanent blocker) {
    String prefix = "> ";
    log.error(prefix + "Tracing game state...");
    if (blocker != null) {
        log.error(prefix + blocker.getLogName() + " could block " + attacker.getLogName());
    }
    log.error(prefix);
    log.error(prefix + "Attacker abilities: ");
    for (Ability ability : attacker.getAbilities()) {
        log.error(prefix + "     " + ability.toString() + ", id=" + ability.getId());
    }
    if (blocker != null) {
        log.error(prefix + "Blocker abilities: ");
        for (Ability ability : blocker.getAbilities()) {
            log.error(prefix + "     " + ability.toString() + ", id=" + ability.getId());
        }
    }
    log.error(prefix);
    log.error(prefix + "Flying ability id: " + FlyingAbility.getInstance().getId());
    log.error(prefix + "Reach ability id: " + ReachAbility.getInstance().getId());
    log.error(prefix + "Intimidate ability id: " + IntimidateAbility.getInstance().getId());
    log.error(prefix);
    log.error(prefix + "Restriction effects:");
    log.error(prefix + "  Applied to ATTACKER:");
    Map<RestrictionEffect, Set<Ability>> attackerResEffects = game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game);
    for (Map.Entry<RestrictionEffect, Set<Ability>> entry : attackerResEffects.entrySet()) {
        log.error(prefix + "    " + entry.getKey());
        log.error(prefix + "        id=" + entry.getKey().getId());
        for (Ability ability : entry.getValue()) {
            log.error(prefix + "        ability=" + ability);
        }
    }
    log.error(prefix + "  Applied to BLOCKER:");
    if (blocker != null) {
        Map<RestrictionEffect, Set<Ability>> blockerResEffects = game.getContinuousEffects().getApplicableRestrictionEffects(blocker, game);
        for (Map.Entry<RestrictionEffect, Set<Ability>> entry : blockerResEffects.entrySet()) {
            log.error(prefix + "    " + entry.getKey());
            log.error(prefix + "        id=" + entry.getKey().getId());
            for (Ability ability : entry.getValue()) {
                log.error(prefix + "        ability=" + ability);
            }
        }
    }
    ContinuousEffectsList<RestrictionEffect> restrictionEffects = (ContinuousEffectsList<RestrictionEffect>) game.getContinuousEffects().getRestrictionEffects();
    log.error(prefix);
    log.error(prefix + "  List of all restriction effects:");
    for (RestrictionEffect effect : restrictionEffects) {
        log.error(prefix + "    " + effect);
        log.error(prefix + "        id=" + effect.getId());
    }
    log.error(prefix);
    log.error(prefix + "  Trace Attacker:");
    traceForPermanent(game, attacker, prefix, restrictionEffects);
    if (blocker != null) {
        log.error(prefix);
        log.error(prefix + "  Trace Blocker:");
        traceForPermanent(game, blocker, prefix, restrictionEffects);
    }
    log.error(prefix);
}
Also used : CantBeBlockedSourceAbility(mage.abilities.keyword.CantBeBlockedSourceAbility) StaticAbility(mage.abilities.StaticAbility) ReachAbility(mage.abilities.keyword.ReachAbility) TriggeredAbility(mage.abilities.TriggeredAbility) FlyingAbility(mage.abilities.keyword.FlyingAbility) Ability(mage.abilities.Ability) IntimidateAbility(mage.abilities.keyword.IntimidateAbility) ContinuousEffectsList(mage.abilities.effects.ContinuousEffectsList) RestrictionEffect(mage.abilities.effects.RestrictionEffect)

Aggregations

ContinuousEffectsList (mage.abilities.effects.ContinuousEffectsList)2 Ability (mage.abilities.Ability)1 StaticAbility (mage.abilities.StaticAbility)1 TriggeredAbility (mage.abilities.TriggeredAbility)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 RestrictionEffect (mage.abilities.effects.RestrictionEffect)1 CantBeBlockedSourceAbility (mage.abilities.keyword.CantBeBlockedSourceAbility)1 FlyingAbility (mage.abilities.keyword.FlyingAbility)1 IntimidateAbility (mage.abilities.keyword.IntimidateAbility)1 ReachAbility (mage.abilities.keyword.ReachAbility)1 Card (mage.cards.Card)1 FilterCard (mage.filter.FilterCard)1 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)1 Test (org.junit.Test)1