mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Added the cost "DamageYou".
- Added Dwarven Driller.
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -2640,6 +2640,7 @@ res/cardsfolder/d/dwarven_berserker.txt svneol=native#text/plain
|
|||||||
res/cardsfolder/d/dwarven_blastminer.txt svneol=native#text/plain
|
res/cardsfolder/d/dwarven_blastminer.txt svneol=native#text/plain
|
||||||
res/cardsfolder/d/dwarven_bloodboiler.txt svneol=native#text/plain
|
res/cardsfolder/d/dwarven_bloodboiler.txt svneol=native#text/plain
|
||||||
res/cardsfolder/d/dwarven_demolition_team.txt svneol=native#text/plain
|
res/cardsfolder/d/dwarven_demolition_team.txt svneol=native#text/plain
|
||||||
|
res/cardsfolder/d/dwarven_driller.txt -text
|
||||||
res/cardsfolder/d/dwarven_grunt.txt svneol=native#text/plain
|
res/cardsfolder/d/dwarven_grunt.txt svneol=native#text/plain
|
||||||
res/cardsfolder/d/dwarven_hold.txt svneol=native#text/plain
|
res/cardsfolder/d/dwarven_hold.txt svneol=native#text/plain
|
||||||
res/cardsfolder/d/dwarven_landslide.txt -text
|
res/cardsfolder/d/dwarven_landslide.txt -text
|
||||||
@@ -11998,6 +11999,7 @@ src/main/java/forge/card/cardfactory/CardFactorySorceries.java svneol=native#tex
|
|||||||
src/main/java/forge/card/cardfactory/CardFactoryUtil.java svneol=native#text/plain
|
src/main/java/forge/card/cardfactory/CardFactoryUtil.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/cardfactory/package-info.java svneol=native#text/plain
|
src/main/java/forge/card/cardfactory/package-info.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/cost/Cost.java svneol=native#text/plain
|
src/main/java/forge/card/cost/Cost.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/card/cost/CostDamage.java -text
|
||||||
src/main/java/forge/card/cost/CostDiscard.java -text
|
src/main/java/forge/card/cost/CostDiscard.java -text
|
||||||
src/main/java/forge/card/cost/CostExile.java -text
|
src/main/java/forge/card/cost/CostExile.java -text
|
||||||
src/main/java/forge/card/cost/CostGainLife.java -text
|
src/main/java/forge/card/cost/CostGainLife.java -text
|
||||||
|
|||||||
11
res/cardsfolder/d/dwarven_driller.txt
Normal file
11
res/cardsfolder/d/dwarven_driller.txt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
Name:Dwarven Driller
|
||||||
|
ManaCost:3 R
|
||||||
|
Types:Creature Dwarf
|
||||||
|
Text:no text
|
||||||
|
PT:2/2
|
||||||
|
A:AB$ Destroy | Cost$ T | ValidTgts$ Land | TgtPrompt$ Select target land | UnlessCost$ DamageYou<2> | SpellDescription$ Destroy target land unless its controller has Dwarven Driller deal 2 damage to him or her.
|
||||||
|
SVar:Rarity:Uncommon
|
||||||
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/dwarven_driller.jpg
|
||||||
|
SetInfo:JUD|Uncommon|http://magiccards.info/scans/en/ju/85.jpg
|
||||||
|
Oracle:{T}: Destroy target land unless its controller has Dwarven Driller deal 2 damage to him or her.
|
||||||
|
End
|
||||||
@@ -25,6 +25,7 @@ import javax.swing.JOptionPane;
|
|||||||
import forge.card.abilityfactory.AbilityFactory;
|
import forge.card.abilityfactory.AbilityFactory;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
|
import forge.card.cost.CostDamage;
|
||||||
import forge.card.cost.CostDiscard;
|
import forge.card.cost.CostDiscard;
|
||||||
import forge.card.cost.CostPart;
|
import forge.card.cost.CostPart;
|
||||||
import forge.card.cost.CostPayLife;
|
import forge.card.cost.CostPayLife;
|
||||||
@@ -463,6 +464,20 @@ public final class GameActionUtil {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (costPart instanceof CostDamage) {
|
||||||
|
String amountString = costPart.getAmount();
|
||||||
|
final int amount = amountString.matches("[0-9][0-9]?") ? Integer.parseInt(amountString)
|
||||||
|
: CardFactoryUtil.xCount(source, source.getSVar(amountString));
|
||||||
|
if (AllZone.getHumanPlayer().canPayLife(amount) && showYesNoDialog(source, "Do you want " + source +
|
||||||
|
" to deal "+ amount + " damage to you?")) {
|
||||||
|
AllZone.getHumanPlayer().addDamage(amount, source);
|
||||||
|
paid.execute();
|
||||||
|
} else {
|
||||||
|
unpaid.execute();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
else if (costPart instanceof CostPutCounter) {
|
else if (costPart instanceof CostPutCounter) {
|
||||||
String amountString = costPart.getAmount();
|
String amountString = costPart.getAmount();
|
||||||
Counters counterType = ((CostPutCounter) costPart).getCounter();
|
Counters counterType = ((CostPutCounter) costPart).getCounter();
|
||||||
|
|||||||
@@ -2785,7 +2785,8 @@ public class AbilityFactory {
|
|||||||
//GameActionUtil.payCostDuringAbilityResolve(source + "\r\n", source, unlessCost, paidCommand, unpaidCommand);
|
//GameActionUtil.payCostDuringAbilityResolve(source + "\r\n", source, unlessCost, paidCommand, unpaidCommand);
|
||||||
GameActionUtil.payCostDuringAbilityResolve(ability, cost, paidCommand, unpaidCommand);
|
GameActionUtil.payCostDuringAbilityResolve(ability, cost, paidCommand, unpaidCommand);
|
||||||
} else {
|
} else {
|
||||||
if (ComputerUtil.canPayCost(ability) && CostUtil.checkLifeCost(cost, source, 4)) {
|
if (ComputerUtil.canPayCost(ability) && CostUtil.checkLifeCost(cost, source, 4)
|
||||||
|
&& CostUtil.checkDamageCost(cost, source, 4)) {
|
||||||
ComputerUtil.playNoStack(ability); // Unless cost was payed - no
|
ComputerUtil.playNoStack(ability); // Unless cost was payed - no
|
||||||
// resolve
|
// resolve
|
||||||
AbilityFactory.resolveSubAbilities(sa);
|
AbilityFactory.resolveSubAbilities(sa);
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ public class Cost {
|
|||||||
private static final String ADD_STR = "AddCounter<";
|
private static final String ADD_STR = "AddCounter<";
|
||||||
private static final String LIFE_STR = "PayLife<";
|
private static final String LIFE_STR = "PayLife<";
|
||||||
private static final String LIFE_GAIN_STR = "OppGainLife<";
|
private static final String LIFE_GAIN_STR = "OppGainLife<";
|
||||||
|
private static final String DAMAGE_STR = "DamageYou<";
|
||||||
private static final String MILL_STR = "Mill<";
|
private static final String MILL_STR = "Mill<";
|
||||||
private static final String DISC_STR = "Discard<";
|
private static final String DISC_STR = "Discard<";
|
||||||
private static final String SAC_STR = "Sac<";
|
private static final String SAC_STR = "Sac<";
|
||||||
@@ -216,6 +217,14 @@ public class Cost {
|
|||||||
this.costParts.add(new CostGainLife(splitStr[0]));
|
this.costParts.add(new CostGainLife(splitStr[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (parse.contains(Cost.DAMAGE_STR)) {
|
||||||
|
// PayLife<LifeCost>
|
||||||
|
final String[] splitStr = this.abCostParse(parse, Cost.DAMAGE_STR, 1);
|
||||||
|
parse = this.abUpdateParse(parse, Cost.DAMAGE_STR);
|
||||||
|
|
||||||
|
this.costParts.add(new CostDamage(splitStr[0]));
|
||||||
|
}
|
||||||
|
|
||||||
while (parse.contains(Cost.MILL_STR)) {
|
while (parse.contains(Cost.MILL_STR)) {
|
||||||
// PayLife<LifeCost>
|
// PayLife<LifeCost>
|
||||||
final String[] splitStr = this.abCostParse(parse, Cost.MILL_STR, 1);
|
final String[] splitStr = this.abCostParse(parse, Cost.MILL_STR, 1);
|
||||||
|
|||||||
171
src/main/java/forge/card/cost/CostDamage.java
Normal file
171
src/main/java/forge/card/cost/CostDamage.java
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
/*
|
||||||
|
* Forge: Play Magic: the Gathering.
|
||||||
|
* Copyright (C) 2011 Forge Team
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package forge.card.cost;
|
||||||
|
|
||||||
|
import forge.AllZone;
|
||||||
|
import forge.Card;
|
||||||
|
import forge.GameActionUtil;
|
||||||
|
import forge.card.abilityfactory.AbilityFactory;
|
||||||
|
import forge.card.spellability.SpellAbility;
|
||||||
|
import forge.game.player.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class CostPayLife.
|
||||||
|
*/
|
||||||
|
public class CostDamage extends CostPart {
|
||||||
|
private int lastPaidAmount = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the last paid amount.
|
||||||
|
*
|
||||||
|
* @return the last paid amount
|
||||||
|
*/
|
||||||
|
public final int getLastPaidAmount() {
|
||||||
|
return this.lastPaidAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the last paid amount.
|
||||||
|
*
|
||||||
|
* @param paidAmount
|
||||||
|
* the new last paid amount
|
||||||
|
*/
|
||||||
|
public final void setLastPaidAmount(final int paidAmount) {
|
||||||
|
this.lastPaidAmount = paidAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new cost pay life.
|
||||||
|
*
|
||||||
|
* @param amount
|
||||||
|
* the amount
|
||||||
|
*/
|
||||||
|
public CostDamage(final String amount) {
|
||||||
|
this.setAmount(amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.card.cost.CostPart#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final String toString() {
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Pay ").append(this.getAmount()).append(" Life");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.card.cost.CostPart#refund(forge.Card)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final void refund(final Card source) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* forge.card.cost.CostPart#canPay(forge.card.spellability.SpellAbility,
|
||||||
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.card.cost.CostPart#payAI(forge.card.spellability.SpellAbility,
|
||||||
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
|
AllZone.getComputerPlayer().addDamage(this.getLastPaidAmount(), source);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* forge.card.cost.CostPart#payHuman(forge.card.spellability.SpellAbility,
|
||||||
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final boolean payHuman(final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
|
final String amount = this.getAmount();
|
||||||
|
final Player activator = ability.getActivatingPlayer();
|
||||||
|
final int life = activator.getLife();
|
||||||
|
|
||||||
|
Integer c = this.convertAmount();
|
||||||
|
if (c == null) {
|
||||||
|
final String sVar = ability.getSVar(amount);
|
||||||
|
// Generalize this
|
||||||
|
if (sVar.equals("XChoice")) {
|
||||||
|
c = CostUtil.chooseXValue(source, ability, life);
|
||||||
|
} else {
|
||||||
|
c = AbilityFactory.calculateAmount(source, amount, ability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(source.getName()).append(" - Pay ").append(c).append(" Life?");
|
||||||
|
|
||||||
|
if (GameActionUtil.showYesNoDialog(source, sb.toString()) && activator.canPayLife(c)) {
|
||||||
|
activator.addDamage(c, source);
|
||||||
|
this.setLastPaidAmount(c);
|
||||||
|
payment.setPaidManaPart(this);
|
||||||
|
} else {
|
||||||
|
payment.setCancel(true);
|
||||||
|
payment.getRequirements().finishPaying();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* forge.card.cost.CostPart#decideAIPayment(forge.card.spellability.SpellAbility
|
||||||
|
* , forge.Card, forge.card.cost.Cost_Payment)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final boolean decideAIPayment(final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
|
Integer c = this.convertAmount();
|
||||||
|
|
||||||
|
if (c == null) {
|
||||||
|
final String sVar = ability.getSVar(this.getAmount());
|
||||||
|
// Generalize this
|
||||||
|
if (sVar.equals("XChoice")) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
c = AbilityFactory.calculateAmount(source, this.getAmount(), ability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// activator.payLife(c, null);
|
||||||
|
this.setLastPaidAmount(c);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ import forge.card.abilityfactory.AbilityFactory;
|
|||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.control.input.Input;
|
import forge.control.input.Input;
|
||||||
import forge.game.player.ComputerUtil;
|
import forge.game.player.ComputerUtil;
|
||||||
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.GuiUtils;
|
import forge.gui.GuiUtils;
|
||||||
|
|
||||||
@@ -134,6 +135,36 @@ public class CostUtil {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check life cost.
|
||||||
|
*
|
||||||
|
* @param cost
|
||||||
|
* the cost
|
||||||
|
* @param source
|
||||||
|
* the source
|
||||||
|
* @param remainingLife
|
||||||
|
* the remaining life
|
||||||
|
* @return true, if successful
|
||||||
|
*/
|
||||||
|
public static boolean checkDamageCost(final Cost cost, final Card source, final int remainingLife) {
|
||||||
|
if (cost == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (final CostPart part : cost.getCostParts()) {
|
||||||
|
if (part instanceof CostDamage) {
|
||||||
|
final CostDamage pay = (CostDamage) part;
|
||||||
|
Player computer = AllZone.getComputerPlayer();
|
||||||
|
int realDamage = computer.predictDamage(pay.convertAmount(), source, false);
|
||||||
|
if (computer.getLife() - realDamage < remainingLife
|
||||||
|
&& realDamage > 0 && !computer.cantLoseForZeroOrLessLife()
|
||||||
|
&& computer.canLoseLife()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check discard cost.
|
* Check discard cost.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user