[DTK] updated implementation of spells which reveal dragon cards as a cost

This commit is contained in:
Evan Kranzler 2021-03-23 19:44:45 -04:00
parent 707de23436
commit d54e1c6eac
10 changed files with 377 additions and 466 deletions

View file

@ -0,0 +1,30 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.costs.common.RevealDragonFromHandCost;
import mage.constants.AbilityType;
import mage.game.Game;
import mage.watchers.common.DragonOnTheBattlefieldWhileSpellWasCastWatcher;
/**
* @author TheElk801
*/
public enum RevealedOrControlledDragonCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
if (source.getAbilityType() == AbilityType.SPELL) {
return source
.getCosts()
.stream()
.filter(RevealDragonFromHandCost.class::isInstance)
.map(RevealDragonFromHandCost.class::cast)
.anyMatch(RevealDragonFromHandCost::isRevealedOrControlled);
}
DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher
= game.getState().getWatcher(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class);
return watcher != null && watcher.checkCondition(source, game);
}
}