From 6b3bfde7aaab6f2f94e8ce50140f883e44670dd4 Mon Sep 17 00:00:00 2001 From: Sloth Date: Wed, 25 Jan 2012 18:18:09 +0000 Subject: [PATCH] - Added an AILogic parameter to AF NameCard. - Added Vexing Arcanix by Jeff. --- .gitattributes | 1 + res/cardsfolder/v/vexing_arcanix.txt | 15 +++++++ .../abilityfactory/AbilityFactoryChoose.java | 44 ++++++++++++------- .../card/cardfactory/CardFactoryUtil.java | 41 +++++++++++++++++ 4 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 res/cardsfolder/v/vexing_arcanix.txt diff --git a/.gitattributes b/.gitattributes index 2147c0b4407..aa3804d7d21 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9337,6 +9337,7 @@ res/cardsfolder/v/veteran_swordsmith.txt svneol=native#text/plain res/cardsfolder/v/veterans_reflexes.txt svneol=native#text/plain res/cardsfolder/v/veterans_voice.txt -text res/cardsfolder/v/vex.txt svneol=native#text/plain +res/cardsfolder/v/vexing_arcanix.txt -text res/cardsfolder/v/vexing_beetle.txt svneol=native#text/plain res/cardsfolder/v/vhati_il_dal.txt -text res/cardsfolder/v/viashino_bladescout.txt svneol=native#text/plain diff --git a/res/cardsfolder/v/vexing_arcanix.txt b/res/cardsfolder/v/vexing_arcanix.txt new file mode 100644 index 00000000000..a9bda2753d1 --- /dev/null +++ b/res/cardsfolder/v/vexing_arcanix.txt @@ -0,0 +1,15 @@ +Name:Vexing Arcanix +ManaCost:4 +Types:Artifact +Text:no text +A:AB$ NameCard | Cost$ 3 T | ValidTgts$ Player | TgtPrompt$ Select target player | SubAbility$ DBDig | AILogic$ MostProminentInComputerDeck | SpellDescription$ Target player names a card, then reveals the top card of his or her library. If it's the named card, the player puts it into his or her hand. Otherwise, the player puts it into his or her graveyard and CARDNAME deals 2 damage to him or her. +SVar:DBDig:DB$ Dig | DigNum$ 1 | Defined$ Targeted | ChangeNum$ All | ChangeValid$ Card.NamedCard | DestinationZone2$ Graveyard | Reveal$ True | RememberChanged$ True | SubAbility$ DBDamage +SVar:DBDamage:DB$ DealDamage | NumDmg$ 2 | Defined$ Targeted | ConditionDefined$ Remembered | ConditionPresent$ Card.NamedCard | ConditionCompare$ EQ0 | SubAbility$ DBCleanup +SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True +SVar:RemAIDeck:True +SVar:Rarity:Rare +SVar:Picture:http://www.wizards.com/global/images/magic/general/vexing_arcanix.jpg +SetInfo:8ED|Rare|http://magiccards.info/scans/en/8e/319.jpg +SetInfo:ICE|Rare|http://magiccards.info/scans/en/ia/319.jpg +Oracle:{3}, {T}: Target player names a card, then reveals the top card of his or her library. If it's the named card, the player puts it into his or her hand. Otherwise, the player puts it into his or her graveyard and Vexing Arcanix deals 2 damage to him or her. +End \ No newline at end of file diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java index 82549f532f7..4ba5b972acb 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java @@ -668,10 +668,10 @@ public final class AbilityFactoryChoose { chosen = CardFactoryUtil.getMostProminentColor(AllZoneUtil.getCardsInGame().getController( AllZone.getHumanPlayer())); } - if (logic.equals("MostProminentInGame")) { + else if (logic.equals("MostProminentInGame")) { chosen = CardFactoryUtil.getMostProminentColor(AllZoneUtil.getCardsInGame()); } - if (logic.equals("MostProminentHumanCreatures")) { + else if (logic.equals("MostProminentHumanCreatures")) { CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); if (list.isEmpty()) { list = AllZoneUtil.getCardsInGame().getController(AllZone.getHumanPlayer()) @@ -679,15 +679,15 @@ public final class AbilityFactoryChoose { } chosen = CardFactoryUtil.getMostProminentColor(list); } - if (logic.equals("MostProminentComputerControls")) { + else if (logic.equals("MostProminentComputerControls")) { chosen = CardFactoryUtil.getMostProminentColor(AllZone.getComputerPlayer().getCardsIn( Zone.Battlefield)); } - if (logic.equals("MostProminentPermanent")) { + else if (logic.equals("MostProminentPermanent")) { final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); chosen = CardFactoryUtil.getMostProminentColor(list); } - if (logic.equals("MostProminentAttackers")) { + else if (logic.equals("MostProminentAttackers")) { chosen = CardFactoryUtil.getMostProminentColor(new CardList(AllZone.getCombat() .getAttackers())); } @@ -1415,7 +1415,7 @@ public final class AbilityFactoryChoose { boolean ok = false; String name = null; while (!ok) { - if (sa.getActivatingPlayer().isHuman()) { + if (p.isHuman()) { final String message = validDesc.equals("card") ? "Name a card" : "Name a " + validDesc + " card. (Case sensitive)"; /* @@ -1446,17 +1446,31 @@ public final class AbilityFactoryChoose { ok = true; } } else { - CardList list = AllZoneUtil.getCardsInGame().getController(AllZone.getHumanPlayer()); - list = list.filter(new CardListFilter() { - @Override - public boolean addCard(final Card c) { - return !c.isLand(); + String chosen = ""; + if (params.containsKey("AILogic")) { + final String logic = params.get("AILogic"); + if (logic.equals("MostProminentInComputerDeck")) { + chosen = CardFactoryUtil.getMostProminentCardName(AllZone.getComputerPlayer() + .getCardsIn(Constant.Zone.Library)); + } + } else { + CardList list = AllZoneUtil.getCardsInGame().getController(AllZone.getHumanPlayer()); + list = list.filter(new CardListFilter() { + @Override + public boolean addCard(final Card c) { + return !c.isLand(); + } + }); + if (!list.isEmpty()) { + chosen = list.get(0).getName(); } - }); - if (!list.isEmpty()) { - host.setNamedCard(list.get(0).getName()); - ok = true; } + if (chosen == "") { + chosen = "Forest"; + } + GuiUtils.getChoice("Computer picked: ", chosen); + host.setNamedCard(chosen); + ok = true; } } } diff --git a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java index e2d4094f0c0..51253d06a6f 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java @@ -3485,6 +3485,47 @@ public class CardFactoryUtil { return untap; } + /** + *

+ * getMostProminentCardName. + *

+ * + * @param list + * a {@link forge.CardList} object. + * @return a {@link java.lang.String} object. + */ + public static String getMostProminentCardName(final CardList list) { + + if (list.size() == 0) { + return ""; + } + + final Map map = new HashMap(); + + for (final Card c : list) { + final String name = c.getName(); + if (!map.containsKey(name)) { + map.put(name, 1); + } else { + map.put(name, map.get(name) + 1); + } + } // for + + int max = 0; + String maxName = ""; + + for (final Entry entry : map.entrySet()) { + final String type = entry.getKey(); + // Log.debug(type + " - " + entry.getValue()); + + if (max < entry.getValue()) { + max = entry.getValue(); + maxName = type; + } + } + return maxName; + } + /** *

* getMostProminentCreatureType.