Page 1 of 1

Wardscale Dragon and Xantid Swarm

PostPosted: 27 Nov 2016, 01:10
by MTGfan
Should Wardscale Dragon be edited to use ConditionalContinuousEffect? Or is the way it is coded the better way to handle it. Functionally I believe it would be the same the difference would be in what code is executed. But I could be wrong. Basically the card's code would change with the ability line being:
Code: Select all
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(<effect>, SourceAttackingCondition.getInstance(), "As long as {this} is attacking, defending player can't cast spells")));
And the effect class at the bottom would change from this:
Code: Select all
    public boolean applies(GameEvent event, Ability source, Game game) {
        Permanent sourcePermanent = game.getPermanent(source.getSourceId());
        if (sourcePermanent != null && sourcePermanent.isAttacking()) {
            return event.getPlayerId().equals(game.getCombat().getDefendingPlayerId(sourcePermanent.getId(), game));
        }
        return false;
    }
to this:
Code: Select all
    public boolean applies(GameEvent event, Ability source, Game game) {
        return event.getPlayerId().equals(game.getCombat().getDefendingPlayerId(sourcePermanent.getId(), game));
    }
At first I thought about having some sort of CantCastSpellsEffect in the framework. There are 40 cards that contain the phrase "can't cast spells" but there probably isn't framework for all the variations. The closest variation to this creature being Xantid Swarm but it is not a ConditionalContinuousEffect it is an AttacksTriggeredAbility.

However Xantid Swarm code doesn't use AttacksTriggeredAbility it appears to me to be redundantly doing it with class XantidSwarmTriggeredAbility. So my guess is that it should be for sure changed to at the ability line from:
Code: Select all
        Ability ability = new XantidSwarmTriggeredAbility(new XantidSwarmReplacementEffect());       
        this.addAbility(ability);
to this:
Code: Select all
this.addAbility(new AttacksTriggeredAbility(new XantidSwarmReplacementEffect(), false));
Wardscale Dragon's WardscaleDragonRuleEffect and Xantid Swarm's XantidSwarmReplacementEffect are functionally equivalent except for the duration. I assume that means they can't be encapsulated into a CantCastSpellsDefenderEffect unless there is a way to set it up to pass duration as a parameter so that within CantCastSpellsDefenderEffect it sets the duration based on that. Outside of these two I'm not sure if there are any that share a common factor like defending play.