Exemple #1
0
  public Pyroblast(GameState state) {
    super(state);

    {
      Target target = this.addTarget(1, Spells.instance(), "target spell");
      EventFactory counter =
          new EventFactory(EventType.IF_CONDITION_THEN_ELSE, "Counter target spell if it's blue.");
      counter.parameters.put(
          EventType.Parameter.IF,
          Intersect.instance(targetedBy(target), HasColor.instance(Color.BLUE)));
      counter.parameters.put(
          EventType.Parameter.THEN,
          Identity.instance(counter(targetedBy(target), "Counter target spell.")));
      this.addEffect(1, counter);
    }

    {
      Target target = this.addTarget(2, Permanents.instance(), "target permanent");
      EventFactory destroy =
          new EventFactory(
              EventType.IF_CONDITION_THEN_ELSE, "Destroy target permanent if it's blue.");
      destroy.parameters.put(
          EventType.Parameter.IF,
          Intersect.instance(targetedBy(target), HasColor.instance(Color.BLUE)));
      destroy.parameters.put(
          EventType.Parameter.THEN,
          Identity.instance(destroy(targetedBy(target), "Destroy target permanent.")));
      this.addEffect(2, destroy);
    }
  }
Exemple #2
0
    public DearlyDepartedAbility1(GameState state) {
      super(
          state,
          "As long as Dearly Departed is in your graveyard, each Human creature you control enters the battlefield with an additional +1/+1 counter on it.");
      this.canApply = THIS_IS_IN_A_GRAVEYARD;

      SetGenerator humanCreatures =
          Intersect.instance(HasSubType.instance(SubType.HUMAN), HasType.instance(Type.CREATURE));

      ZoneChangeReplacementEffect replacement =
          new ZoneChangeReplacementEffect(this.game, this.getName());
      replacement.addPattern(
          new SimpleZoneChangePattern(
              null, Battlefield.instance(), humanCreatures, You.instance(), false));

      SetGenerator zoneChange = ReplacedBy.instance(Identity.instance(replacement));

      EventFactory factory = new EventFactory(EventType.PUT_COUNTERS, this.getName());
      factory.parameters.put(EventType.Parameter.CAUSE, CauseOf.instance(zoneChange));
      factory.parameters.put(
          EventType.Parameter.COUNTER, Identity.instance(Counter.CounterType.PLUS_ONE_PLUS_ONE));
      factory.parameters.put(EventType.Parameter.OBJECT, NewObjectOf.instance(zoneChange));
      replacement.addEffect(factory);

      this.addEffectPart(replacementEffectPart(replacement));
    }
    public TentacleRape(GameState state) {
      super(
          state,
          "Whenever Lorthos, the Tidemaker attacks, you may pay (8). If you do, tap up to eight target permanents. Those permanents don't untap during their controllers' next untap steps.");
      this.addPattern(whenThisAttacks());

      Target target = this.addTarget(Permanents.instance(), "up to eight target permanents");
      target.setNumber(0, 8);

      EventFactory mayPay8 = new EventFactory(EventType.PLAYER_MAY_PAY_MANA, "You may pay (8)");
      mayPay8.parameters.put(EventType.Parameter.CAUSE, This.instance());
      mayPay8.parameters.put(EventType.Parameter.PLAYER, You.instance());
      mayPay8.parameters.put(
          EventType.Parameter.COST, Identity.fromCollection(new ManaPool("(8)")));

      EventFactory tapHard =
          new EventFactory(
              EventType.TAP_HARD,
              "Tap up to eight target permanents. Those permanents don't untap during their controllers' next untap steps.");
      tapHard.parameters.put(EventType.Parameter.CAUSE, This.instance());
      tapHard.parameters.put(EventType.Parameter.OBJECT, targetedBy(target));

      EventFactory totalEffect =
          new EventFactory(
              EventType.IF_EVENT_THEN_ELSE,
              "You may pay (R). If you do, return Punishing Fire from your graveyard to your hand.");
      totalEffect.parameters.put(EventType.Parameter.IF, Identity.instance(mayPay8));
      totalEffect.parameters.put(EventType.Parameter.THEN, Identity.instance(tapHard));
      this.addEffect(totalEffect);
    }
  public ArrowVolleyTrap(GameState state) {
    super(state);

    SetGenerator trapCondition =
        Intersect.instance(Between.instance(4, null), Count.instance(Attacking.instance()));
    this.addAbility(
        new org.rnd.jmagic.abilities.Trap(
            state,
            this.getName(),
            trapCondition,
            "If four or more creatures are attacking",
            "(1)(W)"));

    Target target = this.addTarget(Attacking.instance(), "up to five target attacking creatures");
    target.setNumber(1, 5);

    this.setDivision(Union.instance(numberGenerator(5), Identity.instance("damage")));
    EventType.ParameterMap damageParameters = new EventType.ParameterMap();
    damageParameters.put(EventType.Parameter.SOURCE, This.instance());
    damageParameters.put(
        EventType.Parameter.TAKER,
        ChosenTargetsFor.instance(Identity.instance(target), This.instance()));
    this.addEffect(
        new EventFactory(
            EventType.DISTRIBUTE_DAMAGE,
            damageParameters,
            "Arrow Volley Trap deals 5 damage divided as you choose among any number of target attacking creatures."));
  }
    public ConsumingAberrationAbility1(GameState state) {
      super(
          state,
          "Whenever you cast a spell, each opponent reveals cards from the top of his or her library until he or she reveals a land card, then puts those cards into his or her graveyard.");

      this.addPattern(whenYouCastASpell());

      DynamicEvaluation eachOpponent = DynamicEvaluation.instance();

      SetGenerator toReveal =
          TopMost.instance(
              LibraryOf.instance(eachOpponent), numberGenerator(1), HasType.instance(Type.LAND));
      EventFactory reveal =
          reveal(
              toReveal,
              "Each opponent reveals cards from the top of his or her library until he or she reveals a land card,");
      EventFactory move =
          putIntoGraveyard(toReveal, "then puts those cards into his or her graveyard.");

      EventFactory forEach =
          new EventFactory(
              FOR_EACH_PLAYER,
              "Each opponent reveals cards from the top of his or her library until he or she reveals a land card, then puts those cards into his or her graveyard.");
      forEach.parameters.put(EventType.Parameter.PLAYER, OpponentsOf.instance(You.instance()));
      forEach.parameters.put(EventType.Parameter.TARGET, Identity.instance(eachOpponent));
      forEach.parameters.put(EventType.Parameter.EFFECT, Identity.instance(sequence(reveal, move)));
      this.addEffect(forEach);
    }
