mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 12:02:01 -08:00
Add Event to the signature of updateZoneChangeCounter.
This is required to Implement Skullbriar, the Walking Grave
This commit is contained in:
parent
d53f751711
commit
cdff9bae78
10 changed files with 26 additions and 20 deletions
|
|
@ -10,6 +10,7 @@ import mage.abilities.costs.mana.ManaCosts;
|
||||||
import mage.cards.FrameStyle;
|
import mage.cards.FrameStyle;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.ZoneChangeEvent;
|
||||||
|
|
||||||
public interface MageObject extends MageItem, Serializable {
|
public interface MageObject extends MageItem, Serializable {
|
||||||
|
|
||||||
|
|
@ -75,7 +76,7 @@ public interface MageObject extends MageItem, Serializable {
|
||||||
|
|
||||||
int getZoneChangeCounter(Game game);
|
int getZoneChangeCounter(Game game);
|
||||||
|
|
||||||
void updateZoneChangeCounter(Game game);
|
void updateZoneChangeCounter(Game game, ZoneChangeEvent event);
|
||||||
|
|
||||||
void setZoneChangeCounter(int value, Game game);
|
void setZoneChangeCounter(int value, Game game);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ import mage.abilities.mana.ManaAbility;
|
||||||
import mage.cards.FrameStyle;
|
import mage.cards.FrameStyle;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
import mage.util.GameLog;
|
import mage.util.GameLog;
|
||||||
|
|
||||||
|
|
@ -287,7 +288,7 @@ public abstract class MageObjectImpl implements MageObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateZoneChangeCounter(Game game) {
|
public void updateZoneChangeCounter(Game game, ZoneChangeEvent event) {
|
||||||
game.getState().updateZoneChangeCounter(objectId);
|
game.getState().updateZoneChangeCounter(objectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,8 +174,9 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
||||||
if (targetCard != null || targetPermanent != null || targetPlayer != null) {
|
if (targetCard != null || targetPermanent != null || targetPlayer != null) {
|
||||||
card = game.getCard(event.getTargetId());
|
card = game.getCard(event.getTargetId());
|
||||||
card.removeFromZone(game, fromZone, sourceId);
|
card.removeFromZone(game, fromZone, sourceId);
|
||||||
card.updateZoneChangeCounter(game);
|
|
||||||
PermanentCard permanent = new PermanentCard(card, (controllingPlayer == null ? card.getOwnerId() : controllingPlayer.getId()), game);
|
PermanentCard permanent = new PermanentCard(card, (controllingPlayer == null ? card.getOwnerId() : controllingPlayer.getId()), game);
|
||||||
|
ZoneChangeEvent zoneChangeEvent = new ZoneChangeEvent(permanent, controllerId, fromZone, Zone.BATTLEFIELD);
|
||||||
|
permanent.updateZoneChangeCounter(game, zoneChangeEvent);
|
||||||
game.getBattlefield().addPermanent(permanent);
|
game.getBattlefield().addPermanent(permanent);
|
||||||
card.setZone(Zone.BATTLEFIELD, game);
|
card.setZone(Zone.BATTLEFIELD, game);
|
||||||
if (permanent.entersBattlefield(event.getSourceId(), game, fromZone, true)) {
|
if (permanent.entersBattlefield(event.getSourceId(), game, fromZone, true)) {
|
||||||
|
|
@ -188,7 +189,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
||||||
}
|
}
|
||||||
game.applyEffects();
|
game.applyEffects();
|
||||||
|
|
||||||
game.fireEvent(new ZoneChangeEvent(permanent, controllerId, fromZone, Zone.BATTLEFIELD));
|
game.fireEvent(zoneChangeEvent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@ import mage.counters.Counter;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.PermanentMeld;
|
|
||||||
import mage.players.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -192,20 +190,20 @@ public abstract class MeldCard extends CardImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateZoneChangeCounter(Game game) {
|
public void updateZoneChangeCounter(Game game, ZoneChangeEvent event) {
|
||||||
if (isCopy() || !isMelded()) {
|
if (isCopy() || !isMelded()) {
|
||||||
super.updateZoneChangeCounter(game);
|
super.updateZoneChangeCounter(game, event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
game.getState().updateZoneChangeCounter(objectId);
|
game.getState().updateZoneChangeCounter(objectId);
|
||||||
if (topLastZoneChangeCounter == topHalfCard.getZoneChangeCounter(game)
|
if (topLastZoneChangeCounter == topHalfCard.getZoneChangeCounter(game)
|
||||||
&& halves.contains(topHalfCard.getId())) {
|
&& halves.contains(topHalfCard.getId())) {
|
||||||
topHalfCard.updateZoneChangeCounter(game);
|
topHalfCard.updateZoneChangeCounter(game, event);
|
||||||
topLastZoneChangeCounter = topHalfCard.getZoneChangeCounter(game);
|
topLastZoneChangeCounter = topHalfCard.getZoneChangeCounter(game);
|
||||||
}
|
}
|
||||||
if (bottomLastZoneChangeCounter == bottomHalfCard.getZoneChangeCounter(game)
|
if (bottomLastZoneChangeCounter == bottomHalfCard.getZoneChangeCounter(game)
|
||||||
&& halves.contains(bottomHalfCard.getId())) {
|
&& halves.contains(bottomHalfCard.getId())) {
|
||||||
bottomHalfCard.updateZoneChangeCounter(game);
|
bottomHalfCard.updateZoneChangeCounter(game, event);
|
||||||
bottomLastZoneChangeCounter = bottomHalfCard.getZoneChangeCounter(game);
|
bottomLastZoneChangeCounter = bottomHalfCard.getZoneChangeCounter(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ public class ZonesHandler {
|
||||||
toZone = subInfo.event.getToZone();
|
toZone = subInfo.event.getToZone();
|
||||||
placeInDestinationZone(subInfo, game);
|
placeInDestinationZone(subInfo, game);
|
||||||
}
|
}
|
||||||
|
// We arbitrarily prefer the bottom half card. This should never be relevant.
|
||||||
if (toZone != null) {
|
if (toZone != null) {
|
||||||
game.setZone(unmelded.event.getTargetId(), toZone);
|
game.setZone(unmelded.event.getTargetId(), toZone);
|
||||||
}
|
}
|
||||||
|
|
@ -180,7 +181,8 @@ public class ZonesHandler {
|
||||||
if (unmelded.subInfo.isEmpty()) {
|
if (unmelded.subInfo.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
meld.updateZoneChangeCounter(game);
|
// We arbitrarily prefer the bottom half card. This should never be relevant.
|
||||||
|
meld.updateZoneChangeCounter(game, unmelded.subInfo.get(unmelded.subInfo.size() - 1).event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Handle all normal cases
|
// Handle all normal cases
|
||||||
|
|
@ -235,9 +237,9 @@ public class ZonesHandler {
|
||||||
}
|
}
|
||||||
if (success) {
|
if (success) {
|
||||||
if (event.getToZone() == Zone.BATTLEFIELD && event.getTarget() != null) {
|
if (event.getToZone() == Zone.BATTLEFIELD && event.getTarget() != null) {
|
||||||
event.getTarget().updateZoneChangeCounter(game);
|
event.getTarget().updateZoneChangeCounter(game, event);
|
||||||
} else {
|
} else {
|
||||||
card.updateZoneChangeCounter(game);
|
card.updateZoneChangeCounter(game, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ import mage.cards.Card;
|
||||||
import mage.cards.FrameStyle;
|
import mage.cards.FrameStyle;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.util.GameLog;
|
import mage.util.GameLog;
|
||||||
|
|
||||||
public class Commander implements CommandObject {
|
public class Commander implements CommandObject {
|
||||||
|
|
@ -214,8 +215,8 @@ public class Commander implements CommandObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateZoneChangeCounter(Game game) {
|
public void updateZoneChangeCounter(Game game, ZoneChangeEvent event) {
|
||||||
card.updateZoneChangeCounter(game);
|
card.updateZoneChangeCounter(game, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.cards.FrameStyle;
|
import mage.cards.FrameStyle;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.util.GameLog;
|
import mage.util.GameLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -233,7 +234,7 @@ public class Emblem implements CommandObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateZoneChangeCounter(Game game) {
|
public void updateZoneChangeCounter(Game game, ZoneChangeEvent event) {
|
||||||
throw new UnsupportedOperationException("Unsupported operation");
|
throw new UnsupportedOperationException("Unsupported operation");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -240,8 +240,8 @@ public class PermanentCard extends PermanentImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateZoneChangeCounter(Game game) {
|
public void updateZoneChangeCounter(Game game, ZoneChangeEvent event) {
|
||||||
card.updateZoneChangeCounter(game);
|
card.updateZoneChangeCounter(game, event);
|
||||||
zoneChangeCounter = card.getZoneChangeCounter(game);
|
zoneChangeCounter = card.getZoneChangeCounter(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -778,7 +778,7 @@ public class Spell extends StackObjImpl implements Card {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateZoneChangeCounter(Game game) {
|
public void updateZoneChangeCounter(Game game, ZoneChangeEvent event) {
|
||||||
throw new UnsupportedOperationException("Unsupported operation");
|
throw new UnsupportedOperationException("Unsupported operation");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ import mage.constants.Zone;
|
||||||
import mage.constants.ZoneDetail;
|
import mage.constants.ZoneDetail;
|
||||||
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.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.target.Targets;
|
import mage.target.Targets;
|
||||||
|
|
@ -557,7 +558,7 @@ public class StackAbility extends StackObjImpl implements Ability {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateZoneChangeCounter(Game game) {
|
public void updateZoneChangeCounter(Game game, ZoneChangeEvent event) {
|
||||||
throw new UnsupportedOperationException("Not supported.");
|
throw new UnsupportedOperationException("Not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue