예제 #1
0
 /**
  * Filters out asThough effects that are not active.
  *
  * @param AsThoughEffectType type
  * @param game
  * @return
  */
 private List<AsThoughEffect> getApplicableAsThoughEffects(AsThoughEffectType type, Game game) {
   List<AsThoughEffect> asThoughEffectsList = new ArrayList<>();
   if (asThoughEffectsMap.containsKey(type)) {
     for (AsThoughEffect effect : asThoughEffectsMap.get(type)) {
       HashSet<Ability> abilities = asThoughEffectsMap.get(type).getAbility(effect.getId());
       for (Ability ability : abilities) {
         if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null)) {
           if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
             asThoughEffectsList.add(effect);
             break;
           }
         }
       }
     }
   }
   return asThoughEffectsList;
 }
예제 #2
0
 public boolean asThough(
     UUID objectId,
     AsThoughEffectType type,
     Ability affectedAbility,
     UUID controllerId,
     Game game) {
   List<AsThoughEffect> asThoughEffectsList = getApplicableAsThoughEffects(type, game);
   for (AsThoughEffect effect : asThoughEffectsList) {
     HashSet<Ability> abilities = asThoughEffectsMap.get(type).getAbility(effect.getId());
     for (Ability ability : abilities) {
       if (affectedAbility == null) {
         if (effect.applies(objectId, ability, controllerId, game)) {
           return true;
         }
       } else {
         if (effect.applies(objectId, affectedAbility, ability, game)) {
           return true;
         }
       }
     }
   }
   return false;
 }