From 0d46dc55bc8990e5b8528da156edc50cf082ca22 Mon Sep 17 00:00:00 2001 From: Sol Date: Thu, 28 Feb 2013 01:45:05 +0000 Subject: [PATCH] - Add Arcanis the Omnipotent Avatar - Count$Random can now randomize with SVars for min/max values --- .gitattributes | 1 + .../a/arcanis_the_omnipotent_avatar.txt | 9 +++++++++ .../card/cardfactory/CardFactoryUtil.java | 19 +++++++++++++++++-- src/main/java/forge/card/cost/CostReturn.java | 4 +++- .../forge/card/spellability/SpellAbility.java | 2 ++ .../SpellAbilityRequirements.java | 1 + 6 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 res/cardsfolder/a/arcanis_the_omnipotent_avatar.txt diff --git a/.gitattributes b/.gitattributes index eb5044d2bf4..a0cc9fbc1d3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -416,6 +416,7 @@ res/cardsfolder/a/arcane_sanctum.txt svneol=native#text/plain res/cardsfolder/a/arcane_spyglass.txt svneol=native#text/plain res/cardsfolder/a/arcane_teachings.txt svneol=native#text/plain res/cardsfolder/a/arcanis_the_omnipotent.txt svneol=native#text/plain +res/cardsfolder/a/arcanis_the_omnipotent_avatar.txt -text res/cardsfolder/a/arcbound_bruiser.txt svneol=native#text/plain res/cardsfolder/a/arcbound_crusher.txt svneol=native#text/plain res/cardsfolder/a/arcbound_fiend.txt -text diff --git a/res/cardsfolder/a/arcanis_the_omnipotent_avatar.txt b/res/cardsfolder/a/arcanis_the_omnipotent_avatar.txt new file mode 100644 index 00000000000..011aabd0f6d --- /dev/null +++ b/res/cardsfolder/a/arcanis_the_omnipotent_avatar.txt @@ -0,0 +1,9 @@ +Name:Arcanis, the Omnipotent Avatar +ManaCost:no cost +Types:Vanguard +HandLifeModifier:+1/-3 +A:AB$ Draw | ActivationZone$ Command | Announce$ X | Cost$ XCantBe0 X Return<1/Creature.cmcEQX/creature you control with converted mana cost X> | NumCards$ Y | References$ X,Y | SpellDescription$ Draw a number of cards chosen at random between 0 and X. X can't be 0. | StackDescription$ SpellDescription +SVar:X:Count$xPaid +SVar:Y:Count$Random.0.X +SetInfo:VAN|Special|http://magiccards.info/extras/other/vanguard-mtgo-2/arcanis-the-omnipotent.jpg +Oracle:Hand +1, life -3\n{X}, Return a creature you control with converted mana cost X to its owner's hand: Draw a number of cards chosen at random between 0 and X. X can't be 0. diff --git a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java index b1160a280a3..829ea427b37 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java @@ -23,6 +23,8 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import org.apache.commons.lang.StringUtils; + import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -2178,8 +2180,21 @@ public class CardFactoryUtil { //Count$Random.. if (sq[0].equals("Random")) { - int min = Integer.parseInt(sq[1]); - int max = Integer.parseInt(sq[2]); + int min = 0; + int max = 0; + + if (StringUtils.isNumeric(sq[1])) { + min = Integer.parseInt(sq[1]); + } else { + min = CardFactoryUtil.xCount(c, c.getSVar(sq[1])); + } + + if (StringUtils.isNumeric(sq[2])) { + max = Integer.parseInt(sq[2]); + } else { + max = CardFactoryUtil.xCount(c, c.getSVar(sq[2])); + } + return forge.util.MyRandom.getRandom().nextInt(max) + min; } diff --git a/src/main/java/forge/card/cost/CostReturn.java b/src/main/java/forge/card/cost/CostReturn.java index 3930923f03c..18baa33084e 100644 --- a/src/main/java/forge/card/cost/CostReturn.java +++ b/src/main/java/forge/card/cost/CostReturn.java @@ -99,11 +99,13 @@ public class CostReturn extends CostPartWithList { @Override public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) { if (!this.isTargetingThis()) { + boolean needsAnnoucement = ability.hasParam("Announce") && this.getType().contains(ability.getParam("Announce")); + List typeList = new ArrayList(activator.getCardsIn(ZoneType.Battlefield)); typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source); final Integer amount = this.convertAmount(); - if ((amount != null) && (typeList.size() < amount)) { + if (!needsAnnoucement && amount != null && typeList.size() < amount) { return false; } } else if (!source.isInPlay()) { diff --git a/src/main/java/forge/card/spellability/SpellAbility.java b/src/main/java/forge/card/spellability/SpellAbility.java index 5ce6f568572..70d586e8991 100644 --- a/src/main/java/forge/card/spellability/SpellAbility.java +++ b/src/main/java/forge/card/spellability/SpellAbility.java @@ -1774,6 +1774,8 @@ public abstract class SpellAbility implements ISpellAbility { String value = this.getActivatingPlayer().getController().announceRequirements(this, aVar); if (value == null || !StringUtils.isNumeric(value)) { return false; + } else if (this.getPayCosts().getCostMana().isxCantBe0() && Integer.parseInt(value) == 0) { + return false; } this.setSVar(aVar, "Number$" + value); this.getSourceCard().setSVar(aVar, "Number$" + value); diff --git a/src/main/java/forge/card/spellability/SpellAbilityRequirements.java b/src/main/java/forge/card/spellability/SpellAbilityRequirements.java index 98a1d3ba4f0..7dd24060d2f 100644 --- a/src/main/java/forge/card/spellability/SpellAbilityRequirements.java +++ b/src/main/java/forge/card/spellability/SpellAbilityRequirements.java @@ -125,6 +125,7 @@ public class SpellAbilityRequirements { if (!this.ability.announceRequirements()) { this.select.setCancel(true); this.finishedTargeting(); + return; } // Skip to paying if parent ability doesn't target and has no