mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
- Split OppGainLife costs into the two types, "you may have an opponent gain" and "you may have each other player gain"
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -13336,6 +13336,7 @@ 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
|
||||||
|
src/main/java/forge/card/cost/CostGainLifeEachOther.java -text
|
||||||
src/main/java/forge/card/cost/CostMana.java -text
|
src/main/java/forge/card/cost/CostMana.java -text
|
||||||
src/main/java/forge/card/cost/CostMill.java -text
|
src/main/java/forge/card/cost/CostMill.java -text
|
||||||
src/main/java/forge/card/cost/CostPart.java -text
|
src/main/java/forge/card/cost/CostPart.java -text
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Text:no text
|
|||||||
A:SP$ ChooseType | Cost$ 3 U | Defined$ You | Type$ Creature | SubAbility$ ApplyPressure | SpellDescription$ Choose a creature type. If you control more creatures of that type than each other player, you gain control of all creatures of that type. (This effect lasts indefinitely.)
|
A:SP$ ChooseType | Cost$ 3 U | Defined$ You | Type$ Creature | SubAbility$ ApplyPressure | SpellDescription$ Choose a creature type. If you control more creatures of that type than each other player, you gain control of all creatures of that type. (This effect lasts indefinitely.)
|
||||||
SVar:ApplyPressure:DB$ GainControl | AllValid$ Creature.ChosenType | NewController$ You | ConditionCheckSVar$ YourPeerGroup | ConditionSVarCompare$ GTY | References$ YourPeerGroup,Y
|
SVar:ApplyPressure:DB$ GainControl | AllValid$ Creature.ChosenType | NewController$ You | ConditionCheckSVar$ YourPeerGroup | ConditionSVarCompare$ GTY | References$ YourPeerGroup,Y
|
||||||
SVar:YourPeerGroup:Count$Valid Creature.ChosenType+YouCtrl
|
SVar:YourPeerGroup:Count$Valid Creature.ChosenType+YouCtrl
|
||||||
SVar:Y:Count$Valid Creature.ChosenType+YouDontCtrl
|
SVar:Y:PlayerCountOther$HighestValid Creature.ChosenType+YouCtrl
|
||||||
SVar:RemAIDeck:True
|
SVar:RemAIDeck:True
|
||||||
SVar:RemRandomDeck:True
|
SVar:RemRandomDeck:True
|
||||||
SVar:Rarity:Rare
|
SVar:Rarity:Rare
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ ManaCost:3 G
|
|||||||
Types:Sorcery
|
Types:Sorcery
|
||||||
Text:no text
|
Text:no text
|
||||||
A:SP$ DestroyAll | Cost$ 3 G | ValidCards$ Enchantment | SpellDescription$ Destroy all enchantments.
|
A:SP$ DestroyAll | Cost$ 3 G | ValidCards$ Enchantment | SpellDescription$ Destroy all enchantments.
|
||||||
A:SP$ DestroyAll | Cost$ OppGainLife<6> | ValidCards$ Enchantment | IsPresent$ Forest.YouCtrl | PrecostDesc$ If you control a Forest, rather than pay CARDNAME's mana cost, | CostDesc$ you may have each other player gain 6 life | SpellDescription$ .
|
A:SP$ DestroyAll | Cost$ OthersEachGainLife<6> | ValidCards$ Enchantment | IsPresent$ Forest.YouCtrl | PrecostDesc$ If you control a Forest, rather than pay CARDNAME's mana cost, | CostDesc$ you may have each other player gain 6 life | SpellDescription$ .
|
||||||
SVar:Rarity:Common
|
SVar:Rarity:Common
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/reverent_silence.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/reverent_silence.jpg
|
||||||
SetInfo:NMS|Common|http://magiccards.info/scans/en/ne/111.jpg
|
SetInfo:NMS|Common|http://magiccards.info/scans/en/ne/111.jpg
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ ManaCost:3 G
|
|||||||
Types:Creature Beast
|
Types:Creature Beast
|
||||||
Text:no text
|
Text:no text
|
||||||
PT:2/2
|
PT:2/2
|
||||||
SVar:AltCost:Cost$ OppGainLife<5> | IsPresent$ Forest.YouCtrl | Description$ If you control a Forest, rather than pay Skyshroud Cutter's mana cost, you may have each other player gain 5 life.
|
SVar:AltCost:Cost$ OthersEachGainLife<5> | IsPresent$ Forest.YouCtrl | Description$ If you control a Forest, rather than pay Skyshroud Cutter's mana cost, you may have each other player gain 5 life.
|
||||||
SVar:Rarity:Common
|
SVar:Rarity:Common
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/skyshroud_cutter.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/skyshroud_cutter.jpg
|
||||||
SetInfo:NMS|Common|http://magiccards.info/scans/en/ne/118.jpg
|
SetInfo:NMS|Common|http://magiccards.info/scans/en/ne/118.jpg
|
||||||
|
|||||||
@@ -154,6 +154,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 EACH_OTHER_LIFE_GAIN_STR = "OthersEachGainLife<";
|
||||||
private static final String DAMAGE_STR = "DamageYou<";
|
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<";
|
||||||
@@ -249,6 +250,14 @@ public class Cost {
|
|||||||
this.costParts.add(new CostGainLife(splitStr[0]));
|
this.costParts.add(new CostGainLife(splitStr[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (parse.contains(Cost.EACH_OTHER_LIFE_GAIN_STR)) {
|
||||||
|
// PayLife<LifeCost>
|
||||||
|
final String[] splitStr = this.abCostParse(parse, Cost.EACH_OTHER_LIFE_GAIN_STR, 1);
|
||||||
|
parse = this.abUpdateParse(parse, Cost.EACH_OTHER_LIFE_GAIN_STR);
|
||||||
|
|
||||||
|
this.costParts.add(new CostGainLifeEachOther(splitStr[0]));
|
||||||
|
}
|
||||||
|
|
||||||
while (parse.contains(Cost.DAMAGE_STR)) {
|
while (parse.contains(Cost.DAMAGE_STR)) {
|
||||||
// PayLife<LifeCost>
|
// PayLife<LifeCost>
|
||||||
final String[] splitStr = this.abCostParse(parse, Cost.DAMAGE_STR, 1);
|
final String[] splitStr = this.abCostParse(parse, Cost.DAMAGE_STR, 1);
|
||||||
|
|||||||
@@ -17,11 +17,14 @@
|
|||||||
*/
|
*/
|
||||||
package forge.card.cost;
|
package forge.card.cost;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.GameActionUtil;
|
|
||||||
import forge.card.abilityfactory.AbilityFactory;
|
import forge.card.abilityfactory.AbilityFactory;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
|
import forge.gui.GuiChoose;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CostGainLife.
|
* The Class CostGainLife.
|
||||||
@@ -66,7 +69,7 @@ public class CostGainLife extends CostPart {
|
|||||||
@Override
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Have each other player gain ").append(this.getAmount()).append(" Life");
|
sb.append("Have an opponent gain ").append(this.getAmount()).append(" life");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,11 +93,17 @@ public class CostGainLife extends CostPart {
|
|||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) {
|
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) {
|
||||||
final Integer amount = this.convertAmount();
|
final Integer amount = this.convertAmount();
|
||||||
if ((amount != null) && !activator.getOpponent().canGainLife()) {
|
boolean oppCanGainLife = false;
|
||||||
return false;
|
if (amount != null) {
|
||||||
|
for (final Player opp : activator.getOpponents()) {
|
||||||
|
if (opp.canGainLife()) {
|
||||||
|
oppCanGainLife = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return oppCanGainLife;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -105,7 +114,13 @@ public class CostGainLife extends CostPart {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
ai.getOpponent().gainLife(this.getLastPaidAmount(), null);
|
final List<Player> oppsThatCanGainLife = new ArrayList<Player>();
|
||||||
|
for (final Player opp : ai.getOpponents()) {
|
||||||
|
if (opp.canGainLife()) {
|
||||||
|
oppsThatCanGainLife.add(opp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
oppsThatCanGainLife.get(0).gainLife(this.getLastPaidAmount(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -132,17 +147,26 @@ public class CostGainLife extends CostPart {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
final List<Player> oppsThatCanGainLife = new ArrayList<Player>();
|
||||||
sb.append(source.getName()).append(" - Have each other player gain ").append(c).append(" Life?");
|
for (final Player opp : activator.getOpponents()) {
|
||||||
|
if (opp.canGainLife()) {
|
||||||
|
oppsThatCanGainLife.add(opp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (GameActionUtil.showYesNoDialog(source, sb.toString()) && activator.getOpponent().canGainLife()) {
|
final StringBuilder sb = new StringBuilder();
|
||||||
activator.getOpponent().gainLife(c, null);
|
sb.append(source.getName()).append(" - Choose an opponent to gain ").append(c).append(" life:");
|
||||||
this.setLastPaidAmount(c);
|
|
||||||
payment.setPaidManaPart(this);
|
final Player chosenToGain = GuiChoose.oneOrNone(sb.toString(), oppsThatCanGainLife);
|
||||||
} else {
|
if (null == chosenToGain) {
|
||||||
payment.setCancel(true);
|
payment.setCancel(true);
|
||||||
payment.getRequirements().finishPaying();
|
payment.getRequirements().finishPaying();
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
final Player chosen = chosenToGain;
|
||||||
|
chosen.gainLife(c, null);
|
||||||
|
this.setLastPaidAmount(c);
|
||||||
|
payment.setPaidManaPart(this);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -168,7 +192,15 @@ public class CostGainLife extends CostPart {
|
|||||||
c = AbilityFactory.calculateAmount(source, this.getAmount(), ability);
|
c = AbilityFactory.calculateAmount(source, this.getAmount(), ability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ai.getOpponent().canGainLife()) {
|
|
||||||
|
final List<Player> oppsThatCanGainLife = new ArrayList<Player>();
|
||||||
|
for (final Player opp : ai.getOpponents()) {
|
||||||
|
if (opp.canGainLife()) {
|
||||||
|
oppsThatCanGainLife.add(opp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oppsThatCanGainLife.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.setLastPaidAmount(c);
|
this.setLastPaidAmount(c);
|
||||||
|
|||||||
197
src/main/java/forge/card/cost/CostGainLifeEachOther.java
Normal file
197
src/main/java/forge/card/cost/CostGainLifeEachOther.java
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
/*
|
||||||
|
* 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.Card;
|
||||||
|
import forge.GameActionUtil;
|
||||||
|
import forge.card.abilityfactory.AbilityFactory;
|
||||||
|
import forge.card.spellability.SpellAbility;
|
||||||
|
import forge.game.player.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class CostGainLife.
|
||||||
|
*/
|
||||||
|
public class CostGainLifeEachOther 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 gain life.
|
||||||
|
*
|
||||||
|
* @param amount
|
||||||
|
* the amount
|
||||||
|
*/
|
||||||
|
public CostGainLifeEachOther(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("Have each other player gain ").append(this.getAmount()).append(" life");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.card.cost.CostPart#refund(forge.Card)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public 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) {
|
||||||
|
final Integer amount = this.convertAmount();
|
||||||
|
if (amount != null) {
|
||||||
|
for (final Player otherP : activator.getAllOtherPlayers()) {
|
||||||
|
if (!otherP.canGainLife()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
|
for (final Player otherP : ai.getAllOtherPlayers()) {
|
||||||
|
otherP.gainLife(this.getLastPaidAmount(), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final Player other : activator.getAllOtherPlayers()) {
|
||||||
|
// each other player MUST be able to gain life
|
||||||
|
if (!other.canGainLife()) {
|
||||||
|
payment.setCancel(true);
|
||||||
|
payment.getRequirements().finishPaying();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(source.getName()).append(" - Have each other player gain ").append(c).append(" life?");
|
||||||
|
|
||||||
|
if (GameActionUtil.showYesNoDialog(source, sb.toString())) {
|
||||||
|
for (final Player playerToGain : activator.getAllOtherPlayers()) {
|
||||||
|
playerToGain.gainLife(c, null);
|
||||||
|
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 Player ai, 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final Player otherP : ai.getAllOtherPlayers()) {
|
||||||
|
if (!otherP.canGainLife()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.setLastPaidAmount(c);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user