From 5dce0ab172241969b79043f552e8cdaad9f611ad Mon Sep 17 00:00:00 2001 From: Sloth Date: Thu, 2 May 2013 15:21:36 +0000 Subject: [PATCH] - Added AI support for Divide counters. - Card conversions by marc. --- res/cardsfolder/e/elven_rite.txt | 4 ++-- res/cardsfolder/j/jugan_the_rising_star.txt | 6 +----- res/cardsfolder/w/wurmskin_forger.txt | 5 ++--- .../java/forge/card/ability/ai/CountersPutAi.java | 13 +++++++++++++ 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/res/cardsfolder/e/elven_rite.txt b/res/cardsfolder/e/elven_rite.txt index 741371bc924..a5ec2fe44ed 100644 --- a/res/cardsfolder/e/elven_rite.txt +++ b/res/cardsfolder/e/elven_rite.txt @@ -1,8 +1,8 @@ Name:Elven Rite ManaCost:1 G Types:Sorcery -A:SP$ PutCounter | Cost$ 1 G | ValidTgts$ Creature | TgtPrompt$ Select target creature (1) | CounterType$ P1P1 | CounterNum$ 1 | SubAbility$ DBPutCounter | SpellDescription$ Distribute two +1/+1 counters among one or two target creatures. -SVar:DBPutCounter:DB$PutCounter | ValidTgts$ Creature | TgtPrompt$ Select target creature (2) | CounterType$ P1P1 | CounterNum$ 1 +A:SP$ PutCounter | Cost$ 1 G | ValidTgts$ Creature | TgtPrompt$ Select target creature to distribute counters to | CounterType$ P1P1 | CounterNum$ 2 | TargetMin$ 1 | TargetMax$ 2 | DividedAsYouChoose$ 2 | SpellDescription$ Distribute two +1/+1 counters among one or two target creatures. +SVar:RemAIDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/elven_rite.jpg Oracle:Distribute two +1/+1 counters among one or two target creatures. SetInfo:STH Uncommon \ No newline at end of file diff --git a/res/cardsfolder/j/jugan_the_rising_star.txt b/res/cardsfolder/j/jugan_the_rising_star.txt index ec5ead5c4eb..a023cf51ad4 100644 --- a/res/cardsfolder/j/jugan_the_rising_star.txt +++ b/res/cardsfolder/j/jugan_the_rising_star.txt @@ -4,11 +4,7 @@ Types:Legendary Creature Dragon Spirit PT:5/5 K:Flying T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | ValidCard$ Card.Self | Execute$ TrigPutCounter | OptionalDecider$ TriggeredCardController | TriggerController$ TriggeredCardController | TriggerDescription$ When CARDNAME is put into a graveyard from the battlefield, you may distribute five +1/+1 counters among any number of target creatures. -SVar:TrigPutCounter:AB$PutCounter | Cost$ 0 | ValidTgts$ Creature | TgtPrompt$ Select target creature (1) | CounterType$ P1P1 | CounterNum$ 1 | SubAbility$ PutCounter2 -SVar:PutCounter2:DB$PutCounter | ValidTgts$ Creature | TgtPrompt$ Select target creature (2) | CounterType$ P1P1 | CounterNum$ 1 | SubAbility$ PutCounter3 -SVar:PutCounter3:DB$PutCounter | ValidTgts$ Creature | TgtPrompt$ Select target creature (3) | CounterType$ P1P1 | CounterNum$ 1 | SubAbility$ PutCounter4 -SVar:PutCounter4:DB$PutCounter | ValidTgts$ Creature | TgtPrompt$ Select target creature (4) | CounterType$ P1P1 | CounterNum$ 1 | SubAbility$ PutCounter5 -SVar:PutCounter5:DB$PutCounter | ValidTgts$ Creature | TgtPrompt$ Select target creature (5) | CounterType$ P1P1 | CounterNum$ 1 +SVar:TrigPutCounter:AB$ PutCounter | Cost$ 0 | ValidTgts$ Creature | TgtPrompt$ Select target creature to distribute counters to | CounterType$ P1P1 | CounterNum$ 5 | TargetMin$ 1 | TargetMax$ 5 | DividedAsYouChoose$ 5 SVar:Picture:http://www.wizards.com/global/images/magic/general/jugan_the_rising_star.jpg Oracle:Flying\nWhen Jugan, the Rising Star dies, you may distribute five +1/+1 counters among any number of target creatures. SetInfo:CHK Rare \ No newline at end of file diff --git a/res/cardsfolder/w/wurmskin_forger.txt b/res/cardsfolder/w/wurmskin_forger.txt index 421d6e86271..c1ee8e4f5dc 100644 --- a/res/cardsfolder/w/wurmskin_forger.txt +++ b/res/cardsfolder/w/wurmskin_forger.txt @@ -3,9 +3,8 @@ ManaCost:5 G G Types:Creature Elf Warrior PT:2/2 T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigPutCounter | TriggerDescription$ When CARDNAME enters the battlefield, distribute three +1/+1 counters among one, two, or three target creatures. -SVar:TrigPutCounter:AB$PutCounter | Cost$ 0 | ValidTgts$ Creature | TgtPrompt$ Select target creature | CounterType$ P1P1 | CounterNum$ 1 | SubAbility$ PutCounter2 -SVar:PutCounter2:DB$PutCounter | ValidTgts$ Creature | TgtPrompt$ Select target creature | CounterType$ P1P1 | CounterNum$ 1 | SubAbility$ PutCounter3 -SVar:PutCounter3:DB$PutCounter | ValidTgts$ Creature | TgtPrompt$ Select target creature | CounterType$ P1P1 | CounterNum$ 1 +SVar:TrigPutCounter:AB$ PutCounter | Cost$ 0 | ValidTgts$ Creature | TgtPrompt$ Select target creature to distribute counters to | CounterType$ P1P1 | CounterNum$ 3 | TargetMin$ 1 | TargetMax$ 3 | DividedAsYouChoose$ 3 +SVar:RemAIDeck:True SVar:PlayMain1:TRUE SVar:Picture:http://www.wizards.com/global/images/magic/general/wurmskin_forger.jpg Oracle:When Wurmskin Forger enters the battlefield, distribute three +1/+1 counters among one, two, or three target creatures. diff --git a/src/main/java/forge/card/ability/ai/CountersPutAi.java b/src/main/java/forge/card/ability/ai/CountersPutAi.java index 6aaf5e7bf5b..f85cb83fc17 100644 --- a/src/main/java/forge/card/ability/ai/CountersPutAi.java +++ b/src/main/java/forge/card/ability/ai/CountersPutAi.java @@ -38,6 +38,7 @@ public class CountersPutAi extends SpellAbilityAi { Card choice = null; final String type = sa.getParam("CounterType"); final String amountStr = sa.getParam("CounterNum"); + final boolean divided = sa.hasParam("DividedAsYouChoose"); final Player player = sa.isCurse() ? ai.getOpponent() : ai; @@ -128,7 +129,11 @@ public class CountersPutAi extends SpellAbilityAi { // TODO is this good enough? for up to amounts? break; } + } else if (divided) { + abTgt.addDividedAllocation(choice, amount); + break; } + list.remove(choice); abTgt.addTarget(choice); } @@ -171,6 +176,7 @@ public class CountersPutAi extends SpellAbilityAi { Card choice = null; final String type = sa.getParam("CounterType"); final String amountStr = sa.getParam("CounterNum"); + final boolean divided = sa.hasParam("DividedAsYouChoose"); final int amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa); final Player player = sa.isCurse() ? ai.getOpponent() : ai; @@ -217,6 +223,9 @@ public class CountersPutAi extends SpellAbilityAi { // TODO is this good enough? for up to amounts? break; } + } else if (divided) { + abTgt.addDividedAllocation(choice, amount); + break; } list.remove(choice); abTgt.addTarget(choice); @@ -237,6 +246,7 @@ public class CountersPutAi extends SpellAbilityAi { final Player player = isCurse ? ai.getOpponent() : ai; final String type = sa.getParam("CounterType"); final String amountStr = sa.getParam("CounterNum"); + final boolean divided = sa.hasParam("DividedAsYouChoose"); final int amount = AbilityUtils.calculateAmount(sa.getSourceCard(), amountStr, sa); if (abTgt == null) { @@ -294,6 +304,9 @@ public class CountersPutAi extends SpellAbilityAi { choice = ComputerUtilCard.getRandomCard(list); } } + if (choice != null && divided) { + abTgt.addDividedAllocation(choice, amount); + } } // TODO - I think choice can be null here. Is that ok for