Example #1
0
  public RuneflareTrap(GameState state) {
    super(state);

    // If an opponent drew three or more cards this turn, you may pay (R)
    // rather than pay Runeflare Trap's mana cost.
    state.ensureTracker(new CardsDrawn());
    SetGenerator opponents = OpponentsOf.instance(You.instance());
    SetGenerator cardsDrawn = MaximumPerPlayer.instance(CardsDrawn.class, opponents);
    SetGenerator trapCondition = Intersect.instance(cardsDrawn, Between.instance(3, null));
    this.addAbility(
        new Trap(
            state,
            this.getName(),
            trapCondition,
            "If an opponent drew three or more cards this turn",
            "(R)"));

    // Runeflare Trap deals damage to target player equal to the number of
    // cards in that player's hand.
    Target target = this.addTarget(Players.instance(), "target player");

    SetGenerator amount = Count.instance(InZone.instance(HandOf.instance(targetedBy(target))));
    this.addEffect(
        spellDealDamage(
            amount,
            targetedBy(target),
            "Runeflare Trap deals damage to target player equal to the number of cards in that player's hand."));
  }
Example #2
0
  public PermafrostTrap(GameState state) {
    super(state);

    // If an opponent had a green creature enter the battlefield under his
    // or her control this turn, you may pay (U) rather than pay Permafrost
    // Trap's mana cost.
    state.ensureTracker(new GreenCreaturesPutOntoTheBattlefieldThisTurnCounter());
    SetGenerator opponents = OpponentsOf.instance(You.instance());
    SetGenerator maxPerOpponent =
        MaximumPerPlayer.instance(
            GreenCreaturesPutOntoTheBattlefieldThisTurnCounter.class, opponents);
    SetGenerator trapCondition = Intersect.instance(Between.instance(2, null), maxPerOpponent);
    this.addAbility(
        new org.rnd.jmagic.abilities.Trap(
            state,
            this.getName(),
            trapCondition,
            "If an opponent had a green creature enter the battlefield under his or her control this turn",
            "(U)"));

    Target target = this.addTarget(CreaturePermanents.instance(), "up to two target creatures");
    target.setNumber(0, 2);

    // Tap up to two target creatures. Those creatures don't untap during
    // their controller's next untap step.
    EventFactory tap =
        new EventFactory(
            EventType.TAP_HARD,
            "Tap up to two target creatures. Those creatures don't untap during their controller's next untap step.");
    tap.parameters.put(EventType.Parameter.CAUSE, This.instance());
    tap.parameters.put(EventType.Parameter.OBJECT, targetedBy(target));
    this.addEffect(tap);
  }