From 9dc176cb57b5d17b4c09ee98e449e83dddc0686c Mon Sep 17 00:00:00 2001 From: jendave Date: Sun, 7 Aug 2011 00:33:21 +0000 Subject: [PATCH] - Fixed several flaws in stAnimate. Now Blood Moon and friends will only change subtypes and leave land creatures their type and power/toughness. --- res/cardsfolder/blood_moon.txt | 2 +- res/cardsfolder/contaminated_ground.txt | 2 +- res/cardsfolder/lush_growth.txt | 2 +- res/cardsfolder/magus_of_the_moon.txt | 2 +- src/forge/CardUtil.java | 4 ++ src/forge/GameActionUtil.java | 94 +++++++++++++++---------- src/forge/StaticEffect.java | 10 +++ 7 files changed, 76 insertions(+), 40 deletions(-) diff --git a/res/cardsfolder/blood_moon.txt b/res/cardsfolder/blood_moon.txt index bc527512397..60a7cee7037 100644 --- a/res/cardsfolder/blood_moon.txt +++ b/res/cardsfolder/blood_moon.txt @@ -2,7 +2,7 @@ Name:Blood Moon ManaCost:2 R Types:Enchantment Text:no text -K:stAnimateAll:Land.nonBasic:0/0:Land,Mountain,Overwrite,KeepSupertype:no colors:Overwrite:No Condition:Nonbasic lands are Mountains. +K:stAnimateAll:Land.nonBasic:no changes:Land,Mountain,RemoveSubTypes:no colors:Overwrite:No Condition:Nonbasic lands are Mountains. SVar:RemRandomDeck:True SVar:Rarity:Rare SVar:Picture:http://www.wizards.com/global/images/magic/general/blood_moon.jpg diff --git a/res/cardsfolder/contaminated_ground.txt b/res/cardsfolder/contaminated_ground.txt index b55cbf060f6..99a28a3a3ba 100644 --- a/res/cardsfolder/contaminated_ground.txt +++ b/res/cardsfolder/contaminated_ground.txt @@ -3,7 +3,7 @@ ManaCost:1 B Types:Enchantment Aura Text:no text K:Enchant Land Curse -K:stAnimateEnchanted:Land:0/0:Land,Swamp,Overwrite,KeepSupertype:no colors:Overwrite:No Condition:Enchanted land is a Swamp. +K:stAnimateEnchanted:Land:no changes:Land,Swamp,RemoveSubTypes:no colors:Overwrite:No Condition:Enchanted land is a Swamp. T:Mode$ Taps | ValidCard$ Card.AttachedBy | TriggerZones$ Battlefield | Execute$ TrigLose | TriggerDescription$ Whenever enchanted land becomes tapped, its controller loses 2 life. SVar:TrigLose:AB$LoseLife | Cost$ 0 | Defined$ EnchantedController | LifeAmount$ 2 SVar:Rarity:Common diff --git a/res/cardsfolder/lush_growth.txt b/res/cardsfolder/lush_growth.txt index 3b18f36a566..2c87a7c5781 100644 --- a/res/cardsfolder/lush_growth.txt +++ b/res/cardsfolder/lush_growth.txt @@ -3,7 +3,7 @@ ManaCost:G Types:Enchantment Aura Text:no text K:Enchant Land -K:stAnimateEnchanted:Land:0/0:Land,Mountain,Forest,Plains,Overwrite,KeepSupertype:no colors:Overwrite:No Condition:Enchanted land is a Mountain, Forest, and Plains. +K:stAnimateEnchanted:Land:no changes:Land,Mountain,Forest,Plains,RemoveSubTypes:no colors:Overwrite:No Condition:Enchanted land is a Mountain, Forest, and Plains. SVar:RemRandomDeck:True SVar:Rarity:Common SVar:Picture:http://www.wizards.com/global/images/magic/general/lush_growth.jpg diff --git a/res/cardsfolder/magus_of_the_moon.txt b/res/cardsfolder/magus_of_the_moon.txt index 82ad6d7711b..e2ca1fb855d 100644 --- a/res/cardsfolder/magus_of_the_moon.txt +++ b/res/cardsfolder/magus_of_the_moon.txt @@ -3,7 +3,7 @@ ManaCost:2 R Types:Creature Human Wizard Text:no text PT:2/2 -K:stAnimateAll:Land.nonBasic:0/0:Land,Mountain,Overwrite,KeepSupertype:no colors:Overwrite:No Condition:Nonbasic lands are Mountains. +K:stAnimateAll:Land.nonBasic:no changes:Land,Mountain,RemoveSubTypes:no colors:Overwrite:No Condition:Nonbasic lands are Mountains. SVar:RemRandomDeck:True SVar:Rarity:Rare SVar:Picture:http://www.wizards.com/global/images/magic/general/magus_of_the_moon.jpg diff --git a/src/forge/CardUtil.java b/src/forge/CardUtil.java index 8cc8d742666..37261c2e411 100644 --- a/src/forge/CardUtil.java +++ b/src/forge/CardUtil.java @@ -243,6 +243,10 @@ public class CardUtil { || cardType.equals("Snow") || cardType.equals("World")); } + public static boolean isASubType(String cardType) { + return (!isASuperType(cardType) && !isACardType(cardType)); + } + // Check if a Type is a Creature Type (by excluding all other types) public static boolean isACreatureType(String cardType) { return (!isACardType(cardType) && !isASuperType(cardType) && !isALandType(cardType) diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index b6940447d8f..57630b2a922 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -7343,17 +7343,19 @@ public class GameActionUtil { CardList affectedCards = getAffectedCards(cardWithKeyword, k, specific); // options are All, Self, Enchanted etc. se.setAffectedCards(affectedCards); - String[] pt = k[2].split("/"); - - int x = 0; - if (pt[0].contains("X") || pt[1].contains("X")) - x = CardFactoryUtil.xCount(cardWithKeyword, cardWithKeyword.getSVar("X").split("\\$")[1]); - se.setXValue(x); - - int y = 0; - if (pt[1].contains("Y")) - y = CardFactoryUtil.xCount(cardWithKeyword, cardWithKeyword.getSVar("Y").split("\\$")[1]); - se.setYValue(y); + if(!k[2].equals("no changes")) { + String[] pt = k[2].split("/"); + + int x = 0; + if (pt[0].contains("X") || pt[1].contains("X")) + x = CardFactoryUtil.xCount(cardWithKeyword, cardWithKeyword.getSVar("X").split("\\$")[1]); + se.setXValue(x); + + int y = 0; + if (pt[1].contains("Y")) + y = CardFactoryUtil.xCount(cardWithKeyword, cardWithKeyword.getSVar("Y").split("\\$")[1]); + se.setYValue(y); + } ArrayList types = new ArrayList(); if(!k[3].equalsIgnoreCase("no types")) { @@ -7366,6 +7368,10 @@ public class GameActionUtil { types.remove("KeepSupertype"); se.setKeepSupertype(true); } + if(types.contains("RemoveSubTypes")) { + types.remove("RemoveSubTypes"); + se.setRemoveSubTypes(true); + } } String colors = ""; @@ -7392,18 +7398,33 @@ public class GameActionUtil { private void addStaticEffects(StaticEffect se, Card source, CardList affectedCards, String details, ArrayList types, String colors) { - String[] keyword = details.split("/", 3); - String powerStr = keyword[0]; - String toughStr = keyword[1]; - for(int i = 0; i < affectedCards.size(); i++) { Card affectedCard = affectedCards.get(i); - //copied from stSetPT power/toughness - int power = powerStr.matches("[0-9][0-9]?") ? Integer.parseInt(powerStr) : CardFactoryUtil.xCount(affectedCard, powerStr); - int toughness = toughStr.matches("[0-9][0-9]?") ? Integer.parseInt(toughStr) : CardFactoryUtil.xCount(affectedCard, toughStr); - se.addOriginalPT(affectedCard, affectedCard.getBaseAttack(), affectedCard.getBaseDefense()); - affectedCard.setBaseAttack(power); - affectedCard.setBaseDefense(toughness); + + if(!details.equals("no changes")) { + String[] keyword = details.split("/", 3); + String powerStr = keyword[0]; + String toughStr = keyword[1]; + //copied from stSetPT power/toughness + int power = powerStr.matches("[0-9][0-9]?") ? Integer.parseInt(powerStr) : CardFactoryUtil.xCount(affectedCard, powerStr); + int toughness = toughStr.matches("[0-9][0-9]?") ? Integer.parseInt(toughStr) : CardFactoryUtil.xCount(affectedCard, toughStr); + se.addOriginalPT(affectedCard, affectedCard.getBaseAttack(), affectedCard.getBaseDefense()); + affectedCard.setBaseAttack(power); + affectedCard.setBaseDefense(toughness); + if(se.isOverwriteKeywords()) { + se.addOriginalKeywords(affectedCard, affectedCard.getIntrinsicKeyword()); + affectedCard.clearAllKeywords(); + } + else { + if(keyword.length > 2) { + String keywords[] = keyword[2].split(" & "); + for(int j = 0; j < keywords.length; j++) { + String kw = keywords[j]; + affectedCard.addExtrinsicKeyword(kw); + } + } + } + } if(se.isOverwriteTypes()) { se.addOriginalTypes(affectedCard, affectedCard.getType()); @@ -7417,6 +7438,13 @@ public class GameActionUtil { } } } + if(se.isRemoveSubTypes()) { + se.addOriginalTypes(affectedCard, affectedCard.getType()); + ArrayList acTypes = affectedCard.getType(); + for(String t : acTypes) { + if(CardUtil.isASubType(t)) affectedCard.removeType(t); + } + } for(String type : types) { if(!affectedCard.isType(type)) { affectedCard.addType(type); @@ -7426,19 +7454,6 @@ public class GameActionUtil { se.removeType(affectedCard, type); } } - if(se.isOverwriteKeywords()) { - se.addOriginalKeywords(affectedCard, affectedCard.getIntrinsicKeyword()); - affectedCard.clearAllKeywords(); - } - else { - if(keyword.length > 2) { - String keywords[] = keyword[2].split(" & "); - for(int j = 0; j < keywords.length; j++) { - String kw = keywords[j]; - affectedCard.addExtrinsicKeyword(kw); - } - } - } //Abilities if(se.isOverwriteAbilities()) { se.addOriginalAbilities(affectedCard, affectedCard.getAllButFirstSpellAbility()); @@ -7469,8 +7484,10 @@ public class GameActionUtil { private void removeStaticEffect(StaticEffect se, Card source, Card affectedCard, String[] details) { - affectedCard.setBaseAttack(se.getOriginalPower(affectedCard)); - affectedCard.setBaseDefense(se.getOriginalToughness(affectedCard)); + if(!details[2].equals("no changes")) { + affectedCard.setBaseAttack(se.getOriginalPower(affectedCard)); + affectedCard.setBaseDefense(se.getOriginalToughness(affectedCard)); + } for(String type : se.getTypes(affectedCard)) { affectedCard.removeType(type); @@ -7482,6 +7499,11 @@ public class GameActionUtil { } } } + if(se.isRemoveSubTypes()) { + for(String type : se.getOriginalTypes(affectedCard)) { + if(CardUtil.isASubType(type)) affectedCard.addType(type); + } + } if(se.isOverwriteKeywords()) { for(String kw : se.getOriginalKeywords(affectedCard)) affectedCard.addIntrinsicKeyword(kw); diff --git a/src/forge/StaticEffect.java b/src/forge/StaticEffect.java index ec6f3635464..7cc0238b602 100644 --- a/src/forge/StaticEffect.java +++ b/src/forge/StaticEffect.java @@ -19,6 +19,7 @@ public class StaticEffect { //for types private boolean overwriteTypes = false; private boolean keepSupertype = false; + private boolean removeSubTypes = false; private HashMap> types = new HashMap>(); private HashMap> originalTypes = new HashMap>(); @@ -175,6 +176,15 @@ public class StaticEffect { public void setKeepSupertype(boolean keepSupertype) { this.keepSupertype = keepSupertype; } + + //should we overwrite land types? + public boolean isRemoveSubTypes() { + return removeSubTypes; + } + + public void setRemoveSubTypes(boolean removeSubTypes) { + this.removeSubTypes = removeSubTypes; + } //original types public void addOriginalType(Card c, String s) {