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;
}
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;
}
Aggregations