Package mage.abilities.costs.mana

Examples of mage.abilities.costs.mana.ManaCost


  }

  @Override
  public boolean playMana(ManaCost unpaid, Game game) {
//    logger.fine("playMana");
    ManaCost cost;
    List<Permanent> producers;
    if (unpaid instanceof ManaCosts) {
      cost = ((ManaCosts<ManaCost>)unpaid).get(0);
      producers = getSortedProducers((ManaCosts)unpaid, game);
    }
    else {
      cost = unpaid;
      producers = this.getAvailableManaProducers(game);
    }
    for (Permanent perm: producers) {
      // pay all colored costs first
      for (ManaAbility ability: perm.getAbilities().getManaAbilities(Zone.BATTLEFIELD)) {
        if (cost instanceof ColoredManaCost) {
          if (cost.testPay(ability.getNetMana(game))) {
            if (activateAbility(ability, game))
              return true;
          }
        }
      }
      // then pay hybrid
      for (ManaAbility ability: perm.getAbilities().getManaAbilities(Zone.BATTLEFIELD)) {
        if (cost instanceof HybridManaCost) {
          if (cost.testPay(ability.getNetMana(game))) {
            if (activateAbility(ability, game))
              return true;
          }
        }
      }
      // then pay mono hybrid
      for (ManaAbility ability: perm.getAbilities().getManaAbilities(Zone.BATTLEFIELD)) {
        if (cost instanceof MonoHybridManaCost) {
          if (cost.testPay(ability.getNetMana(game))) {
            if (activateAbility(ability, game))
              return true;
          }
        }
      }
      // finally pay generic
      for (ManaAbility ability: perm.getAbilities().getManaAbilities(Zone.BATTLEFIELD)) {
        if (cost instanceof GenericManaCost) {
          if (cost.testPay(ability.getNetMana(game))) {
            if (activateAbility(ability, game))
              return true;
          }
        }
      }
View Full Code Here


     * @param landName Land to use as mana producer.
     * @param expected1 The amount of mana abilities the land should have.
     * @param expected2 The amount of mana abilities that ManaUtil.tryToAutoPay should be returned after optimization.
     */
    private void testManaToPayVsLand(String manaToPay, String landName, int expected1, int expected2) {
        ManaCost unpaid = new ManaCostsImpl(manaToPay);
        Card card = CardRepository.instance.findCard(landName).getCard();
        Assert.assertNotNull(card);

        HashMap<UUID, ManaAbility> useableAbilities = getManaAbilities(card);
        Assert.assertEquals(expected1, useableAbilities.size());
View Full Code Here

     * @param landName Land to use as mana producer.
     * @param expected1 The amount of mana abilities the land should have.
     * @param expectedChosen
     */
    private void testManaToPayVsLand(String manaToPay, String landName, int expected1, Class<? extends BasicManaAbility> expectedChosen) {
        ManaCost unpaid = new ManaCostsImpl(manaToPay);
        Card card = CardRepository.instance.findCard(landName).getCard();
        Assert.assertNotNull(card);

        HashMap<UUID, ManaAbility> useableAbilities = getManaAbilities(card);
        Assert.assertEquals(expected1, useableAbilities.size());
View Full Code Here

                while (it.hasNext()) {
                    Object cost = it.next();
                    if (cost instanceof ManaCosts) {
                        for (Object object : ((ManaCosts) cost)) {
                            if (object instanceof ManaCost) {
                                ManaCost manaCost = (ManaCost) object;
                                Mana mana = manaCost.getOptions().get(0);
                                int colorless = mana != null ? mana.getColorless() : 0;
                                if (!updated && colorless > 0) {
                                    if ((colorless - reduceCount) > 0) {
                                        int newColorless = colorless - reduceCount;
                                        it.remove();
View Full Code Here

        List<Permanent> creatures = getPermanentsWithTheHighestCMC(game, player.getId(), new FilterControlledCreaturePermanent());

        Permanent creatureToPayFor = chooseOnePermanent(game, player, creatures);

        if (creatureToPayFor != null) {
            ManaCost manaCost = CardUtil.removeVariableManaCost(creatureToPayFor.getManaCost());
            String message = new StringBuilder("Pay ").append(manaCost.getText()).append(" (otherwise sacrifice ")
                    .append(creatureToPayFor.getName()).append(")?").toString();
            if (player.chooseUse(Outcome.Benefit, message, game)) {
                if (manaCost.pay(source, game, source.getSourceId(), player.getId(), false)) {
                    game.informPlayers(new StringBuilder(sourceObject != null ? sourceObject.getName() : "")
                            .append(": ").append(player.getName()).append(" has paid").toString());
                    return;
                }
            }
View Full Code Here

        super.adjustCosts(ability, game);
        int reductionAmount = game.getBattlefield().count(filter,  ability.getSourceId(), ability.getControllerId(), game);
        Iterator<ManaCost> iter = ability.getManaCostsToPay().iterator();

        while ( reductionAmount > 0 && iter.hasNext() ) {
            ManaCost manaCost = iter.next();
            if (manaCost.getMana().getGreen() > 0) { // in case another effect adds additional mana cost
                iter.remove();
                reductionAmount--;
            }
        }
    }
View Full Code Here

TOP

Related Classes of mage.abilities.costs.mana.ManaCost

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.