Example #1
0
 @Override
 protected boolean match(GameState state, Event event) {
   if (event.type == EventType.CAST_SPELL_OR_ACTIVATE_ABILITY) {
     if (event.getResult(state).getOne(GameObject.class).isSpell()) return true;
   } else if (event.type == EventType.BEGIN_TURN) return true;
   return false;
 }
Example #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;
        }
Example #3
0
 @Override
 protected void update(GameState state, Event event) {
   Set objects = event.getResult(state);
   for (GameObject o : objects.getAll(GameObject.class)) {
     int controllerID = o.getController(state).ID;
     if (this.counts.containsKey(controllerID))
       this.counts.put(controllerID, this.counts.get(controllerID) + 1);
     else this.counts.put(controllerID, 1);
   }
 }
Example #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);
      }
    }
Example #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;
  }
Example #6
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;
  }