Ejemplo n.º 1
0
  @Override
  public boolean chkAIDrawback(SpellAbility sa, Player ai) {

    final Card source = sa.getHostCard();

    final String numDefense = sa.hasParam("NumDef") ? sa.getParam("NumDef") : "";
    final String numAttack = sa.hasParam("NumAtt") ? sa.getParam("NumAtt") : "";

    int defense;
    if (numDefense.contains("X") && source.getSVar("X").equals("Count$xPaid")) {
      defense = Integer.parseInt(source.getSVar("PayX"));
    } else {
      defense = AbilityUtils.calculateAmount(sa.getHostCard(), numDefense, sa);
    }

    int attack;
    if (numAttack.contains("X") && source.getSVar("X").equals("Count$xPaid")) {
      if (source.getSVar("PayX").equals("")) {
        // X is not set yet
        final int xPay = ComputerUtilMana.determineLeftoverMana(sa.getRootAbility(), ai);
        source.setSVar("PayX", Integer.toString(xPay));
        attack = xPay;
      } else {
        attack = Integer.parseInt(source.getSVar("PayX"));
      }
    } else {
      attack = AbilityUtils.calculateAmount(sa.getHostCard(), numAttack, sa);
    }

    if ((sa.getTargetRestrictions() == null) || !sa.getTargetRestrictions().doesTarget()) {
      if (source.isCreature()) {
        if (!source.hasKeyword("Indestructible")
            && ((source.getNetDefense() + defense) <= source.getDamage())) {
          return false;
        }
        if ((source.getNetDefense() + defense) <= 0) {
          return false;
        }
      }
    } else {
      // Targeted
      if (!this.pumpTgtAI(ai, sa, defense, attack, false)) {
        return false;
      }
    }

    return true;
  } // pumpDrawbackAI()
Ejemplo n.º 2
0
  /** {@inheritDoc} */
  @Override
  public boolean canPlay() {
    final Card card = this.getHostCard();
    Player activator = this.getActivatingPlayer();
    if (activator == null) {
      activator = card.getController();
      if (activator == null) {
        return false;
      }
    }

    final Game game = activator.getGame();
    if (game.getStack().isSplitSecondOnStack()) {
      return false;
    }

    if (!(card.isInstant()
        || activator.canCastSorcery()
        || card.hasKeyword("Flash")
        || this.getRestrictions().isInstantSpeed()
        || activator.hasKeyword("You may cast nonland cards as though they had flash.")
        || card.hasStartOfKeyword("You may cast CARDNAME as though it had flash."))) {
      return false;
    }

    if (!this.getRestrictions().canPlay(card, this)) {
      return false;
    }

    // for uncastables like lotus bloom, check if manaCost is blank (except for morph spells)
    if (!isCastFaceDown()
        && isBasicSpell()
        && card.getState(card.isFaceDown() ? CardStateName.Original : card.getCurrentStateName())
            .getManaCost()
            .isNoCost()) {
      return false;
    }

    if (this.getPayCosts() != null) {
      if (!CostPayment.canPayAdditionalCosts(this.getPayCosts(), this)) {
        return false;
      }
    }

    return checkOtherRestrictions();
  } // canPlay()