Fixed a bug that sometimes wrongly power of new source instance was used to determine a number and fixed also a bug that counters were added wrongly to an already new instance of the source object (fixes #6035).

This commit is contained in:
LevelX2 2019-12-15 00:50:44 +01:00
parent 515b55f088
commit 81ff37ad17
3 changed files with 176 additions and 3 deletions

View file

@ -3,6 +3,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -29,7 +30,10 @@ public class SourcePermanentPowerCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(sourceAbility.getSourceId());
Permanent sourcePermanent = game.getPermanent(sourceAbility.getSourceId());
if (sourcePermanent == null || sourcePermanent.getZoneChangeCounter(game) > sourceAbility.getSourceObjectZoneChangeCounter()) {
sourcePermanent = (Permanent) game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.BATTLEFIELD);
}
if (sourcePermanent != null
&& (allowNegativeValues || sourcePermanent.getPower().getValue() >= 0)) {
return sourcePermanent.getPower().getValue();

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.counter;
import java.util.ArrayList;
@ -96,7 +95,9 @@ public class AddCountersSourceEffect extends OneShotEffect {
if (permanent == null && source.getAbilityType() == AbilityType.STATIC) {
permanent = game.getPermanentEntering(source.getSourceId());
}
if (permanent != null) {
if (permanent != null
&& (source.getSourceObjectZoneChangeCounter() == 0 // from static ability
|| source.getSourceObjectZoneChangeCounter() == permanent.getZoneChangeCounter(game))) { // prevent to add counters to later source objects
if (counter != null) {
Counter newCounter = counter.copy();
int countersToAdd = amount.calculate(game, source, this);