Exemplo n.º 1
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);
  }
Exemplo n.º 2
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."));
  }
Exemplo n.º 3
0
    @Override
    public Set evaluate(GameState state, Identified thisObject) {
      Tracker tracker = state.getTracker(Tracker.class);

      // if "a player" cast two or more spells this turn -- a single value
      // in the map must be >= 2
      for (int spellCount : tracker.getValue(state).values())
        if (spellCount >= 2) return NonEmpty.set;
      return Empty.set;
    }
Exemplo n.º 4
0
    @Override
    protected void update(GameState state, Event event) {
      MagicSet movements = event.getResult(state);
      for (ZoneChange zc : movements.getAll(ZoneChange.class)) {

        int ownerID = state.<GameObject>get(zc.oldObjectID).ownerID;
        if (this.counts.containsKey(ownerID))
          this.counts.put(ownerID, this.counts.get(ownerID) + 1);
        else this.counts.put(ownerID, 1);
      }
    }
Exemplo n.º 5
0
    @Override
    protected boolean match(GameState state, Event event) {
      if (event.type != EventType.MOVE_BATCH) return false;

      for (ZoneChange change :
          event
              .parametersNow
              .get(EventType.Parameter.TARGET)
              .evaluate(state, null)
              .getAll(ZoneChange.class)) {
        if (state.battlefield().ID != change.destinationZoneID) continue;

        GameObject object = state.get(change.newObjectID);
        if (!object.getColors().contains(Color.GREEN) || !object.getTypes().contains(Type.CREATURE))
          continue;

        return true;
      }
      return false;
    }
Exemplo n.º 6
0
    public MarduWarshriekerAbility0(GameState state) {
      super(
          state,
          "When Mardu Warshrieker enters the battlefield, if you attacked with a creature this turn, add (R)(W)(B) to your mana pool.");
      this.addPattern(whenThisEntersTheBattlefield());

      state.ensureTracker(new org.rnd.jmagic.engine.trackers.AttackTracker());
      this.interveningIf = Raid.instance();

      this.addEffect(addManaToYourManaPoolFromAbility("(R)(W)(B)"));
    }
Exemplo n.º 7
0
  public Monstrosity(GameState state, String manaCost, int N) {
    super(state, manaCost + ": Monstrosity " + N + ".");
    this.manaCost = manaCost;
    this.N = N;

    this.setManaCost(new ManaPool(manaCost));

    state.ensureTracker(new org.rnd.jmagic.engine.eventTypes.Monstrosity.MonstrousTracker());
    EventFactory monstrosity = monstrosity(N);
    this.addEffect(monstrosity);
  }
Exemplo n.º 8
0
    @Override
    public boolean checkSpecialRestrictions(GameState state, List<Target> choices) {
      if (choices.isEmpty()) return true;

      List<Integer> controllers = new LinkedList<Integer>();
      for (Target choice : choices) {
        int controller = state.<GameObject>get(choice.targetID).controllerID;
        if (controllers.contains(controller)) return false;
        controllers.add(controller);
      }

      return true;
    }
Exemplo n.º 9
0
    public BecomeHuman(GameState state, String cardName) {
      super(
          state,
          "At the beginning of each upkeep, if a player cast two or more spells last turn, transform "
              + cardName
              + ".");
      this.cardName = cardName;

      this.addPattern(atTheBeginningOfEachUpkeep());

      state.ensureTracker(new Tracker());
      this.interveningIf = NewMoon.instance();

      this.addEffect(transformThis(cardName));
    }
Exemplo n.º 10
0
    public BecomeFuzzy(GameState state, String cardName) {
      super(
          state,
          "At the beginning of each upkeep, if no spells were cast last turn, transform "
              + cardName
              + ".");
      this.cardName = cardName;

      this.addPattern(atTheBeginningOfEachUpkeep());

      state.ensureTracker(new Tracker());
      this.interveningIf = FullMoon.instance();

      this.addEffect(transformThis(cardName));
    }
Exemplo n.º 11
0
    public Glass(GameState state) {
      super(
          state,
          "Whenever this creature becomes the target of a spell or ability for the first time in a turn, counter that spell or ability.");

      SimpleEventPattern pattern = new SimpleEventPattern(EventType.BECOMES_TARGET);
      pattern.put(
          EventType.Parameter.TARGET,
          RelativeComplement.instance(ABILITY_SOURCE_OF_THIS, TargetedThisTurn.instance()));
      state.ensureTracker(new TargetedThisTurn.Tracker());

      SetGenerator thatSpell =
          EventParameter.instance(
              TriggerEvent.instance(This.instance()), EventType.Parameter.OBJECT);
      this.addEffect(counter(thatSpell, "Counter that spell or ability."));
    }
Exemplo n.º 12
0
 @Override
 public Set evaluate(GameState state, Identified thisObject) {
   Tracker tracker = state.getTracker(Tracker.class);
   if (tracker.getValue(state).isEmpty()) return NonEmpty.set;
   return Empty.set;
 }
Exemplo n.º 13
0
 @Override
 public org.rnd.jmagic.engine.Set evaluate(GameState state, Identified thisObject) {
   Set ret = new Set();
   for (int ID : state.getTracker(Tracker.class).getValue(state)) ret.add(state.get(ID));
   return ret;
 }