Page 1 of 1

Need some guidance on implementing Blinkmoth Urn

PostPosted: 24 Feb 2015, 15:10
by myersn024
I've been working on implementing some older cards that are missing in order to make XMage more attractive to Commander players. Currently I'm working on Blinkmoth Urn, and I have the colorless mana generation based on the number of controlled artifacts working (albeit probably not the best implementation). I'm having trouble figuring out the best way to make the card tappable without having a cost or effect associated with the action. Any pointers would be greatly appreciated.

Code: Select all
public class BlinkmothUrn extends CardImpl {
   
    public BlinkmothUrn(UUID ownerId) {
        super(ownerId, 145, "Blinkmoth Urn", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{5}");
        this.expansionSetCode = "MRD";
       
        // At the beginning of each player's precombat main phase, if
        // Blinkmoth Urn is untapped, that player adds {1} to his or her
        // mana pool for each artifact he or she controls.
        this.addAbility(new BeginningOfPreCombatMainTriggeredAbility(new BlinkmothUrnEffect(), TargetController.ANY, false));
       
        // Tap to stop colorless mana generation (this doesn't currently work)
        Ability tapAbility = new SimpleStaticAbility(Zone.BATTLEFIELD, new TapSourceEffect());
        this.addAbility(tapAbility);
       
       
    }
   
    public BlinkmothUrn(final BlinkmothUrn card) {
        super(card);
    }

    @Override
    public BlinkmothUrn copy() {
        return new BlinkmothUrn(this);
    }
   
}

class BlinkmothUrnEffect extends OneShotEffect {
   
    public BlinkmothUrnEffect() {
        super(Outcome.PutManaInPool);
        this.staticText = "if Blinkmoth Urn is untapped, that player adds {1} to his or her mana pool for each artifact he or she controls";
    }
   
    public BlinkmothUrnEffect(final BlinkmothUrnEffect effect) {
        super(effect);
    }
   
    @Override
    public BlinkmothUrnEffect copy() {
        return new BlinkmothUrnEffect(this);
    }
   
    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(game.getActivePlayerId());
        FilterArtifactPermanent filter = new FilterArtifactPermanent("artifacts you control");
        filter.add(new ControllerIdPredicate(game.getActivePlayerId()));
        Permanent sourcePermanent = game.getPermanent(source.getSourceId());
        if(player != null && sourcePermanent != null && !sourcePermanent.isTapped()) {
            for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
                player.getManaPool().addMana(Mana.ColorlessMana, game, source, true);
            }
            return true;
        }
        return false;
    }
}

Re: Need some guidance on implementing Blinkmoth Urn

PostPosted: 24 Feb 2015, 19:26
by emerald000
myersn024 wrote:I've been working on implementing some older cards that are missing in order to make XMage more attractive to Commander players. Currently I'm working on Blinkmoth Urn, and I have the colorless mana generation based on the number of controlled artifacts working (albeit probably not the best implementation). I'm having trouble figuring out the best way to make the card tappable without having a cost or effect associated with the action. Any pointers would be greatly appreciated.
You cannot tap a permanent for no reason. Unless an outside ability instructs you to tap it, Blinkmoth Urn will stay untapped.

Re: Need some guidance on implementing Blinkmoth Urn

PostPosted: 24 Feb 2015, 20:37
by myersn024
OK, that makes things easier.