Fixed a bug of Curse of Exhaustion checking always controlling player.

This commit is contained in:
LevelX2 2013-03-11 17:33:50 +01:00
parent 82c44b2b3b
commit dcc9828f0f

View file

@ -97,8 +97,9 @@ class CurseOfExhaustionWatcher extends WatcherImpl<CurseOfExhaustionWatcher> {
@Override @Override
public void watch(GameEvent event, Game game) { public void watch(GameEvent event, Game game) {
if (condition == true) //no need to check - condition has already occured if (condition == true) {//no need to check - condition has already occured
return; return;
}
if (event.getType() == GameEvent.EventType.SPELL_CAST ) { if (event.getType() == GameEvent.EventType.SPELL_CAST ) {
Permanent enchantment = game.getPermanent(this.sourceId); Permanent enchantment = game.getPermanent(this.sourceId);
if (enchantment != null && enchantment.getAttachedTo() != null) { if (enchantment != null && enchantment.getAttachedTo() != null) {
@ -116,7 +117,7 @@ class CurseOfExhaustionEffect extends ReplacementEffectImpl<CurseOfExhaustionEff
public CurseOfExhaustionEffect() { public CurseOfExhaustionEffect() {
super(Constants.Duration.WhileOnBattlefield, Constants.Outcome.Benefit); super(Constants.Duration.WhileOnBattlefield, Constants.Outcome.Benefit);
staticText = "Enchanted player can't cast more than one spell each turn."; staticText = "Enchanted player can't cast more than one spell each turn";
} }
public CurseOfExhaustionEffect(final CurseOfExhaustionEffect effect) { public CurseOfExhaustionEffect(final CurseOfExhaustionEffect effect) {
@ -145,9 +146,10 @@ class CurseOfExhaustionEffect extends ReplacementEffectImpl<CurseOfExhaustionEff
if (enchantment != null && enchantment.getAttachedTo() != null) { if (enchantment != null && enchantment.getAttachedTo() != null) {
Player player = game.getPlayer(enchantment.getAttachedTo()); Player player = game.getPlayer(enchantment.getAttachedTo());
if (player != null && event.getPlayerId().equals(player.getId())) { if (player != null && event.getPlayerId().equals(player.getId())) {
Watcher watcher = game.getState().getWatchers().get("SpellCast", source.getControllerId()); Watcher watcher = game.getState().getWatchers().get("SpellCast", player.getId());
if (watcher != null && watcher.conditionMet()) if (watcher != null && watcher.conditionMet()) {
return true; return true;
}
} }
} }
} }