Implemented K'rrik, Son of Yawgmoth

KNOWN ISSUE: K'rrik's ability allowing the player to pay Phyrexian for black mana remains active after K'rrik leaves the battlefield.
This commit is contained in:
ssouders412 2019-11-11 00:17:57 -05:00
parent b4325b1daa
commit 6fd9cab283
9 changed files with 593 additions and 311 deletions

View file

@ -17,6 +17,7 @@ import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.Card;
import mage.cards.SplitCard;
import mage.constants.*;
import mage.filter.FilterMana;
import mage.game.Game;
import mage.game.command.Emblem;
import mage.game.command.Plane;
@ -548,6 +549,11 @@ 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;
PayLifeCost payLifeCost = new PayLifeCost(2);
@ -557,6 +563,37 @@ 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

@ -12,6 +12,7 @@ import mage.constants.ColoredManaSymbol;
import mage.constants.ManaType;
import mage.constants.Outcome;
import mage.filter.Filter;
import mage.filter.FilterMana;
import mage.game.Game;
import mage.players.ManaPool;
import mage.players.Player;
@ -166,6 +167,11 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
while (manaCostIterator.hasNext()) {
ManaCost manaCost = manaCostIterator.next();
PhyrexianManaCost tempPhyrexianCost = null;
Mana mana = manaCost.getMana();
FilterMana phyrexianColors = player.getPhyrexianColors();
if (manaCost instanceof PhyrexianManaCost) {
PhyrexianManaCost phyrexianManaCost = (PhyrexianManaCost) manaCost;
PayLifeCost payLifeCost = new PayLifeCost(2);
@ -175,6 +181,37 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
tempCosts.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(source, source.getSourceId(), player.getId(), game)
&& player.chooseUse(Outcome.LoseLife, "Pay 2 life instead of " + tempPhyrexianCost.getBaseText() + '?', source, game)) {
manaCostIterator.remove();
tempCosts.add(payLifeCost);
}
}
}
}
}
tempCosts.pay(source, game, source.getSourceId(), player.getId(), false, null);

View file

@ -21,6 +21,7 @@ import mage.counters.Counters;
import mage.designations.Designation;
import mage.designations.DesignationType;
import mage.filter.FilterPermanent;
import mage.filter.FilterMana;
import mage.game.Game;
import mage.game.Graveyard;
import mage.game.Table;
@ -894,4 +895,9 @@ public interface Player extends MageItem, Copyable<Player> {
List<Designation> getDesignations();
void addPhyrexianToColors(FilterMana colors);
void removePhyrexianFromColors(FilterMana colors);
FilterMana getPhyrexianColors();
}

View file

@ -36,6 +36,7 @@ import mage.designations.Designation;
import mage.designations.DesignationType;
import mage.filter.FilterCard;
import mage.filter.FilterPermanent;
import mage.filter.FilterMana;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.common.FilterCreatureForCombat;
import mage.filter.common.FilterCreatureForCombatBlock;
@ -174,6 +175,8 @@ public abstract class PlayerImpl implements Player, Serializable {
protected List<Designation> designations = new ArrayList<>();
protected FilterMana phyrexianColors = new FilterMana();
/**
* During some steps we can't play anything
*/
@ -276,6 +279,8 @@ public abstract class PlayerImpl implements Player, Serializable {
this.payManaMode = player.payManaMode;
this.designations.addAll(player.designations);
this.phyrexianColors = player.phyrexianColors;
}
@Override
@ -4160,4 +4165,48 @@ public abstract class PlayerImpl implements Player, Serializable {
hash = 89 * hash + Objects.hashCode(this.playerId);
return hash;
}
@Override
public void addPhyrexianToColors(FilterMana colors) {
if (colors.isWhite()) {
this.phyrexianColors.setWhite(true);
}
if (colors.isBlue()) {
this.phyrexianColors.setBlue(true);
}
if (colors.isBlack()) {
this.phyrexianColors.setBlack(true);
}
if (colors.isRed()) {
this.phyrexianColors.setRed(true);
}
if (colors.isGreen()) {
this.phyrexianColors.setGreen(true);
}
}
@Override
public void removePhyrexianFromColors(FilterMana colors) {
if (colors.isWhite()) {
this.phyrexianColors.setWhite(false);
}
if (colors.isBlue()) {
this.phyrexianColors.setBlue(false);
}
if (colors.isBlack()) {
this.phyrexianColors.setBlack(false);
}
if (colors.isRed()) {
this.phyrexianColors.setRed(false);
}
if (colors.isGreen()) {
this.phyrexianColors.setGreen(false);
}
}
@Override
public FilterMana getPhyrexianColors() {
return this.phyrexianColors.copy();
}
}

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.stream.Collectors.toList;
import mage.filter.FilterMana;
public class StubPlayer extends PlayerImpl implements Player {
@ -216,6 +217,20 @@ public class StubPlayer extends PlayerImpl implements Player {
@Override
public void pickCard(List<Card> cards, Deck deck, Draft draft) {
}
@Override
public void addPhyrexianToColors(FilterMana colors) {
}
@Override
public void removePhyrexianFromColors(FilterMana colors) {
}
@Override
public FilterMana getPhyrexianColors() {
return (new FilterMana());
}
}