From 010c7672baa8ecb40b4b34145f40ea8df11146b0 Mon Sep 17 00:00:00 2001 From: moomarc Date: Fri, 5 Apr 2013 08:42:48 +0000 Subject: [PATCH] - Made some cards ready for multiplayer - minor style cleanup --- res/cardsfolder/h/havoc.txt | 2 +- res/cardsfolder/h/heartless_hidetsugu.txt | 7 ++-- res/cardsfolder/i/impatience.txt | 9 ++--- res/cardsfolder/i/ink_dissolver.txt | 2 +- .../java/forge/card/ability/AbilityUtils.java | 35 ++++++++++--------- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/res/cardsfolder/h/havoc.txt b/res/cardsfolder/h/havoc.txt index 4f09681424e..bb20e92d88e 100644 --- a/res/cardsfolder/h/havoc.txt +++ b/res/cardsfolder/h/havoc.txt @@ -2,7 +2,7 @@ Name:Havoc ManaCost:1 R Types:Enchantment T:Mode$ SpellCast | ValidCard$ Card.White | ValidActivatingPlayer$ Opponent | TriggerZones$ Battlefield | Execute$ TrigLoseLife | TriggerDescription$ Whenever an opponent casts a white spell, he or she loses 2 life. -SVar:TrigLoseLife:AB$LoseLife | Cost$ 0 | Defined$ Opponent | LifeAmount$ 2 +SVar:TrigLoseLife:AB$LoseLife | Cost$ 0 | Defined$ TriggeredActivator | LifeAmount$ 2 SVar:RemRandomDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/havoc.jpg Oracle:Whenever an opponent casts a white spell, he or she loses 2 life. diff --git a/res/cardsfolder/h/heartless_hidetsugu.txt b/res/cardsfolder/h/heartless_hidetsugu.txt index 083aa7b3b45..3290584c5ae 100644 --- a/res/cardsfolder/h/heartless_hidetsugu.txt +++ b/res/cardsfolder/h/heartless_hidetsugu.txt @@ -2,10 +2,9 @@ Name:Heartless Hidetsugu ManaCost:3 R R Types:Legendary Creature Ogre Shaman PT:4/3 -A:AB$ DealDamage | Cost$ T | Defined$ Opponent | NumDmg$ XOpp | SubAbility$ DBDealDamage | References$ XOpp | SpellDescription$ CARDNAME deals damage to each player equal to half that player's life total, rounded down. -SVar:DBDealDamage:DB$DealDamage | Cost$ 0 | Defined$ You | NumDmg$ XYou | References$ XYou -SVar:XOpp:Count$OppLifeTotal/HalfDown -SVar:XYou:Count$YourLifeTotal/HalfDown +A:AB$ RepeatEach | Cost$ T | RepeatPlayers$ Player | RepeatSubAbility$ DBDealDamage | SpellDescription$ CARDNAME deals damage to each player equal to half that player's life total, rounded down. +SVar:DBDealDamage:DB$ DealDamage | Defined$ Remembered | NumDmg$ HeartlessX | References$ HeartlessX +SVar:HeartlessX:PlayerCountRemembered$LifeTotal/HalfDown SVar:RemRandomDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/heartless_hidetsugu.jpg Oracle:{T}: Heartless Hidetsugu deals damage to each player equal to half that player's life total, rounded down. diff --git a/res/cardsfolder/i/impatience.txt b/res/cardsfolder/i/impatience.txt index d94f3638ba5..7914583da5d 100644 --- a/res/cardsfolder/i/impatience.txt +++ b/res/cardsfolder/i/impatience.txt @@ -1,12 +1,9 @@ Name:Impatience ManaCost:2 R Types:Enchantment -T:Mode$ Phase | Phase$ End of Turn | ValidPlayer$ You | CheckSVar$ YouCast | SVarCompare$ EQ0 | Execute$ TrigDamageYou | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of each player's end step, if that player didn't cast a spell this turn, CARDNAME deals 2 damage to him or her. -SVar:TrigDamageYou:AB$ DealDamage | Cost$ 0 | Defined$ You | NumDmg$ 2 -T:Mode$ Phase | Phase$ End of Turn | ValidPlayer$ Opponent | CheckSVar$ OppCast | SVarCompare$ EQ0 | Execute$ TrigDamageOpp | TriggerZones$ Battlefield | Secondary$ True | TriggerDescription$ At the beginning of each player's end step, if that player didn't cast a spell this turn, CARDNAME deals 2 damage to him or her. -SVar:TrigDamageOpp:AB$ DealDamage | Cost$ 0 | Defined$ Opponent | NumDmg$ 2 -SVar:YouCast:Count$ThisTurnCast_Card.YouCtrl -SVar:OppCast:Count$ThisTurnCast_Card.YouDontCtrl +T:Mode$ Phase | Phase$ End of Turn | CheckSVar$ TrigCast | SVarCompare$ EQ0 | Execute$ ImpatientDamage | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of each player's end step, if that player didn't cast a spell this turn, CARDNAME deals 2 damage to him or her. +SVar:ImpatientDamage:AB$ DealDamage | Cost$ 0 | Defined$ TriggeredPlayer | NumDmg$ 2 +SVar:TrigCast:Count$ThisTurnCast_Card.ActivePlayerCtrl SVar:RemRandomDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/impatience.jpg Oracle:At the beginning of each player's end step, if that player didn't cast a spell this turn, Impatience deals 2 damage to him or her. diff --git a/res/cardsfolder/i/ink_dissolver.txt b/res/cardsfolder/i/ink_dissolver.txt index 9adbaa44cb4..c476c02ac59 100644 --- a/res/cardsfolder/i/ink_dissolver.txt +++ b/res/cardsfolder/i/ink_dissolver.txt @@ -4,7 +4,7 @@ Types:Creature Merfolk Wizard PT:2/1 T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | Execute$ TrigKinship | TriggerZones$ Battlefield | OptionalDecider$ You | TriggerDescription$ Kinship - At the beginning of your upkeep, you may look at the top card of your library. If it shares a creature type with CARDNAME, you may reveal it. If you do, each opponent puts the top three cards of his or her library into his or her graveyard. SVar:TrigKinship:DB$ PeekAndReveal | PeekAmount$ 1 | RevealValid$ Card.sharesCreatureTypeWith | RevealOptional$ True | RememberRevealed$ True | SubAbility$ DBMill -SVar:DBMill:DB$ Mill | NumCards$ 3 | Defined$ Opponent | ConditionDefined$ Remembered | ConditionPresent$ Card | ConditionCompare$ EQ1 | SubAbility$ DBCleanup +SVar:DBMill:DB$ Mill | NumCards$ 3 | Defined$ Player.Opponent | ConditionDefined$ Remembered | ConditionPresent$ Card | ConditionCompare$ EQ1 | SubAbility$ DBCleanup SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True SVar:Picture:http://www.wizards.com/global/images/magic/general/ink_dissolver.jpg Oracle:Kinship - At the beginning of your upkeep, you may look at the top card of your library. If it shares a creature type with Ink Dissolver, you may reveal it. If you do, each opponent puts the top three cards of his or her library into his or her graveyard. diff --git a/src/main/java/forge/card/ability/AbilityUtils.java b/src/main/java/forge/card/ability/AbilityUtils.java index 9032da4b071..35a75d1184f 100644 --- a/src/main/java/forge/card/ability/AbilityUtils.java +++ b/src/main/java/forge/card/ability/AbilityUtils.java @@ -291,18 +291,17 @@ public class AbilityUtils { */ public static int calculateAmount(final Card card, String amount, final SpellAbility ability) { // return empty strings and constants - if (StringUtils.isBlank(amount)) return 0; + if (StringUtils.isBlank(amount)) { return 0; } final boolean startsWithPlus = amount.charAt(0) == '+'; - if(startsWithPlus) amount = amount.substring(1); + if (startsWithPlus) { amount = amount.substring(1); } // Strip and save sign for calculations boolean startsWithMinus = amount.charAt(0) == '-'; int multiplier = startsWithMinus ? -1 : 1; - if(startsWithMinus) - amount = amount.substring(1); + if (startsWithMinus) { amount = amount.substring(1); } // return result soon for plain numbers - if (StringUtils.isNumeric(amount)) return Integer.parseInt(amount) * multiplier; + if (StringUtils.isNumeric(amount)) { return Integer.parseInt(amount) * multiplier; } // These are some special cases - who is implementing them? if (amount.equals("ChosenX") || amount.equals("ChosenY")) { @@ -320,34 +319,38 @@ public class AbilityUtils { svarval = ability.getSVar(amount); } if (StringUtils.isBlank(svarval)) { - if( ability != null) { + if (ability != null) { System.err.printf("SVar '%s' not found in ability, fallback to Card (%s). Ability is (%s)%n", amount, card.getName(), ability); } svarval = card.getSVar(amount); } - + // Nothing to do here if value is missing or blank if (StringUtils.isBlank(svarval)) { System.err.printf("SVar '%s' not defined in Card (%s)%n", amount, card.getName()); return 0; } - + // Handle numeric constant coming in svar value - if( StringUtils.isNumeric(svarval) ) + if (StringUtils.isNumeric(svarval)) { return multiplier * Integer.parseInt(svarval); + } // Parse Object$Property string final String[] calcX = svarval.split("\\$"); - - // Incorrect parses mean zero. - if ((calcX.length == 1) || calcX[1].equals("none")) - return 0; - if (calcX[0].startsWith("Count")) + // Incorrect parses mean zero. + if ((calcX.length == 1) || calcX[1].equals("none")) { + return 0; + } + + if (calcX[0].startsWith("Count")) { return AbilityUtils.xCount(card, calcX[1], ability) * multiplier; - - if (calcX[0].startsWith("Number")) + } + + if (calcX[0].startsWith("Number")) { return CardFactoryUtil.xCount(card, svarval) * multiplier; + } if (calcX[0].startsWith("SVar")) { final String[] l = calcX[1].split("/");