@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) { 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; }