From 3fc58ac107e55cabf139a9268ecb1e8df652f9f7 Mon Sep 17 00:00:00 2001 From: Agetian Date: Sat, 1 Dec 2012 13:10:39 +0000 Subject: [PATCH] - Added a possibility to couple sacrifice costs with other costs (currently by sacrificing, pun semi-intended, the input-based sacrifice interface and replacing it with a menu-based selection one). - Added 4 cards by swordshine (Leviathan, Exalted Dragon, Reclamation, Flooded Woodlands). --- .gitattributes | 4 +++ res/cardsfolder/e/exalted_dragon.txt | 12 +++++++ res/cardsfolder/f/flooded_woodlands.txt | 10 ++++++ res/cardsfolder/l/leviathan.txt | 20 +++++++++++ res/cardsfolder/r/reclamation.txt | 10 ++++++ src/main/java/forge/GameActionUtil.java | 45 +++++++++++++++++++++---- 6 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 res/cardsfolder/e/exalted_dragon.txt create mode 100644 res/cardsfolder/f/flooded_woodlands.txt create mode 100644 res/cardsfolder/l/leviathan.txt create mode 100644 res/cardsfolder/r/reclamation.txt diff --git a/.gitattributes b/.gitattributes index e4f13085ba7..b4c3ec77241 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3158,6 +3158,7 @@ res/cardsfolder/e/evolution_charm.txt svneol=native#text/plain res/cardsfolder/e/evolution_vat.txt svneol=native#text/plain res/cardsfolder/e/evolving_wilds.txt svneol=native#text/plain res/cardsfolder/e/exalted_angel.txt svneol=native#text/plain +res/cardsfolder/e/exalted_dragon.txt -text res/cardsfolder/e/excavation.txt svneol=native#text/plain res/cardsfolder/e/excise.txt svneol=native#text/plain res/cardsfolder/e/exclude.txt svneol=native#text/plain @@ -3536,6 +3537,7 @@ res/cardsfolder/f/floodchaser.txt svneol=native#text/plain res/cardsfolder/f/flooded_grove.txt svneol=native#text/plain res/cardsfolder/f/flooded_shoreline.txt svneol=native#text/plain res/cardsfolder/f/flooded_strand.txt svneol=native#text/plain +res/cardsfolder/f/flooded_woodlands.txt -text res/cardsfolder/f/floodgate.txt -text res/cardsfolder/f/floodwater_dam.txt svneol=native#text/plain res/cardsfolder/f/floral_spuzzem.txt svneol=native#text/plain @@ -5634,6 +5636,7 @@ res/cardsfolder/l/lesser_gargadon.txt svneol=native#text/plain res/cardsfolder/l/lesser_werewolf.txt -text svneol=unset#text/plain res/cardsfolder/l/lethargy_trap.txt svneol=native#text/plain res/cardsfolder/l/leveler.txt svneol=native#text/plain +res/cardsfolder/l/leviathan.txt -text res/cardsfolder/l/levitation.txt svneol=native#text/plain res/cardsfolder/l/ley_druid.txt svneol=native#text/plain res/cardsfolder/l/leyline_of_anticipation.txt svneol=native#text/plain @@ -7900,6 +7903,7 @@ res/cardsfolder/r/reckless_spite.txt svneol=native#text/plain res/cardsfolder/r/reckless_waif_merciless_predator.txt -text res/cardsfolder/r/reckless_wurm.txt svneol=native#text/plain res/cardsfolder/r/reclaim.txt svneol=native#text/plain +res/cardsfolder/r/reclamation.txt -text res/cardsfolder/r/reclusive_wight.txt svneol=native#text/plain res/cardsfolder/r/recoil.txt svneol=native#text/plain res/cardsfolder/r/recollect.txt svneol=native#text/plain diff --git a/res/cardsfolder/e/exalted_dragon.txt b/res/cardsfolder/e/exalted_dragon.txt new file mode 100644 index 00000000000..0804b333802 --- /dev/null +++ b/res/cardsfolder/e/exalted_dragon.txt @@ -0,0 +1,12 @@ +Name:Exalted Dragon +ManaCost:4 W W +Types:Creature Dragon +Text:no text +PT:5/5 +K:Flying +S:Mode$ CantAttackUnless | ValidCard$ Creature.Self | Target$ Player,Planeswalker | Cost$ Sac<1/Land> | Description$ CARDNAME can't attack unless you sacrifice a land. +SVar:Rarity:Rare +SVar:Picture:http://www.wizards.com/global/images/magic/general/exalted_dragon.jpg +SetInfo:EXO|Rare|http://magiccards.info/scans/en/ex/5.jpg +Oracle:Flying\nExalted Dragon can't attack unless you sacrifice a land. +End diff --git a/res/cardsfolder/f/flooded_woodlands.txt b/res/cardsfolder/f/flooded_woodlands.txt new file mode 100644 index 00000000000..33b4b147eb9 --- /dev/null +++ b/res/cardsfolder/f/flooded_woodlands.txt @@ -0,0 +1,10 @@ +Name:Flooded Woodlands +ManaCost:2 U B +Types:Enchantment +Text:no text +S:Mode$ CantAttackUnless | ValidCard$ Creature.Green | Target$ Player,Planeswalker | Cost$ Sac<1/Land> | Description$ Green creatures can't attack unless their controller sacrifices a land for each green creature he or she controls that's attacking. +SVar:Rarity:Rare +SVar:Picture:http://www.wizards.com/global/images/magic/general/flooded_woodlands.jpg +SetInfo:ICE|Rare|http://magiccards.info/scans/en/ia/368.jpg +Oracle:Green creatures can't attack unless their controller sacrifices a land for each green creature he or she controls that's attacking. +End diff --git a/res/cardsfolder/l/leviathan.txt b/res/cardsfolder/l/leviathan.txt new file mode 100644 index 00000000000..ef32ab2656e --- /dev/null +++ b/res/cardsfolder/l/leviathan.txt @@ -0,0 +1,20 @@ +Name:Leviathan +ManaCost:5 U U U U +Types:Creature Leviathan +Text:no text +PT:10/10 +K:Trample +K:CARDNAME enters the battlefield tapped. +K:CARDNAME doesn't untap during your untap step. +T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | OptionalDecider$ You | Execute$ TrigUntap | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of your upkeep, you may sacrifice two Islands. If you do, untap CARDNAME. +SVar:TrigUntap:AB$ Untap | Cost$ Sac<2/Island> +S:Mode$ CantAttackUnless | ValidCard$ Creature.Self | Target$ Player,Planeswalker | Cost$ Sac<2/Island> | Description$ CARDNAME can't attack unless you sacrifice two islands. +SVar:NeedsToPlayVar:Y GE4 +SVar:Y:Count$Valid Island.YouCtrl +SVar:Rarity:Rare +SVar:Picture:http://www.wizards.com/global/images/magic/general/leviathan.jpg +SetInfo:5ED|Rare|http://magiccards.info/scans/en/5e/97.jpg +SetInfo:4ED|Rare|http://magiccards.info/scans/en/4e/79.jpg +SetInfo:DRK|Rare|http://magiccards.info/scans/en/dk/28.jpg +Oracle:Trample\nLeviathan enters the battlefield tapped and doesn't untap during your untap step.\nAt the beginning of your upkeep, you may sacrifice two Islands. If you do, untap Leviathan.\nLeviathan can't attack unless you sacrifice two Islands. +End diff --git a/res/cardsfolder/r/reclamation.txt b/res/cardsfolder/r/reclamation.txt new file mode 100644 index 00000000000..c0c02a816cd --- /dev/null +++ b/res/cardsfolder/r/reclamation.txt @@ -0,0 +1,10 @@ +Name:Reclamation +ManaCost:2 W G +Types:Enchantment +Text:no text +S:Mode$ CantAttackUnless | ValidCard$ Creature.Black | Target$ Player,Planeswalker | Cost$ Sac<1/Land> | Description$ Black creatures can't attack unless their controller sacrifices a land for each black creature he or she controls that's attacking. +SVar:Rarity:Rare +SVar:Picture:http://www.wizards.com/global/images/magic/general/reclamation.jpg +SetInfo:ICE|Rare|http://magiccards.info/scans/en/ia/377.jpg +Oracle:Black creatures can't attack unless their controller sacrifices a land for each black creature he or she controls that's attacking. +End diff --git a/src/main/java/forge/GameActionUtil.java b/src/main/java/forge/GameActionUtil.java index 9a336af796d..ce9bc04e54f 100644 --- a/src/main/java/forge/GameActionUtil.java +++ b/src/main/java/forge/GameActionUtil.java @@ -380,6 +380,7 @@ public final class GameActionUtil { final ArrayList parts = cost.getCostParts(); ArrayList remainingParts = new ArrayList(cost.getCostParts()); CostPart costPart = null; + int num_parts = parts.size(); if (!parts.isEmpty()) { costPart = parts.get(0); } @@ -486,6 +487,42 @@ public final class GameActionUtil { } } } + else if (part instanceof CostSacrifice) { + + CostSacrifice sacCost = (CostSacrifice)part; + Player p = Singletons.getControl().getPlayer(); + String valid = sacCost.getType(); + int amount = Integer.parseInt(sacCost.getAmount()); + List list = AbilityFactory.filterListByType(p.getCardsIn(ZoneType.Battlefield), valid, ability); + + if (list.size() < amount) { + // unable to pay (not enough cards) + hasPaid = false; + break; + } + + if (!showYesNoDialog(source, "Do you want to pay the sacrifice cost?")) { + hasPaid = false; + break; + } + + for (int i = 0; i < amount; i++) { + if (list.isEmpty()) { + hasPaid = false; + break; + } + Object o = GuiChoose.one("Select a card to sacrifice", list); + if (o != null) { + final Card c = (Card) o; + + Singletons.getModel().getGame().getAction().sacrifice(c, ability); + + list.remove(c); + } + } + + remainingParts.remove(part); + } } if (!hasPaid) { unpaid.execute(); @@ -501,13 +538,7 @@ public final class GameActionUtil { costPart = remainingParts.get(0); //the following costs need inputs and can't be combined at the moment - if (costPart instanceof CostSacrifice) { - final boolean bResolving = Singletons.getModel().getGame().getStack().isResolving(); - Singletons.getModel().getGame().getStack().setResolving(false); - Singletons.getModel().getMatch().getInput().setInput(new InputPaySacCost((CostSacrifice) costPart, ability, paid, unpaid)); - Singletons.getModel().getGame().getStack().setResolving(bResolving); - } - else if (costPart instanceof CostReturn) { + if (costPart instanceof CostReturn) { final boolean bResolving = Singletons.getModel().getGame().getStack().isResolving(); Singletons.getModel().getGame().getStack().setResolving(false); Singletons.getModel().getMatch().getInput().setInput(new InputPayReturnCost((CostReturn) costPart, ability, paid, unpaid));