From dcfa5458ad183f707baf7d173967b35a94183f63 Mon Sep 17 00:00:00 2001 From: Sloth Date: Sun, 26 Aug 2012 20:21:10 +0000 Subject: [PATCH] - Merged the two payCostDuringAbilityResolve functions into one. - Added Phyrexian Soulgorger. --- .gitattributes | 1 + res/cardsfolder/p/phyrexian_soulgorger.txt | 12 +++++++ src/main/java/forge/GameAction.java | 2 +- src/main/java/forge/GameActionUtil.java | 41 +++++++++++++++++----- src/main/java/forge/game/phase/Upkeep.java | 24 ++++++------- 5 files changed, 58 insertions(+), 22 deletions(-) create mode 100644 res/cardsfolder/p/phyrexian_soulgorger.txt diff --git a/.gitattributes b/.gitattributes index bcccba4f231..1e40b79b8e2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6917,6 +6917,7 @@ res/cardsfolder/p/phyrexian_revoker.txt -text res/cardsfolder/p/phyrexian_scuta.txt svneol=native#text/plain res/cardsfolder/p/phyrexian_slayer.txt -text res/cardsfolder/p/phyrexian_snowcrusher.txt svneol=native#text/plain +res/cardsfolder/p/phyrexian_soulgorger.txt -text res/cardsfolder/p/phyrexian_splicer.txt -text res/cardsfolder/p/phyrexian_swarmlord.txt svneol=native#text/plain res/cardsfolder/p/phyrexian_totem.txt svneol=native#text/plain diff --git a/res/cardsfolder/p/phyrexian_soulgorger.txt b/res/cardsfolder/p/phyrexian_soulgorger.txt new file mode 100644 index 00000000000..4924abb74a4 --- /dev/null +++ b/res/cardsfolder/p/phyrexian_soulgorger.txt @@ -0,0 +1,12 @@ +Name:Phyrexian Soulgorger +ManaCost:3 +Types:Snow Artifact Creature Construct +Text:no text +PT:8/8 +K:Cumulative upkeep:Sac<1/Creature>:Sacrifice a creature. +SVar:RemAIDeck:True +SVar:Rarity:Rare +SVar:Picture:http://www.wizards.com/global/images/magic/general/phyrexian_soulgorger.jpg +SetInfo:CSP|Rare|http://magiccards.info/scans/en/cs/141.jpg +Oracle:Cumulative upkeep-Sacrifice a creature. (At the beginning of your upkeep, put an age counter on this permanent, then sacrifice it unless you pay its upkeep cost for each age counter on it.) +End \ No newline at end of file diff --git a/src/main/java/forge/GameAction.java b/src/main/java/forge/GameAction.java index 19474ec6b08..fa02a227df1 100644 --- a/src/main/java/forge/GameAction.java +++ b/src/main/java/forge/GameAction.java @@ -525,7 +525,7 @@ public class GameAction { @Override public void resolve() { if (recoverable.getController().isHuman()) { - GameActionUtil.payCostDuringAbilityResolve(sb.toString(), recoverable, recoverCost, + GameActionUtil.payCostDuringAbilityResolve(abRecover, abRecover.getPayCosts(), paidCommand, unpaidCommand); } else { // computer if (ComputerUtil.canPayCost(abRecover)) { diff --git a/src/main/java/forge/GameActionUtil.java b/src/main/java/forge/GameActionUtil.java index 009f885c921..996f373724a 100644 --- a/src/main/java/forge/GameActionUtil.java +++ b/src/main/java/forge/GameActionUtil.java @@ -28,6 +28,7 @@ import forge.card.cost.Cost; import forge.card.cost.CostPart; import forge.card.cost.CostPayLife; import forge.card.cost.CostMana; +import forge.card.cost.CostPutCounter; import forge.card.cost.CostSacrifice; import forge.card.spellability.Ability; import forge.card.spellability.AbilityMana; @@ -370,7 +371,7 @@ public final class GameActionUtil { * @param unpaid * a {@link forge.Command} object. */ - public static void payCostDuringAbilityResolve(final String message, Card hostCard, final String manaCost, + /*public static void payCostDuringAbilityResolve(final String message, Card hostCard, final String manaCost, final Command paid, final Command unpaid) { if (manaCost.startsWith("PayLife")) { String amountString = manaCost.split("<")[1].split(">")[0]; @@ -422,7 +423,7 @@ public final class GameActionUtil { AllZone.getStack().setResolving(false); AllZone.getInputControl().setInput(new InputPayManaCostAbility(message, manaCost, paid, unpaid)); AllZone.getStack().setResolving(bResolving); - } + }*/ /** *