Exemple #6
0
    public MotherofRunesAbility0(GameState state) {
      super(
          state,
          "(T): Target creature you control gains protection from the color of your choice until end of turn.");
      this.costsTap = true;
      SetGenerator target =
          targetedBy(
              this.addTarget(
                  Intersect.instance(
                      CreaturePermanents.instance(), ControlledBy.instance(You.instance())),
                  "target creature you control"));

      EventFactory chooseColor =
          playerChoose(
              You.instance(),
              1,
              Identity.fromCollection(Color.allColors()),
              PlayerInterface.ChoiceType.COLOR,
              PlayerInterface.ChooseReason.CHOOSE_COLOR,
              "");
      this.addEffect(chooseColor);

      SetGenerator color = EffectResult.instance(chooseColor);
      this.addEffect(
          addProtectionUntilEndOfTurn(
              target,
              color,
              "Target creature gains protection from the color of your choice until end of turn."));
    }
  public SurgicalExtraction(GameState state) {
    super(state);

    // Choose target card in a graveyard other than a basic land card.
    SetGenerator inGraveyards = InZone.instance(GraveyardOf.instance(Players.instance()));
    SetGenerator basicLands =
        Intersect.instance(HasSuperType.instance(SuperType.BASIC), HasType.instance(Type.LAND));
    SetGenerator legalTargets = RelativeComplement.instance(inGraveyards, basicLands);
    Target t =
        this.addTarget(legalTargets, "target card in a graveyard other than a basic land card");

    // Search its owner's graveyard, hand, and library for all cards with
    // the same name as that card and exile them.
    SetGenerator itsOwner = OwnerOf.instance(targetedBy(t));
    SetGenerator graveyard = GraveyardOf.instance(itsOwner);
    SetGenerator hand = HandOf.instance(itsOwner);
    SetGenerator library = LibraryOf.instance(itsOwner);
    SetGenerator zones = Union.instance(graveyard, hand, library);

    EventFactory effect =
        new EventFactory(
            EventType.SEARCH_FOR_ALL_AND_PUT_INTO,
            "Choose target card in a graveyard other than a basic land card. Search its owner's graveyard, hand, and library for all cards with the same name as that card and exile them.");
    effect.parameters.put(EventType.Parameter.CAUSE, This.instance());
    effect.parameters.put(EventType.Parameter.PLAYER, You.instance());
    effect.parameters.put(EventType.Parameter.ZONE, zones);
    effect.parameters.put(
        EventType.Parameter.TYPE,
        Identity.instance(HasName.instance(NameOf.instance(targetedBy(t)))));
    effect.parameters.put(EventType.Parameter.TO, ExileZone.instance());
    this.addEffect(effect);

    // Then that player shuffles his or her library.
    this.addEffect(shuffleLibrary(targetedBy(t), "Then that player shuffles his or her library."));
  }
