mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- 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:
@@ -1,8 +1,10 @@
|
|||||||
Name:Fracturing Gust
|
Name:Fracturing Gust
|
||||||
ManaCost:2 GW GW GW
|
ManaCost:2 GW GW GW
|
||||||
Types:Instant
|
Types:Instant
|
||||||
Text:Destroy all artifacts and enchantments. You gain 2 life for each permanent destroyed this way.
|
Text:no text
|
||||||
K:spDestroyAll:Artifact,Enchantment:Drawback$GainLifeYou/X.Times.2
|
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:Rarity:Rare
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/fracturing_gust.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/fracturing_gust.jpg
|
||||||
SetInfo:SHM|Rare|http://magiccards.info/scans/en/shm/227.jpg
|
SetInfo:SHM|Rare|http://magiccards.info/scans/en/shm/227.jpg
|
||||||
|
|||||||
@@ -800,8 +800,10 @@ public class AbilityFactory {
|
|||||||
list.add((Card)ability.getSourceCard().getTriggeringObject(calcX[0].substring(9)));
|
list.add((Card)ability.getSourceCard().getTriggeringObject(calcX[0].substring(9)));
|
||||||
}
|
}
|
||||||
else if (calcX[0].startsWith("Remembered")) {
|
else if (calcX[0].startsWith("Remembered")) {
|
||||||
|
// Add whole Remembered list to handlePaid
|
||||||
list = new CardList();
|
list = new CardList();
|
||||||
list.add(AllZoneUtil.getCardState(card.getRemembered().get(0)));
|
for(Card c : card.getRemembered())
|
||||||
|
list.add(AllZoneUtil.getCardState(c));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -596,21 +596,21 @@ public class AbilityFactory_Destroy {
|
|||||||
|
|
||||||
list = list.getValidCards(Valid.split(","), card.getController(), card);
|
list = list.getValidCards(Valid.split(","), card.getController(), card);
|
||||||
|
|
||||||
int destroyedThisWay = 0;
|
boolean remDestroyed = params.containsKey("RememberDestroyed");
|
||||||
|
if (remDestroyed)
|
||||||
|
card.clearRemembered();
|
||||||
|
|
||||||
if(noRegen){
|
if(noRegen){
|
||||||
for(int i = 0; i < list.size(); i++)
|
for(int i = 0; i < list.size(); i++)
|
||||||
if (AllZone.GameAction.destroyNoRegeneration(list.get(i)))
|
if (AllZone.GameAction.destroyNoRegeneration(list.get(i)) && remDestroyed)
|
||||||
destroyedThisWay++;
|
card.addRemembered(list.get(i));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
for(int i = 0; i < list.size(); i++)
|
for(int i = 0; i < list.size(); i++)
|
||||||
if (AllZone.GameAction.destroy(list.get(i)))
|
if (AllZone.GameAction.destroy(list.get(i)) && remDestroyed)
|
||||||
destroyedThisWay++;
|
card.addRemembered(list.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
card.setSVar("DestroyedThisWay", Integer.toString(destroyedThisWay));
|
|
||||||
|
|
||||||
if (af.hasSubAbility()){
|
if (af.hasSubAbility()){
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null){
|
if (abSub != null){
|
||||||
|
|||||||
@@ -3730,10 +3730,10 @@ public class CardFactoryUtil {
|
|||||||
return doXMath(n, m);
|
return doXMath(n, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int doXMath(int num, String[] m) {
|
private static int doXMath(int num, String m){
|
||||||
if(m[0].equals("none")) return num;
|
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]);
|
if(s[0].contains("Plus")) return num + Integer.parseInt(s[1]);
|
||||||
else if(s[0].contains("NMinus")) return Integer.parseInt(s[1]) - num;
|
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 if(s[0].contains("Times")) return num * Integer.parseInt(s[1]);
|
||||||
else return num;
|
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) {
|
public static int handlePaid(CardList paidList, String string, Card source) {
|
||||||
if (paidList == null || paidList.size() == 0)
|
if (paidList == null || paidList.size() == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (string.equals("Amount"))
|
if (string.startsWith("Amount")){
|
||||||
return paidList.size();
|
if (string.contains(".")){
|
||||||
|
String[] splitString = string.split("\\.", 2);
|
||||||
|
return doXMath(paidList.size(), splitString[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return paidList.size();
|
||||||
|
|
||||||
|
}
|
||||||
if( string.contains("Valid") ) {
|
if( string.contains("Valid") ) {
|
||||||
String valid = string.replace("Valid ", "");
|
String valid = string.replace("Valid ", "");
|
||||||
return paidList.getValidCards(valid, source.getController(), source).size();
|
return paidList.getValidCards(valid, source.getController(), source).size();
|
||||||
|
|||||||
Reference in New Issue
Block a user