From f065d0a2a4147d1b6830aefc6e33bd8c76f245a6 Mon Sep 17 00:00:00 2001 From: Sloth Date: Wed, 3 Oct 2012 18:04:51 +0000 Subject: [PATCH] - The AI can now use Quillspike. --- res/cardsfolder/q/quillspike.txt | 2 +- .../forge/card/cost/CostRemoveCounter.java | 31 ++++++++++++------- src/main/java/forge/card/cost/CostUtil.java | 6 ++++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/res/cardsfolder/q/quillspike.txt b/res/cardsfolder/q/quillspike.txt index 988f249d0d6..694263d2ac5 100644 --- a/res/cardsfolder/q/quillspike.txt +++ b/res/cardsfolder/q/quillspike.txt @@ -3,7 +3,7 @@ ManaCost:2 BG Types:Creature Beast Text:no text PT:1/1 -A:AB$ Pump | Cost$ BG SubCounter<1/M1M1/Creature.YouCtrl/Creature you Control> | NumAtt$ +3 | NumDef$ +3 | SpellDescription$ CARDNAME gets +3/+3 until end of turn. +A:AB$ Pump | Cost$ BG SubCounter<1/M1M1/Creature/a creature you control> | NumAtt$ +3 | NumDef$ +3 | SpellDescription$ CARDNAME gets +3/+3 until end of turn. SVar:RemRandomDeck:True SVar:Rarity:Uncommon SVar:Picture:http://www.wizards.com/global/images/magic/general/quillspike.jpg diff --git a/src/main/java/forge/card/cost/CostRemoveCounter.java b/src/main/java/forge/card/cost/CostRemoveCounter.java index d3580fe355c..9b7d43cbfe4 100644 --- a/src/main/java/forge/card/cost/CostRemoveCounter.java +++ b/src/main/java/forge/card/cost/CostRemoveCounter.java @@ -21,6 +21,7 @@ import java.util.List; import forge.Card; +import forge.AllZone; import forge.CardListUtil; import forge.Counters; import forge.card.abilityfactory.AbilityFactory; @@ -167,14 +168,12 @@ public class CostRemoveCounter extends CostPartWithList { else { final List typeList = CardListUtil.getValidCards(activator.getCardsIn(this.getZone()), this.getType().split(";"), activator, source); if (amount != null) { - boolean payable = false; for (Card c : typeList) { if (c.getCounters(cntrs) - amount >= 0) { - payable = true; - break; + return true; } } - return payable; + return false; } } @@ -201,10 +200,9 @@ public class CostRemoveCounter extends CostPartWithList { if (this.getThis()) { source.subtractCounter(this.counter, c); - } - else { + } else { for (final Card card : this.getList()) { - card.subtractCounter(this.counter, 1); + card.subtractCounter(this.counter, c); } } source.setSVar("CostCountersRemoved", "Number$" + Integer.toString(c)); @@ -273,11 +271,7 @@ public class CostRemoveCounter extends CostPartWithList { public final boolean decideAIPayment(final SpellAbility ability, final Card source, final CostPayment payment) { final String amount = this.getAmount(); Integer c = this.convertAmount(); - - if (!this.getThis()) { - // TODO AI Can't handle remove counter by type - return false; - } + Player computer = AllZone.getComputerPlayer(); if (c == null) { final String sVar = ability.getSVar(amount); @@ -290,6 +284,19 @@ public class CostRemoveCounter extends CostPartWithList { c = AbilityFactory.calculateAmount(source, amount, ability); } } + + if (!this.getThis()) { + this.getList().clear(); + final List typeList = CardListUtil + .getValidCards(computer.getCardsIn(this.getZone()), this.getType().split(";"), computer, source); + for (Card card : typeList) { + if (card.getCounters(this.getCounter()) >= c) { + this.addToList(card); + return true; + } + } + return false; + } if (c > source.getCounters(this.getCounter())) { System.out.println("Not enough " + this.counter + " on " + source.getName()); return false; diff --git a/src/main/java/forge/card/cost/CostUtil.java b/src/main/java/forge/card/cost/CostUtil.java index ed52cbec9eb..d2a54934f9c 100644 --- a/src/main/java/forge/card/cost/CostUtil.java +++ b/src/main/java/forge/card/cost/CostUtil.java @@ -257,6 +257,12 @@ public class CostUtil { final Counters type = remCounter.getCounter(); final double percent = type.name().equals("P1P1") ? p1p1Percent : otherPercent; final int currentNum = source.getCounters(type); + if (!part.getThis()) { + if (type.name().equals("P1P1")) { + return false; + } + continue; + } Integer amount = part.convertAmount(); if (amount == null) {