From 4521c5da540d12a193662618dc7c8a6ecda26bf5 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 02:47:16 +0000 Subject: [PATCH] Added a few "sacrifice creature" cards (Diabolic Edict, Chainer's Edict, Innocent Blood, ...). --- res/cards.txt | 27 +++++- src/forge/CardFactory.java | 153 ++++++++++++++++++++++++++++++--- src/forge/CardFactoryUtil.java | 25 ++++++ src/forge/GameAction.java | 31 +++++++ 4 files changed, 224 insertions(+), 12 deletions(-) diff --git a/res/cards.txt b/res/cards.txt index fbf3566c810..e882c0477e9 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,28 @@ +Cruel Edict +1 B +Sorcery +Target opponent sacrifices a creature. + +Imperial Edict +1 B +Sorcery +Target opponent sacrifices a creature. + +Chainer's Edict +1 B +Sorcery +Target player sacrifices a creature. + +Diabolic Edict +1 B +Instant +Target player sacrifices a creature. + +Innocent Blood +B +Sorcery +Each player sacrifices a creature. + Transguild Courier 4 Artifact Creature Golem @@ -4197,7 +4222,7 @@ no text Elephant Ambush 2 G G -Sorcery +Instant no text Crush of Wurms diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index cbae0e9597d..a5fe5859d31 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -15846,7 +15846,7 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); }//*************** END ************ END ************************** //*************** START *********** START ************************** - if (cardName.equals("Standstill")) + else if (cardName.equals("Standstill")) { card.clearSpellAbility(); card.addSpellAbility(new Spell_Permanent(card) @@ -15951,7 +15951,7 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); }//*************** END ************ END ************************** //*************** START *********** START ************************** - if (cardName.equals("Voltaic Key")) + else if (cardName.equals("Voltaic Key")) { final Ability_Tap ability = new Ability_Tap(card, "1") { @@ -15994,7 +15994,7 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); }//*************** END ************ END ************************** //*************** START *********** START ************************** - if (cardName.equals("Seething Song")) + else if (cardName.equals("Seething Song")) { final SpellAbility spell = new Spell(card) { @@ -16025,7 +16025,7 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); }//*************** END ************ END ************************** //*************** START *********** START ************************** - if (cardName.equals("Dark Ritual")) + else if (cardName.equals("Dark Ritual")) { final SpellAbility spell = new Spell(card) { @@ -16054,7 +16054,7 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); }//*************** END ************ END ************************** //*************** START *********** START ************************** - if (cardName.equals("Black Lotus")) + else if (cardName.equals("Black Lotus")) { final SpellAbility ability = new Ability_Tap(card) { @@ -16108,7 +16108,7 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); //*************** START ************ START ************************** - if (cardName.equals("Ashnod's Transmogrant")) + else if (cardName.equals("Ashnod's Transmogrant")) { final Ability_Tap ability = new Ability_Tap(card) { @@ -16164,7 +16164,7 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); }//*************** END ************ END ************************** //*************** START ************ START ************************** - if (cardName.equals("Gemstone Array")) + else if (cardName.equals("Gemstone Array")) { final Ability store = new Ability(card, "2"){ public void resolve(){card.addCounter(Counters.CHARGE, 1);} @@ -16208,7 +16208,7 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); //*************** START ************ START ************************** - if (cardName.equals("Goblin Grenade")) + else if (cardName.equals("Goblin Grenade")) { final SpellAbility DamageCP = new Spell(card) { @@ -16382,7 +16382,7 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); //*************** START *********** START ************************** - if(cardName.equals("Onyx Goblet")) + else if(cardName.equals("Onyx Goblet")) { final Ability_Tap ability = new Ability_Tap(card) { @@ -16403,7 +16403,7 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); }//*************** END ************ END ************************** //*************** START *********** START ************************** - if(cardName.equals("Braidwood Cup")) + else if(cardName.equals("Braidwood Cup")) { final Ability_Tap ability = new Ability_Tap(card) { @@ -16423,7 +16423,7 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); }//*************** END ************ END ************************** //*************** START *********** START ************************** - if(cardName.equals("Scepter of Insight")) + else if(cardName.equals("Scepter of Insight")) { final SpellAbility ability = new Ability_Tap(card, "3 U") { @@ -16442,6 +16442,137 @@ return land.size() > 1 && CardFactoryUtil.AI_isMainPhase(); ability.setStackDescription(card.getName() + " - draw a card."); }//*************** END ************ END ************************** + //*************** START *********** START ************************** + else if(cardName.equals("Innocent Blood")) + { + final SpellAbility spell = new Spell(card) + { + private static final long serialVersionUID = 3915880400376059369L; + + public void resolve() { + AllZone.GameAction.sacrificeCreature(Constant.Player.Human, this); + AllZone.GameAction.sacrificeCreature(Constant.Player.Computer, this); + } + + public boolean canPlayAI() + { + PlayerZone cPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer); + PlayerZone hPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human); + + CardList hList = new CardList(hPlay.getCards()); + CardList cList = new CardList(cPlay.getCards()); + CardList smallCreats = cList.filter(new CardListFilter() + { + public boolean addCard(Card c) { + return c.isCreature() && c.getNetAttack() < 2 && c.getNetDefense() < 3; + } + }); + + hList = hList.getType("Creature"); + cList = cList.getType("Creature"); + + if (hList.size() == 0) + return false; + + return smallCreats.size() > 0; + } + }; + + card.clearSpellAbility(); + card.addSpellAbility(spell); + }//*************** END ************ END ************************** + + //*************** START *********** START ************************** + else if (cardName.equals("Diabolic Edict") || cardName.equals("Chainer's Edict")) + { + final SpellAbility spell = new Spell(card) + { + private static final long serialVersionUID = 8970446094797667088L; + + public void resolve() { + AllZone.GameAction.sacrificeCreature(getTargetPlayer(), this); + } + + public boolean canPlayAI() + { + PlayerZone hPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human); + CardList hList = new CardList(hPlay.getCards()); + hList = hList.getType("Creature"); + return hList.size() > 0; + } + }; + spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman()); + spell.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spell)); + + card.clearSpellAbility(); + card.addSpellAbility(spell); + + if (cardName.equals("Chainer's Edict")) + { + final SpellAbility flashback = new Spell(card) + { + private static final long serialVersionUID = -4889392369463499074L; + + public boolean canPlay() + { + PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard ,card.getController()); + String phase = AllZone.Phase.getPhase(); + String activePlayer = AllZone.Phase.getActivePlayer(); + + return AllZone.GameAction.isCardInZone(card, grave) && + ((phase.equals(Constant.Phase.Main1) || phase.equals(Constant.Phase.Main2)) && + card.getController().equals(activePlayer) && AllZone.Stack.size() == 0 ); + } + + public boolean canPlayAI() + { + PlayerZone hPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human); + CardList hList = new CardList(hPlay.getCards()); + hList = hList.getType("Creature"); + return hList.size() > 0; + } + + public void resolve() { + PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard , card.getController()); + PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, card.getController()); + + grave.remove(card); + removed.add(card); + } + }; + + flashback.setManaCost("5 B B"); + flashback.setBeforePayMana(CardFactoryUtil.input_targetPlayer(flashback)); + flashback.setDescription("Flashback: 5 B B"); + flashback.setChooseTargetAI(CardFactoryUtil.AI_targetHuman()); + + card.addSpellAbility(flashback); + card.setFlashback(true); + }//if Chainer's Edict + }//*************** END ************ END ************************** + + //*************** START *********** START ************************** + else if (cardName.equals("Cruel Edict") || cardName.equals("Imperial Edict")) + { + final SpellAbility spell = new Spell(card) + { + private static final long serialVersionUID = 4782606423085170723L; + + public void resolve() { + AllZone.GameAction.sacrificeCreature(AllZone.GameAction.getOpponent(card.getController()), this); + } + + public boolean canPlayAI() + { + PlayerZone hPlay = AllZone.getZone(Constant.Zone.Play, Constant.Player.Human); + CardList hList = new CardList(hPlay.getCards()); + hList = hList.getType("Creature"); + return hList.size() > 0; + } + }; + card.clearSpellAbility(); + card.addSpellAbility(spell); + }//*************** END ************ END ************************** // Cards with Cycling abilities // -1 means keyword "Cycling" not found diff --git a/src/forge/CardFactoryUtil.java b/src/forge/CardFactoryUtil.java index b1e9f814dc6..b3f39c100bf 100644 --- a/src/forge/CardFactoryUtil.java +++ b/src/forge/CardFactoryUtil.java @@ -486,6 +486,31 @@ public class CardFactoryUtil return target; }//input_sacrifice() + + public static Input input_sacrificePermanent(final CardList choices, final String message) + { + Input target = new Input() + { + private static final long serialVersionUID = 2685832214519141903L; + + public void showMessage() + { + AllZone.Display.showMessage(message); + ButtonUtil.disableAll(); + } + public void selectCard(Card card, PlayerZone zone) + { + if(choices.contains(card)) + { + AllZone.getZone(card).remove(card); + AllZone.GameAction.moveToGraveyard(card); + stop(); + } + } + }; + return target; + }//input_sacrifice() + public static Input input_putFromHandToLibrary(final String TopOrBottom, final int num) { Input target = new Input() diff --git a/src/forge/GameAction.java b/src/forge/GameAction.java index dac195faa8d..d16a8041827 100644 --- a/src/forge/GameAction.java +++ b/src/forge/GameAction.java @@ -471,6 +471,37 @@ private Card getCurrentCard(int ID) } return a; } + + + public void sacrificeCreature(String player, SpellAbility sa) + { + PlayerZone play = AllZone.getZone(Constant.Zone.Play, player); + CardList list = new CardList(play.getCards()); + list = list.getType("Creature"); + + this.sacrificePermanent(player, sa, list); + } + + public void sacrificePermanent(String player, SpellAbility sa, CardList choices) + { + if (choices.size() > 0 ){ + if (player.equals(Constant.Player.Human)) + { + Input in = CardFactoryUtil.input_sacrificePermanent(choices, "Select a creature to sacrifice."); + AllZone.InputControl.setInput(in); + } + else + { + //Card c = CardFactoryUtil.AI_getCheapestPermanent(choices, sa.getSourceCard(), false); + CardListUtil.sortDefense(choices); + choices.reverse(); + CardListUtil.sortAttackLowFirst(choices); + Card c = choices.get(0); + this.sacrificeDestroy(c); + } + } + } + public void sacrifice(Card c) { sacrificeDestroy(c);