mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
*Added CC-prefix to ExtraActions of spCounter
*Fixed Cancel not having anything in it's TargetingRestriction section.
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
#Forge
|
||||
#Mon Aug 16 20:50:29 CEST 2010
|
||||
gui.laf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel
|
||||
AI.stack.land=false
|
||||
gui.new=true
|
||||
stack.offset=tiny
|
||||
card.images.size=medium
|
||||
card.overlay=true
|
||||
card.scale.larger.than.original=true
|
||||
stack.max.size=3
|
||||
gui.laf.fonts=false
|
||||
loss.condition.milling=false
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
Cancel
|
||||
1 U U
|
||||
Instant
|
||||
Counter target spell.
|
||||
spCounter:Spell:None:Graveyard:None
|
||||
SVar:Rarity:Common
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/cancel.jpg
|
||||
|
||||
Dream Fracture
|
||||
1 U U
|
||||
Instant
|
||||
Counter target spell. Its controller draws a card. Draw a card.
|
||||
spCounter:Spell:None:Graveyard:My-Draw(1) CC-Draw(1)
|
||||
SVar:Rarity:Uncommon
|
||||
|
||||
Hallowed Burial
|
||||
3 W W
|
||||
Sorcery
|
||||
@@ -1493,13 +1508,6 @@ SVar:PlayMain1:TRUE
|
||||
SVar:Rarity:Common
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/umara_raptor.jpg
|
||||
|
||||
Dream Fracture
|
||||
1 U U
|
||||
Instant
|
||||
Counter target spell. Its controller draws a card. Draw a card.
|
||||
spCounter:Spell:None:Graveyard:My-Draw(1) Opp-Draw(1)
|
||||
SVar:Rarity:Uncommon
|
||||
|
||||
Absorb
|
||||
W U U
|
||||
Instant
|
||||
@@ -1545,14 +1553,6 @@ Counter target activated ability. Draw a card.
|
||||
spCounter:Ability:None:None:My-Draw(1)
|
||||
SVar:Rarity:Rare
|
||||
|
||||
Cancel
|
||||
1 U U
|
||||
Instant
|
||||
Counter target spell.
|
||||
spCounter:Spell::Graveyard:None
|
||||
SVar:Rarity:Common
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/cancel.jpg
|
||||
|
||||
Confound
|
||||
1 U
|
||||
Instant
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<java version="1.6.0_21" class="java.beans.XMLDecoder">
|
||||
<java version="1.6.0_18" class="java.beans.XMLDecoder">
|
||||
<object id="MultiSplitLayout$Split0" class="org.jdesktop.swingx.MultiSplitLayout$Split">
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>0</int>
|
||||
<int>0</int>
|
||||
<int>1289</int>
|
||||
<int>932</int>
|
||||
<int>1600</int>
|
||||
<int>1123</int>
|
||||
</object>
|
||||
</void>
|
||||
<void id="ArrayList0" property="children">
|
||||
@@ -17,7 +17,7 @@
|
||||
<int>0</int>
|
||||
<int>0</int>
|
||||
<int>197</int>
|
||||
<int>932</int>
|
||||
<int>1123</int>
|
||||
</object>
|
||||
</void>
|
||||
<void id="ArrayList1" property="children">
|
||||
@@ -28,7 +28,7 @@
|
||||
<int>0</int>
|
||||
<int>0</int>
|
||||
<int>197</int>
|
||||
<int>184</int>
|
||||
<int>199</int>
|
||||
</object>
|
||||
</void>
|
||||
<void property="name">
|
||||
@@ -47,7 +47,7 @@
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>0</int>
|
||||
<int>184</int>
|
||||
<int>199</int>
|
||||
<int>197</int>
|
||||
<int>5</int>
|
||||
</object>
|
||||
@@ -62,9 +62,9 @@
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>0</int>
|
||||
<int>189</int>
|
||||
<int>204</int>
|
||||
<int>197</int>
|
||||
<int>260</int>
|
||||
<int>280</int>
|
||||
</object>
|
||||
</void>
|
||||
<void property="name">
|
||||
@@ -83,7 +83,7 @@
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>0</int>
|
||||
<int>449</int>
|
||||
<int>484</int>
|
||||
<int>197</int>
|
||||
<int>5</int>
|
||||
</object>
|
||||
@@ -98,9 +98,9 @@
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>0</int>
|
||||
<int>454</int>
|
||||
<int>489</int>
|
||||
<int>197</int>
|
||||
<int>120</int>
|
||||
<int>159</int>
|
||||
</object>
|
||||
</void>
|
||||
<void property="name">
|
||||
@@ -119,7 +119,7 @@
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>0</int>
|
||||
<int>574</int>
|
||||
<int>648</int>
|
||||
<int>197</int>
|
||||
<int>5</int>
|
||||
</object>
|
||||
@@ -134,9 +134,9 @@
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>0</int>
|
||||
<int>579</int>
|
||||
<int>653</int>
|
||||
<int>197</int>
|
||||
<int>165</int>
|
||||
<int>182</int>
|
||||
</object>
|
||||
</void>
|
||||
<void property="name">
|
||||
@@ -155,7 +155,7 @@
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>0</int>
|
||||
<int>744</int>
|
||||
<int>835</int>
|
||||
<int>197</int>
|
||||
<int>5</int>
|
||||
</object>
|
||||
@@ -170,9 +170,9 @@
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>0</int>
|
||||
<int>749</int>
|
||||
<int>840</int>
|
||||
<int>197</int>
|
||||
<int>183</int>
|
||||
<int>283</int>
|
||||
</object>
|
||||
</void>
|
||||
<void property="name">
|
||||
@@ -205,7 +205,7 @@
|
||||
<int>197</int>
|
||||
<int>0</int>
|
||||
<int>5</int>
|
||||
<int>932</int>
|
||||
<int>1123</int>
|
||||
</object>
|
||||
</void>
|
||||
<void property="parent">
|
||||
@@ -219,8 +219,8 @@
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>202</int>
|
||||
<int>0</int>
|
||||
<int>772</int>
|
||||
<int>932</int>
|
||||
<int>1083</int>
|
||||
<int>1123</int>
|
||||
</object>
|
||||
</void>
|
||||
<void id="ArrayList2" property="children">
|
||||
@@ -230,8 +230,8 @@
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>202</int>
|
||||
<int>0</int>
|
||||
<int>772</int>
|
||||
<int>381</int>
|
||||
<int>1083</int>
|
||||
<int>501</int>
|
||||
</object>
|
||||
</void>
|
||||
<void property="name">
|
||||
@@ -250,8 +250,8 @@
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>202</int>
|
||||
<int>381</int>
|
||||
<int>772</int>
|
||||
<int>501</int>
|
||||
<int>1083</int>
|
||||
<int>5</int>
|
||||
</object>
|
||||
</void>
|
||||
@@ -265,9 +265,9 @@
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>202</int>
|
||||
<int>386</int>
|
||||
<int>772</int>
|
||||
<int>378</int>
|
||||
<int>506</int>
|
||||
<int>1083</int>
|
||||
<int>404</int>
|
||||
</object>
|
||||
</void>
|
||||
<void property="name">
|
||||
@@ -286,8 +286,8 @@
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>202</int>
|
||||
<int>764</int>
|
||||
<int>772</int>
|
||||
<int>910</int>
|
||||
<int>1083</int>
|
||||
<int>5</int>
|
||||
</object>
|
||||
</void>
|
||||
@@ -301,9 +301,9 @@
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>202</int>
|
||||
<int>769</int>
|
||||
<int>772</int>
|
||||
<int>163</int>
|
||||
<int>915</int>
|
||||
<int>1083</int>
|
||||
<int>208</int>
|
||||
</object>
|
||||
</void>
|
||||
<void property="name">
|
||||
@@ -336,10 +336,10 @@
|
||||
<object class="org.jdesktop.swingx.MultiSplitLayout$Divider">
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>974</int>
|
||||
<int>1285</int>
|
||||
<int>0</int>
|
||||
<int>5</int>
|
||||
<int>932</int>
|
||||
<int>1123</int>
|
||||
</object>
|
||||
</void>
|
||||
<void property="parent">
|
||||
@@ -351,10 +351,10 @@
|
||||
<object id="MultiSplitLayout$Split3" class="org.jdesktop.swingx.MultiSplitLayout$Split">
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>979</int>
|
||||
<int>1290</int>
|
||||
<int>0</int>
|
||||
<int>310</int>
|
||||
<int>932</int>
|
||||
<int>1123</int>
|
||||
</object>
|
||||
</void>
|
||||
<void id="ArrayList3" property="children">
|
||||
@@ -362,10 +362,10 @@
|
||||
<object class="org.jdesktop.swingx.MultiSplitLayout$Leaf">
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>979</int>
|
||||
<int>1290</int>
|
||||
<int>0</int>
|
||||
<int>310</int>
|
||||
<int>496</int>
|
||||
<int>622</int>
|
||||
</object>
|
||||
</void>
|
||||
<void property="name">
|
||||
@@ -383,8 +383,8 @@
|
||||
<object class="org.jdesktop.swingx.MultiSplitLayout$Divider">
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>979</int>
|
||||
<int>496</int>
|
||||
<int>1290</int>
|
||||
<int>622</int>
|
||||
<int>310</int>
|
||||
<int>5</int>
|
||||
</object>
|
||||
@@ -398,10 +398,10 @@
|
||||
<object class="org.jdesktop.swingx.MultiSplitLayout$Leaf">
|
||||
<void property="bounds">
|
||||
<object class="java.awt.Rectangle">
|
||||
<int>979</int>
|
||||
<int>501</int>
|
||||
<int>1290</int>
|
||||
<int>627</int>
|
||||
<int>310</int>
|
||||
<int>431</int>
|
||||
<int>496</int>
|
||||
</object>
|
||||
</void>
|
||||
<void property="name">
|
||||
|
||||
@@ -277,6 +277,318 @@ public class CardFactory implements NewConstants {
|
||||
}
|
||||
});
|
||||
}//if "Comes into play tapped."
|
||||
if(hasKeyword(card,"spCounter") != -1) {
|
||||
System.out.println("Processing spCounter for card " + card.getName());
|
||||
ComputerAI_counterSpells2.KeywordedCounterspells.add(card.getName());
|
||||
String keyword = card.getKeyword().get(hasKeyword(card,"spCounter"));
|
||||
if(keyword.contains("X"))
|
||||
{
|
||||
keyword = keyword.replace("X", card.getSVar("X"));
|
||||
}
|
||||
card.removeIntrinsicKeyword(keyword);
|
||||
|
||||
String[] splitkeyword = keyword.split(":");
|
||||
|
||||
final String TargetType = splitkeyword[1];
|
||||
final String TargetingRestrictions = splitkeyword[2];
|
||||
final String Destination = splitkeyword[3];
|
||||
final String ExtraActions = splitkeyword[4];
|
||||
|
||||
final String[] SplitTargetingRestrictions = TargetingRestrictions.split(" ");
|
||||
final String[] SplitExtraActions = ExtraActions.split(" ");
|
||||
|
||||
SpellAbility spCounterAbility = new Spell(card)
|
||||
{
|
||||
private static final long serialVersionUID = 9763720166553L;
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI()
|
||||
{
|
||||
System.out.println("AI is pondering us...");
|
||||
return canPlay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlay()
|
||||
{
|
||||
if(AllZone.Stack.size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean fullResult = true;
|
||||
SpellAbility sa = AllZone.Stack.peek();
|
||||
Card tgtCard = sa.getSourceCard();
|
||||
|
||||
if(TargetType.equals("Spell"))
|
||||
{
|
||||
if(sa.isAbility())
|
||||
{
|
||||
System.out.println(card.getName() + " can only counter spells, not abilities.");
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
else if(TargetType.equals("Ability"))
|
||||
{
|
||||
if(sa.isSpell())
|
||||
{
|
||||
System.out.println(card.getName() + " can only counter abilities, not spells.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(TargetType.equals("SpellOrAbility"))
|
||||
{
|
||||
//Do nothing. This block is only for clarity and enforcing parameters.
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("Invalid target type for card " + card.getName());
|
||||
}
|
||||
|
||||
for(int i=0;i<SplitTargetingRestrictions.length;i++)
|
||||
{
|
||||
boolean subResult = false;
|
||||
if(TargetingRestrictions.equals("None"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
String RestrictionID = SplitTargetingRestrictions[i].substring(0,SplitTargetingRestrictions[i].indexOf('('));
|
||||
String Parameters = SplitTargetingRestrictions[i].substring(SplitTargetingRestrictions[i].indexOf('(')+1);
|
||||
Parameters = Parameters.substring(0,Parameters.length()-1);
|
||||
|
||||
String[] SplitParameters = Parameters.split(",");
|
||||
|
||||
System.out.println(card.getName() + " currently checking restriction '" + RestrictionID + "'");
|
||||
if(RestrictionID.equals("Color"))
|
||||
{
|
||||
for(int p=0;p<SplitParameters.length;p++)
|
||||
{
|
||||
System.out.println("Parameter: " + SplitParameters[p]);
|
||||
if(SplitParameters[p].startsWith("Non-"))
|
||||
{
|
||||
subResult |= !CardUtil.getColors(tgtCard).contains(SplitParameters[p].substring(4).toLowerCase());
|
||||
}
|
||||
else
|
||||
{
|
||||
subResult |= CardUtil.getColors(tgtCard).contains(SplitParameters[p].toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(RestrictionID.equals("Type"))
|
||||
{
|
||||
for(int p=0;p<SplitParameters.length;p++)
|
||||
{
|
||||
System.out.println("Parameter: " + SplitParameters[p]);
|
||||
if(SplitParameters[p].startsWith("Non-"))
|
||||
{
|
||||
System.out.println(SplitParameters[p].substring(4));
|
||||
subResult |= !tgtCard.getType().contains(SplitParameters[p].substring(4));
|
||||
}
|
||||
else
|
||||
{
|
||||
subResult |= tgtCard.getType().contains(SplitParameters[p]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(RestrictionID.equals("CMC"))
|
||||
{
|
||||
String mode = SplitParameters[0];
|
||||
int value = Integer.parseInt(SplitParameters[1]);
|
||||
System.out.println(mode);
|
||||
System.out.println(Integer.toString(value));
|
||||
|
||||
if(mode.equals("<"))
|
||||
{
|
||||
subResult |= (CardUtil.getConvertedManaCost(tgtCard) < value);
|
||||
}
|
||||
else if(mode.equals(">"))
|
||||
{
|
||||
subResult |= (CardUtil.getConvertedManaCost(tgtCard) > value);
|
||||
}
|
||||
else if(mode.equals("=="))
|
||||
{
|
||||
subResult |= (CardUtil.getConvertedManaCost(tgtCard) == value);
|
||||
}
|
||||
else if(mode.equals("!="))
|
||||
{
|
||||
subResult |= (CardUtil.getConvertedManaCost(tgtCard) != value);
|
||||
}
|
||||
else if(mode.equals("<="))
|
||||
{
|
||||
subResult |= (CardUtil.getConvertedManaCost(tgtCard) <= value);
|
||||
}
|
||||
else if(mode.equals(">="))
|
||||
{
|
||||
subResult |= (CardUtil.getConvertedManaCost(tgtCard) >= value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("spCounter: Invalid mode parameter to CMC restriction in card " + card.getName());
|
||||
}
|
||||
}
|
||||
else if(RestrictionID.equals("Targets"))
|
||||
{
|
||||
for(int p=0;p<SplitParameters.length;p++)
|
||||
{
|
||||
System.out.println("Parameter: " + SplitParameters[p]);
|
||||
if(SplitParameters[p].startsWith("My-")) //Targets my <type> permanent
|
||||
{
|
||||
if(sa.getTargetCard().getController() != card.getController())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(SplitParameters[p].contains("Non-"))
|
||||
{
|
||||
subResult |= !sa.getTargetCard().getType().contains(SplitParameters[p].substring(7));
|
||||
}
|
||||
else
|
||||
{
|
||||
subResult |= (sa.getTargetCard().getType().contains(SplitParameters[p].substring(3)));
|
||||
}
|
||||
}
|
||||
else if(SplitParameters[p].startsWith("Opp-")) //Targets opponent's <type> permanent
|
||||
{
|
||||
if(sa.getTargetCard().getController() == card.getController())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(SplitParameters[p].contains("Non-"))
|
||||
{
|
||||
subResult |= !(sa.getTargetCard().getType().contains(SplitParameters[p].substring(8)));
|
||||
}
|
||||
else
|
||||
{
|
||||
subResult |= (sa.getTargetCard().getType().contains(SplitParameters[p].substring(4)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(SplitParameters[p].contains("Non-"))
|
||||
{
|
||||
subResult |= !(sa.getTargetCard().getType().contains(SplitParameters[p].substring(4)));
|
||||
}
|
||||
else
|
||||
{
|
||||
subResult |= (sa.getTargetCard().getType().contains(SplitParameters[p]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("Sub: " + Boolean.toString(subResult));
|
||||
fullResult &= subResult;
|
||||
} //End Targeting parsing
|
||||
System.out.println("Success: " + Boolean.toString(fullResult));
|
||||
return fullResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve()
|
||||
{
|
||||
System.out.println("Resolving " + card.getName());
|
||||
SpellAbility sa = AllZone.Stack.pop();
|
||||
|
||||
System.out.println("Send countered spell to " + Destination);
|
||||
|
||||
if(Destination.equals("None") || TargetType.contains("Ability")) //For Ability-targeting counterspells
|
||||
{
|
||||
|
||||
}
|
||||
else if(Destination.equals("Graveyard"))
|
||||
{
|
||||
AllZone.GameAction.moveToGraveyard(sa.getSourceCard());
|
||||
}
|
||||
else if(Destination.equals("Exile"))
|
||||
{
|
||||
AllZone.GameAction.exile(sa.getSourceCard());
|
||||
}
|
||||
else if(Destination.equals("Topdeck"))
|
||||
{
|
||||
AllZone.GameAction.moveToTopOfLibrary(sa.getSourceCard());
|
||||
}
|
||||
else if(Destination.equals("Hand"))
|
||||
{
|
||||
AllZone.GameAction.moveToHand(sa.getSourceCard());
|
||||
}
|
||||
else if(Destination.equals("BottomDeck"))
|
||||
{
|
||||
AllZone.GameAction.moveToBottomOfLibrary(sa.getSourceCard());
|
||||
}
|
||||
else if(Destination.equals("Shuffle"))
|
||||
{
|
||||
AllZone.GameAction.moveToBottomOfLibrary(sa.getSourceCard());
|
||||
AllZone.GameAction.shuffle(sa.getSourceCard().getController());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("spCounter: Invalid Destination argument for card " + card.getName());
|
||||
}
|
||||
|
||||
for(int ea = 0;ea<SplitExtraActions.length;ea++)
|
||||
{
|
||||
|
||||
if(ExtraActions.equals("None"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
String ActionID = SplitExtraActions[ea].substring(0,SplitExtraActions[ea].indexOf('('));
|
||||
|
||||
String Target = "";
|
||||
|
||||
String ActionParams = SplitExtraActions[ea].substring(SplitExtraActions[ea].indexOf('(')+1);
|
||||
ActionParams = ActionParams.substring(0,ActionParams.length()-1);
|
||||
|
||||
String[] SplitActionParams = ActionParams.split(",");
|
||||
|
||||
System.out.println("Extra Action: " + ActionID);
|
||||
System.out.println("Parameters: " + ActionParams);
|
||||
|
||||
if(ActionID.startsWith("My-"))
|
||||
{
|
||||
ActionID = ActionID.substring(3);
|
||||
Target = card.getController();
|
||||
}
|
||||
else if(ActionID.startsWith("Opp-"))
|
||||
{
|
||||
ActionID = ActionID.substring(4);
|
||||
Target = AllZone.GameAction.getOpponent(card.getController());
|
||||
}
|
||||
else if(ActionID.startsWith("CC-"))
|
||||
{
|
||||
ActionID = ActionID.substring(3);
|
||||
Target = sa.getSourceCard().getController();
|
||||
}
|
||||
|
||||
if(ActionID.equals("Draw"))
|
||||
{
|
||||
AllZone.GameAction.drawCards(Target, Integer.parseInt(SplitActionParams[0]));
|
||||
}
|
||||
else if(ActionID.equals("Discard"))
|
||||
{
|
||||
AllZone.GameAction.discard(Target, Integer.parseInt(SplitActionParams[0]));
|
||||
}
|
||||
else if(ActionID.equals("LoseLife"))
|
||||
{
|
||||
AllZone.GameAction.getPlayerLife(Target).subtractLife(Integer.parseInt(SplitActionParams[0]), card);
|
||||
}
|
||||
else if(ActionID.equals("GainLife"))
|
||||
{
|
||||
AllZone.GameAction.getPlayerLife(Target).addLife(Integer.parseInt(SplitActionParams[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("spCounter: Invalid Extra Action for card " + card.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
card.clearSpellAbility();
|
||||
card.addSpellAbility(spCounterAbility);
|
||||
} //spCounter
|
||||
|
||||
if (hasKeyword(card, "CARDNAME enters the battlefield tapped unless you control") != -1)
|
||||
{
|
||||
int n = hasKeyword(card, "CARDNAME enters the battlefield tapped unless you control");
|
||||
@@ -23696,313 +24008,6 @@ public class CardFactory implements NewConstants {
|
||||
card.addChangeControllerCommand(controllerChanges);
|
||||
} //HandSize
|
||||
|
||||
if(hasKeyword(card,"spCounter") != -1) {
|
||||
System.out.println("Processing spCounter for card " + card.getName());
|
||||
ComputerAI_counterSpells2.KeywordedCounterspells.add(card.getName());
|
||||
String keyword = card.getKeyword().get(hasKeyword(card,"spCounter"));
|
||||
if(keyword.contains("X"))
|
||||
{
|
||||
keyword = keyword.replace("X", card.getSVar("X"));
|
||||
}
|
||||
card.removeIntrinsicKeyword(keyword);
|
||||
|
||||
String[] splitkeyword = keyword.split(":");
|
||||
|
||||
final String TargetType = splitkeyword[1];
|
||||
final String TargetingRestrictions = splitkeyword[2];
|
||||
final String Destination = splitkeyword[3];
|
||||
final String ExtraActions = splitkeyword[4];
|
||||
|
||||
final String[] SplitTargetingRestrictions = TargetingRestrictions.split(" ");
|
||||
final String[] SplitExtraActions = ExtraActions.split(" ");
|
||||
|
||||
SpellAbility spCounterAbility = new Spell(card)
|
||||
{
|
||||
private static final long serialVersionUID = 9763720166553L;
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI()
|
||||
{
|
||||
System.out.println("AI is pondering us...");
|
||||
return canPlay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlay()
|
||||
{
|
||||
if(AllZone.Stack.size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean fullResult = true;
|
||||
SpellAbility sa = AllZone.Stack.peek();
|
||||
Card tgtCard = sa.getSourceCard();
|
||||
|
||||
if(TargetType.equals("Spell"))
|
||||
{
|
||||
if(sa.isAbility())
|
||||
{
|
||||
System.out.println(card.getName() + " can only counter spells, not abilities.");
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
else if(TargetType.equals("Ability"))
|
||||
{
|
||||
if(sa.isSpell())
|
||||
{
|
||||
System.out.println(card.getName() + " can only counter abilities, not spells.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(TargetType.equals("SpellOrAbility"))
|
||||
{
|
||||
//Do nothing. This block is only for clarity and enforcing parameters.
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("Invalid target type for card " + card.getName());
|
||||
}
|
||||
|
||||
for(int i=0;i<SplitTargetingRestrictions.length;i++)
|
||||
{
|
||||
boolean subResult = false;
|
||||
if(TargetingRestrictions.equals("None"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
String RestrictionID = SplitTargetingRestrictions[i].substring(0,SplitTargetingRestrictions[i].indexOf('('));
|
||||
String Parameters = SplitTargetingRestrictions[i].substring(SplitTargetingRestrictions[i].indexOf('(')+1);
|
||||
Parameters = Parameters.substring(0,Parameters.length()-1);
|
||||
|
||||
String[] SplitParameters = Parameters.split(",");
|
||||
|
||||
System.out.println(card.getName() + " currently checking restriction '" + RestrictionID + "'");
|
||||
if(RestrictionID.equals("Color"))
|
||||
{
|
||||
for(int p=0;p<SplitParameters.length;p++)
|
||||
{
|
||||
System.out.println("Parameter: " + SplitParameters[p]);
|
||||
if(SplitParameters[p].startsWith("Non-"))
|
||||
{
|
||||
subResult |= !CardUtil.getColors(tgtCard).contains(SplitParameters[p].substring(4).toLowerCase());
|
||||
}
|
||||
else
|
||||
{
|
||||
subResult |= CardUtil.getColors(tgtCard).contains(SplitParameters[p].toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(RestrictionID.equals("Type"))
|
||||
{
|
||||
for(int p=0;p<SplitParameters.length;p++)
|
||||
{
|
||||
System.out.println("Parameter: " + SplitParameters[p]);
|
||||
if(SplitParameters[p].startsWith("Non-"))
|
||||
{
|
||||
System.out.println(SplitParameters[p].substring(4));
|
||||
subResult |= !tgtCard.getType().contains(SplitParameters[p].substring(4));
|
||||
}
|
||||
else
|
||||
{
|
||||
subResult |= tgtCard.getType().contains(SplitParameters[p]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(RestrictionID.equals("CMC"))
|
||||
{
|
||||
String mode = SplitParameters[0];
|
||||
int value = Integer.parseInt(SplitParameters[1]);
|
||||
System.out.println(mode);
|
||||
System.out.println(Integer.toString(value));
|
||||
|
||||
if(mode.equals("<"))
|
||||
{
|
||||
subResult |= (CardUtil.getConvertedManaCost(tgtCard) < value);
|
||||
}
|
||||
else if(mode.equals(">"))
|
||||
{
|
||||
subResult |= (CardUtil.getConvertedManaCost(tgtCard) > value);
|
||||
}
|
||||
else if(mode.equals("=="))
|
||||
{
|
||||
subResult |= (CardUtil.getConvertedManaCost(tgtCard) == value);
|
||||
}
|
||||
else if(mode.equals("!="))
|
||||
{
|
||||
subResult |= (CardUtil.getConvertedManaCost(tgtCard) != value);
|
||||
}
|
||||
else if(mode.equals("<="))
|
||||
{
|
||||
subResult |= (CardUtil.getConvertedManaCost(tgtCard) <= value);
|
||||
}
|
||||
else if(mode.equals(">="))
|
||||
{
|
||||
subResult |= (CardUtil.getConvertedManaCost(tgtCard) >= value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("spCounter: Invalid mode parameter to CMC restriction in card " + card.getName());
|
||||
}
|
||||
}
|
||||
else if(RestrictionID.equals("Targets"))
|
||||
{
|
||||
for(int p=0;p<SplitParameters.length;p++)
|
||||
{
|
||||
System.out.println("Parameter: " + SplitParameters[p]);
|
||||
if(SplitParameters[p].startsWith("My-")) //Targets my <type> permanent
|
||||
{
|
||||
if(sa.getTargetCard().getController() != card.getController())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(SplitParameters[p].contains("Non-"))
|
||||
{
|
||||
subResult |= !sa.getTargetCard().getType().contains(SplitParameters[p].substring(7));
|
||||
}
|
||||
else
|
||||
{
|
||||
subResult |= (sa.getTargetCard().getType().contains(SplitParameters[p].substring(3)));
|
||||
}
|
||||
}
|
||||
else if(SplitParameters[p].startsWith("Opp-")) //Targets opponent's <type> permanent
|
||||
{
|
||||
if(sa.getTargetCard().getController() == card.getController())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(SplitParameters[p].contains("Non-"))
|
||||
{
|
||||
subResult |= !(sa.getTargetCard().getType().contains(SplitParameters[p].substring(8)));
|
||||
}
|
||||
else
|
||||
{
|
||||
subResult |= (sa.getTargetCard().getType().contains(SplitParameters[p].substring(4)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(SplitParameters[p].contains("Non-"))
|
||||
{
|
||||
subResult |= !(sa.getTargetCard().getType().contains(SplitParameters[p].substring(4)));
|
||||
}
|
||||
else
|
||||
{
|
||||
subResult |= (sa.getTargetCard().getType().contains(SplitParameters[p]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("Sub: " + Boolean.toString(subResult));
|
||||
fullResult &= subResult;
|
||||
} //End Targeting parsing
|
||||
System.out.println("Success: " + Boolean.toString(fullResult));
|
||||
return fullResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve()
|
||||
{
|
||||
System.out.println("Resolving " + card.getName());
|
||||
SpellAbility sa = AllZone.Stack.pop();
|
||||
|
||||
System.out.println("Send countered spell to " + Destination);
|
||||
|
||||
if(Destination.equals("None") || TargetType.contains("Ability")) //For Ability-targeting counterspells
|
||||
{
|
||||
|
||||
}
|
||||
else if(Destination.equals("Graveyard"))
|
||||
{
|
||||
AllZone.GameAction.moveToGraveyard(sa.getSourceCard());
|
||||
}
|
||||
else if(Destination.equals("Exile"))
|
||||
{
|
||||
AllZone.GameAction.exile(sa.getSourceCard());
|
||||
}
|
||||
else if(Destination.equals("Topdeck"))
|
||||
{
|
||||
AllZone.GameAction.moveToTopOfLibrary(sa.getSourceCard());
|
||||
}
|
||||
else if(Destination.equals("Hand"))
|
||||
{
|
||||
AllZone.GameAction.moveToHand(sa.getSourceCard());
|
||||
}
|
||||
else if(Destination.equals("BottomDeck"))
|
||||
{
|
||||
AllZone.GameAction.moveToBottomOfLibrary(sa.getSourceCard());
|
||||
}
|
||||
else if(Destination.equals("Shuffle"))
|
||||
{
|
||||
AllZone.GameAction.moveToBottomOfLibrary(sa.getSourceCard());
|
||||
AllZone.GameAction.shuffle(sa.getSourceCard().getController());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("spCounter: Invalid Destination argument for card " + card.getName());
|
||||
}
|
||||
|
||||
for(int ea = 0;ea<SplitExtraActions.length;ea++)
|
||||
{
|
||||
|
||||
if(ExtraActions.equals("None"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
String ActionID = SplitExtraActions[ea].substring(0,SplitExtraActions[ea].indexOf('('));
|
||||
|
||||
String Target = "";
|
||||
|
||||
String ActionParams = SplitExtraActions[ea].substring(SplitExtraActions[ea].indexOf('(')+1);
|
||||
ActionParams = ActionParams.substring(0,ActionParams.length()-1);
|
||||
|
||||
String[] SplitActionParams = ActionParams.split(",");
|
||||
|
||||
System.out.println("Extra Action: " + ActionID);
|
||||
System.out.println("Parameters: " + ActionParams);
|
||||
|
||||
if(ActionID.startsWith("My-"))
|
||||
{
|
||||
ActionID = ActionID.substring(3);
|
||||
Target = card.getController();
|
||||
}
|
||||
else if(ActionID.startsWith("Opp-"))
|
||||
{
|
||||
ActionID = ActionID.substring(4);
|
||||
Target = AllZone.GameAction.getOpponent(card.getController());
|
||||
}
|
||||
|
||||
if(ActionID.equals("Draw"))
|
||||
{
|
||||
AllZone.GameAction.drawCards(Target, Integer.parseInt(SplitActionParams[0]));
|
||||
}
|
||||
else if(ActionID.equals("Discard"))
|
||||
{
|
||||
AllZone.GameAction.discard(Target, Integer.parseInt(SplitActionParams[0]));
|
||||
}
|
||||
else if(ActionID.equals("LoseLife"))
|
||||
{
|
||||
AllZone.GameAction.getPlayerLife(Target).subtractLife(Integer.parseInt(SplitActionParams[0]), card);
|
||||
}
|
||||
else if(ActionID.equals("GainLife"))
|
||||
{
|
||||
AllZone.GameAction.getPlayerLife(Target).addLife(Integer.parseInt(SplitActionParams[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("spCounter: Invalid Extra Action for card " + card.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
card.clearSpellAbility();
|
||||
card.addSpellAbility(spCounterAbility);
|
||||
} //spCounter
|
||||
|
||||
if (card.getManaCost().contains("X"))
|
||||
{
|
||||
SpellAbility sa = card.getSpellAbility()[0];
|
||||
|
||||
Reference in New Issue
Block a user