Rework sacrifice effects to support "can't be sacrificed" (#11587)

* add TargetSacrifice and canBeSacrificed

* SacrificeTargetCost refactor, now uses TargetSacrifice, constructors simplified, subclasses aligned

* fix text errors introduced by refactor

* refactor SacrificeEffect, SacrificeAllEffect, SacrificeOpponentsEffect

* cleanup keyword abilities involving sacrifice

* fix a bunch of custom effect classes involving sacrifice

* fix test choices

* update Assault Suit implementation

* fix filter check arguments

* add documentation to refactored common classes

* [CLB] Implement Jon Irenicus, Shattered One

* implement "{this} can't be sacrificed"

* add tests for Assault Suit and Jon Irenicus

* refactor out PlayerToRightGainsControlOfSourceEffect

* implement [LTC] Hithlain Rope

* add choose hint to all TargetSacrifice

---------

Co-authored-by: Evan Kranzler <theelk801@gmail.com>
Co-authored-by: PurpleCrowbar <26198472+PurpleCrowbar@users.noreply.github.com>
This commit is contained in:
xenohedron 2023-12-31 14:10:37 -05:00 committed by GitHub
parent f28c5c4fc5
commit 9b3ff32a33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
699 changed files with 1837 additions and 1619 deletions

View file

@ -72,6 +72,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
protected boolean manifested = false;
protected boolean morphed = false;
protected boolean ringBearerFlag = false;
protected boolean canBeSacrificed = true;
protected int classLevel = 1;
protected final Set<UUID> goadingPlayers = new HashSet<>();
protected UUID originalControllerId;
@ -176,6 +177,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
this.manifested = permanent.manifested;
this.createOrder = permanent.createOrder;
this.prototyped = permanent.prototyped;
this.canBeSacrificed = permanent.canBeSacrificed;
}
@Override
@ -215,6 +217,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
this.goadingPlayers.clear();
this.loyaltyActivationsAvailable = 1;
this.legendRuleApplies = true;
this.canBeSacrificed = true;
}
@Override
@ -1361,7 +1364,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
@Override
public boolean sacrifice(Ability source, Game game) {
//20091005 - 701.13
if (isPhasedIn() && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.SACRIFICE_PERMANENT, objectId, source, controllerId))) {
if (isPhasedIn() && canBeSacrificed && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.SACRIFICE_PERMANENT, objectId, source, controllerId))) {
// Commander replacement effect or Rest in Peace (exile instead of graveyard) in play does not prevent successful sacrifice
// so the return value of the moveToZone is not taken into account here
moveToZone(Zone.GRAVEYARD, source, game, false);
@ -1773,6 +1776,16 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
return protectorId != null && protectorId.equals(playerId);
}
@Override
public void setCanBeSacrificed(boolean canBeSacrificed) {
this.canBeSacrificed = canBeSacrificed;
}
@Override
public boolean canBeSacrificed() {
return canBeSacrificed;
}
@Override
public void setPairedCard(MageObjectReference pairedCard) {
this.pairedPermanent = pairedCard;