@Override public MagicSet evaluate(GameState state, Identified thisObject) { MagicSet allAttackers = Attacking.get(state); if (this.what == null) return allAttackers; Set<Integer> beingAttackedIDs = new HashSet<Integer>(); MagicSet evaluateWhat = this.what.evaluate(state, thisObject); for (GameObject o : evaluateWhat.getAll(GameObject.class)) if (o.getTypes().contains(Type.PLANESWALKER)) beingAttackedIDs.add(o.ID); for (Player p : evaluateWhat.getAll(Player.class)) beingAttackedIDs.add(p.ID); Set<GameObject> attackingThisPlayer = allAttackers.getAll(GameObject.class); Iterator<GameObject> objectIterator = attackingThisPlayer.iterator(); while (objectIterator.hasNext()) { GameObject attacker = objectIterator.next(); if (!beingAttackedIDs.contains(attacker.getAttackingID())) objectIterator.remove(); } return new MagicSet(attackingThisPlayer); }
@Override protected boolean match(GameState state, Event event) { if (event.type != EventType.MOVE_BATCH) return false; for (ZoneChange change : event .parametersNow .get(EventType.Parameter.TARGET) .evaluate(state, null) .getAll(ZoneChange.class)) { if (state.battlefield().ID != change.destinationZoneID) continue; GameObject object = state.get(change.newObjectID); if (!object.getColors().contains(Color.GREEN) || !object.getTypes().contains(Type.CREATURE)) continue; return true; } return false; }