Beispiel #1
0
    public AnotherCreatureEntersTheBattlefield(GameState state) {
      super(
          state,
          "Whenever another creature enters the battlefield under your control, if you control both that creature and this one and both are unpaired, you may pair that creature with this creature for as long as both remain creatures on the battlefield under your control.");
      SetGenerator thisCreature = ABILITY_SOURCE_OF_THIS;
      SetGenerator otherCreatures =
          RelativeComplement.instance(CreaturePermanents.instance(), thisCreature);
      this.addPattern(
          new SimpleZoneChangePattern(
              null, Battlefield.instance(), otherCreatures, You.instance(), false));

      SetGenerator thatCreature = NewObjectOf.instance(TriggerZoneChange.instance(This.instance()));
      SetGenerator youControl = ControlledBy.instance(You.instance());
      SetGenerator youControlUnpairedThis =
          Intersect.instance(youControl, Unpaired.instance(), thisCreature);
      SetGenerator youControlUnpairedThat =
          Intersect.instance(youControl, Unpaired.instance(), thatCreature);
      this.interveningIf = Both.instance(youControlUnpairedThis, youControlUnpairedThat);

      ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.PAIR);
      part.parameters.put(
          ContinuousEffectType.Parameter.OBJECT, Union.instance(thisCreature, thatCreature));

      SetGenerator youControlCreatureThis = Intersect.instance(CREATURES_YOU_CONTROL, thisCreature);
      SetGenerator youControlCreatureThat = Intersect.instance(CREATURES_YOU_CONTROL, thatCreature);
      SetGenerator expires =
          Not.instance(Both.instance(youControlCreatureThis, youControlCreatureThat));
      EventFactory floatingEffect =
          createFloatingEffect(expires, "Pair this creature with that creature", part);

      this.addEffect(youMay(floatingEffect));
    }
Beispiel #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 CountrysideCrusherAbility0(GameState state) {
      super(
          state,
          "At the beginning of your upkeep, reveal the top card of your library. If it's a land card, put it into your graveyard and repeat this process.");
      this.addPattern(atTheBeginningOfYourUpkeep());

      SetGenerator yourLibrary = LibraryOf.instance(You.instance());
      SetGenerator toReveal =
          TopMost.instance(
              yourLibrary,
              numberGenerator(1),
              RelativeComplement.instance(
                  InZone.instance(yourLibrary), HasType.instance(Type.LAND)));

      EventFactory reveal =
          new EventFactory(
              EventType.REVEAL,
              "Reveal cards from the top of your library until you reveal a nonland card.");
      reveal.parameters.put(EventType.Parameter.CAUSE, This.instance());
      reveal.parameters.put(EventType.Parameter.OBJECT, toReveal);
      this.addEffect(reveal);

      SetGenerator landsRevealed = Intersect.instance(toReveal, HasType.instance(Type.LAND));

      EventFactory pitch =
          new EventFactory(
              EventType.PUT_INTO_GRAVEYARD, "Put all revealed nonland cards into your graveyard.");
      pitch.parameters.put(EventType.Parameter.CAUSE, This.instance());
      pitch.parameters.put(EventType.Parameter.OBJECT, landsRevealed);
      this.addEffect(pitch);
    }
Beispiel #4
0
    public ThisEntersTheBattlefield(GameState state) {
      super(
          state,
          "When this creature enters the battlefield, if you control both this creature and another creature and both are unpaired, you may pair this creature with another unpaired creature you control for as long as both remain creatures on the battlefield under your control.");
      SetGenerator thisCreature = ABILITY_SOURCE_OF_THIS;
      this.addPattern(
          new SimpleZoneChangePattern(null, Battlefield.instance(), thisCreature, false));

      SetGenerator otherCreaturesYouControl =
          RelativeComplement.instance(CREATURES_YOU_CONTROL, thisCreature);
      SetGenerator youControl = ControlledBy.instance(You.instance());
      SetGenerator youControlUnpairedThis =
          Intersect.instance(youControl, Unpaired.instance(), thisCreature);
      SetGenerator youControlUnpairedOtherCreatures =
          Intersect.instance(Unpaired.instance(), otherCreaturesYouControl);
      this.interveningIf = Both.instance(youControlUnpairedThis, youControlUnpairedOtherCreatures);

      EventFactory choose =
          playerChoose(
              You.instance(),
              1,
              youControlUnpairedOtherCreatures,
              PlayerInterface.ChoiceType.OBJECTS,
              REASON,
              "Choose another unpaired creature you control");
      SetGenerator thatCreature = EffectResult.instance(choose);

      ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.PAIR);
      part.parameters.put(
          ContinuousEffectType.Parameter.OBJECT, Union.instance(thisCreature, thatCreature));

      SetGenerator youControlCreatureThis = Intersect.instance(CREATURES_YOU_CONTROL, thisCreature);
      SetGenerator youControlCreatureThat = Intersect.instance(CREATURES_YOU_CONTROL, thatCreature);
      SetGenerator expires =
          Not.instance(Both.instance(youControlCreatureThis, youControlCreatureThat));
      EventFactory floatingEffect =
          createFloatingEffect(expires, "and pair this creature with the chosen creature.", part);

      this.addEffect(
          youMay(
              sequence(choose, floatingEffect),
              "You may pair this creature with another unpaired creature you control for as long as both remain creatures on the battlefield under your control."));
    }
Beispiel #5
0
    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);
    }
    public ShrineofBoundlessGrowthAbility0(GameState state) {
      super(
          state,
          "At the beginning of your upkeep or whenever you cast a green spell, put a charge counter on Shrine of Boundless Growth.");
      this.addPattern(atTheBeginningOfYourUpkeep());

      SimpleEventPattern castABlueSpell = new SimpleEventPattern(EventType.BECOMES_PLAYED);
      castABlueSpell.put(EventType.Parameter.PLAYER, You.instance());
      castABlueSpell.put(
          EventType.Parameter.OBJECT,
          Intersect.instance(Spells.instance(), HasColor.instance(Color.GREEN)));
      this.addPattern(castABlueSpell);

      this.addEffect(
          putCounters(
              1,
              Counter.CounterType.CHARGE,
              ABILITY_SOURCE_OF_THIS,
              "Put a charge counter on Shrine of Boundless Growth."));
    }
  @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;
  }