SacrificeEffect streamline optional

This commit is contained in:
Northmoc
2021-11-05 20:21:41 -04:00
parent b0f87d9da1
commit e25de294fa

View File

@@ -100,15 +100,19 @@ public class SacrificeEffect extends SpellAbilityEffect {
final boolean destroy = sa.hasParam("Destroy"); final boolean destroy = sa.hasParam("Destroy");
final boolean remSacrificed = sa.hasParam("RememberSacrificed"); final boolean remSacrificed = sa.hasParam("RememberSacrificed");
final boolean optional = sa.hasParam("Optional");
CardZoneTable table = new CardZoneTable(); CardZoneTable table = new CardZoneTable();
Map<AbilityKey, Object> params = AbilityKey.newMap(); Map<AbilityKey, Object> params = AbilityKey.newMap();
params.put(AbilityKey.LastStateBattlefield, game.copyLastStateBattlefield()); params.put(AbilityKey.LastStateBattlefield, game.copyLastStateBattlefield());
if (valid.equals("Self") && game.getZoneOf(card) != null) { if (valid.equals("Self") && game.getZoneOf(card) != null) {
if (game.getZoneOf(card).is(ZoneType.Battlefield)) { if (game.getZoneOf(card).is(ZoneType.Battlefield)) {
if (game.getAction().sacrifice(card, sa, table, params) != null) { if (!optional || activator.getController().confirmAction(sa, null,
if (remSacrificed) { Localizer.getInstance().getMessage("lblDoYouWantSacrificeThis"), card.getName())) {
card.addRemembered(card); if (game.getAction().sacrifice(card, sa, table, params) != null) {
if (remSacrificed) {
card.addRemembered(card);
}
} }
} }
} }
@@ -147,12 +151,11 @@ public class SacrificeEffect extends SpellAbilityEffect {
if (sa.hasParam("Random")) { if (sa.hasParam("Random")) {
choosenToSacrifice = Aggregates.random(validTargets, Math.min(amount, validTargets.size()), new CardCollection()); choosenToSacrifice = Aggregates.random(validTargets, Math.min(amount, validTargets.size()), new CardCollection());
} else if (sa.hasParam("OptionalSacrifice") && !p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantSacrifice"))) { } else if (optional && !p.getController().confirmAction(sa, null, Localizer.getInstance().getMessage("lblDoYouWantSacrifice"))) {
choosenToSacrifice = CardCollection.EMPTY; choosenToSacrifice = CardCollection.EMPTY;
} else { } else {
boolean isOptional = sa.hasParam("Optional");
boolean isStrict = sa.hasParam("StrictAmount"); boolean isStrict = sa.hasParam("StrictAmount");
int minTargets = isOptional ? 0 : amount; int minTargets = optional ? 0 : amount;
boolean notEnoughTargets = isStrict && validTargets.size() < minTargets; boolean notEnoughTargets = isStrict && validTargets.size() < minTargets;
if (!notEnoughTargets) { if (!notEnoughTargets) {