Rework Spell.counter using PutCards and reimplement Desertion. Fixes #9299

This commit is contained in:
Alex W. Jackson 2022-10-10 21:21:31 -04:00
parent cbe610d339
commit e40934921f
27 changed files with 124 additions and 251 deletions

View file

@ -6,8 +6,7 @@ import java.util.Date;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.constants.Zone;
import mage.constants.ZoneDetail;
import mage.constants.PutCards;
import mage.game.Game;
import mage.game.events.GameEvent;
import org.apache.log4j.Logger;
@ -60,13 +59,10 @@ public class SpellStack extends ArrayDeque<StackObject> {
}
public boolean counter(UUID objectId, Ability source, Game game) {
return counter(objectId, source, game, Zone.GRAVEYARD, false, ZoneDetail.TOP);
return counter(objectId, source, game, PutCards.GRAVEYARD);
}
public boolean counter(UUID objectId, Ability source, Game game, Zone zone, boolean owner, ZoneDetail zoneDetail) {
// the counter logic is copied by some spells to handle replacement effects of the countered spell
// so if logic is changed here check those spells for needed changes too
// Concerned cards to check: Hinder, Spell Crumple
public boolean counter(UUID objectId, Ability source, Game game, PutCards zone) {
StackObject stackObject = getStackObject(objectId);
MageObject sourceObject = game.getObject(source);
if (stackObject != null && sourceObject != null) {
@ -86,7 +82,7 @@ public class SpellStack extends ArrayDeque<StackObject> {
if (!(stackObject instanceof Spell)) { // spells are removed from stack by the card movement
this.remove(stackObject, game);
}
stackObject.counter(source, game, zone, owner, zoneDetail);
stackObject.counter(source, game, zone);
if (!game.isSimulation()) {
game.informPlayers(counteredObjectName + " is countered by " + sourceObject.getLogName());
}