Package mage.game.permanent

Examples of mage.game.permanent.Permanent


      Player player = game.getPlayer(card.getOwnerId());
      if (player != null) {
        player.removeFromGraveyard(card, game);
        if (card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getId(), source.getControllerId())) {
          if (tapped) {
            Permanent permanent = game.getPermanent(card.getId());
            if (permanent != null)
              permanent.setTapped(true);
          }
          return true;
        }
      }
    }
View Full Code Here


    this.name = cost.name;
  }

  @Override
  public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
    Permanent permanent = game.getPermanent(sourceId);
    if (permanent.getCounters().getCount(name) >= amount)
      return true;
    return false;
  }
View Full Code Here

    return false;
  }

  @Override
  public boolean pay(Game game, UUID sourceId, UUID controllerId, boolean noMana) {
    Permanent permanent = game.getPermanent(sourceId);
    if (permanent != null && permanent.getCounters().getCount(name) >= amount) {
      permanent.removeCounters(name, amount, game);
      this.paid = true;
    }
    return paid;
  }
View Full Code Here

        for (UUID cardId: (List<UUID>)target.getTargets()) {
          Card card = player.getLibrary().remove(cardId, game);
          if (card != null) {
            if (card.putOntoBattlefield(game, Zone.HAND, source.getId(), source.getControllerId())) {
              if (tapped) {
                Permanent permanent = game.getPermanent(card.getId());
                if (permanent != null)
                  permanent.setTapped(true);
              }
            }
          }
        }
        player.shuffleLibrary(game);
View Full Code Here

  @Override
  public boolean pay(Game game, UUID sourceId, UUID controllerId, boolean noMana) {
    if (targets.choose(Outcome.ReturnToHand, controllerId, game)) {
      for (UUID targetId: targets.get(0).getTargets()) {
        Permanent permanent = game.getPermanent(targetId);
        if (permanent == null)
          return false;
        paid |= permanent.moveToZone(Zone.HAND, sourceId, game, false);
      }
    }
    return paid;
  }
View Full Code Here

    return new AttacksIfAbleTargetEffect(this);
  }

  @Override
  public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(source.getFirstTarget());
    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

    super(effect);
  }

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

  @Override
  public boolean removeFromBattlefield(Permanent permanent, Game game) {
    permanent.removeFromCombat(game);
    game.getBattlefield().removePermanent(permanent.getId());
    if (permanent.getAttachedTo() != null) {
      Permanent attachedTo = game.getPermanent(permanent.getAttachedTo());
      if (attachedTo != null)
        attachedTo.removeAttachment(permanent.getId(), game);
    }
    return true;
  }
View Full Code Here

      GameEvent event = new DamagePlayerEvent(playerId, sourceId, playerId, damage, preventable, combatDamage);
      if (!game.replaceEvent(event)) {
        int actualDamage = event.getAmount();
        if (actualDamage > 0) {
          actualDamage = this.loseLife(actualDamage, game);
          Permanent source = game.getPermanent(sourceId);
          if (source != null && source.getAbilities().containsKey(LifelinkAbility.getInstance().getId())) {
            Player player = game.getPlayer(source.getControllerId());
            player.gainLife(actualDamage, game);
          }
          game.fireEvent(new DamagedPlayerEvent(playerId, sourceId, playerId, actualDamage, combatDamage));
//          game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DAMAGED_PLAYER, playerId, sourceId, playerId, actualDamage));
//          if (combatDamage)
View Full Code Here

    //20100423 - 800.4a
    this.hand.clear();
    this.graveyard.clear();
    this.library.clear();
    for (Iterator<Permanent> it = game.getBattlefield().getAllPermanents().iterator(); it.hasNext();) {
      Permanent perm = it.next();
      if (perm.getOwnerId().equals(playerId)) {
        if (perm.getAttachedTo() != null) {
          Permanent attachedTo = game.getPermanent(perm.getAttachedTo());
          if (attachedTo != null)
            attachedTo.removeAttachment(perm.getId(), game);
        }
        it.remove();
      }
    }
    for (Iterator<StackObject> it = game.getStack().iterator(); it.hasNext();) {
      StackObject object = it.next();
      if (object.getControllerId().equals(playerId)) {
        it.remove();
      }
    }
    for (Iterator<Permanent> it = game.getBattlefield().getAllPermanents().iterator(); it.hasNext();) {
      Permanent perm = it.next();
      if (perm.getControllerId().equals(playerId)) {
        perm.moveToExile(null, "", null, game);
      }
    }
  }
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.