Exemple #8
0
  @Override
  public boolean perform(Game game, Event event, Map<Parameter, MagicSet> parameters) {
    Answer[] possibleResults = {Answer.WIN, Answer.LOSE};
    if (parameters.containsKey(Parameter.TYPE)) {
      Set<Answer> typeParameter = parameters.get(Parameter.TYPE).getAll(Answer.class);
      if (typeParameter.size() != 2)
        throw new UnsupportedOperationException(
            "Coin flip type " + typeParameter + " does not contain exactly two Answer objects!");
      possibleResults = typeParameter.toArray(possibleResults);
    }

    Answer flipResult = possibleResults[this.generator.nextBoolean() ? 1 : 0];
    if (game.noRandom) {
      Player player = parameters.get(Parameter.PLAYER).getOne(Player.class);
      flipResult =
          player
              .choose(
                  1,
                  Arrays.asList(possibleResults),
                  PlayerInterface.ChoiceType.COIN_FLIP,
                  PlayerInterface.ChooseReason.MANIPULATE_COIN_FLIP)
              .get(0);
    }

    event.setResult(Identity.instance(flipResult));

    // This returns false if the flip resulted in Answer.LOSE, but true
    // for everything else (including Answer.WIN, and any specified
    // Answers)
    return (flipResult != Answer.LOSE);
  }
Exemple #9
0
    public SnapcasterMageAbility1(GameState state) {
      super(
          state,
          "When Snapcaster Mage enters the battlefield, target instant or sorcery card in your graveyard gains flashback until end of turn. The flashback cost is equal to its mana cost.");
      this.addPattern(whenThisEntersTheBattlefield());

      SetGenerator target =
          targetedBy(
              this.addTarget(
                  Intersect.instance(
                      HasType.instance(Type.INSTANT, Type.SORCERY),
                      InZone.instance(GraveyardOf.instance(You.instance()))),
                  "target instant or sorcery card in your graveyard"));

      ContinuousEffect.Part part =
          new ContinuousEffect.Part(ContinuousEffectType.GRANT_COSTED_KEYWORD);
      part.parameters.put(
          ContinuousEffectType.Parameter.ABILITY,
          Identity.instance(org.rnd.jmagic.abilities.keywords.Flashback.class));
      part.parameters.put(ContinuousEffectType.Parameter.OBJECT, target);
      this.addEffect(
          createFloatingEffect(
              "Target instant or sorcery card in your graveyard gains flashback until end of turn. The flashback cost is equal to its mana cost.",
              part));
    }
    public AgadeemOccultistAbility0(GameState state) {
      super(
          state,
          "(T): Put target creature card from an opponent's graveyard onto the battlefield under your control if its converted mana cost is less than or equal to the number of Allies you control.");
      this.costsTap = true;

      SetGenerator creatureCards = HasType.instance(Type.CREATURE);
      SetGenerator inOpponentsYard =
          InZone.instance(GraveyardOf.instance(OpponentsOf.instance(You.instance())));
      Target t =
          this.addTarget(
              Intersect.instance(creatureCards, inOpponentsYard),
              "target creature card from an opponent's graveyard");

      EventFactory move =
          new EventFactory(
              EventType.PUT_ONTO_BATTLEFIELD,
              "Put target creature card from an opponent's graveyard onto the battlefield under your control");
      move.parameters.put(EventType.Parameter.CAUSE, This.instance());
      move.parameters.put(EventType.Parameter.CONTROLLER, You.instance());
      move.parameters.put(EventType.Parameter.OBJECT, targetedBy(t));

      SetGenerator lessThanOrEqualNumAllies =
          Between.instance(null, Count.instance(ALLIES_YOU_CONTROL));
      SetGenerator condition =
          Intersect.instance(ConvertedManaCostOf.instance(targetedBy(t)), lessThanOrEqualNumAllies);

      EventFactory effect =
          new EventFactory(
              EventType.IF_CONDITION_THEN_ELSE,
              "Put target creature card from an opponent's graveyard onto the battlefield under your control if its converted mana cost is less than or equal to the number of Allies you control.");
      effect.parameters.put(EventType.Parameter.IF, condition);
      effect.parameters.put(EventType.Parameter.THEN, Identity.instance(move));
      this.addEffect(effect);
    }