@@ -443,9 +444,9 @@ public final class GameActionUtil { if (cost.getCostParts().size() > 1) { throw new RuntimeException("GameActionUtil::payCostDuringAbilityResolve - Too many payment types - " + source); } - final CostPart unlessCost = cost.getCostParts().get(0); - if (unlessCost instanceof CostPayLife) { - String amountString = unlessCost.getAmount(); + final CostPart costPart = cost.getCostParts().get(0); + if (costPart instanceof CostPayLife) { + String amountString = costPart.getAmount(); final int amount = amountString.matches("[0-9][0-9]?") ? Integer.parseInt(amountString) : CardFactoryUtil.xCount(source, source.getSVar(amountString)); if (AllZone.getHumanPlayer().canPayLife(amount) && showYesNoDialog(source, "Do you want to pay " @@ -458,14 +459,36 @@ public final class GameActionUtil { return; } - else if (unlessCost instanceof CostSacrifice) { + else if (costPart instanceof CostPutCounter) { + String amountString = costPart.getAmount(); + Counters counterType = ((CostPutCounter) costPart).getCounter(); + int amount = amountString.matches("[0-9][0-9]?") ? Integer.parseInt(amountString) + : CardFactoryUtil.xCount(source, source.getSVar(amountString)); + String plural = amount > 1 ? "s" : ""; + if (showYesNoDialog(source, "Do you want to put " + amount + " " + counterType.getName() + + " counter" + plural + " on " + source + "?")) { + if (source.canHaveCountersPlacedOnIt(counterType)) { + source.addCounterFromNonEffect(counterType, amount); + paid.execute(); + } else { + unpaid.execute(); + AllZone.getGameLog().add("ResolveStack", "Trying to pay upkeep for " + source + " but it can't have " + + counterType.getName() + " counters put on it.", 2); + } + } else { + unpaid.execute(); + } + return; + } + + else if (costPart instanceof CostSacrifice) { final boolean bResolving = AllZone.getStack().getResolving(); AllZone.getStack().setResolving(false); - AllZone.getInputControl().setInput(new InputPaySacCost((CostSacrifice) unlessCost, ability, paid, unpaid)); + AllZone.getInputControl().setInput(new InputPaySacCost((CostSacrifice) costPart, ability, paid, unpaid)); AllZone.getStack().setResolving(bResolving); } - else if (unlessCost instanceof CostMana) { - if (unlessCost.getAmount().equals("0")) { + else if (costPart instanceof CostMana) { + if (costPart.getAmount().equals("0")) { if (showYesNoDialog(source, "Do you want to pay 0?")) { paid.execute(); } else { diff --git a/src/main/java/forge/game/phase/Upkeep.java b/src/main/java/forge/game/phase/Upkeep.java index c1bc0d57647..3e816133cb4 100644 --- a/src/main/java/forge/game/phase/Upkeep.java +++ b/src/main/java/forge/game/phase/Upkeep.java @@ -182,7 +182,7 @@ public class Upkeep extends Phase implements java.io.Serializable { } }; - final Ability aiPaid = Upkeep.upkeepAIPayment(c, c.getEchoCost()); + final Ability blankAbility = Upkeep.BlankAbility(c, c.getEchoCost()); final StringBuilder sb = new StringBuilder(); sb.append("Echo for ").append(c).append("\n"); @@ -192,10 +192,10 @@ public class Upkeep extends Phase implements java.io.Serializable { public void resolve() { if (c.getController().isHuman()) { Cost cost = new Cost(c, c.getEchoCost().trim(), true); - GameActionUtil.payCostDuringAbilityResolve(aiPaid, cost, paidCommand, unpaidCommand); + GameActionUtil.payCostDuringAbilityResolve(blankAbility, cost, paidCommand, unpaidCommand); } else { // computer - if (ComputerUtil.canPayCost(aiPaid)) { - ComputerUtil.playNoStack(aiPaid); + if (ComputerUtil.canPayCost(blankAbility)) { + ComputerUtil.playNoStack(blankAbility); } else { Singletons.getModel().getGameAction().sacrifice(c, null); } @@ -302,7 +302,7 @@ public class Upkeep extends Phase implements java.io.Serializable { final Command paidCommand = Command.BLANK; - final Ability aiPaid = Upkeep.upkeepAIPayment(c, upkeepCost); + final Ability aiPaid = Upkeep.BlankAbility(c, upkeepCost); final StringBuilder sb = new StringBuilder(); sb.append("Upkeep for ").append(c).append("\n"); @@ -362,17 +362,17 @@ public class Upkeep extends Phase implements java.io.Serializable { final Command paidCommand = Command.BLANK; - final Ability aiPaid = Upkeep.upkeepAIPayment(c, upkeepCost); + final Ability blankAbility = Upkeep.BlankAbility(c, upkeepCost); final Ability upkeepAbility = new Ability(c, "0") { @Override public void resolve() { if (controller.isHuman()) { - GameActionUtil.payCostDuringAbilityResolve(sb.toString(), c, upkeepCost, paidCommand, - unpaidCommand); + GameActionUtil.payCostDuringAbilityResolve(blankAbility, blankAbility.getPayCosts(), + paidCommand, unpaidCommand); } else { // computer - if (ComputerUtil.shouldPayCost(c, upkeepCost) && ComputerUtil.canPayCost(aiPaid)) { - ComputerUtil.playNoStack(aiPaid); + if (ComputerUtil.shouldPayCost(c, upkeepCost) && ComputerUtil.canPayCost(blankAbility)) { + ComputerUtil.playNoStack(blankAbility); } else { Singletons.getModel().getGameAction().sacrifice(c, null); } @@ -404,7 +404,7 @@ public class Upkeep extends Phase implements java.io.Serializable { final Command paidCommand = Command.BLANK; - final Ability aiPaid = Upkeep.upkeepAIPayment(c, upkeepCost); + final Ability aiPaid = Upkeep.BlankAbility(c, upkeepCost); final StringBuilder sb = new StringBuilder(); sb.append("Damage upkeep for ").append(c).append("\n"); @@ -447,7 +447,7 @@ public class Upkeep extends Phase implements java.io.Serializable { * a {@link java.lang.String} object. * @return a {@link forge.card.spellability.Ability} object. */ - private static Ability upkeepAIPayment(final Card c, final String costString) { + private static Ability BlankAbility(final Card c, final String costString) { Cost cost = new Cost(c, costString, true); return new AbilityStatic(c, cost, null) { @Override