Tabnine Logo
Player.canBeTargetedBy
Code IndexAdd Tabnine to your IDE (free)

How to use
canBeTargetedBy
method
in
mage.players.Player

Best Java code snippets using mage.players.Player.canBeTargetedBy (Showing top 20 results out of 315)

origin: magefree/mage

@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
  Set<UUID> possibleTargets = new HashSet<>();
  MageObject targetSource = game.getObject(sourceId);
  for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
    Player player = game.getPlayer(playerId);
    if (player != null && !player.hasLeft() && filter.match(player, sourceId, sourceControllerId, game)) {
      if (isNotTarget() || player.canBeTargetedBy(targetSource, sourceControllerId, game)) {
        possibleTargets.add(playerId);
      }
    }
  }
  return possibleTargets;
}
origin: magefree/mage

@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
  Set<UUID> possibleTargets = new HashSet<>();
  MageObject targetSource = game.getObject(sourceId);
  for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
    Player player = game.getPlayer(playerId);
    if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) {
      possibleTargets.add(playerId);
    }
  }
  for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT, sourceControllerId, game)) {
    if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) {
      possibleTargets.add(permanent.getId());
    }
  }
  return possibleTargets;
}
origin: magefree/mage

@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
  Set<UUID> possibleTargets = new HashSet<>();
  MageObject targetSource = game.getObject(sourceId);
  for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
    Player player = game.getPlayer(playerId);
    if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) {
      possibleTargets.add(playerId);
    }
  }
  for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, sourceControllerId, game)) {
    if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) {
      possibleTargets.add(permanent.getId());
    }
  }
  return possibleTargets;
}
origin: magefree/mage

@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
  Set<UUID> possibleTargets = new HashSet<>();
  MageObject targetSource = game.getObject(sourceId);
  for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
    Player player = game.getPlayer(playerId);
    if (player != null
        && (notTarget 
        || player.canBeTargetedBy(targetSource, sourceControllerId, game))
        && filter.match(player, game)) {
      possibleTargets.add(playerId);
    }
  }
  for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_PLANESWALKER, sourceControllerId, game)) {
    if ((notTarget 
        || permanent.canBeTargetedBy(targetSource, sourceControllerId, game))
        && filter.match(permanent, game)) {
      possibleTargets.add(permanent.getId());
    }
  }
  return possibleTargets;
}
origin: magefree/mage

@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
  Set<UUID> possibleTargets = new HashSet<>();
  MageObject targetSource = game.getObject(sourceId);
  for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
    Player player = game.getPlayer(playerId);
    if (player != null && (notTarget || player.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.getPlayerFilter().match(player, sourceId, sourceControllerId, game)) {
      possibleTargets.add(playerId);
    }
  }
  for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterPermanent(), sourceControllerId, game)) {
    if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(permanent, sourceId, sourceControllerId, game)) {
      possibleTargets.add(permanent.getId());
    }
  }
  return possibleTargets;
}
origin: magefree/mage

@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
  Set<UUID> possibleTargets = new HashSet<>();
  MageObject targetSource = game.getObject(sourceId);
  for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
    Player player = game.getPlayer(playerId);
    if (player != null
        && player.canBeTargetedBy(targetSource, sourceControllerId, game)
        && filter.getPlayerFilter().match(player, sourceId, sourceControllerId, game)) {
      possibleTargets.add(playerId);
    }
  }
  for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getCreatureFilter(), sourceControllerId, game)) {
    if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)
        && filter.getCreatureFilter().match(permanent, sourceId, sourceControllerId, game)) {
      possibleTargets.add(permanent.getId());
    }
  }
  return possibleTargets;
}
origin: magefree/mage

/**
 * Checks if there are enough {@link Player} that can be chosen. Should only
 * be used for Ability targets since this checks for protection, shroud etc.
 *
 * @param sourceId - the target event source
 * @param sourceControllerId - controller of the target event source
 * @param game
 * @return - true if enough valid {@link Player} exist
 */
@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
  int count = 0;
  MageObject targetSource = game.getObject(sourceId);
  for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
    Player player = game.getPlayer(playerId);
    if (player != null && !player.hasLeft() && filter.match(player, sourceId, sourceControllerId, game)) {
      if (player.canBeTargetedBy(targetSource, sourceControllerId, game)) {
        count++;
        if (count >= this.minNumberOfTargets) {
          return true;
        }
      }
    }
  }
  return false;
}
origin: magefree/mage

