From 26d961282178d043fffd6be84089f067602cb56d Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 04:49:59 +0000 Subject: [PATCH] Slight modification of ally code to account for simultaneous token creation and added Rite of Replication (Tested but may have bugs as it is quite complex). --- res/card-pictures.txt | 1 + res/cards.txt | 5 + src/forge/CardFactory.java | 167 ++++++++++++++++++++++++ src/forge/PlayerZone_ComesIntoPlay.java | 9 +- 4 files changed, 181 insertions(+), 1 deletion(-) diff --git a/res/card-pictures.txt b/res/card-pictures.txt index 2942e275cb2..a35a5162676 100644 --- a/res/card-pictures.txt +++ b/res/card-pictures.txt @@ -38,6 +38,7 @@ snow_covered_mountain.jpg http://www.wizards.com/global/images/magic/gene snow_covered_mountain1.jpg http://www.wizards.com/global/images/magic/general/snow_covered_mountain.jpg snow_covered_mountain2.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg snow_covered_mountain3.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg +rite_of_replication.jpg http://www.wizards.com/global/images/magic/general/rite_of_replication.jpg undead_gladiator.jpg http://www.wizards.com/global/images/magic/general/undead_gladiator.jpg martial_coup.jpg http://www.wizards.com/global/images/magic/general/martial_coup.jpg linvala_keeper_of_silence.jpg http://www.wizards.com/global/images/magic/general/linvala_keeper_of_silence.jpg diff --git a/res/cards.txt b/res/cards.txt index 8c7c0ded519..2889a1399c0 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,8 @@ +Rite of Replication +2 U U +Sorcery +no text + Eternity Vessel 6 Artifact diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index 81f60275e0d..382d37bbd41 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -16145,6 +16145,173 @@ public class CardFactory implements NewConstants { })); }//*************** END ************ END ************************** + //*************** START *********** START ************************** + else if(cardName.equals("Rite of Replication")) { + SpellAbility spell = new Spell(card) { + private static final long serialVersionUID = -2902112019334177L; + @Override + public boolean canPlayAI() { + PlayerZone zone = AllZone.getZone(Constant.Zone.Play, card.getController()); + Card biggest = null; + if(zone != null) { + CardList creature = new CardList(); + creature.addAll(zone.getCards()); + creature = creature.getType("Creature"); + creature = creature.filter(new CardListFilter() { + public boolean addCard(Card card) { + return (!card.getType().contains("Legendary")); + } + }); + if(creature.size() == 0) return false; + biggest = creature.get(0); + for(int i = 0; i < creature.size(); i++) + if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i); + setTargetCard(biggest); + } + return biggest.getNetAttack() > 4; + } + + @Override + public void chooseTargetAI() { + PlayerZone zone = AllZone.getZone(Constant.Zone.Play, card.getController()); + if(zone != null) { + CardList creature = new CardList(); + creature.addAll(zone.getCards()); + creature = creature.getType("Creature"); + creature = creature.filter(new CardListFilter() { + public boolean addCard(Card card) { + return (!card.getType().contains("Legendary")); + } + }); + if(creature.size() > 0) { + Card biggest = creature.get(0); + for(int i = 0; i < creature.size(); i++) + if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i); + setTargetCard(biggest); + } + } + } + @Override + public void resolve() { + + if(AllZone.GameAction.isCardInPlay(getTargetCard()) + && CardFactoryUtil.canTarget(card, getTargetCard())) { + PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); + Card Copy = copyCard(getTargetCard()); + CardList all = AllZone.CardFactory.getAllCards(); + CardList tokens = new CardList(play.getCards()); + tokens = tokens.filter(new CardListFilter() { + public boolean addCard(Card c) { + return c.isToken(); + } + }); + all.add(tokens); + int Unumber = 0; + for(int i = 0; i < all.size(); i++) { + if(all.get(i).getUniqueNumber() > Unumber) Unumber = all.get(i).getUniqueNumber(); + } + Copy.setUniqueNumber(Unumber + 1); + Copy.setToken(true); + Copy.setController(card.getController()); + play.add(Copy); + } + }//resolve() + }; + + spell.setDescription("Put a token onto the battlefield that's a copy of target creature."); + spell.setStackDescription(card.getName() + " - " + card.getController() + + " puts a token onto the battlefield that's a copy of target creature."); + + SpellAbility kicker = new Spell(card) { + private static final long serialVersionUID = 13762512058673590L; + @Override + public boolean canPlayAI() { + PlayerZone zone = AllZone.getZone(Constant.Zone.Play, card.getController()); + Card biggest = null; + if(zone != null) { + CardList creature = new CardList(); + creature.addAll(zone.getCards()); + creature = creature.getType("Creature"); + creature = creature.filter(new CardListFilter() { + public boolean addCard(Card card) { + return (!card.getType().contains("Legendary")); + } + }); + if(creature.size() == 0) return false; + biggest = creature.get(0); + for(int i = 0; i < creature.size(); i++) + if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i); + setTargetCard(biggest); + } + return biggest.getNetAttack() > 3; + } + + @Override + public void chooseTargetAI() { + PlayerZone zone = AllZone.getZone(Constant.Zone.Play, card.getController()); + if(zone != null) { + CardList creature = new CardList(); + creature.addAll(zone.getCards()); + creature = creature.getType("Creature"); + creature = creature.filter(new CardListFilter() { + public boolean addCard(Card card) { + return (!card.getType().contains("Legendary")); + } + }); + if(creature.size() > 0) { + Card biggest = creature.get(0); + for(int i = 0; i < creature.size(); i++) + if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i); + setTargetCard(biggest); + } + } + } + @Override + public void resolve() { + PlayerZone_ComesIntoPlay.SimultaneousEntry = true; + card.setKicked(true); + PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); + if(AllZone.GameAction.isCardInPlay(getTargetCard()) + && CardFactoryUtil.canTarget(card, getTargetCard())) { + for(int x = 0; x < 5; x++) { + if(x == 4) PlayerZone_ComesIntoPlay.SimultaneousEntry = false; + Card Copy = copyCard(getTargetCard()); + CardList all = AllZone.CardFactory.getAllCards(); + CardList tokens = new CardList(play.getCards()); + tokens = tokens.filter(new CardListFilter() { + public boolean addCard(Card c) { + return c.isToken(); + } + }); + all.add(tokens); + int Unumber = 0; + for(int i = 0; i < all.size(); i++) { + if(all.get(i).getUniqueNumber() > Unumber) Unumber = all.get(i).getUniqueNumber(); + } + Copy.setUniqueNumber(Unumber + 4); + Copy.setToken(true); + Copy.setController(card.getController()); + play.add(Copy); + AllZone.Display.showMessage("Hack for Legendaries going to the graveyard :)"); // Not Working + AI is stuffed + }//for + + } + + }//resolve() + }; + kicker.setKickerAbility(true); + kicker.setManaCost("7 U U"); + kicker.setAdditionalManaCost("5"); + kicker.setDescription("Kicker 5: If Rite of Replication was kicked, put five of those tokens onto the battlefield instead."); + kicker.setStackDescription(card.getName() + " - " + card.getController() + + " puts five tokens onto the battlefield that's a copy of target creature."); + kicker.setBeforePayMana(CardFactoryUtil.input_targetCreature(kicker)); + + card.clearSpellAbility(); + card.addSpellAbility(spell); + card.addSpellAbility(kicker); + spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell)); + }//*************** END ************ END ************************** //*************** START *********** START ************************** else if(cardName.equals("Conqueror's Pledge")) { diff --git a/src/forge/PlayerZone_ComesIntoPlay.java b/src/forge/PlayerZone_ComesIntoPlay.java index 1318f9c89ab..6cf0e0816c3 100644 --- a/src/forge/PlayerZone_ComesIntoPlay.java +++ b/src/forge/PlayerZone_ComesIntoPlay.java @@ -10,6 +10,8 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone { private boolean trigger = true; private boolean leavesTrigger = true; + static boolean SimultaneousEntry = false; // For Cards with Multiple Token Entry. Only Affects Allies at the moment. + static int SimultaneousEntryCounter = 1; // For Cards with Multiple Token Entry. Only Affects Allies at the moment. public PlayerZone_ComesIntoPlay(String zone, String player) { super(zone, player); @@ -132,6 +134,8 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone { allyNamesList.add(allyNames[i]); } + if(SimultaneousEntry == false) { // For Cards with Multiple Token Entry. Only Affects Allies at the moment. + for(int i = 0; i < SimultaneousEntryCounter; i++) { if(c.getType().contains("Ally") || (c.getKeyword().contains("Changeling") && c.isCreature()) || (clist.size() > 0 && (c.getType().contains("Creature") || c.getKeyword().contains( "Changeling"))) || allyNamesList.contains(c.getName())) { @@ -147,8 +151,11 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone { GameActionUtil.executeAllyEffects(var); } } - + } + SimultaneousEntryCounter = 1; + } else SimultaneousEntryCounter = SimultaneousEntryCounter + 1; } + if(AllZone.StaticEffects.getCardToEffectsList().containsKey(c.getName())) { String[] effects = AllZone.StaticEffects.getCardToEffectsList().get(c.getName()); for(String effect:effects) {