Exemple #11
0
    public MysticRemoraAbility1(GameState state) {
      super(
          state,
          "Whenever an opponent casts a noncreature spell, you may draw a card unless that player pays (4).");

      SimpleEventPattern pattern = new SimpleEventPattern(EventType.BECOMES_PLAYED);
      pattern.put(EventType.Parameter.PLAYER, OpponentsOf.instance(You.instance()));
      pattern.put(
          EventType.Parameter.OBJECT,
          RelativeComplement.instance(Spells.instance(), HasType.instance(Type.CREATURE)));
      this.addPattern(pattern);

      SetGenerator thatPlayer =
          EventParameter.instance(
              TriggerEvent.instance(This.instance()), EventType.Parameter.PLAYER);

      EventFactory mayDraw =
          youMay(drawCards(You.instance(), 1, "Draw a card"), "You may draw a card");

      EventFactory pay = new EventFactory(EventType.PAY_MANA, "Pay (4)");
      pay.parameters.put(EventType.Parameter.CAUSE, This.instance());
      pay.parameters.put(EventType.Parameter.PLAYER, thatPlayer);
      pay.parameters.put(EventType.Parameter.MANA, Identity.instance(new ManaPool("4")));
      this.addEffect(
          unless(thatPlayer, mayDraw, pay, "You may draw a card unless that player pays (4)."));
    }
Exemple #12
0
    public ElephantGrassAbility2(GameState state) {
      super(
          state,
          "Nonblack creatures can't attack you unless their controller pays (2) for each creature he or she controls that's attacking you.");

      SetGenerator nonblackCreatures =
          RelativeComplement.instance(
              CreaturePermanents.instance(), HasColor.instance(Color.BLACK));

      ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.ATTACKING_COST);
      part.parameters.put(
          ContinuousEffectType.Parameter.COST, Identity.fromCollection(new ManaPool("2")));
      part.parameters.put(
          ContinuousEffectType.Parameter.OBJECT, Identity.instance(nonblackCreatures));
      part.parameters.put(ContinuousEffectType.Parameter.PLAYER, You.instance());
      this.addEffectPart(part);
    }
Exemple #13
0
  public EvolutionCharm(GameState state) {
    super(state);

    // Choose one

    // Search your library for a basic land card, reveal it, put it into
    // your hand, then shuffle your library
    {
      EventType.ParameterMap searchParameters = new EventType.ParameterMap();
      searchParameters.put(EventType.Parameter.CAUSE, This.instance());
      searchParameters.put(EventType.Parameter.PLAYER, You.instance());
      searchParameters.put(EventType.Parameter.NUMBER, numberGenerator(1));
      searchParameters.put(
          EventType.Parameter.TYPE,
          Identity.instance(
              Intersect.instance(
                  HasSuperType.instance(SuperType.BASIC), HasType.instance(Type.LAND))));
      searchParameters.put(EventType.Parameter.TO, HandOf.instance(You.instance()));
      this.addEffect(
          1,
          new EventFactory(
              EventType.SEARCH_LIBRARY_AND_PUT_INTO,
              searchParameters,
              "Search your library for a basic land card, reveal it, put it into your hand, then shuffle your library."));
    }

    // Return target creature card from your graveyard to your hand
    {
      SetGenerator graveyard = GraveyardOf.instance(You.instance());
      Target target =
          this.addTarget(
              2,
              Intersect.instance(HasType.instance(Type.CREATURE), InZone.instance(graveyard)),
              "target creature from your graveyard");

      EventType.ParameterMap moveParameters = new EventType.ParameterMap();
      moveParameters.put(EventType.Parameter.CAUSE, This.instance());
      moveParameters.put(EventType.Parameter.TO, HandOf.instance(You.instance()));
      moveParameters.put(EventType.Parameter.OBJECT, targetedBy(target));
      this.addEffect(
          2,
          new EventFactory(
              EventType.MOVE_OBJECTS,
              moveParameters,
              "Return target creature card from your graveyard to your hand."));
    }

    // Target creature gains flying until end of turn.
    {
      Target target = this.addTarget(3, CreaturePermanents.instance(), "target creature");
      this.addEffect(
          3,
          addAbilityUntilEndOfTurn(
              targetedBy(target),
              org.rnd.jmagic.abilities.keywords.Flying.class,
              "Target creature gains flying until end of turn."));
    }
  }
 @Override
 protected EventFactory getFactory(SetGenerator thisAbility) {
   EventFactory factory = new EventFactory(EventType.PAY_MANA, "Pay " + this.cumulativeUpkeep);
   factory.parameters.put(EventType.Parameter.CAUSE, thisAbility);
   factory.parameters.put(
       EventType.Parameter.COST, Identity.instance(new ManaPool(this.cumulativeUpkeep)));
   factory.parameters.put(EventType.Parameter.PLAYER, ControllerOf.instance(thisAbility));
   return factory;
 }
