mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- Added the beginnings of X manacost support, also added the card Prosperity.
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
Prosperity
|
||||||
|
X U
|
||||||
|
Sorcery
|
||||||
|
no text
|
||||||
|
|
||||||
Azorius Chancery
|
Azorius Chancery
|
||||||
no cost
|
no cost
|
||||||
Land
|
Land
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ public class Card extends MyObservable {
|
|||||||
|
|
||||||
private int X = 0;
|
private int X = 0;
|
||||||
|
|
||||||
|
private int xManaCostPaid = 0;
|
||||||
|
|
||||||
private int multiKickerMagnitude = 0;
|
private int multiKickerMagnitude = 0;
|
||||||
|
|
||||||
private String owner = "";
|
private String owner = "";
|
||||||
@@ -151,6 +153,21 @@ public class Card extends MyObservable {
|
|||||||
|
|
||||||
//***************/
|
//***************/
|
||||||
|
|
||||||
|
public void addXManaCostPaid(int n)
|
||||||
|
{
|
||||||
|
xManaCostPaid += n;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXManaCostPaid(int n)
|
||||||
|
{
|
||||||
|
xManaCostPaid = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getXManaCostPaid()
|
||||||
|
{
|
||||||
|
return xManaCostPaid;
|
||||||
|
}
|
||||||
|
|
||||||
public void setCheckedPropagandaThisTurn(boolean b)
|
public void setCheckedPropagandaThisTurn(boolean b)
|
||||||
{
|
{
|
||||||
checkedPropagandaThisTurn = b;
|
checkedPropagandaThisTurn = b;
|
||||||
|
|||||||
@@ -272,6 +272,8 @@ public class CardFactory implements NewConstants {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* //Creatures with simple, self-targeted mana-activated keyword adding abilities
|
/* //Creatures with simple, self-targeted mana-activated keyword adding abilities
|
||||||
//-1 means not found
|
//-1 means not found
|
||||||
while(hasKeyword(card, "KPump") != -1)
|
while(hasKeyword(card, "KPump") != -1)
|
||||||
@@ -16646,6 +16648,36 @@ public class CardFactory implements NewConstants {
|
|||||||
}
|
}
|
||||||
//*************** END ************ END **************************
|
//*************** END ************ END **************************
|
||||||
|
|
||||||
|
//*************** START *********** START **************************
|
||||||
|
else if (cardName.equals("Prosperity"))
|
||||||
|
{
|
||||||
|
final SpellAbility spell = new Spell(card)
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = -4885933011194027735L;
|
||||||
|
|
||||||
|
public void resolve()
|
||||||
|
{
|
||||||
|
for (int i=0;i<card.getXManaCostPaid();i++)
|
||||||
|
{
|
||||||
|
AllZone.GameAction.drawCard(Constant.Player.Human);
|
||||||
|
AllZone.GameAction.drawCard(Constant.Player.Computer);
|
||||||
|
}
|
||||||
|
card.setXManaCostPaid(0);
|
||||||
|
}
|
||||||
|
public boolean canPlayAI()
|
||||||
|
{
|
||||||
|
return AllZone.Computer_Hand.size() < 5 && ComputerUtil.canPayCost("3 U");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
spell.setDescription("Each player draws X cards.");
|
||||||
|
spell.setStackDescription(card + " - Each player draws X cards.");
|
||||||
|
|
||||||
|
card.clearSpellAbility();
|
||||||
|
card.addSpellAbility(spell);
|
||||||
|
}
|
||||||
|
//*************** END ************ END **************************
|
||||||
|
|
||||||
|
|
||||||
// Cards with Cycling abilities
|
// Cards with Cycling abilities
|
||||||
// -1 means keyword "Cycling" not found
|
// -1 means keyword "Cycling" not found
|
||||||
if(hasKeyword(card, "Cycling") != -1) {
|
if(hasKeyword(card, "Cycling") != -1) {
|
||||||
@@ -16717,6 +16749,17 @@ public class CardFactory implements NewConstants {
|
|||||||
}
|
}
|
||||||
}//Vanishing
|
}//Vanishing
|
||||||
|
|
||||||
|
if (card.getManaCost().contains("X"))
|
||||||
|
{
|
||||||
|
SpellAbility sa = card.getSpellAbility()[0];
|
||||||
|
sa.setIsXCost(true);
|
||||||
|
|
||||||
|
if (card.getManaCost().startsWith("X X"))
|
||||||
|
sa.setXManaCost("2");
|
||||||
|
else if (card.getManaCost().startsWith("X"))
|
||||||
|
sa.setXManaCost("1");
|
||||||
|
}
|
||||||
|
|
||||||
return card;
|
return card;
|
||||||
}//getCard2
|
}//getCard2
|
||||||
|
|
||||||
|
|||||||
@@ -198,6 +198,9 @@ public class CardUtil {
|
|||||||
|
|
||||||
if(manaCost.equals("")) return 0;
|
if(manaCost.equals("")) return 0;
|
||||||
|
|
||||||
|
while (manaCost.startsWith("X"))
|
||||||
|
manaCost = manaCost.substring(2);
|
||||||
|
|
||||||
if(!manaCost.matches(".*[A-Z]+.*")) {
|
if(!manaCost.matches(".*[A-Z]+.*")) {
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(manaCost);
|
return Integer.parseInt(manaCost);
|
||||||
|
|||||||
@@ -186,6 +186,37 @@ public class ComputerUtil
|
|||||||
return false;
|
return false;
|
||||||
}//canPayCost()
|
}//canPayCost()
|
||||||
|
|
||||||
|
static public boolean canPayCost(String cost)
|
||||||
|
{
|
||||||
|
if(cost.equals(("0")))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
CardList land = getAvailableMana();
|
||||||
|
|
||||||
|
ManaCost manacost = new ManaCost(cost);
|
||||||
|
ArrayList<String> colors = new ArrayList<String>();
|
||||||
|
|
||||||
|
for(int i = 0; i < land.size(); i++)
|
||||||
|
{
|
||||||
|
colors = getColors(land.get(i));
|
||||||
|
int once = 0;
|
||||||
|
|
||||||
|
for(int j =0; j < colors.size(); j++)
|
||||||
|
{
|
||||||
|
if(manacost.isNeeded(colors.get(j)) && once == 0)
|
||||||
|
{
|
||||||
|
manacost.subtractMana(colors.get(j));
|
||||||
|
once++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(manacost.isPaid()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}//canPayCost()
|
||||||
|
|
||||||
|
|
||||||
static public void payManaCost(SpellAbility sa)
|
static public void payManaCost(SpellAbility sa)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,11 +16,53 @@ public class MagicStack extends MyObservable
|
|||||||
if(sp instanceof Ability_Mana || sp instanceof Ability_Triggered)//TODO make working triggered abilities!
|
if(sp instanceof Ability_Mana || sp instanceof Ability_Triggered)//TODO make working triggered abilities!
|
||||||
sp.resolve();
|
sp.resolve();
|
||||||
else {
|
else {
|
||||||
if (!sp.isMultiKicker())
|
if (!sp.isMultiKicker() && !sp.isXCost())
|
||||||
{
|
{
|
||||||
push(sp);
|
push(sp);
|
||||||
}
|
}
|
||||||
else //this spell does have multikicker
|
else if (sp.isXCost())
|
||||||
|
{
|
||||||
|
final SpellAbility sa = sp;
|
||||||
|
final Ability ability = new Ability(sp.getSourceCard(), sa.getXManaCost())
|
||||||
|
{
|
||||||
|
public void resolve()
|
||||||
|
{
|
||||||
|
this.getSourceCard().addXManaCostPaid(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
final Command unpaidCommand = new Command()
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = -3342222770086269767L;
|
||||||
|
|
||||||
|
public void execute()
|
||||||
|
{
|
||||||
|
push(sa);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
final Command paidCommand = new Command() {
|
||||||
|
private static final long serialVersionUID = -2224875229611007788L;
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
ability.resolve();
|
||||||
|
Card crd = sa.getSourceCard();
|
||||||
|
AllZone.InputControl.setInput(new Input_PayManaCost_Ability("Pay X cost for " + crd.getName() + " (X=" +crd.getXManaCostPaid()+")\r\n",
|
||||||
|
ability.getManaCost(), this, unpaidCommand));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if(sp.getSourceCard().getController().equals(Constant.Player.Human)) {
|
||||||
|
AllZone.InputControl.setInput(new Input_PayManaCost_Ability("Pay X cost for " + sp.getSourceCard().getName() + " (X=0)\r\n",
|
||||||
|
ability.getManaCost(), paidCommand, unpaidCommand));
|
||||||
|
}
|
||||||
|
else //computer
|
||||||
|
{
|
||||||
|
while(ComputerUtil.canPayCost(ability)) ComputerUtil.playNoStack(ability);
|
||||||
|
push(sa);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (sp.isMultiKicker()) //both X and multi is not supported yet
|
||||||
{
|
{
|
||||||
final SpellAbility sa = sp;
|
final SpellAbility sa = sp;
|
||||||
final Ability ability = new Ability(sp.getSourceCard(), sp.getMultiKickerManaCost())
|
final Ability ability = new Ability(sp.getSourceCard(), sp.getMultiKickerManaCost())
|
||||||
@@ -34,7 +76,9 @@ public class MagicStack extends MyObservable
|
|||||||
|
|
||||||
final Command unpaidCommand = new Command()
|
final Command unpaidCommand = new Command()
|
||||||
{
|
{
|
||||||
public void execute()
|
private static final long serialVersionUID = -3342222770086269767L;
|
||||||
|
|
||||||
|
public void execute()
|
||||||
{
|
{
|
||||||
push(sa);
|
push(sa);
|
||||||
}
|
}
|
||||||
@@ -56,6 +100,7 @@ public class MagicStack extends MyObservable
|
|||||||
else //computer
|
else //computer
|
||||||
{
|
{
|
||||||
while(ComputerUtil.canPayCost(ability)) ComputerUtil.playNoStack(ability);
|
while(ComputerUtil.canPayCost(ability)) ComputerUtil.playNoStack(ability);
|
||||||
|
push(sa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ class ManaCost {
|
|||||||
private Mana_PayCost m;
|
private Mana_PayCost m;
|
||||||
|
|
||||||
public ManaCost(String cost) {
|
public ManaCost(String cost) {
|
||||||
|
while (cost.startsWith("X"))
|
||||||
|
cost = cost.substring(2);
|
||||||
m = new Mana_PayCost(cost);
|
m = new Mana_PayCost(cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public abstract class SpellAbility {
|
|||||||
private String manaCost = "";
|
private String manaCost = "";
|
||||||
private String additionalManaCost = "";
|
private String additionalManaCost = "";
|
||||||
private String multiKickerManaCost= "";
|
private String multiKickerManaCost= "";
|
||||||
|
private String xManaCost = "";
|
||||||
|
|
||||||
private String type = "Intrinsic"; //set to Intrinsic by default
|
private String type = "Intrinsic"; //set to Intrinsic by default
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ public abstract class SpellAbility {
|
|||||||
private boolean buyBackAbility = false; //false by default
|
private boolean buyBackAbility = false; //false by default
|
||||||
private boolean flashBackAbility = false;
|
private boolean flashBackAbility = false;
|
||||||
private boolean multiKicker = false;
|
private boolean multiKicker = false;
|
||||||
|
private boolean xCost = false;
|
||||||
|
|
||||||
private Input beforePayMana;
|
private Input beforePayMana;
|
||||||
private Input afterResolve;
|
private Input afterResolve;
|
||||||
@@ -115,6 +117,16 @@ public abstract class SpellAbility {
|
|||||||
multiKickerManaCost = cost;
|
multiKickerManaCost = cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getXManaCost()
|
||||||
|
{
|
||||||
|
return xManaCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXManaCost(String cost)
|
||||||
|
{
|
||||||
|
xManaCost = cost;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSpell() {
|
public boolean isSpell() {
|
||||||
return spell;
|
return spell;
|
||||||
}
|
}
|
||||||
@@ -153,6 +165,15 @@ public abstract class SpellAbility {
|
|||||||
return multiKicker;
|
return multiKicker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIsXCost(boolean b) {
|
||||||
|
xCost = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isXCost(){
|
||||||
|
return xCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setSourceCard(Card c) {
|
public void setSourceCard(Card c) {
|
||||||
sourceCard = c;
|
sourceCard = c;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user