Package mage.game.permanent

Examples of mage.game.permanent.Permanent


    return new GainAbilityAttachedEffect(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.addAbility(ability.copy());
    }
    return true;
  }
View Full Code Here


  @Override
  public boolean apply(Game game, Ability source) {
    Target multiTarget = source.getTargets().get(0);
    for (UUID target: multiTarget.getTargets()) {
      Permanent permanent = game.getPermanent(target);
      if (permanent != null) {
        permanent.damage(multiTarget.getTargetAmount(target), source.getId(), game, true, false);
      }
      else {
        Player player = game.getPlayer(target);
        if (player != null) {
          player.damage(multiTarget.getTargetAmount(target), source.getId(), game, false, true);
View Full Code Here

  public boolean canTarget(UUID id, Ability source, Game game) {
    return canTarget(null, id, source, game);
  }

  public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
    Permanent permanent = game.getPermanent(id);
    if (permanent != null) {
      if (source != null)
        //TODO: check for replacement effects
        return permanent.canBeTargetedBy(game.getObject(source.getSourceId())) && filter.match(permanent, controllerId, game);
      else
        return filter.match(permanent, controllerId, game);
    }
    return false;
  }
View Full Code Here

    return new GainAbilitySourceEffect(this);
  }

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

    return new TapSourceEffect(this);
  }

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

  }

  @Override
  public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    DamageEvent damageEvent = (DamageEvent)event;
    Permanent permanent = game.getPermanent(redirectTarget.getFirstTarget());
    Ability damageSource = getSource(damageEvent.getSourceId(), game);
    if (permanent != null) {
      permanent.damage(damageEvent.getAmount(), damageSource.getId(), game, damageEvent.isPreventable(), damageEvent.isCombatDamage());
      return true;
    }
    Player player = game.getPlayer(redirectTarget.getFirstTarget());
    if (player != null) {
      player.damage(damageEvent.getAmount(), damageSource.getId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable());
View Full Code Here

  }

  @Override
  public boolean apply(Game game, Ability source) {
    int amount = source.getManaCosts().getVariableCosts().get(0).getAmount();
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent != null) {
      permanent.damage(amount, source.getId(), game, true, false);
      return true;
    }
    Player player = game.getPlayer(source.getFirstTarget());
    if (player != null) {
      player.damage(amount, source.getId(), game, false, true);
View Full Code Here

    return new BecomesCreatureSourceEOTEffect(this);
  }

  @Override
  public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent != null) {
      switch (layer) {
        case TypeChangingEffects_4:
          if (sublayer == SubLayer.NA) {
            if (token.getCardType().size() > 0)
              permanent.getCardType().addAll(token.getCardType());
            if (token.getSubtype().size() > 0)
              permanent.getSubtype().addAll(token.getSubtype());
          }
          break;
        case ColorChangingEffects_5:
          if (sublayer == SubLayer.NA) {
            if (token.getColor().hasColor())
              permanent.getColor().setColor(token.getColor());
          }
          break;
        case AbilityAddingRemovingEffects_6:
          if (sublayer == SubLayer.NA) {
            if (token.getAbilities().size() > 0) {
              for (Ability ability: token.getAbilities()) {
                permanent.addAbility(ability);
              }
            }
          }
          break;
        case PTChangingEffects_7:
          if (sublayer == SubLayer.SetPT_7b) {
            if (token.getPower() != MageInt.EmptyMageInt)
              permanent.getPower().setValue(token.getPower().getValue());
            if (token.getToughness() != MageInt.EmptyMageInt)
              permanent.getToughness().setValue(token.getToughness().getValue());
          }
      }
      return true;
    }
    return false;
View Full Code Here

    return new DamageTargetEffect(this);
  }

  @Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent != null) {
      permanent.damage(amount, source.getId(), game, preventable, false);
      return true;
    }
    Player player = game.getPlayer(source.getFirstTarget());
    if (player != null) {
      player.damage(amount, source.getId(), game, false, preventable);
View Full Code Here

  }

  @Override
  public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).getToZone() == Zone.BATTLEFIELD) {
      Permanent permanent = game.getPermanent(event.getTargetId());
      if (permanent != null && permanent.getCardType().contains(CardType.LAND) && permanent.getControllerId().equals(this.controllerId)) {
        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.