Fix Vexing Puzzlebox (#5180)

This commit is contained in:
tool4ever
2024-05-02 22:16:35 +02:00
committed by GitHub
parent 732259f78b
commit 249c259dbf
3 changed files with 12 additions and 10 deletions

View File

@@ -673,17 +673,18 @@ public class AbilityUtils {
final SpellAbility root = sa.getRootAbility();
final String[] l = calcX[1].split("/");
final String m = CardFactoryUtil.extractOperators(calcX[1]);
final Object to = root.getTriggeringObject(AbilityKey.fromString(l[0]));
Integer count = null;
if (calcX[0].endsWith("Max")) {
if (to instanceof Iterable<?>) {
@SuppressWarnings("unchecked")
Iterable<Integer> numbers = (Iterable<Integer>) root.getTriggeringObject(AbilityKey.fromString(l[0]));
for (Integer n : numbers) {
if (count == null || n > count) {
count = n;
}
Iterable<Integer> numbers = (Iterable<Integer>) to;
if (calcX[0].endsWith("Max")) {
count = Aggregates.max(numbers, Functions.identity());
} else {
count = Aggregates.sum(numbers, Functions.identity());
}
} else {
count = (Integer) root.getTriggeringObject(AbilityKey.fromString(l[0]));
count = (Integer) to;
}
val = doXMath(ObjectUtils.firstNonNull(count, 0), m, card, ability);

View File

@@ -5,9 +5,10 @@ PT:0/0
K:Flying
K:etbCounter:P1P1:5
R:Event$ DamageDone | ActiveZones$ Battlefield | ValidTarget$ Card.Self+counters_GE1_P1P1 | ReplaceWith$ Counters | PreventionEffect$ True | AlwaysReplace$ True | Description$ If damage would be dealt to CARDNAME while it has a +1/+1 counter on it, prevent that damage, remove that many +1/+1 counters it, then give each player a rad counter for each +1/+1 counter removed this way.
SVar:Counters:DB$ RemoveCounter | Defined$ ReplacedTarget | CounterType$ P1P1 | CounterNum$ Y | RememberRemoved$ True | SubAbility$ DBRadiation
SVar:DBRadiation:DB$ Radiation | Defined$ Player | Num$ Y | SubAbility$ DBCleanup
SVar:Counters:DB$ RemoveCounter | Defined$ ReplacedTarget | CounterType$ P1P1 | CounterNum$ Y | RememberAmount$ True | SubAbility$ DBRadiation
SVar:DBRadiation:DB$ Radiation | Defined$ Player | Num$ Z | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
SVar:Y:ReplaceCount$DamageAmount
SVar:Z:Count$RememberedNumber
DeckHas:Ability$Counters
Oracle:Flying\nBloatfly Swarm enters the battlefield with five +1/+1 counters on it.\nIf damage would be dealt to Bloatfly Swarm while it has a +1/+1 counter on it, prevent that damage, remove that many +1/+1 counters from it, then give each player a rad counter for each +1/+1 counter removed this way.

View File

@@ -2,7 +2,7 @@ Name:Vexing Puzzlebox
ManaCost:3
Types:Artifact
T:Mode$ RolledDieOnce | TriggerZones$ Battlefield | ValidPlayer$ You | Execute$ TrigPutCounter | TriggerDescription$ Whenever you roll one or more dice, put a number of charge counters on CARDNAME equal to the result.
SVar:DiceResult:TriggerCountMax$Result
SVar:DiceResult:TriggerCount$Result
SVar:TrigPutCounter:DB$ PutCounter | CounterType$ CHARGE | CounterNum$ DiceResult
A:AB$ Mana | Cost$ T | Produced$ Any | SubAbility$ DBRollDice | SpellDescription$ Add one mana of any color. Roll a d20.
SVar:DBRollDice:DB$ RollDice | Sides$ 20