Search in sources :

Example 1 with BrudicladTelchorMyrToken

use of mage.game.permanent.token.BrudicladTelchorMyrToken in project mage by magefree.

the class BrudicladTelchorEngineerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    CreateTokenEffect effect = new CreateTokenEffect(new BrudicladTelchorMyrToken(), 1);
    if (effect.apply(game, source)) {
        TargetControlledPermanent target = new TargetControlledPermanent(0, 1, filter, true);
        target.setNotTarget(true);
        if (controller.chooseUse(outcome, "Select a token to copy?", source, game) && controller.choose(Outcome.Neutral, target, source.getSourceId(), game)) {
            Permanent toCopyFromPermanent = game.getPermanent(target.getFirstTarget());
            if (toCopyFromPermanent != null) {
                for (Permanent toCopyToPermanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
                    if (!toCopyToPermanent.equals(toCopyFromPermanent)) {
                        game.copyPermanent(toCopyFromPermanent, toCopyToPermanent.getId(), source, new EmptyCopyApplier());
                    }
                }
                return true;
            }
        }
    }
    return false;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) BrudicladTelchorMyrToken(mage.game.permanent.token.BrudicladTelchorMyrToken)

Aggregations

CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)1 Permanent (mage.game.permanent.Permanent)1 BrudicladTelchorMyrToken (mage.game.permanent.token.BrudicladTelchorMyrToken)1 Player (mage.players.Player)1 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)1 EmptyCopyApplier (mage.util.functions.EmptyCopyApplier)1