* 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.condition.common.MorbidCondition;
import mage.abilities.costs.AdjustingSourceCosts;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.DeathtouchAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game;
import mage.util.CardUtil;
import mage.watchers.common.MorbidWatcher;
@ -54,7 +52,7 @@ public class BonePicker extends CardImpl {
public BonePicker(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}");
this.subtype.add("Bird");
this.power = new MageInt(3);
this.toughness = new MageInt(2);
@ -106,6 +104,6 @@ class BonePickerCostAdjustmentAbility extends SimpleStaticAbility implements Adj
if (MorbidCondition.instance.apply(game, ability)) {
CardUtil.adjustCost((SpellAbility) ability, 3);
}
}
}
}
}

View file

@ -981,6 +981,7 @@ public abstract class GameImpl implements Game, Serializable {
}
}
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();
// add default watchers
for (UUID playerId : state.getPlayerList(startingPlayerId)) {

View file

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

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,21 +20,17 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.watchers.common;
import mage.constants.CardType;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.watchers.Watcher;
/**
@ -56,11 +52,10 @@ public class MorbidWatcher extends Watcher {
if (condition) {
return;
}
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (p != null && p.isCreature()) {
condition = true;
}
if (event.getType() == GameEvent.EventType.ZONE_CHANGE
&& ((ZoneChangeEvent) event).isDiesEvent()
&& ((ZoneChangeEvent) event).getTarget().isCreature()) {
condition = true;
}
}