- handlePaid calls using Amount can now handle Math

- More elegant solution to "Destroyed This Way" taking advantage of Remembered.
- Convert Fracturing Gust to AF as an Example
This commit is contained in:
jendave
2011-08-06 22:44:57 +00:00
parent 64ff874931
commit f4a6a8976c
4 changed files with 33 additions and 15 deletions

View File

@@ -1,8 +1,10 @@
Name:Fracturing Gust
ManaCost:2 GW GW GW
Types:Instant
Text:Destroy all artifacts and enchantments. You gain 2 life for each permanent destroyed this way.
K:spDestroyAll:Artifact,Enchantment:Drawback$GainLifeYou/X.Times.2
Text:no text
A:SP$DestroyAll | Cost$ 2 GW GW GW | ValidCards$ Artifact,Enchantment | RememberDestroyed$ True | SubAbility$ SVar=DBGainLife | SpellDescription$ Destroy all artifacts and enchantments. You gain 2 life for each permanent destroyed this way.
SVar:DBGainLife:DB$GainLife | LifeAmount$ X
SVar:X:Remembered$Amount.Twice
SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/fracturing_gust.jpg
SetInfo:SHM|Rare|http://magiccards.info/scans/en/shm/227.jpg

View File

@@ -800,8 +800,10 @@ public class AbilityFactory {
list.add((Card)ability.getSourceCard().getTriggeringObject(calcX[0].substring(9)));
}
else if (calcX[0].startsWith("Remembered")) {
// Add whole Remembered list to handlePaid
list = new CardList();
list.add(AllZoneUtil.getCardState(card.getRemembered().get(0)));
for(Card c : card.getRemembered())
list.add(AllZoneUtil.getCardState(c));
}
else
return 0;

View File

@@ -596,21 +596,21 @@ public class AbilityFactory_Destroy {
list = list.getValidCards(Valid.split(","), card.getController(), card);
int destroyedThisWay = 0;
boolean remDestroyed = params.containsKey("RememberDestroyed");
if (remDestroyed)
card.clearRemembered();
if(noRegen){
for(int i = 0; i < list.size(); i++)
if (AllZone.GameAction.destroyNoRegeneration(list.get(i)))
destroyedThisWay++;
if (AllZone.GameAction.destroyNoRegeneration(list.get(i)) && remDestroyed)
card.addRemembered(list.get(i));
}
else{
for(int i = 0; i < list.size(); i++)
if (AllZone.GameAction.destroy(list.get(i)))
destroyedThisWay++;
if (AllZone.GameAction.destroy(list.get(i)) && remDestroyed)
card.addRemembered(list.get(i));
}
card.setSVar("DestroyedThisWay", Integer.toString(destroyedThisWay));
if (af.hasSubAbility()){
Ability_Sub abSub = sa.getSubAbility();
if (abSub != null){

View File

@@ -3730,10 +3730,10 @@ public class CardFactoryUtil {
return doXMath(n, m);
}
private static int doXMath(int num, String[] m) {
if(m[0].equals("none")) return num;
private static int doXMath(int num, String m){
if(m.equals("none")) return num;
String[] s = m[0].split("\\.");
String[] s = m.split("\\.");
if(s[0].contains("Plus")) return num + Integer.parseInt(s[1]);
else if(s[0].contains("NMinus")) return Integer.parseInt(s[1]) - num;
@@ -3747,13 +3747,27 @@ public class CardFactoryUtil {
else if(s[0].contains("Times")) return num * Integer.parseInt(s[1]);
else return num;
}
private static int doXMath(int num, String[] m) {
if (m.length == 0)
return num;
return doXMath(num, m[0]);
}
public static int handlePaid(CardList paidList, String string, Card source) {
if (paidList == null || paidList.size() == 0)
return 0;
if (string.equals("Amount"))
return paidList.size();
if (string.startsWith("Amount")){
if (string.contains(".")){
String[] splitString = string.split("\\.", 2);
return doXMath(paidList.size(), splitString[1]);
}
else
return paidList.size();
}
if( string.contains("Valid") ) {
String valid = string.replace("Valid ", "");
return paidList.getValidCards(valid, source.getController(), source).size();