Exemple #15
0
    public EntomberExarchAbility0(GameState state) {
      super(
          state,
          "When Entomber Exarch enters the battlefield, choose one \u2014\n\u2022 Return target creature card from your graveyard to your hand.\n\u2022 Target opponent reveals his or her hand, you choose a noncreature card from it, then that player discards that card.");
      this.addPattern(whenThisEntersTheBattlefield());

      // Return target creature card from your graveyard to your hand
      {
        SetGenerator yourYard = GraveyardOf.instance(You.instance());
        SetGenerator target =
            targetedBy(
                this.addTarget(
                    1,
                    Intersect.instance(HasType.instance(Type.CREATURE), InZone.instance(yourYard)),
                    "target creature card in your graveyard"));

        EventFactory move =
            new EventFactory(
                EventType.MOVE_OBJECTS,
                "Return target creature card from your graveyard to your hand");
        move.parameters.put(EventType.Parameter.CAUSE, This.instance());
        move.parameters.put(EventType.Parameter.TO, HandOf.instance(You.instance()));
        move.parameters.put(EventType.Parameter.OBJECT, target);
        this.addEffect(1, move);
      }

      // target opponent reveals his or her hand, you choose a noncreature
      // card from it, then that player discards that card
      {
        SetGenerator target =
            targetedBy(this.addTarget(2, OpponentsOf.instance(You.instance()), "target opponent"));

        SetGenerator cards = InZone.instance(HandOf.instance(target));
        EventType.ParameterMap revealParameters = new EventType.ParameterMap();
        revealParameters.put(EventType.Parameter.CAUSE, This.instance());
        revealParameters.put(EventType.Parameter.OBJECT, cards);
        this.addEffect(
            2,
            new EventFactory(
                EventType.REVEAL, revealParameters, "Target opponent reveals his or her hand."));

        SetGenerator choices = RelativeComplement.instance(cards, HasType.instance(Type.CREATURE));

        EventType.ParameterMap parameters = new EventType.ParameterMap();
        parameters.put(EventType.Parameter.CAUSE, This.instance());
        parameters.put(EventType.Parameter.PLAYER, You.instance());
        parameters.put(EventType.Parameter.TARGET, target);
        parameters.put(EventType.Parameter.CHOICE, Identity.instance(choices));
        this.addEffect(
            2,
            new EventFactory(
                EventType.DISCARD_FORCE,
                parameters,
                "You choose a noncreature card from it, then that player discards that card."));
      }
    }
Exemple #16
0
    public Spread(GameState state) {
      super(state, "Enchanted land is an Island.");

      SetGenerator enchantedLand = EnchantedBy.instance(This.instance());

      ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.SET_TYPES);
      part.parameters.put(ContinuousEffectType.Parameter.OBJECT, enchantedLand);
      part.parameters.put(ContinuousEffectType.Parameter.TYPE, Identity.instance(SubType.ISLAND));
      this.addEffectPart(part);
    }
Exemple #17
0
  public IllGottenGains(GameState state) {
    super(state);

    // Exile Ill-Gotten Gains.
    this.addEffect(exile(This.instance(), "Exile Ill-Gotten Gains."));

    // Each player discards his or her hand,
    this.addEffect(discardHand(Players.instance(), "Each player discards his or her hand,"));

    // then returns up to three cards from his or her graveyard to his or
    // her hand.
    SetGenerator eachPlayer = DynamicEvaluation.instance();
    SetGenerator graveyard = GraveyardOf.instance(eachPlayer);
    EventFactory chooseCards =
        new EventFactory(EventType.PLAYER_CHOOSE, "Choose up to three cards in your graveyard");
    chooseCards.parameters.put(EventType.Parameter.PLAYER, eachPlayer);
    chooseCards.parameters.put(EventType.Parameter.NUMBER, Between.instance(0, 3));
    chooseCards.parameters.put(EventType.Parameter.CHOICE, InZone.instance(graveyard));
    chooseCards.parameters.put(
        EventType.Parameter.TYPE, Identity.instance(PlayerInterface.ChoiceType.OBJECTS, REASON));

    EventFactory eachPlayerChooses = new EventFactory(FOR_EACH_PLAYER, "");
    eachPlayerChooses.parameters.put(EventType.Parameter.TARGET, Identity.instance(eachPlayer));
    eachPlayerChooses.parameters.put(EventType.Parameter.EFFECT, Identity.instance(chooseCards));
    this.addEffect(eachPlayerChooses);

    SetGenerator chosenCards = ForEachResult.instance(eachPlayerChooses, eachPlayer);

    EventFactory returnCards =
        new EventFactory(EventType.MOVE_OBJECTS, "Return those cards to your hand");
    returnCards.parameters.put(EventType.Parameter.CAUSE, This.instance());
    returnCards.parameters.put(EventType.Parameter.TO, HandOf.instance(eachPlayer));
    returnCards.parameters.put(EventType.Parameter.OBJECT, chosenCards);

    EventFactory effect =
        new EventFactory(
            FOR_EACH_PLAYER,
            "then returns up to three cards from his or her graveyard to his or her hand.");
    effect.parameters.put(EventType.Parameter.TARGET, Identity.instance(eachPlayer));
    effect.parameters.put(EventType.Parameter.EFFECT, Identity.instance(returnCards));
    this.addEffect(effect);
  }
