From a00a1ceb0a72b1c4bd7f46a73ae79631faa382bb Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 04:22:09 +0000 Subject: [PATCH] Added the Rampage ability as a Keyowrd in the form: Rampage X Added the following cards that make use of this ability: AErathi Berserker (from Legends) Balduvian War-Makers (from Alliances) Chromium (from Legends) Craw Giant (from Legends) Frost Giant (from Legends) Horrible Hordes (from Mirage) Hunding Gjornersen (from Legends) Marhault Elsdragon (from Legends) Teeka's Dragon (from Mirage) Wolverine Pack (from Legends) --- res/card-pictures.txt | 10 ++++++ res/cards.txt | 76 +++++++++++++++++++++++++++++++++++++++ src/forge/CombatUtil.java | 65 +++++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+) diff --git a/res/card-pictures.txt b/res/card-pictures.txt index c8cbb80f0f4..42ba4ccadfa 100644 --- a/res/card-pictures.txt +++ b/res/card-pictures.txt @@ -38,6 +38,16 @@ 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 +aerathi_berserker.jpg http://www.wizards.com/global/images/magic/general/aerathi_berserker.jpg +balduvian_war_makers.jpg http://www.wizards.com/global/images/magic/general/balduvian_war_makers.jpg +chromium.jpg http://www.wizards.com/global/images/magic/general/chromium.jpg +craw_giant.jpg http://www.wizards.com/global/images/magic/general/craw_giant.jpg +frost_giant.jpg http://www.wizards.com/global/images/magic/general/frost_giant.jpg +horrible_hordes.jpg http://www.wizards.com/global/images/magic/general/horrible_hordes.jpg +hunding_gjornersen.jpg http://www.wizards.com/global/images/magic/general/hunding_gjornersen.jpg +marhault_elsdragon.jpg http://www.wizards.com/global/images/magic/general/marhault_elsdragon.jpg +teekas_dragon.jpg http://www.wizards.com/global/images/magic/general/teekas_dragon.jpg +wolverine_pack.jpg http://www.wizards.com/global/images/magic/general/wolverine_pack.jpg binding_grasp.jpg http://www.wizards.com/global/images/magic/general/binding_grasp.jpg mind_harness.jpg http://www.wizards.com/global/images/magic/general/mind_harness.jpg persuasion.jpg http://www.wizards.com/global/images/magic/general/persuasion.jpg diff --git a/res/cards.txt b/res/cards.txt index f4c86e28b42..d47d3e7a81e 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,79 @@ +AErathi Berserker +2 R R R +Creature Human Berserker +no text +2/4 +Rampage 3 + +Balduvian War-Makers +4 R +Creature Human Barbarian +no text +3/3 +Haste +Rampage 1 + +Chromium +2 W W U U B B +Legendary Creature Elder Dragon +no text +7/7 +Flying +Rampage 2 +At the beginning of your upkeep, sacrifice CARDNAME unless you pay:W U B + +Craw Giant +3 G G G G +Creature Giant +no text +6/4 +Trample +Rampage 2 + +Frost Giant +3 R R R +Creature Giant +no text +4/4 +Rampage 2 + +Horrible Hordes +3 +Artifact Creature Spirit +no text +2/2 +Rampage 1 + +Hunding Gjornersen +3 U U W +Legendary Creature Human Warrior +no text +5/4 +Rampage 1 + +Marhault Elsdragon +3 G R R +Legendary Creature Elf Warrior +no text +4/6 +Rampage 1 + +Teeka's Dragon +9 +Artifact Creature Dragon +no text +5/5 +Flying +Trample +Rampage 4 + +Wolverine Pack +2 G G +Creature Wolverine +no text +2/4 +Rampage 2 + Binding Grasp 3 U Enchantment Aura diff --git a/src/forge/CombatUtil.java b/src/forge/CombatUtil.java index 2ff49b462a0..d24ba67b170 100644 --- a/src/forge/CombatUtil.java +++ b/src/forge/CombatUtil.java @@ -1727,6 +1727,26 @@ public class CombatUtil { AllZone.Stack.add(ab); } + ////////////////////Rampage + //not sure why this is "not" - but I copied from Bushido... + if(!a.getCreatureGotBlockedThisCombat()) { + ArrayList keywords = a.getKeyword(); + Pattern p = Pattern.compile("Rampage [0-9]+"); + Matcher m; + for (String keyword : keywords) { + m = p.matcher(keyword); + if (m.find()){ + String k[] = keyword.split(" "); + final int magnitude = Integer.valueOf(k[1]); + final int numBlockers = AllZone.Combat.getBlockers(a).size(); + if(numBlockers > 1) { + executeRampageAbility(a, magnitude, numBlockers); + } + } //find + } + } + ////////////////////END Rampage + if(a.getKeyword().contains("Flanking") && !b.getKeyword().contains("Flanking")) { int flankingMagnitude = 0; String kw = ""; @@ -2055,4 +2075,49 @@ public class CombatUtil { } } + /////////////////////////Rampage + /** + * executes rampage abilities for a given card + * + * @param c the card to add rampage bonus to + * @param magnitude the magnitude of rampage (ie Rampage 2 means magnitude should be 2) + * @param numBlockers - the number of creatures blocking this rampaging creature + */ + private static void executeRampageAbility(Card c, int magnitude, int numBlockers) { + //TODO - possibly can get magnitude from Keyword on the Card here + final Card crd = c; + final int pump = magnitude; + Ability ability; + + //numBlockers -1 since it is for every creature beyond the first + for(int i = 0; i < numBlockers - 1; i++) { + ability = new Ability(c, "0") { + @Override + public void resolve() { + final Command untilEOT = new Command() { + private static final long serialVersionUID = -3215615538474963181L; + + public void execute() { + if(AllZone.GameAction.isCardInPlay(crd)) { + crd.addTempAttackBoost(-pump); + crd.addTempDefenseBoost(-pump); + } + } + };//Command + + if(AllZone.GameAction.isCardInPlay(crd)) { + crd.addTempAttackBoost(pump); + crd.addTempDefenseBoost(pump); + + AllZone.EndOfTurn.addUntil(untilEOT); + } + }//resolve + + };//ability + ability.setStackDescription(c + " - (Rampage) gets +"+pump+"/+"+pump+" until EOT."); + AllZone.Stack.add(ability); + } + } + /////////////////////////END Rampage + }//Class CombatUtil