- Added AI support for Realmwright.

This commit is contained in:
Sloth
2013-02-25 20:26:00 +00:00
parent ebd38fd02a
commit 8c5f8f16e2
3 changed files with 40 additions and 10 deletions

View File

@@ -3,10 +3,8 @@ ManaCost:U
Types:Creature Vedalken Wizard Types:Creature Vedalken Wizard
PT:1/1 PT:1/1
K:ETBReplacement:Other:DBChooseBasic K:ETBReplacement:Other:DBChooseBasic
SVar:DBChooseBasic:DB$ ChooseType | Type$ Basic Land | SpellDescription$ As CARDNAME enters the battlefield, choose a basic land type. SVar:DBChooseBasic:DB$ ChooseType | Type$ Basic Land | AILogic$ MostNeededType | SpellDescription$ As CARDNAME enters the battlefield, choose a basic land type.
S:Mode$ Continuous | Affected$ Land.YouCtrl | AddType$ ChosenType | Description$ Lands you control are the chosen type in addition to their other types. S:Mode$ Continuous | Affected$ Land.YouCtrl | AddType$ ChosenType | Description$ Lands you control are the chosen type in addition to their other types.
SVar:RemAIDeck:True
SVar:Rarity:Common
SVar:Picture:http://www.wizards.com/global/images/magic/general/realmwright.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/realmwright.jpg
SetInfo:GTC|Rare|http://magiccards.info/scans/en/gtc/45.jpg SetInfo:GTC|Rare|http://magiccards.info/scans/en/gtc/45.jpg
Oracle:As Realmwright enters the battlefield, choose a basic land type.\nLands you control are the chosen type in addition to their other types. Oracle:As Realmwright enters the battlefield, choose a basic land type.\nLands you control are the chosen type in addition to their other types.

View File

@@ -6,7 +6,6 @@ K:Enchant creature
A:SP$ Attach | Cost$ 2 U B | ValidTgts$ Creature | AILogic$ GainControl A:SP$ Attach | Cost$ 2 U B | ValidTgts$ Creature | AILogic$ GainControl
A:AB$ Sacrifice | Cost$ Discard<2/Card> | AnyOpponent$ True | SacValid$ Self | SubAbility$ DBDraw | SpellDescription$ CARDNAME's controller sacrifices it, then draws two cards. Only any opponent may activate this ability. A:AB$ Sacrifice | Cost$ Discard<2/Card> | AnyOpponent$ True | SacValid$ Self | SubAbility$ DBDraw | SpellDescription$ CARDNAME's controller sacrifices it, then draws two cards. Only any opponent may activate this ability.
SVar:DBDraw:DB$ Draw | NumCards$ 2 | Defined$ SourceController SVar:DBDraw:DB$ Draw | NumCards$ 2 | Defined$ SourceController
SVar:RemAIDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/soul_ransom.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/soul_ransom.jpg
SetInfo:GTC|Rare|http://magiccards.info/scans/en/gtc/198.jpg SetInfo:GTC|Rare|http://magiccards.info/scans/en/gtc/198.jpg
Oracle:Enchant creature\nYou control enchanted creature.\nDiscard two cards: Soul Ransom's controller sacrifices it, then draws two cards. Only any opponent may activate this ability. Oracle:Enchant creature\nYou control enchanted creature.\nDiscard two cards: Soul Ransom's controller sacrifices it, then draws two cards. Only any opponent may activate this ability.

View File

@@ -4,8 +4,11 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import com.google.common.collect.Iterables;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.CardPredicates;
import forge.Constant; import forge.Constant;
import forge.Singletons; import forge.Singletons;
import forge.card.CardType; import forge.card.CardType;
@@ -102,19 +105,19 @@ public class ChooseTypeEffect extends SpellAbilityEffect {
if (logic.equals("MostProminentOnBattlefield")) { if (logic.equals("MostProminentOnBattlefield")) {
chosen = CardFactoryUtil.getMostProminentCreatureType(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield)); chosen = CardFactoryUtil.getMostProminentCreatureType(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield));
} }
if (logic.equals("MostProminentComputerControls")) { else if (logic.equals("MostProminentComputerControls")) {
chosen = CardFactoryUtil.getMostProminentCreatureType(ai.getCardsIn(ZoneType.Battlefield)); chosen = CardFactoryUtil.getMostProminentCreatureType(ai.getCardsIn(ZoneType.Battlefield));
} }
if (logic.equals("MostProminentHumanControls")) { else if (logic.equals("MostProminentHumanControls")) {
chosen = CardFactoryUtil.getMostProminentCreatureType(opp.getCardsIn(ZoneType.Battlefield)); chosen = CardFactoryUtil.getMostProminentCreatureType(opp.getCardsIn(ZoneType.Battlefield));
if (!CardType.isACreatureType(chosen) || invalidTypes.contains(chosen)) { if (!CardType.isACreatureType(chosen) || invalidTypes.contains(chosen)) {
chosen = CardFactoryUtil.getMostProminentCreatureType(CardLists.filterControlledBy(Singletons.getModel().getGame().getCardsInGame(), opp)); chosen = CardFactoryUtil.getMostProminentCreatureType(CardLists.filterControlledBy(Singletons.getModel().getGame().getCardsInGame(), opp));
} }
} }
if (logic.equals("MostProminentInComputerDeck")) { else if (logic.equals("MostProminentInComputerDeck")) {
chosen = CardFactoryUtil.getMostProminentCreatureType(CardLists.filterControlledBy(Singletons.getModel().getGame().getCardsInGame(), ai)); chosen = CardFactoryUtil.getMostProminentCreatureType(CardLists.filterControlledBy(Singletons.getModel().getGame().getCardsInGame(), ai));
} }
if (logic.equals("MostProminentInComputerGraveyard")) { else if (logic.equals("MostProminentInComputerGraveyard")) {
chosen = CardFactoryUtil.getMostProminentCreatureType(ai.getCardsIn(ZoneType.Graveyard)); chosen = CardFactoryUtil.getMostProminentCreatureType(ai.getCardsIn(ZoneType.Graveyard));
} }
} }
@@ -143,8 +146,38 @@ public class ChooseTypeEffect extends SpellAbilityEffect {
card.setChosenType(choice); card.setChosenType(choice);
} }
} else { } else {
// TODO AttachAI for ChosenType should have the exact same logic Player ai = sa.getActivatingPlayer();
card.setChosenType("Island"); String chosen = "";
if (sa.hasParam("AILogic")) {
final String logic = sa.getParam("AILogic");
if (logic.equals("MostNeededType")) {
// Choose a type that is in the deck, but not in hand or on the battlefield
final ArrayList<String> basics = new ArrayList<String>();
basics.addAll(Constant.CardTypes.BASIC_TYPES);
List<Card> presentCards = ai.getCardsIn(ZoneType.Battlefield);
presentCards.addAll(ai.getCardsIn(ZoneType.Hand));
List<Card> possibleCards = ai.getAllCards();
for (String b : basics) {
if(!Iterables.any(presentCards, CardPredicates.isType(b)) && Iterables.any(possibleCards, CardPredicates.isType(b))) {
chosen = b;
}
}
if (chosen.equals("")) {
for (String b : basics) {
if(Iterables.any(possibleCards, CardPredicates.isType(b))) {
chosen = b;
}
}
}
}
}
if (!CardType.isABasicLandType(chosen) || invalidTypes.contains(chosen)) {
chosen = "Island";
}
GuiChoose.one("Computer picked: ", new String[]{chosen});
card.setChosenType(chosen);
valid = true; valid = true;
} }
} }