[AFC] Fixed Belt of Giant Strength cost reduction (fixes #8347)

This commit is contained in:
Daniel Bomar 2021-10-23 15:40:58 -05:00
parent 4094580a6c
commit b63623b40f
No known key found for this signature in database
GPG key ID: C86C8658F4023918
2 changed files with 23 additions and 6 deletions

View file

@ -51,10 +51,28 @@ enum BeltOfGiantStrengthAdjuster implements CostAdjuster {
@Override
public void adjustCosts(Ability ability, Game game) {
Permanent permanent = game.getPermanent(ability.getFirstTarget());
if (permanent == null) {
return;
if (game.inCheckPlayableState()) {
int maxPower = 0;
for (UUID permId : CardUtil.getAllPossibleTargets(ability, game)) {
Permanent permanent = game.getPermanent(permId);
if (permanent != null) {
int power = permanent.getPower().getValue();
if (power > maxPower) {
maxPower = power;
}
}
}
if (maxPower > 0) {
CardUtil.reduceCost(ability, maxPower);
}
} else {
Permanent permanent = game.getPermanent(ability.getFirstTarget());
if (permanent != null) {
int power = permanent.getPower().getValue();
if (power > 0) {
CardUtil.reduceCost(ability, power);
}
}
}
CardUtil.reduceCost(ability, Integer.max(permanent.getPower().getValue(), 0));
}
}
}

View file

@ -42,7 +42,6 @@ public class BeltOfGiantStrengthTest extends CardTestPlayerBase {
);
}
@Ignore // currently failing, need to fix
@Test
public void testWithoutManaAvailable() {
addCard(Zone.BATTLEFIELD, playerA, belt);