Search in sources :

Example 1 with ManaAbility

use of mage.abilities.mana.ManaAbility in project mage by magefree.

the class VariableCostImpl method announceXValue.

@Override
public int announceXValue(Ability source, Game game) {
    int xValue = 0;
    Player controller = game.getPlayer(source.getControllerId());
    StackObject stackObject = game.getStack().getStackObject(source.getId());
    if (controller != null && (source instanceof ManaAbility || stackObject != null)) {
        xValue = controller.announceXCost(getMinValue(source, game), getMaxValue(source, game), "Announce the number of " + actionText, game, source, this);
    }
    return xValue;
}
Also used : Player(mage.players.Player) ManaAbility(mage.abilities.mana.ManaAbility) StackObject(mage.game.stack.StackObject)

Example 2 with ManaAbility

use of mage.abilities.mana.ManaAbility in project mage by magefree.

the class HumanPlayer method playManaAbilities.

protected void playManaAbilities(UUID objectId, Ability abilityToCast, ManaCost unpaid, Game game) {
    updateGameStatePriority("playManaAbilities", game);
    MageObject object = game.getObject(objectId);
    if (object == null) {
        return;
    }
    // can't see lands as playable and must know the reason (if they click on land then they get that message)
    if (abilityToCast.getAbilityType() == AbilityType.SPELL) {
        Spell spell = game.getStack().getSpell(abilityToCast.getSourceId());
        boolean haveManaAbilities = object.getAbilities().stream().anyMatch(a -> a instanceof ManaAbility);
        if (spell != null && !spell.isResolving() && haveManaAbilities) {
            switch(spell.getCurrentActivatingManaAbilitiesStep()) {
                // if you used special mana ability like convoke then normal mana abilities will be restricted to use, see Convoke for details
                case BEFORE:
                case NORMAL:
                    break;
                case AFTER:
                    game.informPlayer(this, "You can no longer use activated mana abilities to pay for the current spell (special mana pay already used). Cancel and recast the spell to activate mana abilities first.");
                    return;
            }
        }
    }
    Zone zone = game.getState().getZone(object.getId());
    if (zone != null) {
        LinkedHashMap<UUID, ActivatedManaAbilityImpl> useableAbilities = getUseableManaAbilities(object, zone, game);
        if (!useableAbilities.isEmpty()) {
            // eliminates other abilities if one fits perfectly
            useableAbilities = ManaUtil.tryToAutoPay(unpaid, useableAbilities);
            currentlyUnpaidMana = unpaid;
            activateAbility(useableAbilities, object, game);
            currentlyUnpaidMana = null;
        }
    }
}
Also used : ManaAbility(mage.abilities.mana.ManaAbility) MageObject(mage.MageObject) ActivatedManaAbilityImpl(mage.abilities.mana.ActivatedManaAbilityImpl) Spell(mage.game.stack.Spell)

Aggregations

ManaAbility (mage.abilities.mana.ManaAbility)2 MageObject (mage.MageObject)1 ActivatedManaAbilityImpl (mage.abilities.mana.ActivatedManaAbilityImpl)1 Spell (mage.game.stack.Spell)1 StackObject (mage.game.stack.StackObject)1 Player (mage.players.Player)1