Search in sources :

Example 41 with StackAbility

use of mage.game.stack.StackAbility in project mage by magefree.

the class ChandrasRegulatorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    ManaCostsImpl cost = new ManaCostsImpl("{1}");
    if (player == null) {
        return false;
    }
    if (!cost.canPay(source, source, player.getId(), game) || !player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + "? If you do, copy that ability. You may choose new targets for the copy.", source, game)) {
        return true;
    }
    if (!cost.pay(source, game, source, source.getControllerId(), false, null)) {
        return true;
    }
    StackAbility ability = (StackAbility) getValue("stackAbility");
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (ability == null || controller == null || sourcePermanent == null) {
        return false;
    }
    ability.createCopyOnStack(game, source, source.getControllerId(), true);
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) StackAbility(mage.game.stack.StackAbility)

Example 42 with StackAbility

use of mage.game.stack.StackAbility in project mage by magefree.

the class BattlemagesBracersTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent equipment = game.getPermanent(this.getSourceId());
    if (equipment == null || !equipment.isAttachedTo(event.getSourceId())) {
        return false;
    }
    StackAbility stackAbility = (StackAbility) game.getStack().getStackObject(event.getSourceId());
    if (stackAbility == null || stackAbility.getStackAbility() instanceof ActivatedManaAbilityImpl) {
        return false;
    }
    getEffects().setValue("stackAbility", stackAbility);
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) ActivatedManaAbilityImpl(mage.abilities.mana.ActivatedManaAbilityImpl) StackAbility(mage.game.stack.StackAbility)

Aggregations

StackAbility (mage.game.stack.StackAbility)42 Permanent (mage.game.permanent.Permanent)15 StackObject (mage.game.stack.StackObject)12 Player (mage.players.Player)11 Target (mage.target.Target)9 MageObject (mage.MageObject)8 Ability (mage.abilities.Ability)7 Spell (mage.game.stack.Spell)7 ActivatedManaAbilityImpl (mage.abilities.mana.ActivatedManaAbilityImpl)6 GameEvent (mage.game.events.GameEvent)6 Game (mage.game.Game)5 UUID (java.util.UUID)4 MageObjectReference (mage.MageObjectReference)4 PassAbility (mage.abilities.common.PassAbility)4 Mode (mage.abilities.Mode)3 Card (mage.cards.Card)3 FixedTarget (mage.target.targetpointer.FixedTarget)3 ActivatedAbility (mage.abilities.ActivatedAbility)2 LoyaltyAbility (mage.abilities.LoyaltyAbility)2 SpellAbility (mage.abilities.SpellAbility)2