From ec6dd95c15f874e7e263bf75a9e996ad552e5f90 Mon Sep 17 00:00:00 2001 From: swordshine Date: Sat, 8 Jun 2013 08:47:49 +0000 Subject: [PATCH] - Added Jotun Grunt --- .gitattributes | 1 + res/cardsfolder/j/jotun_grunt.txt | 9 ++++++ .../forge/card/cost/CostPutCardToLib.java | 30 ++++++++++++++++--- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 res/cardsfolder/j/jotun_grunt.txt diff --git a/.gitattributes b/.gitattributes index a56c2c9ff65..a2f924e703f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5606,6 +5606,7 @@ res/cardsfolder/j/jor_kadeen_the_prevailer.txt svneol=native#text/plain res/cardsfolder/j/joraga_bard.txt svneol=native#text/plain res/cardsfolder/j/joraga_treespeaker.txt svneol=native#text/plain res/cardsfolder/j/joraga_warcaller.txt svneol=native#text/plain +res/cardsfolder/j/jotun_grunt.txt -text res/cardsfolder/j/jotun_owl_keeper.txt -text res/cardsfolder/j/journey_of_discovery.txt -text res/cardsfolder/j/journey_to_nowhere.txt svneol=native#text/plain diff --git a/res/cardsfolder/j/jotun_grunt.txt b/res/cardsfolder/j/jotun_grunt.txt new file mode 100644 index 00000000000..28d647274e0 --- /dev/null +++ b/res/cardsfolder/j/jotun_grunt.txt @@ -0,0 +1,9 @@ +Name:Jotun Grunt +ManaCost:1 W +Types:Creature Giant Soldier +PT:4/4 +K:Cumulative upkeep:PutCardToLibFromSameGrave<2/-1/Card>:Put two cards from a single graveyard on the bottom of their owner's library. +SVar:X:PlayerCountPlayers$HighestValidGraveyard Card.YouOwn +SVar:NeedsToPlayVar:X GE2 +SVar:Picture:http://www.wizards.com/global/images/magic/general/jotun_grunt.jpg +Oracle:Cumulative upkeep-Put two cards from a single graveyard on the bottom of their owner's library. (At the beginning of your upkeep, put an age counter on this permanent, then sacrifice it unless you pay its upkeep cost for each age counter on it.) diff --git a/src/main/java/forge/card/cost/CostPutCardToLib.java b/src/main/java/forge/card/cost/CostPutCardToLib.java index c1e8696018a..ff60385716a 100644 --- a/src/main/java/forge/card/cost/CostPutCardToLib.java +++ b/src/main/java/forge/card/cost/CostPutCardToLib.java @@ -319,6 +319,16 @@ public class CostPutCardToLib extends CostPartWithList { @Override public PaymentDecision decideAIPayment(Player ai, SpellAbility ability, Card source) { Integer c = this.convertAmount(); + final Game game = ai.getGame(); + List chosen = new ArrayList(); + List list; + + if (this.sameZone) { + list = new ArrayList(game.getCardsIn(this.getFrom())); + } else { + list = new ArrayList(ai.getCardsIn(this.getFrom())); + } + if (c == null) { final String sVar = ability.getSVar(this.getAmount()); // Generalize this @@ -328,12 +338,24 @@ public class CostPutCardToLib extends CostPartWithList { c = AbilityUtils.calculateAmount(source, this.getAmount(), ability); } + + list = CardLists.getValidCards(list, this.getType().split(";"), ai, source); + if (this.sameZone) { - // TODO Determine exile from same zone for AI - return null; + // Jotun Grunt + // TODO: improve AI + final List players = game.getPlayers(); + for (Player p : players) { + List enoughType = CardLists.filter(list, CardPredicates.isOwner(p)); + if (enoughType.size() >= c) { + chosen.addAll(enoughType); + break; + } + } + chosen = chosen.subList(0, c); } else { - List chosen = ComputerUtil.choosePutToLibraryFrom(ai, this.getFrom(), this.getType(), source, ability.getTargetCard(), c); - return null == chosen ? null : new PaymentDecision(chosen); + chosen = ComputerUtil.choosePutToLibraryFrom(ai, this.getFrom(), this.getType(), source, ability.getTargetCard(), c); } + return chosen.isEmpty() ? null : new PaymentDecision(chosen); } }