@Override
public boolean canTarget(UUID id, Ability source, Game game) {
  Player player = game.getPlayer(id);
  if (player != null) {
    if (source != null) {
      return (isNotTarget() || player.canBeTargetedBy(game.getObject(source.getSourceId()), source.getControllerId(), game))
          && filter.match(player, source.getSourceId(), source.getControllerId(), game);
    } else {
      return filter.match(player, game);
    }
  }
  return false;
}
origin: magefree/mage

@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
  Set<UUID> possibleTargets = new HashSet<>();
  MageObject targetSource = game.getObject(sourceId);
  for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
    Player player = game.getPlayer(playerId);
    if (player != null
        && player.canBeTargetedBy(targetSource, sourceControllerId, game)
        && filter.getPlayerFilter().match(player, sourceId, sourceControllerId, game)) {
      possibleTargets.add(playerId);
    }
  }
  for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getCreatureFilter(), sourceControllerId, game)) {
    if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)
        && filter.getCreatureFilter().match(permanent, sourceId, sourceControllerId, game)) {
      possibleTargets.add(permanent.getId());
    }
  }
  for (Permanent planeswalker : game.getBattlefield().getActivePermanents(filter.getPlaneswalkerFilter(), sourceControllerId, game)) {
    if (planeswalker.canBeTargetedBy(targetSource, sourceControllerId, game)
        && filter.getPlaneswalkerFilter().match(planeswalker, sourceId, sourceControllerId, game)) {
      possibleTargets.add(planeswalker.getId());
    }
  }
  return possibleTargets;
}
origin: magefree/mage

@Override
public boolean canTarget(UUID id, Ability source, Game game) {
  Player player = game.getPlayer(id);
  MageObject targetSource = game.getObject(attackerId);
  if (player != null) {
    return (notTarget 
        || player.canBeTargetedBy(targetSource, (source == null ? null : source.getControllerId()), game))
        && filter.match(player, game);
  }
  Permanent permanent = game.getPermanent(id); // planeswalker
  if (permanent != null) {
    //Could be targeting due to combat decision to attack a player or planeswalker.
    UUID controllerId = null;
    if (source != null) {
      controllerId = source.getControllerId();
    }
    return (notTarget 
        || permanent.canBeTargetedBy(targetSource, controllerId, game))
        && filter.match(permanent, game);
  }
  return false;
}
origin: magefree/mage

@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
  int count = 0;
  MageObject targetSource = game.getObject(sourceId);
  for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
    Player player = game.getPlayer(playerId);
    if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) {
      count++;
      if (count >= this.minNumberOfTargets) {
        return true;
      }
    }
  }
  for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, sourceControllerId, game)) {
    if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) {
      count++;
      if (count >= this.minNumberOfTargets) {
        return true;
      }
    }
  }
  return false;
}
origin: magefree/mage

@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
  int count = 0;
  MageObject targetSource = game.getObject(sourceId);
  Player controller = game.getPlayer(sourceControllerId);
  if (controller != null && targetSource != null) {
    for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
      Player player = game.getPlayer(playerId);
      if (player != null
          && controller.getLife() < player.getLife()
          && !player.hasLeft()
          && filter.match(player, sourceId, sourceControllerId, game)
          && player.canBeTargetedBy(targetSource, sourceControllerId, game)) {
        count++;
        if (count >= this.minNumberOfTargets) {
          return true;
        }
      }
    }
  }
  return false;
}
origin: magefree/mage

@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
  int count = 0;
  MageObject targetSource = game.getObject(sourceId);
  for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
    Player player = game.getPlayer(playerId);
    if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) {
      count++;
      if (count >= this.minNumberOfTargets) {
        return true;
      }
    }
  }
  for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT, sourceControllerId, game)) {
    if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) {
      count++;
      if (count >= this.minNumberOfTargets) {
        return true;
      }
    }
  }
  return false;
}
origin: magefree/mage

@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
  int count = 0;
  MageObject targetSource = game.getObject(sourceId);
  for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
    Player player = game.getPlayer(playerId);
    if (player != null
        && (notTarget || player.canBeTargetedBy(targetSource, sourceControllerId, game))
        && filter.match(player, game)) {
      count++;
      if (count >= this.minNumberOfTargets) {
        return true;
      }
    }
  }
  for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_PLANESWALKER, sourceControllerId, game)) {
    if ((notTarget 
        || permanent.canBeTargetedBy(targetSource, sourceControllerId, game))
        && filter.match(permanent, game)) {
      count++;
      if (count >= this.minNumberOfTargets) {
        return true;
      }
    }
  }
  return false;
}
origin: magefree/mage

