K'rrik fixes, payment for triggered abilities (#6060)

* K'rrik fixes, payment for triggered abilities

K'rrik's Phyrexian ability is now handled separately from actual Phyrexian mana costs. It can now be used to pay for triggered abilities like Extort.

* K'rrik tests added

Tests include:
- only usable by 1 player
- usable with activated/triggered abilities
- usable as an alternative to true Phyrexian mana, getting around Trinisphere
This commit is contained in:
Sarah Souders 2019-12-04 17:27:41 -05:00 committed by Jeff Wadsworth
parent 95d749648e
commit e437577b5a
4 changed files with 115 additions and 44 deletions

View file

@ -549,10 +549,6 @@ public abstract class AbilityImpl implements Ability {
Iterator<ManaCost> costIterator = manaCostsToPay.iterator();
while (costIterator.hasNext()) {
ManaCost cost = costIterator.next();
PhyrexianManaCost tempPhyrexianCost = null;
Mana mana = cost.getMana();
FilterMana phyrexianColors = controller.getPhyrexianColors();
if (cost instanceof PhyrexianManaCost) {
PhyrexianManaCost phyrexianManaCost = (PhyrexianManaCost) cost;
@ -563,37 +559,6 @@ public abstract class AbilityImpl implements Ability {
costs.add(payLifeCost);
}
}
/* K'rrik, Son of Yawgmoth ability check */
else if (phyrexianColors != null) {
int phyrexianEnabledPips = mana.count(phyrexianColors);
if (phyrexianEnabledPips > 0) {
/* find which color mana is in the cost and set it in the temp Phyrexian cost */
if (phyrexianColors.isWhite() && mana.getWhite() > 0) {
tempPhyrexianCost = new PhyrexianManaCost(ColoredManaSymbol.W);
}
else if (phyrexianColors.isBlue() && mana.getBlue() > 0) {
tempPhyrexianCost = new PhyrexianManaCost(ColoredManaSymbol.U);
}
else if (phyrexianColors.isBlack() && mana.getBlack() > 0) {
tempPhyrexianCost = new PhyrexianManaCost(ColoredManaSymbol.B);
}
else if (phyrexianColors.isRed() && mana.getRed() > 0) {
tempPhyrexianCost = new PhyrexianManaCost(ColoredManaSymbol.R);
}
else if (phyrexianColors.isGreen() && mana.getGreen() > 0) {
tempPhyrexianCost = new PhyrexianManaCost(ColoredManaSymbol.G);
}
if (tempPhyrexianCost != null) {
PayLifeCost payLifeCost = new PayLifeCost(2);
if (payLifeCost.canPay(this, sourceId, controller.getId(), game)
&& controller.chooseUse(Outcome.LoseLife, "Pay 2 life instead of " + tempPhyrexianCost.getBaseText() + '?', this, game)) {
costIterator.remove();
costs.add(payLifeCost);
}
}
}
}
}
}

View file

@ -118,6 +118,7 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
}
Player player = game.getPlayer(controllerId);
handleKrrikPhyrexianManaCosts(controllerId, ability, game);
if (!player.getManaPool().isForcedToPay()) {
assignPayment(game, ability, player.getManaPool(), this);
}
@ -181,8 +182,27 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
tempCosts.add(payLifeCost);
}
}
}
tempCosts.pay(source, game, source.getSourceId(), player.getId(), false, null);
}
private void handleKrrikPhyrexianManaCosts(UUID payingPlayerId, Ability source, Game game) {
Player player = game.getPlayer(payingPlayerId);
if (this == null || player == null) {
return; // nothing to be done without any mana costs. prevents NRE from occurring here
}
Iterator<T> manaCostIterator = this.iterator();
Costs<PayLifeCost> tempCosts = new CostsImpl<>();
while (manaCostIterator.hasNext()) {
ManaCost manaCost = manaCostIterator.next();
Mana mana = manaCost.getMana();
PhyrexianManaCost tempPhyrexianCost = null;
FilterMana phyrexianColors = player.getPhyrexianColors();
/* K'rrik, Son of Yawgmoth ability check */
else if (phyrexianColors != null) {
if (phyrexianColors != null) {
int phyrexianEnabledPips = mana.count(phyrexianColors);
if (phyrexianEnabledPips > 0) {
/* find which color mana is in the cost and set it in the temp Phyrexian cost */
@ -205,7 +225,7 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
if (tempPhyrexianCost != null) {
PayLifeCost payLifeCost = new PayLifeCost(2);
if (payLifeCost.canPay(source, source.getSourceId(), player.getId(), game)
&& player.chooseUse(Outcome.LoseLife, "Pay 2 life instead of " + tempPhyrexianCost.getBaseText() + '?', source, game)) {
&& player.chooseUse(Outcome.LoseLife, "Pay 2 life (using an active ability) instead of " + tempPhyrexianCost.getBaseText() + '?', source, game)) {
manaCostIterator.remove();
tempCosts.add(payLifeCost);
}