- The AI can now use Quillspike.

This commit is contained in:
Sloth
2012-10-03 18:04:51 +00:00
parent 854f4be584
commit f065d0a2a4
3 changed files with 26 additions and 13 deletions

View File

@@ -3,7 +3,7 @@ ManaCost:2 BG
Types:Creature Beast Types:Creature Beast
Text:no text Text:no text
PT:1/1 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:RemRandomDeck:True
SVar:Rarity:Uncommon SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/quillspike.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/quillspike.jpg

View File

@@ -21,6 +21,7 @@ import java.util.List;
import forge.Card; import forge.Card;
import forge.AllZone;
import forge.CardListUtil; import forge.CardListUtil;
import forge.Counters; import forge.Counters;
import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactory;
@@ -167,14 +168,12 @@ public class CostRemoveCounter extends CostPartWithList {
else { else {
final List<Card> typeList = CardListUtil.getValidCards(activator.getCardsIn(this.getZone()), this.getType().split(";"), activator, source); final List<Card> typeList = CardListUtil.getValidCards(activator.getCardsIn(this.getZone()), this.getType().split(";"), activator, source);
if (amount != null) { if (amount != null) {
boolean payable = false;
for (Card c : typeList) { for (Card c : typeList) {
if (c.getCounters(cntrs) - amount >= 0) { if (c.getCounters(cntrs) - amount >= 0) {
payable = true; return true;
break;
} }
} }
return payable; return false;
} }
} }
@@ -201,10 +200,9 @@ public class CostRemoveCounter extends CostPartWithList {
if (this.getThis()) { if (this.getThis()) {
source.subtractCounter(this.counter, c); source.subtractCounter(this.counter, c);
} } else {
else {
for (final Card card : this.getList()) { for (final Card card : this.getList()) {
card.subtractCounter(this.counter, 1); card.subtractCounter(this.counter, c);
} }
} }
source.setSVar("CostCountersRemoved", "Number$" + Integer.toString(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) { public final boolean decideAIPayment(final SpellAbility ability, final Card source, final CostPayment payment) {
final String amount = this.getAmount(); final String amount = this.getAmount();
Integer c = this.convertAmount(); Integer c = this.convertAmount();
Player computer = AllZone.getComputerPlayer();
if (!this.getThis()) {
// TODO AI Can't handle remove counter by type
return false;
}
if (c == null) { if (c == null) {
final String sVar = ability.getSVar(amount); final String sVar = ability.getSVar(amount);
@@ -290,6 +284,19 @@ public class CostRemoveCounter extends CostPartWithList {
c = AbilityFactory.calculateAmount(source, amount, ability); c = AbilityFactory.calculateAmount(source, amount, ability);
} }
} }
if (!this.getThis()) {
this.getList().clear();
final List<Card> 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())) { if (c > source.getCounters(this.getCounter())) {
System.out.println("Not enough " + this.counter + " on " + source.getName()); System.out.println("Not enough " + this.counter + " on " + source.getName());
return false; return false;

View File

@@ -257,6 +257,12 @@ public class CostUtil {
final Counters type = remCounter.getCounter(); final Counters type = remCounter.getCounter();
final double percent = type.name().equals("P1P1") ? p1p1Percent : otherPercent; final double percent = type.name().equals("P1P1") ? p1p1Percent : otherPercent;
final int currentNum = source.getCounters(type); final int currentNum = source.getCounters(type);
if (!part.getThis()) {
if (type.name().equals("P1P1")) {
return false;
}
continue;
}
Integer amount = part.convertAmount(); Integer amount = part.convertAmount();
if (amount == null) { if (amount == null) {