Package mage.game.permanent

Examples of mage.game.permanent.Permanent


  }

  @Override
  public boolean apply(Game game, Ability source) {
    for (UUID target: source.getTargets().get(0).getTargets()) {
      Permanent permanent = game.getPermanent(target);
      if (permanent != null) {
        permanent.setTapped(false);
      }
      else {
        return false;
      }
    }
View Full Code Here


  public void removeInactiveEffects(Game game) {
    for (Iterator<ContinuousEffect> i = layeredEffects.iterator(); i.hasNext();) {
      ContinuousEffect entry = i.next();
      if (entry.getDuration() == Duration.WhileOnBattlefield) {
        Permanent permanent = game.getPermanent(abilityMap.get(entry.getId()).getSourceId());
        if (permanent == null || !permanent.isPhasedIn())
          i.remove();
      }
      else if (entry.getDuration() == Duration.OneUse && entry.isUsed())
        i.remove();
    }
    for (Iterator<ReplacementEffect> i = replacementEffects.iterator(); i.hasNext();) {
      ReplacementEffect entry = i.next();
      if (entry.getDuration() == Duration.WhileOnBattlefield) {
        Permanent permanent = game.getPermanent(abilityMap.get(entry.getId()).getSourceId());
        if (permanent == null || !permanent.isPhasedIn())
          i.remove();
      }
      else if (entry.getDuration() == Duration.OneUse && entry.isUsed())
        i.remove();
    }
    for (Iterator<PreventionEffect> i = preventionEffects.iterator(); i.hasNext();) {
      PreventionEffect entry = i.next();
      if (entry.getDuration() == Duration.WhileOnBattlefield) {
        Permanent permanent = game.getPermanent(abilityMap.get(entry.getId()).getSourceId());
        if (permanent == null || !permanent.isPhasedIn())
          i.remove();
      }
      else if (entry.getDuration() == Duration.OneUse && entry.isUsed())
        i.remove();
    }
    for (Iterator<AsThoughEffect> i = asThoughEffects.iterator(); i.hasNext();) {
      AsThoughEffect entry = i.next();
      if (entry.getDuration() == Duration.WhileOnBattlefield) {
        Permanent permanent = game.getPermanent(abilityMap.get(entry.getId()).getSourceId());
        if (permanent == null || !permanent.isPhasedIn())
          i.remove();
      }
      else if (entry.getDuration() == Duration.OneUse && entry.isUsed())
        i.remove();
    }
View Full Code Here

    return new BoostEnchantedEffect(this);
  }

  @Override
  public boolean apply(Game game, Ability source) {
    Permanent enchantment = game.getPermanent(source.getSourceId());
    if (enchantment != null && enchantment.getAttachedTo() != null) {
      Permanent creature = game.getPermanent(enchantment.getAttachedTo());
      if (creature != null) {
        creature.addPower(power);
        creature.addToughness(toughness);
      }
    }
    return true;
  }
View Full Code Here

    return new BoostEquippedEffect(this);
  }

  @Override
  public boolean apply(Game game, Ability source) {
    Permanent equipment = game.getPermanent(source.getSourceId());
    if (equipment != null && equipment.getAttachedTo() != null) {
      Permanent creature = game.getPermanent(equipment.getAttachedTo());
      if (creature != null) {
        creature.addPower(power);
        creature.addToughness(toughness);
      }
    }
    return true;
  }
View Full Code Here

    super(effect);
  }

  @Override
  public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(source.getSourceId());
    if (creature != null) {
      if (creature.canAttack(game)) {
        TargetDefender target = new TargetDefender(game.getCombat().getDefenders(), creature.getControllerId());
        target.setRequired(true);
        Player controller = game.getPlayer(creature.getControllerId());
        while (!target.isChosen())
          controller.chooseTarget(Outcome.Damage, target, source, game);
        game.getCombat().declareAttacker(creature.getId(), target.getFirstTarget(), game);
        return true;
      }
    }
    return false;
  }