Exemple #18
0
    public FathomMageAbility1(GameState state) {
      super(state, "Whenever a +1/+1 counter is placed on Fathom Mage, you may draw a card.");

      SimpleEventPattern pattern = new SimpleEventPattern(EventType.PUT_ONE_COUNTER);
      pattern.put(EventType.Parameter.OBJECT, ABILITY_SOURCE_OF_THIS);
      pattern.put(
          EventType.Parameter.COUNTER, Identity.instance(Counter.CounterType.PLUS_ONE_PLUS_ONE));
      this.addPattern(pattern);

      this.addEffect(youMay(drawACard()));
    }
Exemple #19
0
    public GroundSealAbility1(GameState state) {
      super(state, "Cards in graveyards can't be the targets of spells or abilities.");

      SetGenerator inYards = InZone.instance(GraveyardOf.instance(Players.instance()));

      ContinuousEffect.Part part =
          new ContinuousEffect.Part(ContinuousEffectType.CANT_BE_THE_TARGET_OF);
      part.parameters.put(ContinuousEffectType.Parameter.OBJECT, inYards);
      part.parameters.put(
          ContinuousEffectType.Parameter.RESTRICTION, Identity.instance(SetPattern.EVERYTHING));
      this.addEffectPart(part);
    }
  public BravetheElements(GameState state) {
    super(state);

    EventFactory factory =
        new EventFactory(
            BRAVE_THE_ELEMENTS_EVENT,
            "Choose a color. White creatures you control gain protection from the chosen color until end of turn.");
    factory.parameters.put(EventType.Parameter.CAUSE, This.instance());
    factory.parameters.put(EventType.Parameter.CHOICE, Identity.instance(Color.allColors()));
    factory.parameters.put(EventType.Parameter.PLAYER, You.instance());
    this.addEffect(factory);
  }
Exemple #21
0
    public ElephantGrassAbility1(GameState state) {
      super(state, "Black creatures can't attack you.");

      SetGenerator restriction =
          Intersect.instance(HasColor.instance(Color.BLACK), Attacking.instance(You.instance()));

      ContinuousEffect.Part part =
          new ContinuousEffect.Part(ContinuousEffectType.ATTACKING_RESTRICTION);
      part.parameters.put(
          ContinuousEffectType.Parameter.RESTRICTION, Identity.instance(restriction));
      this.addEffectPart(part);
    }
    public UntargetableByBU(GameState state) {
      super(state, "Karplusan Strider can't be the target of blue or black spells.");

      ContinuousEffect.Part part =
          new ContinuousEffect.Part(ContinuousEffectType.CANT_BE_THE_TARGET_OF);
      part.parameters.put(ContinuousEffectType.Parameter.OBJECT, This.instance());
      SetGenerator blueOrBlackSpells =
          Intersect.instance(Spells.instance(), HasColor.instance(Color.BLUE, Color.BLACK));
      part.parameters.put(
          ContinuousEffectType.Parameter.RESTRICTION,
          Identity.instance(new SimpleSetPattern(blueOrBlackSpells)));
      this.addEffectPart(part);
    }
  @Override
  public boolean perform(Game game, Event event, Map<Parameter, MagicSet> parameters) {
    Event damageEvent =
        createEvent(game, event.getName(), EventType.DEAL_DAMAGE_EVENLY, parameters);
    boolean ret = damageEvent.perform(event, false);

    SetPattern affectedCreatures =
        new SimpleSetPattern(
            Intersect.instance(
                TakerOfDamage.instance(EventDamage.instance(Identity.instance(event))),
                CreaturePermanents.instance()));

    SimpleEventPattern regenerate = new SimpleEventPattern(EventType.REGENERATE);
    regenerate.put(EventType.Parameter.OBJECT, affectedCreatures);

    EventReplacementEffectStopper stopRegen =
        new EventReplacementEffectStopper(
            parameters.get(Parameter.SOURCE).getOne(GameObject.class), null, regenerate);
    ContinuousEffect.Part part =
        new ContinuousEffect.Part(ContinuousEffectType.STOP_REPLACEMENT_EFFECT);
    part.parameters.put(ContinuousEffectType.Parameter.PROHIBITION, Identity.instance(stopRegen));

    Map<EventType.Parameter, MagicSet> stopRegenParameters =
        new HashMap<EventType.Parameter, MagicSet>();
    stopRegenParameters.put(EventType.Parameter.CAUSE, parameters.get(Parameter.SOURCE));
    stopRegenParameters.put(EventType.Parameter.EFFECT, new MagicSet(part));
    Event regenStopper =
        createEvent(
            game,
            "A creature dealt damage this way can't be regenerated this turn.",
            EventType.CREATE_FLOATING_CONTINUOUS_EFFECT,
            stopRegenParameters);
    ret = regenStopper.perform(event, false) && ret;

    event.setResult(Empty.set);

    return ret;
  }
    public LazavDimirMastermindAbility1(GameState state) {
      super(
          state,
          "Whenever a creature card is put into an opponent's graveyard from anywhere, you may have Lazav, Dimir Mastermind become a copy of that card except its name is still Lazav, Dimir Mastermind, it's legendary in addition to its other types, and it gains hexproof and this ability.");

      this.addPattern(
          new SimpleZoneChangePattern(
              null,
              GraveyardOf.instance(OpponentsOf.instance(You.instance())),
              HasType.instance(Type.CREATURE),
              false));

      SetGenerator thatCard = NewObjectOf.instance(TriggerZoneChange.instance(This.instance()));

      ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.COPY_OBJECT);
      part.parameters.put(
          ContinuousEffectType.Parameter.ABILITY,
          Identity.instance(
              new SimpleAbilityFactory(LazavDimirMastermindAbility1.class),
              new SimpleAbilityFactory(Hexproof.class)));
      part.parameters.put(ContinuousEffectType.Parameter.OBJECT, ABILITY_SOURCE_OF_THIS);
      part.parameters.put(ContinuousEffectType.Parameter.ORIGINAL, thatCard);
      part.parameters.put(
          ContinuousEffectType.Parameter.RETAIN,
          Identity.instance(Characteristics.Characteristic.NAME));
      part.parameters.put(
          ContinuousEffectType.Parameter.TYPE, Identity.instance(SuperType.LEGENDARY));

      EventFactory copy =
          createFloatingEffect(
              Empty.instance(),
              "Have Lazav, Dimir Mastermind become a copy of that card except its name is still Lazav, Dimir Mastermind, it's legendary in addition to its other types, and it gains hexproof and this ability.",
              part);
      this.addEffect(
          youMay(
              copy,
              "Have Lazav, Dimir Mastermind become a copy of that card except its name is still Lazav, Dimir Mastermind, it's legendary in addition to its other types, and it gains hexproof and this ability."));
    }
