From 7ea6ebb1fc814641fd6ceabc34c3ad6c2e5f8052 Mon Sep 17 00:00:00 2001 From: jendave Date: Sun, 7 Aug 2011 00:18:52 +0000 Subject: [PATCH] - Added AI to AF Dig. --- .gitattributes | 2 +- res/cardsfolder/lead_the_stampede.txt | 17 ++--- .../abilityFactory/AbilityFactory_Reveal.java | 75 +++++++++---------- 3 files changed, 44 insertions(+), 50 deletions(-) diff --git a/.gitattributes b/.gitattributes index 320dccbc2f2..f70c0a9fc3b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3953,7 +3953,7 @@ res/cardsfolder/lay_waste.txt -text svneol=native#text/plain res/cardsfolder/lead_astray.txt -text svneol=native#text/plain res/cardsfolder/lead_belly_chimera.txt svneol=native#text/plain res/cardsfolder/lead_golem.txt -text svneol=native#text/plain -res/cardsfolder/lead_the_stampede.txt svneol=native#text/plain +res/cardsfolder/lead_the_stampede.txt -text svneol=native#text/plain res/cardsfolder/leaden_fists.txt -text svneol=native#text/plain res/cardsfolder/leaden_myr.txt -text svneol=native#text/plain res/cardsfolder/leaf_arrow.txt svneol=native#text/plain diff --git a/res/cardsfolder/lead_the_stampede.txt b/res/cardsfolder/lead_the_stampede.txt index d1a3a3e186b..9013749b015 100644 --- a/res/cardsfolder/lead_the_stampede.txt +++ b/res/cardsfolder/lead_the_stampede.txt @@ -1,10 +1,9 @@ -Name:Lead the Stampede -ManaCost:2 G -Types:Sorcery -Text:no text -A:SP$ Dig | Cost$ 2 G | DigNum$ 5 | ChangeValid$ Creature | AnyNumber$ True | SpellDescription$ Look at the top five cards of your library. You may reveal any number of creature cards from among them and put the revealed cards into your hand. Put the rest on the bottom of your library in any order. -SVar:RemAIDeck:True -SVar:Rarity:Uncommon -SVar:Picture:http://www.wizards.com/global/images/magic/general/lead_the_stampede.jpg -SetInfo:MBS|Uncommon|http://magiccards.info/scans/en/mbs/82.jpg +Name:Lead the Stampede +ManaCost:2 G +Types:Sorcery +Text:no text +A:SP$ Dig | Cost$ 2 G | DigNum$ 5 | ChangeValid$ Creature | AnyNumber$ True | SpellDescription$ Look at the top five cards of your library. You may reveal any number of creature cards from among them and put the revealed cards into your hand. Put the rest on the bottom of your library in any order. +SVar:Rarity:Uncommon +SVar:Picture:http://www.wizards.com/global/images/magic/general/lead_the_stampede.jpg +SetInfo:MBS|Uncommon|http://magiccards.info/scans/en/mbs/82.jpg End \ No newline at end of file diff --git a/src/forge/card/abilityFactory/AbilityFactory_Reveal.java b/src/forge/card/abilityFactory/AbilityFactory_Reveal.java index 66d678e9819..1992b90f9a9 100644 --- a/src/forge/card/abilityFactory/AbilityFactory_Reveal.java +++ b/src/forge/card/abilityFactory/AbilityFactory_Reveal.java @@ -178,26 +178,6 @@ public class AbilityFactory_Reveal { } } return randomReturn; - - /* - if (!ComputerUtil.canPayCost(sa)) - return false; - - Target tgt = sa.getTarget(); - - if (sa.getTarget() != null){ - tgt.resetTargets(); - sa.getTarget().addTarget(AllZone.ComputerPlayer); - } - else{ - ArrayList tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), af.getMapParams().get("Defined"), sa); - for (Player p : tgtPlayers) - if (p.isHuman()) - return false; - // not sure if the AI should be playing with cards that give the Human more turns. - } - return true; - */ } private static boolean digTriggerAI(final AbilityFactory af, final SpellAbility sa, boolean mandatory) { @@ -223,6 +203,7 @@ public class AbilityFactory_Reveal { private static void digResolve(final AbilityFactory af, final SpellAbility sa) { HashMap params = af.getMapParams(); Card host = af.getHostCard(); + Player player = sa.getActivatingPlayer(); int numToDig = AbilityFactory.calculateAmount(af.getHostCard(), params.get("DigNum"), sa); String destZone1 = params.containsKey("DestinationZone") ? params.get("DestinationZone") : "Hand"; int libraryPosition = params.containsKey("LibraryPosition") ? Integer.parseInt(params.get("LibraryPosition")) : -1; @@ -270,7 +251,7 @@ public class AbilityFactory_Reveal { GuiUtils.getChoice("Revealing cards from library", top.toArray()); //AllZone.GameAction.revealToCopmuter(top.toArray()); - for when it exists } - else { + else if (player.isHuman()){ //show the user the revealed cards GuiUtils.getChoice("Looking at cards from library", top.toArray()); } @@ -312,27 +293,41 @@ public class AbilityFactory_Reveal { } else { int j = 0; - while(j < destZone1ChangeNum || (anyNumber && j < numToDig)) { - //let user get choice - Card chosen = null; - if(anyNumber || optional) { - chosen = GuiUtils.getChoiceOptional("Choose a card to put into "+destZone1, valid.toArray()); + if (player.isHuman()) { + while(j < destZone1ChangeNum || (anyNumber && j < numToDig)) { + //let user get choice + Card chosen = null; + if(anyNumber || optional) { + chosen = GuiUtils.getChoiceOptional("Choose a card to put into "+destZone1, valid.toArray()); + } + else { + chosen = GuiUtils.getChoice("Choose a card to put into "+destZone1, valid.toArray()); + } + if(chosen == null || chosen.getName().equals("[No valid cards]")) break; + valid.remove(chosen); + PlayerZone zone = AllZone.getZone(destZone1, chosen.getOwner()); + if(zone.is("Library")) { + //System.out.println("Moving to lib position: "+libraryPosition); + AllZone.GameAction.moveToLibrary(chosen, libraryPosition); + } + else { + AllZone.GameAction.moveTo(zone, chosen); + } + //AllZone.GameAction.revealToComputer() - for when this exists + j++; } - else { - chosen = GuiUtils.getChoice("Choose a card to put into "+destZone1, valid.toArray()); - } - if(chosen == null || chosen.getName().equals("[No valid cards]")) break; - valid.remove(chosen); - PlayerZone zone = AllZone.getZone(destZone1, chosen.getOwner()); - if(zone.is("Library")) { - //System.out.println("Moving to lib position: "+libraryPosition); - AllZone.GameAction.moveToLibrary(chosen, libraryPosition); - } - else { + }//human + else { //computer (pick the first cards) + int changeNum = Math.min(destZone1ChangeNum, valid.size()); + if(anyNumber) changeNum = valid.size();//always take all + for (j=0;j 0) { Card chosen;