mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
*Moved all parameter->xCount and optional parameter parsing inside AF_Token.
This commit is contained in:
@@ -297,44 +297,12 @@ public class AbilityFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(API.equals("Token")){
|
if(API.equals("Token")){
|
||||||
AbilityFactory_Token AFT = new AbilityFactory_Token();
|
AbilityFactory_Token AFT = new AbilityFactory_Token(this);
|
||||||
|
|
||||||
String numTokens,numPower,numToughness,image;
|
|
||||||
String[] keywords;
|
|
||||||
|
|
||||||
if(!mapParams.get("TokenAmount").matches("[0-9][0-9]?")) //It's an X-value.
|
|
||||||
numTokens = getHostCard().getSVar(mapParams.get("TokenAmount"));
|
|
||||||
else
|
|
||||||
numTokens = mapParams.get("TokenAmount");
|
|
||||||
|
|
||||||
if(!mapParams.get("TokenPower").matches("[0-9][0-9]?"))
|
|
||||||
numPower = getHostCard().getSVar(mapParams.get("TokenPower"));
|
|
||||||
else
|
|
||||||
numPower = mapParams.get("TokenPower");
|
|
||||||
|
|
||||||
if(!mapParams.get("TokenToughness").matches("[0-9][0-9]?"))
|
|
||||||
numToughness = getHostCard().getSVar(mapParams.get("TokenToughness"));
|
|
||||||
else
|
|
||||||
numToughness = mapParams.get("TokenToughness");
|
|
||||||
|
|
||||||
if(mapParams.containsKey("TokenKeywords")) {
|
|
||||||
keywords = mapParams.get("TokenKeywords").split("<>");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
keywords = new String[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mapParams.containsKey("TokenImage")) {
|
|
||||||
image = mapParams.get("TokenImage");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
image = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isAb)
|
if(isAb)
|
||||||
SA = AFT.getAbility(this, numTokens, mapParams.get("TokenName"), mapParams.get("TokenTypes").split(","), mapParams.get("TokenOwner"), mapParams.get("TokenColors").split(","), numPower, numToughness, keywords, image);
|
SA = AFT.getAbility();
|
||||||
if(isSp)
|
if(isSp)
|
||||||
SA = AFT.getSpell(this, numTokens, mapParams.get("TokenName"), mapParams.get("TokenTypes").split(","), mapParams.get("TokenOwner"), mapParams.get("TokenColors").split(","), numPower, numToughness, keywords, image);
|
SA = AFT.getSpell();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (API.equals("GainControl")) {
|
if (API.equals("GainControl")) {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package forge;
|
package forge;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class AbilityFactory_Token extends AbilityFactory {
|
public class AbilityFactory_Token extends AbilityFactory {
|
||||||
private AbilityFactory AF = null;
|
private AbilityFactory AF = null;
|
||||||
|
|
||||||
@@ -13,18 +15,56 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
private String tokenToughness;
|
private String tokenToughness;
|
||||||
private String tokenImage;
|
private String tokenImage;
|
||||||
|
|
||||||
public SpellAbility getAbility(final AbilityFactory af,final String numTokens,final String name,final String[] types,final String owner,final String[] colors,final String power,final String toughness,final String[] keywords,final String image)
|
public AbilityFactory_Token(final AbilityFactory af) {
|
||||||
{
|
|
||||||
AF = af;
|
AF = af;
|
||||||
|
|
||||||
|
HashMap<String,String> mapParams = af.getMapParams();
|
||||||
|
String numTokens,numPower,numToughness,image;
|
||||||
|
String[] keywords;
|
||||||
|
|
||||||
|
if(!mapParams.get("TokenAmount").matches("[0-9][0-9]?")) //It's an X-value.
|
||||||
|
numTokens = AF.getHostCard().getSVar(mapParams.get("TokenAmount"));
|
||||||
|
else
|
||||||
|
numTokens = mapParams.get("TokenAmount");
|
||||||
|
|
||||||
|
if(!mapParams.get("TokenPower").matches("[0-9][0-9]?"))
|
||||||
|
numPower = AF.getHostCard().getSVar(mapParams.get("TokenPower"));
|
||||||
|
else
|
||||||
|
numPower = mapParams.get("TokenPower");
|
||||||
|
|
||||||
|
if(!mapParams.get("TokenToughness").matches("[0-9][0-9]?"))
|
||||||
|
numToughness = AF.getHostCard().getSVar(mapParams.get("TokenToughness"));
|
||||||
|
else
|
||||||
|
numToughness = mapParams.get("TokenToughness");
|
||||||
|
|
||||||
|
if(mapParams.containsKey("TokenKeywords")) {
|
||||||
|
keywords = mapParams.get("TokenKeywords").split("<>");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
keywords = new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mapParams.containsKey("TokenImage")) {
|
||||||
|
image = mapParams.get("TokenImage");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
image = "";
|
||||||
|
}
|
||||||
|
|
||||||
tokenAmount = numTokens;
|
tokenAmount = numTokens;
|
||||||
tokenName = name;
|
tokenName = mapParams.get("TokenName");
|
||||||
tokenTypes = types;
|
tokenTypes = mapParams.get("TokenTypes").split(",");
|
||||||
tokenOwner = owner;
|
tokenOwner = mapParams.get("TokenOwner");
|
||||||
tokenColors = colors;
|
tokenColors = mapParams.get("TokenColors").split(",");
|
||||||
tokenPower = power;
|
tokenPower = numPower;
|
||||||
tokenToughness = toughness;
|
tokenToughness = numToughness;
|
||||||
tokenKeywords = keywords;
|
tokenKeywords = keywords;
|
||||||
tokenImage = image;
|
tokenImage = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SpellAbility getAbility()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
final SpellAbility abToken = new Ability_Activated(AF.getHostCard(),AF.getAbCost(),AF.getAbTgt())
|
final SpellAbility abToken = new Ability_Activated(AF.getHostCard(),AF.getAbCost(),AF.getAbTgt())
|
||||||
{
|
{
|
||||||
@@ -55,19 +95,8 @@ public class AbilityFactory_Token extends AbilityFactory {
|
|||||||
return abToken;
|
return abToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpellAbility getSpell(final AbilityFactory af,final String numTokens,final String name,final String[] types,final String owner,final String[] colors,final String power,final String toughness,final String[] keywords,final String image)
|
public SpellAbility getSpell()
|
||||||
{
|
{
|
||||||
AF = af;
|
|
||||||
tokenAmount = numTokens;
|
|
||||||
tokenName = name;
|
|
||||||
tokenTypes = types;
|
|
||||||
tokenOwner = owner;
|
|
||||||
tokenColors = colors;
|
|
||||||
tokenPower = power;
|
|
||||||
tokenToughness = toughness;
|
|
||||||
tokenKeywords = keywords;
|
|
||||||
tokenImage = image;
|
|
||||||
|
|
||||||
final SpellAbility spToken = new Spell(AF.getHostCard(),AF.getAbCost(),AF.getAbTgt())
|
final SpellAbility spToken = new Spell(AF.getHostCard(),AF.getAbCost(),AF.getAbTgt())
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = -8041427947613029670L;
|
private static final long serialVersionUID = -8041427947613029670L;
|
||||||
|
|||||||
Reference in New Issue
Block a user