View Full Code Here

    this.name = effect.name;
  }

  @Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent != null) {
      permanent.addCounters(name, amount);
    }
    return true;
  }
View Full Code Here

    return new BoostSourceWhileControlsEffect(this);
  }

  @Override
  public boolean applyEffect(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent != null) {
      permanent.addPower(power);
      permanent.addToughness(toughness);
    }
    return true;
  }
View Full Code Here

        player.choose(Outcome.Sacrifice, target, game);
      }
      perms.addAll(target.getTargets());
    }
    for (UUID permID: perms) {
      Permanent permanent = game.getPermanent(permID);
      if (permanent != null)
        permanent.sacrifice(source.getSourceId(), game);
    }
    return true;
  }
View Full Code Here

        if (perm.moveToZone(Zone.GRAVEYARD, null, this, false))
          somethingHappened = true;
      }
      else {
        //TODO: handle player auras
        Permanent attachedTo = getPermanent(perm.getAttachedTo());
        if (attachedTo == null) {
          if (perm.moveToZone(Zone.GRAVEYARD, null, this, false))
            somethingHappened = true;
        }
        else {
          Filter auraFilter = perm.getSpellAbility().getTargets().get(0).getFilter();
          if (!auraFilter.match(attachedTo) || attachedTo.hasProtectionFrom(perm)) {
            if (perm.moveToZone(Zone.GRAVEYARD, null, this, false))
              somethingHappened = true;
          }
        }
      }
    }
    //20091005 - 704.5k, 801.12
    if (getBattlefield().countAll(filterLegendary) > 1) {  //don't bother checking if less than 2 legends in play
      for (Permanent legend: getBattlefield().getAllActivePermanents(filterLegendary)) {
        filterLegendName.getName().clear();
        filterLegendName.getName().add(legend.getName());
        if (getBattlefield().count(filterLegendName, legend.getControllerId(), this) > 1) {
          for (Permanent dupLegend: getBattlefield().getActivePermanents(filterLegendName, legend.getControllerId(), this)) {
            dupLegend.moveToZone(Zone.GRAVEYARD, null, this, false);
          }
          return true;
        }
      }
    }
    //20091005 - 704.5p, 702.14d
    for (Permanent perm: getBattlefield().getAllActivePermanents(filterEquipment)) {
      if (perm.getAttachedTo() != null) {
        Permanent creature = getPermanent(perm.getAttachedTo());
        if (creature == null) {
          perm.attachTo(null);
        }
        else if (!creature.getCardType().contains(CardType.CREATURE) || creature.hasProtectionFrom(perm)) {
          if (creature.removeAttachment(perm.getId(), this))
            somethingHappened = true;
        }
      }
    }
    for (Permanent perm: getBattlefield().getAllActivePermanents(filterFortification)) {
      if (perm.getAttachedTo() != null) {
        Permanent land = getPermanent(perm.getAttachedTo());
        if (land == null) {
          perm.attachTo(null);
        }
        else if (!land.getCardType().contains(CardType.LAND) || land.hasProtectionFrom(perm)) {
          if (land.removeAttachment(perm.getId(), this))
            somethingHappened = true;
        }
      }
    }
    //20091005 - 704.5q
    for (Permanent perm: getBattlefield().getAllActivePermanents()) {
      if (perm.getAttachments().size() > 0) {
        for (UUID attachmentId: perm.getAttachments()) {
          Permanent attachment = getPermanent(attachmentId);
          if (attachment != null && !(attachment.getSubtype().contains("Aura") ||
              attachment.getSubtype().contains("Equipment") ||
              attachment.getSubtype().contains("Fortification"))) {
            if (perm.removeAttachment(id, this))
              return true;
          }
        }
      }
View Full Code Here

    return new BoostSourceEffect(this);
  }

  @Override
  public boolean apply(Game game, Ability source) {
    Permanent target = (Permanent) game.getPermanent(source.getSourceId());
    if (target != null) {
      target.addPower(power);
      target.addToughness(toughness);
      return true;
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of mage.game.permanent.Permanent

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.