Package mage

Examples of mage.MageObject


  @Override
  public boolean resolve(Game game) {
    if (optional) {
      Player player = game.getPlayer(this.getControllerId());
      MageObject object = game.getObject(sourceId);
      StringBuilder sb = new StringBuilder();
      sb.append("Use ").append(this.getRule()).append("ability");
      if (object != null) {
        sb.append(" from ").append(object.getName());
      }
      sb.append("?");
      if (!player.chooseUse(this.effects.get(0).getOutcome(), sb.toString(), game)) {
        return false;
      }
View Full Code Here


    return sb.toString();
  }

  @Override
  public boolean canTarget(UUID id, Game game) {
    MageObject object = game.getObject(id);
    if (object != null && game.getZone(id).match(zone))
      return getFilter().match(object);
    return false;
  }
View Full Code Here

  }

  @Override
  public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
    int count = 0;
    MageObject targetSource = game.getObject(sourceId);
    for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
      Player player = game.getPlayer(playerId);
      if (player != null && !player.hasLeft() && filter.match(player)) {
        if (player.canBeTargetedBy(targetSource)) {
          count++;
View Full Code Here

  }

  @Override
  public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
    Set<UUID> possibleTargets = new HashSet<UUID>();
    MageObject targetSource = game.getObject(sourceId);
    for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
      Player player = game.getPlayer(playerId);
      if (player != null && !player.hasLeft() && filter.match(player)) {
        if (player.canBeTargetedBy(targetSource))
          possibleTargets.add(playerId);
View Full Code Here

  }

  @Override
  public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
    int count = 0;
    MageObject targetSource = game.getObject(sourceId);
    for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, game)) {
      if (permanent.canBeTargetedBy(targetSource)) {
        count++;
        if (count >= this.minNumberOfTargets)
          return true;
View Full Code Here

  }

  @Override
  public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
    Set<UUID> possibleTargets = new HashSet<UUID>();
    MageObject targetSource = game.getObject(sourceId);
    for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, game)) {
      if (permanent.canBeTargetedBy(targetSource)) {
        possibleTargets.add(permanent.getId());
      }
    }
View Full Code Here

      if (spell != null) {
        if (filterTarget.match(spell)) {
          if (filterSource == null)
            return true;
          else {
            MageObject sourceObject = game.getObject(source.getSourceId());
            if (sourceObject != null && filterSource.match(sourceObject)) {
              return true;
            }
          }
        }
View Full Code Here

    super(ability);
  }

  @Override
  public boolean canActivate(UUID playerId, Game game) {
    MageObject object = game.getObject(sourceId);
    if ((object.getCardType().contains(CardType.INSTANT) ||
        object.getAbilities().containsKey(FlashAbility.getInstance().getId()) ||
        game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.CAST, game) ||
        game.canPlaySorcery(playerId))) {
      if (costs.canPay(sourceId, controllerId, game) && targets.canChoose(sourceId, playerId, game)) {
        return true;
      }
View Full Code Here

    return state.getPlayer(playerId);
  }

  @Override
  public MageObject getObject(UUID objectId) {
    MageObject object;
    if (state.getBattlefield().containsPermanent(objectId)) {
      object = state.getBattlefield().getPermanent(objectId);
      state.setZone(objectId, Zone.BATTLEFIELD);
      return object;
    }
View Full Code Here

  }

  @Override
  public boolean canTarget(UUID id, Ability source, Game game) {
    Permanent permanent = game.getPermanent(id);
    MageObject targetSource = game.getObject(source.getSourceId());
    if (permanent != null) {
      if (source != null)
        return permanent.canBeTargetedBy(targetSource) && filter.match(permanent, source.getControllerId(), game);
      else
        return filter.match(permanent);
View Full Code Here

TOP

Related Classes of mage.MageObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.