update cards and effects that missed canPaySacrificeCost (#13916)

* update SacrificeAttachmentCost to work with canPaySacrificeCost

* update SacrificeXTargetCost to use canPaySacrificeCost

* update SacrificeXManaValueCost to use canPaySacrificeCost and getMaxValue

* update Phyrexian Dreadnought to use canPaySacrificeCost

* enable testNahiriSacrificePrevented test
This commit is contained in:
Jmlundeen 2025-08-27 21:38:02 -05:00 committed by GitHub
parent 366ffbb1e0
commit 47f2eb4c94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 73 additions and 5 deletions

View file

@ -6,6 +6,7 @@ import mage.abilities.costs.SacrificeCost;
import mage.abilities.costs.UseAttachedCost;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.UUID;
@ -52,7 +53,12 @@ public class SacrificeAttachmentCost extends UseAttachedCost implements Sacrific
if (!super.canPay(ability, source, controllerId, game)) {
return false;
}
return game.getPermanent(source.getSourceId()).canBeSacrificed();
Player controller = game.getPlayer(controllerId);
Permanent permanent = mageObjectReference.getPermanent(game);
if (controller == null || permanent == null) {
return false;
}
return controller.canPaySacrificeCost(permanent, source, controllerId, game);
}
@Override

View file

@ -7,8 +7,12 @@ import mage.abilities.costs.VariableCostImpl;
import mage.abilities.costs.VariableCostType;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetSacrifice;
import java.util.UUID;
/**
* @author LevelX2
*/
@ -39,6 +43,26 @@ public class SacrificeXTargetCost extends VariableCostImpl implements SacrificeC
this.minValue = cost.minValue;
}
@Override
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
int canSacAmount = getValidSacAmount(source, controllerId, game);
return canSacAmount >= minValue;
}
private int getValidSacAmount(Ability source, UUID controllerId, Game game) {
Player controller = game.getPlayer(controllerId);
if (controller == null) {
return -1;
}
int canSacAmount = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controllerId, game)) {
if (controller.canPaySacrificeCost(permanent, source, controllerId, game)) {
canSacAmount++;
}
}
return canSacAmount;
}
@Override
public SacrificeXTargetCost copy() {
return new SacrificeXTargetCost(this);
@ -51,7 +75,7 @@ public class SacrificeXTargetCost extends VariableCostImpl implements SacrificeC
@Override
public int getMaxValue(Ability source, Game game) {
return game.getBattlefield().count(filter, source.getControllerId(), source, game);
return getValidSacAmount(source, source.getControllerId(), game);
}
@Override