Exemple #25
0
    public InfernoTitanAbility1(GameState state) {
      super(
          state,
          "Whenever Inferno Titan enters the battlefield or attacks, it deals 3 damage divided as you choose among one, two, or three target creatures and/or players.");
      this.addPattern(whenThisEntersTheBattlefield());
      this.addPattern(whenThisAttacks());

      Target target =
          this.addTarget(
              CREATURES_AND_PLAYERS, "one, two, or three target creatures and/or players");
      target.setNumber(1, 3);
      this.setDivision(Union.instance(numberGenerator(3), Identity.instance("damage")));

      EventFactory damage =
          new EventFactory(
              EventType.DISTRIBUTE_DAMAGE,
              "It deals 3 damage divided as you choose among one, two, or three target creatures and/or players.");
      damage.parameters.put(EventType.Parameter.SOURCE, ABILITY_SOURCE_OF_THIS);
      damage.parameters.put(
          EventType.Parameter.TAKER,
          ChosenTargetsFor.instance(Identity.instance(target), This.instance()));
      this.addEffect(damage);
    }
Exemple #26
0
    public ThisArtifactKindOfSucksNow(GameState state) {
      super(state, "At the beginning of your upkeep, sacrifice this artifact unless you pay (2).");
      this.addPattern(atTheBeginningOfYourUpkeep());

      EventFactory sacrifice = sacrificeThis("this artifact");

      EventFactory pay = new EventFactory(EventType.PAY_MANA, "Pay (2)");
      pay.parameters.put(EventType.Parameter.CAUSE, This.instance());
      pay.parameters.put(EventType.Parameter.COST, Identity.instance(new ManaPool("(2)")));
      pay.parameters.put(EventType.Parameter.PLAYER, You.instance());

      this.addEffect(
          unless(You.instance(), sacrifice, pay, "Sacrifice this artifact unless you pay (2)."));
    }
    public ThisCreatureKindOfSucksNow(GameState state) {
      super(state, "At the beginning of your upkeep, destroy this creature unless you pay (1).");
      this.addPattern(atTheBeginningOfYourUpkeep());

      EventFactory destroy = destroy(ABILITY_SOURCE_OF_THIS, "Destroy this creature");

      EventFactory pay = new EventFactory(EventType.PAY_MANA, "Pay (1)");
      pay.parameters.put(EventType.Parameter.CAUSE, This.instance());
      pay.parameters.put(EventType.Parameter.COST, Identity.fromCollection(new ManaPool("(1)")));
      pay.parameters.put(EventType.Parameter.PLAYER, You.instance());

      this.addEffect(
          unless(You.instance(), destroy, pay, "Destroy this creature unless you pay (1)."));
    }
    public CumulativeUpkeepAbility(GameState state, CumulativeUpkeep parent) {
      super(
          state,
          "At the beginning of your upkeep, if this permanent is on the battlefield, put an age counter on this permanent. Then you may pay its cumulative upkeep cost for each age counter on it. If you don't, sacrifice it.");
      this.parent = parent;

      SetGenerator thisCard = ABILITY_SOURCE_OF_THIS;

      EventFactory cost = parent.getFactory(This.instance());

      this.addPattern(atTheBeginningOfYourUpkeep());
      this.interveningIf = Intersect.instance(ABILITY_SOURCE_OF_THIS, Permanents.instance());
      this.addEffect(putCountersOnThis(1, Counter.CounterType.AGE, "this permanent"));

      EventFactory payFactory =
          new EventFactory(
              EventType.PAY_CUMULATIVE_UPKEEP, (cost.name + " for each age counter on it."));
      payFactory.parameters.put(EventType.Parameter.CAUSE, This.instance());
      payFactory.parameters.put(EventType.Parameter.EVENT, Identity.instance(cost));
      payFactory.parameters.put(
          EventType.Parameter.NUMBER,
          Count.instance(CountersOn.instance(thisCard, Counter.CounterType.AGE)));

      EventFactory mayFactory =
          youMay(payFactory, "You may " + cost.name + " for each age counter on it.");
      EventFactory sacFactory = sacrificeThis("it");

      EventFactory mainFactory =
          new EventFactory(
              EventType.IF_EVENT_THEN_ELSE,
              ("You may "
                  + cost.name
                  + " for each age counter on it.  If you don't, sacrifice it."));
      mainFactory.parameters.put(EventType.Parameter.IF, Identity.instance(mayFactory));
      mainFactory.parameters.put(EventType.Parameter.ELSE, Identity.instance(sacFactory));
      this.addEffect(mainFactory);
    }
