From 53e6671143c6f77f92b74a1168a124e3d12474aa Mon Sep 17 00:00:00 2001 From: swordshine Date: Sun, 1 Dec 2013 05:34:21 +0000 Subject: [PATCH] - Added Call to Arms --- .gitattributes | 1 + forge-gui/res/cardsfolder/c/call_to_arms.txt | 14 ++++++++ .../java/forge/game/card/CardFactoryUtil.java | 34 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 forge-gui/res/cardsfolder/c/call_to_arms.txt diff --git a/.gitattributes b/.gitattributes index 3c4b2f0c7b8..06207a77aad 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1656,6 +1656,7 @@ forge-gui/res/cardsfolder/c/call_of_the_herd.txt svneol=native#text/plain forge-gui/res/cardsfolder/c/call_of_the_nightwing.txt -text forge-gui/res/cardsfolder/c/call_of_the_wild.txt svneol=native#text/plain forge-gui/res/cardsfolder/c/call_the_skybreaker.txt svneol=native#text/plain +forge-gui/res/cardsfolder/c/call_to_arms.txt -text forge-gui/res/cardsfolder/c/call_to_glory.txt svneol=native#text/plain forge-gui/res/cardsfolder/c/call_to_heel.txt svneol=native#text/plain forge-gui/res/cardsfolder/c/call_to_mind.txt svneol=native#text/plain diff --git a/forge-gui/res/cardsfolder/c/call_to_arms.txt b/forge-gui/res/cardsfolder/c/call_to_arms.txt new file mode 100644 index 00000000000..8555d91bd37 --- /dev/null +++ b/forge-gui/res/cardsfolder/c/call_to_arms.txt @@ -0,0 +1,14 @@ +Name:Call to Arms +ManaCost:1 W +Types:Enchantment +K:ETBReplacement:Other:ChooseColor +SVar:ChooseColor:DB$ ChooseColor | AILogic$ MostProminentHumanControls | Defined$ You | SubAbility$ ChooseOpp | SpellDescription$ As CARDNAME enters the battlefield, choose a color and an opponent. +SVar:ChooseOpp:DB$ ChoosePlayer | Defined$ You | Choices$ Player.Opponent | AILogic$ Curse +SVar:X:Count$Valid Permanent.nonToken+ChosenColor+ChosenCtrl +SVar:Y:Count$SecondMostProminentColor Permanent.nonToken+ChosenCtrl +S:Mode$ Continuous | Affected$ Creature.White | AddPower$ 1 | AddToughness$ 1 | CheckSVar$ X | SVarCompare$ GTY | Description$ White creatures get +1/+1 as long as the chosen color is the most common color among nontoken permanents the chosen player controls but isn't tied for most common. +T:Mode$ Always | CheckSVar$ X | SVarCompare$ LEY | TriggerZones$ Battlefield | Execute$ TrigSac | TriggerDescription$ When the chosen color isn't the most common color among nontoken permanents the chosen player controls or is tied for most common, sacrifice CARDNAME. +SVar:TrigSac:DB$ Sacrifice | SacValid$ Self +SVar:RemRandomDeck:True +SVar:Picture:http://www.wizards.com/global/images/magic/general/call_to_arms.jpg +Oracle:As Call to Arms enters the battlefield, choose a color and an opponent.\nWhite creatures get +1/+1 as long as the chosen color is the most common color among nontoken permanents the chosen player controls but isn't tied for most common.\nWhen the chosen color isn't the most common color among nontoken permanents the chosen player controls or is tied for most common, sacrifice Call to Arms. diff --git a/forge-gui/src/main/java/forge/game/card/CardFactoryUtil.java b/forge-gui/src/main/java/forge/game/card/CardFactoryUtil.java index 315ec3816bb..aaebb5a207e 100644 --- a/forge-gui/src/main/java/forge/game/card/CardFactoryUtil.java +++ b/forge-gui/src/main/java/forge/game/card/CardFactoryUtil.java @@ -1117,6 +1117,13 @@ public class CardFactoryUtil { return doXMath(getMostProminentCreatureTypeSize(list), m, c); } + if (l[0].startsWith("SecondMostProminentColor")) { + String restriction = l[0].split(" ")[1]; + List list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), restriction, cc, c); + int[] colorSize = SortColorsFromList(list); + return doXMath(colorSize[colorSize.length - 2], m, c); + } + if (l[0].startsWith("RolledThisTurn")) { return game.getPhaseHandler().getPlanarDiceRolledthisTurn(); } @@ -1822,6 +1829,33 @@ public class CardFactoryUtil { return mask; } + /** + *

+ * SortColorsFromList. + *

+ * + * @param list + * a {@link forge.CardList} object. + * @return a List. + */ + public static int[] SortColorsFromList(final List list) { + int cntColors = MagicColor.WUBRG.length; + final int[] map = new int[cntColors]; + for(int i = 0; i < cntColors; i++) { + map[i] = 0; + } + + for (final Card crd : list) { + ColorSet color = CardUtil.getColors(crd); + for(int i = 0; i < cntColors; i++) { + if( color.hasAnyColor(MagicColor.WUBRG[i])) + map[i]++; + } + } // for + Arrays.sort(map); + return map; + } + /** *

* getMostProminentColorsFromList.