From dd71f9731052cef3b170579a1f5fecfe4cac5f84 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 02:52:10 +0000 Subject: [PATCH] - Added Sarkhan Vol. - AI playing Viridian Shaman / Uktabi Urangutan should choose its targets a bit smarter now. --- res/cards.txt | 5 + src/forge/CardFactory_Creatures.java | 23 +- src/forge/CardFactory_Planeswalkers.java | 256 ++++++++++++++++++++++- 3 files changed, 279 insertions(+), 5 deletions(-) diff --git a/res/cards.txt b/res/cards.txt index 7e9099ff554..fccf46478ae 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,8 @@ +Sarkhan Vol +2 R G +Planeswalker - Sarkhan +no text + Tezzeret the Seeker 3 U U Planeswalker - Tezzeret diff --git a/src/forge/CardFactory_Creatures.java b/src/forge/CardFactory_Creatures.java index 06c151431e9..48caf847243 100644 --- a/src/forge/CardFactory_Creatures.java +++ b/src/forge/CardFactory_Creatures.java @@ -13502,8 +13502,15 @@ public class CardFactory_Creatures { CardList all = new CardList(); all.addAll(AllZone.Human_Play.getCards()); all.addAll(AllZone.Computer_Play.getCards()); - all = all.getType("Artifact"); + all = all.filter(new CardListFilter(){ + public boolean addCard(Card c) + { + return c.isArtifact() && CardFactoryUtil.canTarget(card, c); + } + }); + CardList humanList = new CardList(AllZone.Human_Play.getCards()); + humanList = humanList.getType("Artifact"); if (all.size() != 0) { @@ -13512,9 +13519,17 @@ public class CardFactory_Creatures { ButtonUtil.disableAll(); } else if (card.getController().equals(Constant.Player.Computer)) { - Card human = CardFactoryUtil.AI_getBestArtifact(all); - ability.setTargetCard(human); - AllZone.Stack.add(ability); + if (humanList.size() > 0 ){ + Card human = CardFactoryUtil.AI_getBestArtifact(humanList); + ability.setTargetCard(human); + AllZone.Stack.add(ability); + } + else + { + Card comp = CardFactoryUtil.AI_getCheapestPermanent(all, card, true); + ability.setTargetCard(comp); + AllZone.Stack.add(ability); + } } } diff --git a/src/forge/CardFactory_Planeswalkers.java b/src/forge/CardFactory_Planeswalkers.java index abd60bc4a55..f8f36070c59 100644 --- a/src/forge/CardFactory_Planeswalkers.java +++ b/src/forge/CardFactory_Planeswalkers.java @@ -2557,12 +2557,266 @@ class CardFactory_Planeswalkers { card2.addSpellAbility(ability3); return card2; + }//*************** END ************ END ************************** + + //*************** START *********** START ************************** + else if(cardName.equals("Sarkhan Vol")) + { + final int turn[] = new int[1]; + turn[0] = -1; + + final Card card2 = new Card() + { + public void addDamage(int n) + { + subtractCounter(Counters.LOYALTY,n); + AllZone.GameAction.checkStateEffects(); + } + }; + card2.addCounter(Counters.LOYALTY,4); + + card2.setOwner(owner); + card2.setController(owner); + + card2.setName(card.getName()); + card2.setType(card.getType()); + card2.setManaCost(card.getManaCost()); + card2.addSpellAbility(new Spell_Permanent(card2)); + + final SpellAbility ability1 = new Ability(card2, "0") + { + public void resolve() + { + card2.addCounter(Counters.LOYALTY, 1); + turn[0] = AllZone.Phase.getTurn(); + + final int boost = 1; + PlayerZone play = AllZone.getZone(Constant.Zone.Play, card2.getController()); + CardList list = new CardList(play.getCards()); + + for(int i = 0; i < list.size(); i++) + { + final Card[] target = new Card[1]; + target[0] = list.get(i); + + final Command untilEOT = new Command() + { + private static final long serialVersionUID = 2893066467461166183L; + + public void execute() + { + if(AllZone.GameAction.isCardInPlay(target[0])) + { + target[0].addTempAttackBoost(-boost); + target[0].addTempDefenseBoost(-boost); + + target[0].removeExtrinsicKeyword("Haste"); + } + } + };//Command + + if(AllZone.GameAction.isCardInPlay(target[0])) + { + target[0].addTempAttackBoost(boost); + target[0].addTempDefenseBoost(boost); + + target[0].addExtrinsicKeyword("Haste"); + + AllZone.EndOfTurn.addUntil(untilEOT); + }//if + }//for + + }//resolve() + public boolean canPlay() + { + return AllZone.getZone(card2).is(Constant.Zone.Play) && + turn[0] != AllZone.Phase.getTurn() && + AllZone.Phase.getActivePlayer().equals(card2.getController()) && + !AllZone.Phase.getPhase().equals("End of Turn") && + (AllZone.Phase.getPhase().equals("Main1") || AllZone.Phase.getPhase().equals("Main2")) + && AllZone.Stack.size() == 0; + }//canPlay() + public boolean canPlayAI() + { + return AllZone.Phase.getPhase().equals(Constant.Phase.Main1) && card2.getCounters(Counters.LOYALTY) < 7; + } + };//ability1 + Input runtime1 = new Input() + { + private static final long serialVersionUID = 3843631106383444950L; + + int check = -1; + public void showMessage() + { + if(check != AllZone.Phase.getTurn()) + { + check = AllZone.Phase.getTurn(); + turn[0] = AllZone.Phase.getTurn(); + + AllZone.Stack.push(ability1); + stop(); + } + } + };//Input + ability1.setStackDescription(card2.getName() +" - Creatures you control get +1/+1 and gain haste until end of turn."); + ability1.setDescription("+1: Creatures you control get +1/+1 and gain haste until end of turn."); + ability1.setBeforePayMana(runtime1); + card2.addSpellAbility(ability1); + + final PlayerZone[] orig = new PlayerZone[1]; + final PlayerZone[] temp = new PlayerZone[1]; + final String[] controllerEOT = new String[1]; + final Card[] target = new Card[1]; + + final Command untilEOT = new Command() + { + + private static final long serialVersionUID = -815595604846219653L; + + public void execute() + { + //if card isn't in play, do nothing + if(! AllZone.GameAction.isCardInPlay(target[0])) + return; + + target[0].setController(controllerEOT[0]); + + ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(false); + ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(false); + + //moveTo() makes a new card, so you don't have to remove "Haste" + //AllZone.GameAction.moveTo(playEOT[0], target[0]); + temp[0].remove(target[0]); + orig[0].add(target[0]); + target[0].untap(); + target[0].removeExtrinsicKeyword("Haste"); + + ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(true); + ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(true); + }//execute() + };//Command + + final Ability ability2 = new Ability(card, "0") + { + + public void resolve() + { + if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card2, getTargetCard()) ) + { + card2.subtractCounter(Counters.LOYALTY, 2); + + orig[0] = AllZone.getZone(getTargetCard()); + controllerEOT[0] = getTargetCard().getController(); + target[0] = getTargetCard(); + + //set the controller + getTargetCard().setController(card.getController()); + + ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(false); + ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(false); + + PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); + play.add(getTargetCard()); + temp[0] = play; + orig[0].remove(getTargetCard()); + + ((PlayerZone_ComesIntoPlay)AllZone.Human_Play).setTriggers(true); + ((PlayerZone_ComesIntoPlay)AllZone.Computer_Play).setTriggers(true); + + + getTargetCard().untap(); + getTargetCard().addExtrinsicKeyword("Haste"); + + AllZone.EndOfTurn.addUntil(untilEOT); + }//is card in play? + }//resolve() + public boolean canPlayAI() + { + return false; + }//canPlayAI() + + public boolean canPlay() + { + return AllZone.getZone(card2).is(Constant.Zone.Play) && + turn[0] != AllZone.Phase.getTurn() && + card2.getCounters(Counters.LOYALTY) >= 2 && + AllZone.Phase.getActivePlayer().equals(card2.getController()) && + !AllZone.Phase.getPhase().equals("End of Turn") && + (AllZone.Phase.getPhase().equals("Main1") || AllZone.Phase.getPhase().equals("Main2")) + && AllZone.Stack.size() == 0; + } + };//SpellAbility + ability2.setBeforePayMana(CardFactoryUtil.input_targetCreature(ability2)); + ability2.setDescription("-2: Gain control of target creature until end of turn. Untap that creature. It gains haste until end of turn."); + card2.addSpellAbility(ability2); + + //ability3 + final Ability ability3 = new Ability(card2, "0") + { + public void resolve() + { + card2.subtractCounter(Counters.LOYALTY, 6); + turn[0] = AllZone.Phase.getTurn(); + + PlayerZone play = AllZone.getZone(Constant.Zone.Play, card2.getController()); + for (int i=0;i<5;i++) + { + play.add(getToken()); + } + + } + Card getToken() + { + Card c = new Card(); + + c.setOwner(card.getController()); + c.setController(card.getController()); + + c.setImageName("R 4 4 Dragon"); + c.setName("Dragon"); + c.setManaCost("R"); + c.setToken(true); + + c.addType("Creature"); + c.addType("Dragon"); + c.setBaseAttack(4); + c.setBaseDefense(4); + c.addIntrinsicKeyword("Flying"); + + return c; + }//makeToken() + + public boolean canPlay() + { + return AllZone.getZone(card2).is(Constant.Zone.Play) && + turn[0] != AllZone.Phase.getTurn() && + card2.getCounters(Counters.LOYALTY) >=6 && + AllZone.Phase.getActivePlayer().equals(card2.getController()) && + !AllZone.Phase.getPhase().equals("End of Turn") && + (AllZone.Phase.getPhase().equals("Main1") || AllZone.Phase.getPhase().equals("Main2")) + && AllZone.Stack.size() == 0; + }//canPlay() + public boolean canPlayAI() + { + return card2.getCounters(Counters.LOYALTY) > 6; + } + };//ability3 + ability3.setStackDescription(card2.getName() +" - Put five 4/4 red Dragon creature tokens with flying onto the battlefield."); + ability3.setDescription("-6: Put five 4/4 red Dragon creature tokens with flying onto the battlefield."); + card2.addSpellAbility(ability3); + //end ability 2 + + return card2; + }//*************** END ************ END ************************** + + - } return card; } + + // copies stats like attack, defense, etc.. private static Card copyStats(Object o) { Card sim = (Card) o;