Exemple #29
0
    public FlashAbility(GameState state) {
      super(state, "You may play this card any time you could play an instant.");

      SetGenerator youHavePriority =
          Intersect.instance(You.instance(), PlayerWithPriority.instance());

      ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.MAY_PLAY_TIMING);
      part.parameters.put(ContinuousEffectType.Parameter.OBJECT, This.instance());
      part.parameters.put(
          ContinuousEffectType.Parameter.PERMISSION,
          Identity.instance(new PlayPermission(youHavePriority)));
      this.addEffectPart(part);

      this.canApply = NonEmpty.instance();
    }
        @Override
        public boolean perform(Game game, Event event, Map<Parameter, MagicSet> parameters) {
          MagicSet cause = parameters.get(Parameter.CAUSE);
          event.setResult(Empty.set);

          Set<Color> choices = parameters.get(Parameter.CHOICE).getAll(Color.class);
          Player player = parameters.get(Parameter.PLAYER).getOne(Player.class);

          PlayerInterface.ChooseParameters<Color> chooseParameters =
              new PlayerInterface.ChooseParameters<Color>(
                  1,
                  1,
                  new LinkedList<Color>(choices),
                  PlayerInterface.ChoiceType.COLOR,
                  PlayerInterface.ChooseReason.CHOOSE_COLOR);
          chooseParameters.thisID = cause.getOne(GameObject.class).ID;
          List<Color> chosenList = player.choose(chooseParameters);
          if (chosenList.isEmpty()) return false;

          Color color = chosenList.get(0);

          Class<? extends Protection> ability = Protection.from(color);

          ContinuousEffect.Part part =
              new ContinuousEffect.Part(ContinuousEffectType.ADD_ABILITY_TO_OBJECT);
          part.parameters.put(
              ContinuousEffectType.Parameter.OBJECT,
              Intersect.instance(
                  HasColor.instance(Color.WHITE),
                  Intersect.instance(
                      HasType.instance(Type.CREATURE), ControlledBy.instance(You.instance()))));
          part.parameters.put(
              ContinuousEffectType.Parameter.ABILITY,
              Identity.instance(new SimpleAbilityFactory(ability)));

          Map<Parameter, MagicSet> fceParameters = new HashMap<Parameter, MagicSet>();
          fceParameters.put(Parameter.CAUSE, cause);
          fceParameters.put(Parameter.EFFECT, new MagicSet(part));
          Event protection =
              createEvent(
                  game,
                  "White creatures you control gain protection from the chosen color until end of turn.",
                  EventType.CREATE_FLOATING_CONTINUOUS_EFFECT,
                  fceParameters);
          protection.perform(event, false);

          return true;
        }