[DTK] Added Orator of Ojutai and Scale Blessing.

This commit is contained in:
LevelX2 2015-03-18 21:55:48 +01:00
parent 227052f108
commit cb8d19906a
6 changed files with 302 additions and 44 deletions

View file

@ -30,6 +30,8 @@ package mage.watchers.common;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.RevealTargetFromHandCost;
import mage.constants.WatcherScope;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
@ -41,7 +43,6 @@ import mage.watchers.Watcher;
*
* @author LevelX2
*/
public class DragonOnTheBattlefieldWhileSpellWasCastWatcher extends Watcher {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Dragon", "Dragons");
@ -49,39 +50,50 @@ public class DragonOnTheBattlefieldWhileSpellWasCastWatcher extends Watcher {
private final Set<UUID> castWithDragonOnTheBattlefield = new HashSet<>();
public DragonOnTheBattlefieldWhileSpellWasCastWatcher() {
super("DragonOnTheBattlefieldWhileSpellWasCastWatcher", WatcherScope.GAME);
super("DragonOnTheBattlefieldWhileSpellWasCastWatcher", WatcherScope.GAME);
}
public DragonOnTheBattlefieldWhileSpellWasCastWatcher(final DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher) {
super(watcher);
this.castWithDragonOnTheBattlefield.addAll(watcher.castWithDragonOnTheBattlefield);
super(watcher);
this.castWithDragonOnTheBattlefield.addAll(watcher.castWithDragonOnTheBattlefield);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
// targetId is the unique ID of the spell
Spell spell = game.getState().getStack().getSpell(event.getTargetId());
if (spell != null) {
if (game.getBattlefield().countAll(filter, spell.getControllerId(), game) > 0) {
castWithDragonOnTheBattlefield.add(spell.getId());
}
}
}
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
// targetId is the unique ID of the spell
Spell spell = game.getState().getStack().getSpell(event.getTargetId());
// revealed a Dragon card or controlled a Dragon as you cast the spell
if (spell != null) {
boolean revealedOrOnBattlefield = false;
for (Cost cost : spell.getSpellAbility().getCosts()) {
if (cost instanceof RevealTargetFromHandCost) {
revealedOrOnBattlefield = ((RevealTargetFromHandCost) cost).getNumberRevealedCards() > 0;
break;
}
}
if (!revealedOrOnBattlefield) {
revealedOrOnBattlefield = game.getBattlefield().countAll(filter, spell.getControllerId(), game) > 0;
}
if (revealedOrOnBattlefield){
castWithDragonOnTheBattlefield.add(spell.getId());
}
}
}
}
@Override
public void reset() {
castWithDragonOnTheBattlefield.clear();
castWithDragonOnTheBattlefield.clear();
}
public boolean castWithConditionTrue(UUID spellId) {
return castWithDragonOnTheBattlefield.contains(spellId);
return castWithDragonOnTheBattlefield.contains(spellId);
}
@Override
public DragonOnTheBattlefieldWhileSpellWasCastWatcher copy() {
return new DragonOnTheBattlefieldWhileSpellWasCastWatcher(this);
return new DragonOnTheBattlefieldWhileSpellWasCastWatcher(this);
}
}