mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 22:42:03 -08:00
[DTK] Added Orator of Ojutai and Scale Blessing.
This commit is contained in:
parent
227052f108
commit
cb8d19906a
6 changed files with 302 additions and 44 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue