From 0b8af7f05f34fbd2fc5ec061d8e726305317ca0c Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 04:05:19 +0000 Subject: [PATCH] - Annihilator Part 2, added Kozilek, Butcher of Truth (draw cards on cast not yet implemented), Annihilator seems to work alright though. - Fixed some AI mistakes of cards using sortCMC. --- res/cards.txt | 8 +++++ src/forge/CardFactory.java | 2 +- src/forge/CardListUtil.java | 1 + src/forge/CombatUtil.java | 71 +++++++++++++++++++++---------------- 4 files changed, 51 insertions(+), 31 deletions(-) diff --git a/res/cards.txt b/res/cards.txt index 72676579e69..2a6bbfd2568 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,11 @@ +Kozilek, Butcher of Truth +10 +Legendary Creature Eldrazi +no text +12/12 +Annihilator 4 +When this card is put into a graveyard from anywhere, reveal this card and shuffle it into its owner's library instead. + Glasses of Urza 1 Artifact diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index fef2681b1b7..30f1d1f0bcc 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -14249,7 +14249,6 @@ public class CardFactory implements NewConstants { CardList list = getArtEnchantments(); if(list.size() > 0) { CardListUtil.sortCMC(list); - list.reverse(); setTargetCard(list.get(0)); AllZone.GameAction.sacrifice(card); } @@ -17289,6 +17288,7 @@ public class CardFactory implements NewConstants { { CardListUtil.sortAttackLowFirst(compCreats); CardListUtil.sortCMC(compCreats); + compCreats.reverse(); for (int i=0; i < compCreats.size()-humCreats.size();i++) AllZone.GameAction.sacrifice(compCreats.get(i)); } diff --git a/src/forge/CardListUtil.java b/src/forge/CardListUtil.java index 34987d398e5..d16eac73400 100644 --- a/src/forge/CardListUtil.java +++ b/src/forge/CardListUtil.java @@ -208,6 +208,7 @@ public class CardListUtil list.sort(com); } + //Sorts from high to low public static void sortCMC(CardList list) { Comparator com = new Comparator() diff --git a/src/forge/CombatUtil.java b/src/forge/CombatUtil.java index 079bdf5f5d5..3fb7a09a503 100644 --- a/src/forge/CombatUtil.java +++ b/src/forge/CombatUtil.java @@ -780,37 +780,48 @@ public class CombatUtil { AllZone.Phase.getPhase().equals(Constant.Phase.Combat_Declare_Attackers_InstantAbility)) { //Annihilator: - ArrayList kws = c.getKeyword(); - Pattern p = Pattern.compile("Annihilator [0-9]+"); - Matcher m; - for (String key : kws) + if (!c.getCreatureAttackedThisCombat()) { - m = p.matcher(key); - if (m.find()) - { - String k[] = key.split(" "); - final int a = Integer.valueOf(k[1]); - final Card crd = c; - - final Ability ability = new Ability(c, "0") - { - public void resolve() - { - if (crd.getController().equals(Constant.Player.Human)) - { - //comp sacks - } - else - { - AllZone.InputControl.setInput(CardFactoryUtil.input_sacrificePermanents(a)); - } - - } - }; - ability.setStackDescription(""); - AllZone.Stack.add(ability); - } - } + ArrayList kws = c.getKeyword(); + Pattern p = Pattern.compile("Annihilator [0-9]+"); + Matcher m; + for (String key : kws) + { + m = p.matcher(key); + if (m.find()) + { + String k[] = key.split(" "); + final int a = Integer.valueOf(k[1]); + final Card crd = c; + + final Ability ability = new Ability(c, "0") + { + public void resolve() + { + if (crd.getController().equals(Constant.Player.Human)) + { + CardList list = new CardList(AllZone.Computer_Play.getCards()); + CardListUtil.sortCMC(list); + list.reverse(); + int max = list.size(); + if (max>a) + max = a; + + for (int i=0;i