mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Fix AI casting suspended spells against Drannith Magistrate (#1098)
* Cleanup cards * Fix AI casting suspended spells against Drannith Magistrate Co-authored-by: tool4EvEr <tool4EvEr@192.168.0.59>
This commit is contained in:
@@ -34,6 +34,7 @@ import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.card.CardPlayOption.PayManaCost;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.cost.CostPayment;
|
||||
import forge.game.keyword.Keyword;
|
||||
import forge.game.keyword.KeywordInterface;
|
||||
import forge.game.player.Player;
|
||||
@@ -842,4 +843,46 @@ public final class GameActionUtil {
|
||||
c.getGame().getTriggerHandler().resetActiveTriggers();
|
||||
}
|
||||
|
||||
public static void rollbackAbility(SpellAbility ability, final Zone fromZone, final int zonePosition, CostPayment payment, Card oldCard) {
|
||||
// cancel ability during target choosing
|
||||
final Game game = ability.getActivatingPlayer().getGame();
|
||||
|
||||
if (fromZone != null) { // and not a copy
|
||||
oldCard.setCastSA(null);
|
||||
oldCard.setCastFrom(null);
|
||||
// add back to where it came from, hopefully old state
|
||||
// skip GameAction
|
||||
oldCard.getZone().remove(oldCard);
|
||||
fromZone.add(oldCard, zonePosition >= 0 ? Integer.valueOf(zonePosition) : null);
|
||||
ability.setHostCard(oldCard);
|
||||
ability.setXManaCostPaid(null);
|
||||
ability.setSpendPhyrexianMana(false);
|
||||
if (ability.hasParam("Announce")) {
|
||||
for (final String aVar : ability.getParam("Announce").split(",")) {
|
||||
final String varName = aVar.trim();
|
||||
if (!varName.equals("X")) {
|
||||
ability.setSVar(varName, "0");
|
||||
}
|
||||
}
|
||||
}
|
||||
// better safe than sorry approach in case rolled back ability was copy (from addExtraKeywordCost)
|
||||
for (SpellAbility sa : oldCard.getSpells()) {
|
||||
sa.setHostCard(oldCard);
|
||||
}
|
||||
//for Chorus of the Conclave
|
||||
ability.rollback();
|
||||
|
||||
oldCard.setBackSide(false);
|
||||
oldCard.setState(oldCard.getFaceupCardStateName(), true);
|
||||
oldCard.unanimateBestow();
|
||||
}
|
||||
|
||||
ability.clearTargets();
|
||||
|
||||
ability.resetOnceResolved();
|
||||
payment.refundPayment();
|
||||
game.getStack().clearFrozen();
|
||||
game.getTriggerHandler().clearWaitingTriggers();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
||||
// need to unfreeze tracker
|
||||
game.getTracker().unfreeze();
|
||||
|
||||
// check if it can recive the Tribute
|
||||
// check if it can receive the Tribute
|
||||
if (abort) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user