Exemple #1
0
  @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);
  }
Exemple #2
0
 public static MagicSet get(GameState state) {
   MagicSet ret = new MagicSet();
   for (GameObject o : state.battlefield()) if (-1 != o.getAttackingID()) ret.add(o);
   return ret;
 }