diff --git a/.gitattributes b/.gitattributes index 508f9db0d9a..1a5ce176e6d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7245,6 +7245,7 @@ res/cardsfolder/m/mosquito_guard.txt svneol=native#text/plain res/cardsfolder/m/moss_diamond.txt svneol=native#text/plain res/cardsfolder/m/moss_kami.txt svneol=native#text/plain res/cardsfolder/m/moss_monster.txt svneol=native#text/plain +res/cardsfolder/m/mossbridge_troll.txt -text res/cardsfolder/m/mossdog.txt svneol=native#text/plain res/cardsfolder/m/mossfire_egg.txt svneol=native#text/plain res/cardsfolder/m/mossfire_valley.txt svneol=native#text/plain diff --git a/res/cardsfolder/m/mossbridge_troll.txt b/res/cardsfolder/m/mossbridge_troll.txt new file mode 100644 index 00000000000..d6d8c48615a --- /dev/null +++ b/res/cardsfolder/m/mossbridge_troll.txt @@ -0,0 +1,9 @@ +Name:Mossbridge Troll +ManaCost:5 G G +Types:Creature Troll +PT:5/5 +K:If CARDNAME would be destroyed, regenerate it. +A:AB$ Pump | Cost$ tapXType | CostDesc$ Tap any number of untapped creatures you control other than CARDNAME with total power 10 or greater: | Defined$ Self | NumAtt$ +20 | NumDef$ +20 | SpellDescription$ CARDNAME gets +20/+20 until end of turn. +SVar:RemAIDeck:True +SVar:Picture:http://www.wizards.com/global/images/magic/general/mossbridge_troll.jpg +Oracle:If Mossbridge Troll would be destroyed, regenerate it.\nTap any number of untapped creatures you control other than Mossbridge Troll with total power 10 or greater: Mossbridge Troll gets +20/+20 until end of turn. diff --git a/src/main/java/forge/CardLists.java b/src/main/java/forge/CardLists.java index 877cee04304..4b8b361f426 100644 --- a/src/main/java/forge/CardLists.java +++ b/src/main/java/forge/CardLists.java @@ -281,4 +281,18 @@ public class CardLists { } return tiedForLowest; } + + /** + * Given a List cardList, return a int TotalPower. + * + * @param cardList the Card List to be filtered. + * @return the total power. + */ + public static int getTotalPower(Iterable cardList) { + int total =0; + for (final Card crd : cardList) { + total += crd.getNetAttack(); + } + return total; + } } diff --git a/src/main/java/forge/card/cost/CostTapType.java b/src/main/java/forge/card/cost/CostTapType.java index 24bbafb49de..27544c58ed9 100644 --- a/src/main/java/forge/card/cost/CostTapType.java +++ b/src/main/java/forge/card/cost/CostTapType.java @@ -79,6 +79,9 @@ public class CostTapType extends CostPartWithList { if (type.contains("sharesCreatureTypeWith")) { sb.append("two untapped creatures you control that share a creature type"); + } else if (type.contains("+withTotalPowerGE")) { + String num = type.split("+withTotalPowerGE")[1]; + sb.append("Tap any number of untapped creatures you control other than CARDNAME with total power " + num + "or greater"); } else { sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), "untapped " + desc)); sb.append(" you control"); @@ -120,7 +123,14 @@ public class CostTapType extends CostPartWithList { sameType = true; type = type.replace("sharesCreatureTypeWith", ""); } - + boolean totalPower = false; + String totalP = ""; + if (type.contains("+withTotalPowerGE")) { + totalPower = true; + totalP = type.split("withTotalPowerGE")[1]; + type = type.replace("+withTotalPowerGE" + totalP, ""); + } + typeList = CardLists.getValidCards(typeList, type.split(";"), activator, source); if (!canTapSource) { @@ -142,6 +152,11 @@ public class CostTapType extends CostPartWithList { return false; } + if (totalPower) { + final int i = Integer.parseInt(totalP); + return CardLists.getTotalPower(typeList) >= i; + } + final Integer amount = this.convertAmount(); if ((typeList.size() == 0) || ((amount != null) && (typeList.size() < amount))) { return false; @@ -170,9 +185,18 @@ public class CostTapType extends CostPartWithList { sameType = true; type = type.replace("sharesCreatureTypeWith", ""); } + + boolean totalPower = false; + String totalP = ""; + if (type.contains("+withTotalPowerGE")) { + totalPower = true; + totalP = type.split("withTotalPowerGE")[1]; + type = type.replace("+withTotalPowerGE" + totalP, ""); + } + typeList = CardLists.getValidCards(typeList, type.split(";"), ability.getActivatingPlayer(), ability.getSourceCard()); typeList = CardLists.filter(typeList, Presets.UNTAPPED); - if (c == null) { + if (c == null && !amount.equals("Any")) { final String sVar = ability.getSVar(amount); // Generalize this if (sVar.equals("XChoice")) { @@ -217,6 +241,21 @@ public class CostTapType extends CostPartWithList { } return executePayment(ability, tapped); } + + if (totalPower) { + int i = Integer.parseInt(totalP); + InputSelectCards inp = new InputSelectCardsFromList(0, typeList.size(), typeList); + inp.setMessage("Select a card to tap."); + inp.setUnselectAllowed(true); + inp.setCancelAllowed(true); + Singletons.getControl().getInputQueue().setInputAndWait(inp); + + if (inp.hasCancelled() || CardLists.getTotalPower(inp.getSelected()) < i) { + return false; + } else { + return executePayment(ability, inp.getSelected()); + } + } InputSelectCards inp = new InputSelectCardsFromList(c, c, typeList); inp.setMessage("Select a " + getDescriptiveType() + " to tap (%d left)"); @@ -246,7 +285,7 @@ public class CostTapType extends CostPartWithList { c = AbilityUtils.calculateAmount(source, amount, ability); } } - if (this.getType().contains("sharesCreatureTypeWith")) { + if (this.getType().contains("sharesCreatureTypeWith") || this.getType().contains("withTotalPowerGE")) { return null; }