From 15a0d22d1c9e8b9eb46d7144ce5d5bf7af076b7c Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 21:30:22 +0000 Subject: [PATCH] - Gave the generic auras code some AI. Will now check for aura magnets. If non found it will check for unenchanted cards and if there is non the AI will enchant a previously enchanted card. --- .../card/cardFactory/CardFactory_Auras.java | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/forge/card/cardFactory/CardFactory_Auras.java b/src/forge/card/cardFactory/CardFactory_Auras.java index bebf41705ab..f0f84b79990 100644 --- a/src/forge/card/cardFactory/CardFactory_Auras.java +++ b/src/forge/card/cardFactory/CardFactory_Auras.java @@ -1948,17 +1948,37 @@ class CardFactory_Auras { player = AllZone.ComputerPlayer; } CardList list = AllZoneUtil.getPlayerTypeInPlay(player, type); - + if (list.isEmpty()) return false; - //TODO - maybe do something intelligent here if it's not a curse, like - //checking the aura magnet list + // Enchant a random Aura magnet if one is in play. + // Else enchant a random unenchanted card if one exists. + // Enchant a previously enchanted card if no unenchanted cards exist. + if (! curse) { + CardList magnets = list.getEnchantMagnets(); + + if (! magnets.isEmpty()) { + list = magnets; + + } else { + CardList notEnchanted = list.filter(AllZoneUtil.unenchanted); + if (! notEnchanted.isEmpty()) { + list = notEnchanted; + } + } + } else { + CardList notEnchanted = list.filter(AllZoneUtil.unenchanted); + if (! notEnchanted.isEmpty()) { + list = notEnchanted; + } + } // We do not want the AI to always enchant the same card. - list.shuffle(); + list.shuffle(); setTargetCard(list.get(0)); return super.canPlayAI(); + }//canPlayAI() @Override