@Override
public boolean canTarget(UUID objectId, Ability source, Game game) {
  Permanent permanent = game.getPermanent(objectId);
  Player player = game.getPlayer(objectId);
  if (source != null) {
    MageObject targetSource = source.getSourceObject(game);
    if (permanent != null) {
      return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
    }
    if (player != null) {
      return player.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(player, game);
    }
  }
  if (permanent != null) {
    return filter.match(permanent, game);
  }
  return player != null && filter.match(player, game);
}
origin: magefree/mage

@Override
public boolean canTarget(UUID objectId, Ability source, Game game) {
  Permanent permanent = game.getPermanent(objectId);
  Player player = game.getPlayer(objectId);
  if (source != null) {
    MageObject targetSource = source.getSourceObject(game);
    if (permanent != null) {
      return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
    }
    if (player != null) {
      return player.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(player, game);
    }
  }
  if (permanent != null) {
    return filter.match(permanent, game);
  }
  return player != null && filter.match(player, game);
}
origin: magefree/mage

@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
  int count = 0;
  MageObject targetSource = game.getObject(sourceId);
  Player controller = game.getPlayer(sourceControllerId);
  if (controller != null && targetSource != null) {
    for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
      Player player = game.getPlayer(playerId);
      if (player != null
          && game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, sourceControllerId, game)
          < game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, playerId, game)
          && !player.hasLeft()
          && filter.match(player, sourceId, sourceControllerId, game)
          && player.canBeTargetedBy(targetSource, sourceControllerId, game)) {
        count++;
        if (count >= this.minNumberOfTargets) {
          return true;
        }
      }
    }
  }
  return false;
}
origin: magefree/mage

@Override
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
  Permanent permanent = game.getPermanent(id);
  Player player = game.getPlayer(id);
  if (source != null) {
    MageObject targetSource = game.getObject(source.getSourceId());
    if (permanent != null) {
      return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
    }
    if (player != null) {
      return player.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(player, game);
    }
  }
  if (permanent != null) {
    return filter.match(permanent, game);
  }
  return player != null && filter.match(player, game);
}
origin: magefree/mage

@Override
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
  Permanent permanent = game.getPermanent(id);
  Player player = game.getPlayer(id);
  if (source != null) {
    MageObject targetSource = game.getObject(source.getSourceId());
    if (permanent != null) {
      return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
    }
    if (player != null) {
      return player.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(player, game);
    }
  }
  if (permanent != null) {
    return filter.match(permanent, game);
  }
  return player != null && filter.match(player, game);
}
origin: magefree/mage

@Override
public boolean canTarget(UUID id, Ability source, Game game) {
  Permanent permanent = game.getPermanent(id);
  Player player = game.getPlayer(id);
  if (source != null) {
    MageObject targetSource = game.getObject(source.getSourceId());
    if (permanent != null) {
      if (!isNotTarget()) {
        if (!permanent.canBeTargetedBy(game.getObject(source.getId()), source.getControllerId(), game)
            || !permanent.canBeTargetedBy(game.getObject(source.getSourceId()), source.getControllerId(), game)) {
          return false;
        }
      }
      return filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
    }
    if (player != null) {
      if (!isNotTarget()) {
        if (!player.canBeTargetedBy(targetSource, source.getControllerId(), game)
            || !filter.match(player, source.getSourceId(), source.getControllerId(), game)) {
          return false;
        }
      }
      return filter.match(player, game);
    }
  }
  if (permanent != null) {
    return filter.match(permanent, game);
  }
  return player != null && filter.match(player, game);
}
mage.playersPlayercanBeTargetedBy

Popular methods of Player

  • getId
  • getHand
  • getName
  • getLife
  • getLibrary
  • hasLeft
  • hasWon
  • getCounters
  • hasLost
  • copy
  • damage
  • declareAttacker
  • damage,
  • declareAttacker,
  • getGraveyard,
  • getPlayersUnderYourControl,
  • activateAbility,
  • canLose,
  • choose,
  • declareBlocker,
  • gainLife,
  • getAttachments

Popular in Java

  • Reactive rest calls using spring rest template
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (Timer)
  • setRequestProperty (URLConnection)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now