mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
put getCount method in SpellsCastWatcher and use it where applicable
This commit is contained in:
parent
7d170ef902
commit
817e1a813a
12 changed files with 32 additions and 119 deletions
|
|
@ -4,11 +4,8 @@ import mage.abilities.effects.Effect;
|
|||
import mage.filter.FilterSpell;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.watchers.common.SpellsCastWatcher;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
|
|
@ -19,7 +16,6 @@ public class FirstSpellOpponentsTurnTriggeredAbility extends SpellCastController
|
|||
|
||||
public FirstSpellOpponentsTurnTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(effect, defaultFilter, optional);
|
||||
this.addWatcher(new SpellsCastWatcher());
|
||||
}
|
||||
|
||||
private FirstSpellOpponentsTurnTriggeredAbility(final FirstSpellOpponentsTurnTriggeredAbility ability) {
|
||||
|
|
@ -38,13 +34,7 @@ public class FirstSpellOpponentsTurnTriggeredAbility extends SpellCastController
|
|||
|| !game.getOpponents(this.getControllerId()).contains(game.getActivePlayerId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
|
||||
if (watcher == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Spell> spells = watcher.getSpellsCastThisTurn(event.getPlayerId());
|
||||
return spells != null && spells.size() == 1;
|
||||
return watcher != null && watcher.getCount(event.getPlayerId()) == 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ public final class JaceUnravelerOfSecretsEmblem extends Emblem {
|
|||
Effect effect = new CounterTargetEffect();
|
||||
effect.setText("counter that spell");
|
||||
Ability ability = new JaceUnravelerOfSecretsTriggeredAbility(effect, false);
|
||||
ability.addWatcher(new SpellsCastWatcher());
|
||||
this.getAbilities().add(ability);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,4 +89,9 @@ public class SpellsCastWatcher extends Watcher {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getCount(UUID playerId) {
|
||||
return spellsCast.getOrDefault(playerId, new ArrayList<>()).size();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue