Example #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;
          }
Example #2
0
    public EntwineAdditionalCost(GameState state, CostCollection costs, String costName) {
      super(
          state,
          "If you choose all the modes of this spell, you pay an additional " + costName + ".");

      this.costCollection = costs;
      this.costName = costName;

      Set newCosts = Set.fromCollection(costs.manaCost);
      newCosts.addAll(costs.events);

      ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.COST_ADDITION);
      part.parameters.put(ContinuousEffectType.Parameter.OBJECT, This.instance());
      part.parameters.put(ContinuousEffectType.Parameter.COST, Identity.fromCollection(newCosts));
      this.addEffectPart(part);

      // This only applies if you've chosen all of its modes
      this.canApply =
          Not.instance(
              RelativeComplement.instance(
                  ModesOf.instance(This.instance()), SelectedModesOf.instance(This.instance())));
    }
Example #3
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;
  }