* Fixed a problem that watcher added from cards are not reset between games of a match (fixes #3228).

This commit is contained in:
LevelX2 2017-05-28 18:24:37 +02:00
parent c0f02259ec
commit 09e4435a89
4 changed files with 15 additions and 22 deletions

View file

@ -34,14 +34,12 @@ import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.MorbidCondition; import mage.abilities.condition.common.MorbidCondition;
import mage.abilities.costs.AdjustingSourceCosts; import mage.abilities.costs.AdjustingSourceCosts;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.DeathtouchAbility; import mage.abilities.keyword.DeathtouchAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game; import mage.game.Game;
import mage.util.CardUtil; import mage.util.CardUtil;
import mage.watchers.common.MorbidWatcher; import mage.watchers.common.MorbidWatcher;
@ -106,6 +104,6 @@ class BonePickerCostAdjustmentAbility extends SimpleStaticAbility implements Adj
if (MorbidCondition.instance.apply(game, ability)) { if (MorbidCondition.instance.apply(game, ability)) {
CardUtil.adjustCost((SpellAbility) ability, 3); CardUtil.adjustCost((SpellAbility) ability, 3);
} }
} }
} }
} }

View file

@ -981,6 +981,7 @@ public abstract class GameImpl implements Game, Serializable {
} }
} }
getState().setChoosingPlayerId(null); getState().setChoosingPlayerId(null);
state.getWatchers().reset(); // watcher objects from cards are reused during match so reset all card watchers already added
Watchers watchers = state.getWatchers(); Watchers watchers = state.getWatchers();
// add default watchers // add default watchers
for (UUID playerId : state.getPlayerList(startingPlayerId)) { for (UUID playerId : state.getPlayerList(startingPlayerId)) {

View file

@ -27,6 +27,8 @@
*/ */
package mage.game; package mage.game;
import java.io.Serializable;
import java.util.*;
import mage.MageObject; import mage.MageObject;
import mage.abilities.*; import mage.abilities.*;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
@ -58,9 +60,6 @@ import mage.util.ThreadLocalStringBuilder;
import mage.watchers.Watcher; import mage.watchers.Watcher;
import mage.watchers.Watchers; import mage.watchers.Watchers;
import java.io.Serializable;
import java.util.*;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com

View file

@ -25,16 +25,12 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.watchers.common; package mage.watchers.common;
import mage.constants.CardType;
import mage.constants.WatcherScope; import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent; import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.watchers.Watcher; import mage.watchers.Watcher;
/** /**
@ -56,11 +52,10 @@ public class MorbidWatcher extends Watcher {
if (condition) { if (condition) {
return; return;
} }
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) { if (event.getType() == GameEvent.EventType.ZONE_CHANGE
Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); && ((ZoneChangeEvent) event).isDiesEvent()
if (p != null && p.isCreature()) { && ((ZoneChangeEvent) event).getTarget().isCreature()) {
condition = true; condition = true;
}
} }
} }