예제 #1
0
          @Override
          public boolean perform(Game game, Event event, java.util.Map<Parameter, Set> parameters) {
            Set cards = new Set();

            for (Player player : parameters.get(Parameter.PLAYER).getAll(Player.class))
              cards.addAll(player.getHand(game.actualState).objects);

            java.util.Map<Parameter, Set> discardParameters =
                new java.util.HashMap<Parameter, Set>();
            discardParameters.put(EventType.Parameter.CAUSE, parameters.get(Parameter.CAUSE));
            discardParameters.put(EventType.Parameter.CARD, cards);
            Event discardEvent =
                createEvent(
                    game,
                    "Each player discards his or her hand",
                    EventType.DISCARD_CARDS,
                    discardParameters);
            discardEvent.perform(event, true);

            java.util.Map<Parameter, Set> drawParameters = new java.util.HashMap<Parameter, Set>();
            drawParameters.put(EventType.Parameter.CAUSE, parameters.get(Parameter.CAUSE));
            drawParameters.put(EventType.Parameter.PLAYER, parameters.get(Parameter.PLAYER));
            drawParameters.put(EventType.Parameter.NUMBER, new Set(4));
            Event drawEvent =
                createEvent(game, "and draws four cards.", EventType.DRAW_CARDS, drawParameters);
            drawEvent.perform(event, true);

            event.setResult(Empty.set);

            return true;
          }
예제 #2
0
        @Override
        public boolean perform(Game game, Event event, Map<Parameter, MagicSet> parameters) {
          event.setResult(Empty.set);

          MagicSet cause = parameters.get(Parameter.CAUSE);
          Player you = parameters.get(Parameter.PLAYER).getOne(Player.class);
          Zone library = you.getLibrary(game.actualState);

          Map<Parameter, MagicSet> zombieParameters = new HashMap<Parameter, MagicSet>();
          zombieParameters.put(Parameter.CAUSE, cause);
          zombieParameters.put(Parameter.PLAYER, new MagicSet(you));
          zombieParameters.put(Parameter.NUMBER, ONE);
          zombieParameters.put(Parameter.CARD, new MagicSet(library));
          zombieParameters.put(Parameter.TYPE, new MagicSet(HasSubType.instance(SubType.ZOMBIE)));
          Event zombieSearch =
              createEvent(game, "Search your library for a Zombie card", SEARCH, zombieParameters);
          zombieSearch.perform(event, false);

          Map<Parameter, MagicSet> swampParameters =
              new HashMap<Parameter, MagicSet>(zombieParameters);
          swampParameters.put(Parameter.TYPE, new MagicSet(HasSubType.instance(SubType.SWAMP)));
          Event swampSearch =
              createEvent(game, "Search your library for a Swamp card", SEARCH, swampParameters);
          swampSearch.perform(event, false);

          MagicSet thoseCards = new MagicSet();
          thoseCards.addAll(zombieSearch.getResult());
          thoseCards.addAll(swampSearch.getResult());

          Map<Parameter, MagicSet> moveParameters = new HashMap<Parameter, MagicSet>();
          moveParameters.put(Parameter.CAUSE, cause);
          moveParameters.put(Parameter.TO, new MagicSet(you.getHand(game.actualState)));
          moveParameters.put(Parameter.OBJECT, thoseCards);
          Event move =
              createEvent(game, "Put those cards into your hand", MOVE_OBJECTS, moveParameters);
          move.perform(event, true);

          Map<Parameter, MagicSet> shuffleParameters = new HashMap<Parameter, MagicSet>();
          shuffleParameters.put(Parameter.CAUSE, cause);
          shuffleParameters.put(Parameter.PLAYER, new MagicSet(you));
          Event shuffle =
              createEvent(game, "Shuffle your library", SHUFFLE_LIBRARY, shuffleParameters);
          shuffle.perform(event, true);

          return true;
        }
  @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;
  }
예제 #4
0
        @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;
        }
예제 #5
0
  @Override
  public boolean perform(Game game, Event event, java.util.Map<Parameter, Set> parameters) {
    boolean allDiscarded = event.allChoicesMade;
    Set cause = parameters.get(Parameter.CAUSE);
    Set result = new Set();

    for (Player player : parameters.get(Parameter.PLAYER).getAll(Player.class)) {
      Set discardThese = event.getChoices(player);

      java.util.Map<Parameter, Set> discardParameters = new java.util.HashMap<Parameter, Set>();
      discardParameters.put(Parameter.CAUSE, cause);
      discardParameters.put(Parameter.CARD, discardThese);
      Event discard =
          createEvent(
              game, player + " discards " + discardThese + ".", DISCARD_CARDS, discardParameters);
      if (!discard.perform(event, false)) allDiscarded = false;
      result.addAll(discard.getResult());
    }

    event.setResult(Identity.instance(result));
    return allDiscarded;
  }
예제 #6
0
  @Override
  public boolean perform(Game game, Event event, Map<Parameter, MagicSet> parameters) {
    GameObject permanent = parameters.get(Parameter.PERMANENT).getOne(GameObject.class);
    Player owner = permanent.getOwner(game.actualState);
    Zone graveyard = owner.getGraveyard(game.actualState);

    Map<Parameter, MagicSet> moveParameters = new HashMap<Parameter, MagicSet>();
    moveParameters.put(Parameter.CAUSE, parameters.get(Parameter.CAUSE));
    moveParameters.put(Parameter.TO, new MagicSet(graveyard));
    moveParameters.put(Parameter.OBJECT, new MagicSet(permanent));

    // move the permanent to the graveyard
    Event move =
        createEvent(
            game,
            "Put " + permanent + " in " + owner + "'s graveyard.",
            MOVE_OBJECTS,
            moveParameters);
    boolean status = move.perform(event, false);

    event.setResult(move.getResultGenerator());
    return status;
  }
예제 #7
0
  @Override
  public boolean perform(Game game, Event event, Map<Parameter, MagicSet> parameters) {
    int lifeGain = Sum.get(parameters.get(Parameter.NUMBER));
    if (lifeGain <= 0) {
      event.setResult(Empty.set);
      return true;
    }

    MagicSet result = new MagicSet();
    MagicSet players = parameters.get(Parameter.PLAYER);
    for (Player player : players.getAll(Player.class)) {
      HashMap<Parameter, MagicSet> newParameters = new HashMap<Parameter, MagicSet>(parameters);
      newParameters.put(Parameter.PLAYER, new MagicSet(player));
      Event gain =
          createEvent(
              game, player + " gains " + lifeGain + " life", GAIN_LIFE_ONE_PLAYER, newParameters);
      gain.perform(event, false);
      result.addAll(gain.getResult());
    }

    event.setResult(result);
    return true;
  }