mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Cost*: removed 4 parameters needless from canPlay() method
also removed excessive parameters in their callers
This commit is contained in:
@@ -1102,7 +1102,7 @@ public class AbilityUtils {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if it's paid by the AI already the human can pay, but it won't change anything
|
// if it's paid by the AI already the human can pay, but it won't change anything
|
||||||
paid |= GameActionUtil.payCostDuringAbilityResolve(payer, ability, cost, sa, game);
|
paid |= GameActionUtil.payCostDuringAbilityResolve(ability, cost, sa, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class CostDamage extends CostPart {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,10 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
|
final Player activator = ability.getActivatingPlayer();
|
||||||
|
final Card source = ability.getSourceCard();
|
||||||
|
|
||||||
List<Card> handList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Hand));
|
List<Card> handList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Hand));
|
||||||
String type = this.getType();
|
String type = this.getType();
|
||||||
final Integer amount = this.convertAmount();
|
final Integer amount = this.convertAmount();
|
||||||
|
|||||||
@@ -461,7 +461,11 @@ public class CostExile extends CostPartWithList {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
|
final Player activator = ability.getActivatingPlayer();
|
||||||
|
final Card source = ability.getSourceCard();
|
||||||
|
final GameState game = activator.getGame();
|
||||||
|
|
||||||
List<Card> typeList = new ArrayList<Card>();
|
List<Card> typeList = new ArrayList<Card>();
|
||||||
if (this.getType().equals("All")) {
|
if (this.getType().equals("All")) {
|
||||||
return true; // this will always work
|
return true; // this will always work
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ public class CostGainLife extends CostPart {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Player> getPotentialTargets(final GameState game, final Player payer, final Card source)
|
private List<Player> getPotentialTargets(final Player payer, final Card source)
|
||||||
{
|
{
|
||||||
List<Player> res = new ArrayList<Player>();
|
List<Player> res = new ArrayList<Player>();
|
||||||
for(Player p : game.getPlayers())
|
for(Player p : payer.getGame().getPlayers())
|
||||||
{
|
{
|
||||||
if(p.isValid(getType(), payer, source))
|
if(p.isValid(getType(), payer, source))
|
||||||
res.add(p);
|
res.add(p);
|
||||||
@@ -76,12 +76,12 @@ public class CostGainLife extends CostPart {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
final Integer amount = this.convertAmount();
|
final Integer amount = this.convertAmount();
|
||||||
if ( amount == null ) return false;
|
if ( amount == null ) return false;
|
||||||
|
|
||||||
int cntAbleToGainLife = 0;
|
int cntAbleToGainLife = 0;
|
||||||
List<Player> possibleTargets = getPotentialTargets(game, activator, source);
|
List<Player> possibleTargets = getPotentialTargets(ability.getActivatingPlayer(), ability.getSourceCard());
|
||||||
|
|
||||||
for (final Player opp : possibleTargets) {
|
for (final Player opp : possibleTargets) {
|
||||||
if (opp.canGainLife()) {
|
if (opp.canGainLife()) {
|
||||||
@@ -101,7 +101,7 @@ public class CostGainLife extends CostPart {
|
|||||||
@Override
|
@Override
|
||||||
public final void payAI(final PaymentDecision decision, final AIPlayer ai, SpellAbility ability, Card source) {
|
public final void payAI(final PaymentDecision decision, final AIPlayer ai, SpellAbility ability, Card source) {
|
||||||
int playersLeft = cntPlayers;
|
int playersLeft = cntPlayers;
|
||||||
for (final Player opp : getPotentialTargets(ai.getGame(), ai, source)) {
|
for (final Player opp : getPotentialTargets(ai, source)) {
|
||||||
if (opp.canGainLife() && playersLeft > 0) {
|
if (opp.canGainLife() && playersLeft > 0) {
|
||||||
playersLeft--;
|
playersLeft--;
|
||||||
opp.gainLife(decision.c, null);
|
opp.gainLife(decision.c, null);
|
||||||
@@ -135,7 +135,7 @@ public class CostGainLife extends CostPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final List<Player> oppsThatCanGainLife = new ArrayList<Player>();
|
final List<Player> oppsThatCanGainLife = new ArrayList<Player>();
|
||||||
for (final Player opp : getPotentialTargets(game, activator, source)) {
|
for (final Player opp : getPotentialTargets(activator, source)) {
|
||||||
if (opp.canGainLife()) {
|
if (opp.canGainLife()) {
|
||||||
oppsThatCanGainLife.add(opp);
|
oppsThatCanGainLife.add(opp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,9 @@ public class CostMill extends CostPartWithList {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
|
final Player activator = ability.getActivatingPlayer();
|
||||||
|
final Card source = ability.getSourceCard();
|
||||||
final PlayerZone zone = activator.getZone(ZoneType.Library);
|
final PlayerZone zone = activator.getZone(ZoneType.Library);
|
||||||
|
|
||||||
Integer i = this.convertAmount();
|
Integer i = this.convertAmount();
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import forge.Card;
|
|||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.player.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CostPart.
|
* The Class CostPart.
|
||||||
@@ -147,7 +146,7 @@ public abstract class CostPart {
|
|||||||
* @param game
|
* @param game
|
||||||
* @return true, if successful
|
* @return true, if successful
|
||||||
*/
|
*/
|
||||||
public abstract boolean canPay(SpellAbility ability, Card source, Player activator, Cost cost, GameState game);
|
public abstract boolean canPay(SpellAbility ability);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decide ai payment.
|
* Decide ai payment.
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import forge.control.input.InputPayment;
|
|||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
import forge.game.ai.ComputerUtilMana;
|
import forge.game.ai.ComputerUtilMana;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.player.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The mana component of any spell or ability cost
|
* The mana component of any spell or ability cost
|
||||||
@@ -181,7 +180,7 @@ public class CostPartMana extends CostPart {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
// For now, this will always return true. But this should probably be
|
// For now, this will always return true. But this should probably be
|
||||||
// checked at some point
|
// checked at some point
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ public abstract class CostPartWithList extends CostPart {
|
|||||||
sa.addCostToHashList(CardUtil.getLKICopy(card), paymentMethod);
|
sa.addCostToHashList(CardUtil.getLKICopy(card), paymentMethod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public abstract List<Card> getValidCards();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new cost part with list.
|
* Instantiates a new cost part with list.
|
||||||
|
|||||||
@@ -72,8 +72,9 @@ public class CostPayLife extends CostPart {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
final Integer amount = this.convertAmount();
|
final Integer amount = this.convertAmount();
|
||||||
|
Player activator = ability.getActivatingPlayer();
|
||||||
if ((amount != null) && !activator.canPayLife(amount)) {
|
if ((amount != null) && !activator.canPayLife(amount)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class CostPayment {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public static boolean canPayAdditionalCosts(final GameState game, final Cost cost, final SpellAbility ability) {
|
public static boolean canPayAdditionalCosts(final Cost cost, final SpellAbility ability) {
|
||||||
if (cost == null) {
|
if (cost == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ public class CostPayment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (final CostPart part : cost.getCostParts()) {
|
for (final CostPart part : cost.getCostParts()) {
|
||||||
if (!part.canPay(ability, card, activator, cost, game)) {
|
if (!part.canPay(ability)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,7 +189,9 @@ public class CostPutCounter extends CostPartWithList {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
|
final Player activator = ability.getActivatingPlayer();
|
||||||
|
final Card source = ability.getSourceCard();
|
||||||
if (this.payCostFromSource()) {
|
if (this.payCostFromSource()) {
|
||||||
if (source.hasKeyword("CARDNAME can't have counters placed on it.")) {
|
if (source.hasKeyword("CARDNAME can't have counters placed on it.")) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -297,8 +297,10 @@ public class CostRemoveCounter extends CostPartWithList {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
final CounterType cntrs = this.getCounter();
|
final CounterType cntrs = this.getCounter();
|
||||||
|
final Player activator = ability.getActivatingPlayer();
|
||||||
|
final Card source = ability.getSourceCard();
|
||||||
|
|
||||||
final Integer amount = this.convertAmount();
|
final Integer amount = this.convertAmount();
|
||||||
if (this.payCostFromSource()) {
|
if (this.payCostFromSource()) {
|
||||||
|
|||||||
@@ -93,7 +93,9 @@ public class CostReturn extends CostPartWithList {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
|
final Player activator = ability.getActivatingPlayer();
|
||||||
|
final Card source = ability.getSourceCard();
|
||||||
if (!this.payCostFromSource()) {
|
if (!this.payCostFromSource()) {
|
||||||
boolean needsAnnoucement = ability.hasParam("Announce") && this.getType().contains(ability.getParam("Announce"));
|
boolean needsAnnoucement = ability.hasParam("Announce") && this.getType().contains(ability.getParam("Announce"));
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,10 @@ public class CostReveal extends CostPartWithList {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
|
final Player activator = ability.getActivatingPlayer();
|
||||||
|
final Card source = ability.getSourceCard();
|
||||||
|
|
||||||
List<Card> handList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Hand));
|
List<Card> handList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Hand));
|
||||||
final String type = this.getType();
|
final String type = this.getType();
|
||||||
final Integer amount = this.convertAmount();
|
final Integer amount = this.convertAmount();
|
||||||
|
|||||||
@@ -150,7 +150,10 @@ public class CostSacrifice extends CostPartWithList {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
|
final Player activator = ability.getActivatingPlayer();
|
||||||
|
final Card source = ability.getSourceCard();
|
||||||
|
|
||||||
// You can always sac all
|
// You can always sac all
|
||||||
if (!this.payCostFromSource()) {
|
if (!this.payCostFromSource()) {
|
||||||
// If the sacrificed type is dependant on an annoucement, can't necesarily rule out the CanPlay call
|
// If the sacrificed type is dependant on an annoucement, can't necesarily rule out the CanPlay call
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import forge.Card;
|
|||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.player.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CostTap.
|
* The Class CostTap.
|
||||||
@@ -70,7 +69,8 @@ public class CostTap extends CostPart {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
|
final Card source = ability.getSourceCard();
|
||||||
return source.isUntapped() && (!source.isSick() || source.hasKeyword("CARDNAME may activate abilities as though it has haste."));
|
return source.isUntapped() && (!source.isSick() || source.hasKeyword("CARDNAME may activate abilities as though it has haste."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,12 +110,15 @@ public class CostTapType extends CostPartWithList {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
|
final Player activator = ability.getActivatingPlayer();
|
||||||
|
final Card source = ability.getSourceCard();
|
||||||
|
|
||||||
List<Card> typeList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Battlefield));
|
List<Card> typeList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Battlefield));
|
||||||
|
|
||||||
typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source);
|
typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source);
|
||||||
|
|
||||||
if (cost.hasTapCost()) {
|
if (!canTapSource) {
|
||||||
typeList.remove(source);
|
typeList.remove(source);
|
||||||
}
|
}
|
||||||
typeList = CardLists.filter(typeList, Presets.UNTAPPED);
|
typeList = CardLists.filter(typeList, Presets.UNTAPPED);
|
||||||
|
|||||||
@@ -65,7 +65,10 @@ public class CostUnattach extends CostPartWithList {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
|
final Player activator = ability.getActivatingPlayer();
|
||||||
|
final Card source = ability.getSourceCard();
|
||||||
|
|
||||||
final String type = this.getType();
|
final String type = this.getType();
|
||||||
if (type.equals("CARDNAME")) {
|
if (type.equals("CARDNAME")) {
|
||||||
if (source.isEquipping()) {
|
if (source.isEquipping()) {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import forge.Card;
|
|||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.player.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CostUntap.
|
* The Class CostUntap.
|
||||||
@@ -69,7 +68,8 @@ public class CostUntap extends CostPart {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
|
final Card source = ability.getSourceCard();
|
||||||
return source.isTapped() && (!source.isSick() || source.hasKeyword("CARDNAME may activate abilities as though it has haste."));
|
return source.isTapped() && (!source.isSick() || source.hasKeyword("CARDNAME may activate abilities as though it has haste."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,8 +113,10 @@ public class CostUntapType extends CostPartWithList {
|
|||||||
* forge.Card, forge.Player, forge.card.cost.Cost)
|
* forge.Card, forge.Player, forge.card.cost.Cost)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
|
public final boolean canPay(final SpellAbility ability) {
|
||||||
List<Card> typeList = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
final Player activator = ability.getActivatingPlayer();
|
||||||
|
final Card source = ability.getSourceCard();
|
||||||
|
List<Card> typeList = activator.getGame().getCardsIn(ZoneType.Battlefield);
|
||||||
|
|
||||||
typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source);
|
typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source);
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public abstract class AbilityActivated extends SpellAbility implements java.io.S
|
|||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlay() {
|
public boolean canPlay() {
|
||||||
final GameState game = Singletons.getModel().getGame();
|
final GameState game = getActivatingPlayer().getGame();
|
||||||
if (game.getStack().isSplitSecondOnStack() && !this.isManaAbility()) {
|
if (game.getStack().isSplitSecondOnStack() && !this.isManaAbility()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ public abstract class AbilityActivated extends SpellAbility implements java.io.S
|
|||||||
final Card c = this.getSourceCard();
|
final Card c = this.getSourceCard();
|
||||||
|
|
||||||
// CantBeActivated static abilities
|
// CantBeActivated static abilities
|
||||||
for (final Card ca : Singletons.getModel().getGame().getCardsIn(ZoneType.listValueOf("Battlefield,Command"))) {
|
for (final Card ca : game.getCardsIn(ZoneType.listValueOf("Battlefield,Command"))) {
|
||||||
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
|
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
|
||||||
for (final StaticAbility stAb : staticAbilities) {
|
for (final StaticAbility stAb : staticAbilities) {
|
||||||
if (stAb.applyAbility("CantBeActivated", c, this)) {
|
if (stAb.applyAbility("CantBeActivated", c, this)) {
|
||||||
@@ -104,7 +104,7 @@ public abstract class AbilityActivated extends SpellAbility implements java.io.S
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.isCycling()
|
if (this.isCycling()
|
||||||
&& Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noCycling)) {
|
&& game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noCycling)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ public abstract class AbilityActivated extends SpellAbility implements java.io.S
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CostPayment.canPayAdditionalCosts(game, this.getPayCosts(), this);
|
return CostPayment.canPayAdditionalCosts(this.getPayCosts(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.getPayCosts() != null) {
|
if (this.getPayCosts() != null) {
|
||||||
if (!CostPayment.canPayAdditionalCosts(game, this.getPayCosts(), this)) {
|
if (!CostPayment.canPayAdditionalCosts(this.getPayCosts(), this)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -508,7 +508,7 @@ public class GameAction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
abRecover.setActivatingPlayer(recoverable.getController());
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Recover ").append(recoverable).append("\n");
|
sb.append("Recover ").append(recoverable).append("\n");
|
||||||
|
|
||||||
@@ -518,7 +518,7 @@ public class GameAction {
|
|||||||
Player p = recoverable.getController();
|
Player p = recoverable.getController();
|
||||||
|
|
||||||
if (p.isHuman()) {
|
if (p.isHuman()) {
|
||||||
if ( GameActionUtil.payCostDuringAbilityResolve(p, abRecover, abRecover.getPayCosts(), null, game) )
|
if ( GameActionUtil.payCostDuringAbilityResolve(abRecover, abRecover.getPayCosts(), null, game) )
|
||||||
moveToHand(recoverable);
|
moveToHand(recoverable);
|
||||||
else
|
else
|
||||||
exile(recoverable);
|
exile(recoverable);
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ import forge.game.player.Player;
|
|||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
import forge.gui.GuiDialog;
|
import forge.gui.GuiDialog;
|
||||||
import forge.gui.GuiUtils;
|
|
||||||
import forge.sound.SoundEffectType;
|
import forge.sound.SoundEffectType;
|
||||||
|
|
||||||
|
|
||||||
@@ -401,8 +400,10 @@ public final class GameActionUtil {
|
|||||||
* a {@link forge.Command} object.
|
* a {@link forge.Command} object.
|
||||||
* @param sourceAbility TODO
|
* @param sourceAbility TODO
|
||||||
*/
|
*/
|
||||||
public static boolean payCostDuringAbilityResolve(final Player p, final SpellAbility ability, final Cost cost, SpellAbility sourceAbility, final GameState game) {
|
public static boolean payCostDuringAbilityResolve(final SpellAbility ability, final Cost cost, SpellAbility sourceAbility, final GameState game) {
|
||||||
|
|
||||||
// Only human player pays this way
|
// Only human player pays this way
|
||||||
|
final Player p = ability.getActivatingPlayer();
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
final List<CostPart> parts = cost.getCostParts();
|
final List<CostPart> parts = cost.getCostParts();
|
||||||
ArrayList<CostPart> remainingParts = new ArrayList<CostPart>(cost.getCostParts());
|
ArrayList<CostPart> remainingParts = new ArrayList<CostPart>(cost.getCostParts());
|
||||||
@@ -464,7 +465,7 @@ public final class GameActionUtil {
|
|||||||
int amount = getAmountFromPartX(part, source, sourceAbility);
|
int amount = getAmountFromPartX(part, source, sourceAbility);
|
||||||
String plural = amount > 1 ? "s" : "";
|
String plural = amount > 1 ? "s" : "";
|
||||||
|
|
||||||
if (!part.canPay(sourceAbility, source, p, cost, game))
|
if (!part.canPay(sourceAbility))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( false == GuiDialog.confirm(source, "Do you want to remove " + amount + " " + counterType.getName() + " counter" + plural + " from " + source + "?"))
|
if ( false == GuiDialog.confirm(source, "Do you want to remove " + amount + " " + counterType.getName() + " counter" + plural + " from " + source + "?"))
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ public class ComputerUtil {
|
|||||||
final SpellAbility newSA = sa.copyWithNoManaCost();
|
final SpellAbility newSA = sa.copyWithNoManaCost();
|
||||||
newSA.setActivatingPlayer(ai);
|
newSA.setActivatingPlayer(ai);
|
||||||
|
|
||||||
if (!ComputerUtilCost.canPayAdditionalCosts(newSA, ai, game)) {
|
if (!ComputerUtilCost.canPayAdditionalCosts(newSA, ai)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CounterType;
|
import forge.CounterType;
|
||||||
import forge.Singletons;
|
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
import forge.card.cost.CostDamage;
|
import forge.card.cost.CostDamage;
|
||||||
@@ -21,7 +20,6 @@ import forge.card.cost.CostRemoveCounter;
|
|||||||
import forge.card.cost.CostSacrifice;
|
import forge.card.cost.CostSacrifice;
|
||||||
import forge.card.spellability.Spell;
|
import forge.card.spellability.Spell;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.GameState;
|
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
@@ -338,8 +336,6 @@ public class ComputerUtilCost {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public static boolean canPayCost(final SpellAbility sa, final Player player) {
|
public static boolean canPayCost(final SpellAbility sa, final Player player) {
|
||||||
|
|
||||||
final GameState game = Singletons.getModel().getGame();
|
|
||||||
// Check for stuff like Nether Void
|
// Check for stuff like Nether Void
|
||||||
int extraManaNeeded = 0;
|
int extraManaNeeded = 0;
|
||||||
if (sa instanceof Spell) {
|
if (sa instanceof Spell) {
|
||||||
@@ -361,7 +357,7 @@ public class ComputerUtilCost {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ComputerUtilCost.canPayAdditionalCosts(sa, player, game);
|
return ComputerUtilCost.canPayAdditionalCosts(sa, player);
|
||||||
} // canPayCost()
|
} // canPayCost()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -375,7 +371,7 @@ public class ComputerUtilCost {
|
|||||||
* a {@link forge.game.player.Player} object.
|
* a {@link forge.game.player.Player} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public static boolean canPayAdditionalCosts(final SpellAbility sa, final Player player, final GameState game) {
|
public static boolean canPayAdditionalCosts(final SpellAbility sa, final Player player) {
|
||||||
if (sa.getActivatingPlayer() == null) {
|
if (sa.getActivatingPlayer() == null) {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append(sa.getSourceCard());
|
sb.append(sa.getSourceCard());
|
||||||
@@ -383,7 +379,7 @@ public class ComputerUtilCost {
|
|||||||
System.out.println(sb.toString());
|
System.out.println(sb.toString());
|
||||||
sa.setActivatingPlayer(player);
|
sa.setActivatingPlayer(player);
|
||||||
}
|
}
|
||||||
return CostPayment.canPayAdditionalCosts(game, sa.getPayCosts(), sa);
|
return CostPayment.canPayAdditionalCosts(sa.getPayCosts(), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import forge.card.spellability.AbilityManaPart;
|
|||||||
import forge.card.spellability.AbilitySub;
|
import forge.card.spellability.AbilitySub;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.GameActionUtil;
|
import forge.game.GameActionUtil;
|
||||||
import forge.game.GameState;
|
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
@@ -58,8 +57,6 @@ public class ComputerUtilMana {
|
|||||||
*/
|
*/
|
||||||
public static boolean payManaCost(final SpellAbility sa, final Player ai, final boolean test, final int extraMana, boolean checkPlayable) {
|
public static boolean payManaCost(final SpellAbility sa, final Player ai, final boolean test, final int extraMana, boolean checkPlayable) {
|
||||||
ManaCostBeingPaid cost = ComputerUtilMana.calculateManaCost(sa, test, extraMana);
|
ManaCostBeingPaid cost = ComputerUtilMana.calculateManaCost(sa, test, extraMana);
|
||||||
|
|
||||||
final GameState game = Singletons.getModel().getGame();
|
|
||||||
final ManaPool manapool = ai.getManaPool();
|
final ManaPool manapool = ai.getManaPool();
|
||||||
|
|
||||||
cost = manapool.payManaFromPool(sa, cost);
|
cost = manapool.payManaFromPool(sa, cost);
|
||||||
@@ -109,7 +106,7 @@ public class ComputerUtilMana {
|
|||||||
ma.setActivatingPlayer(ai);
|
ma.setActivatingPlayer(ai);
|
||||||
// if the AI can't pay the additional costs skip the mana ability
|
// if the AI can't pay the additional costs skip the mana ability
|
||||||
if (ma.getPayCosts() != null && checkPlayable) {
|
if (ma.getPayCosts() != null && checkPlayable) {
|
||||||
if (!ComputerUtilCost.canPayAdditionalCosts(ma, ai, game)) {
|
if (!ComputerUtilCost.canPayAdditionalCosts(ma, ai)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (sourceCard.isTapped() && checkPlayable) {
|
} else if (sourceCard.isTapped() && checkPlayable) {
|
||||||
@@ -186,7 +183,7 @@ public class ComputerUtilMana {
|
|||||||
// Pay additional costs
|
// Pay additional costs
|
||||||
if (ma.getPayCosts() != null) {
|
if (ma.getPayCosts() != null) {
|
||||||
final CostPayment pay = new CostPayment(ma.getPayCosts(), ma);
|
final CostPayment pay = new CostPayment(ma.getPayCosts(), ma);
|
||||||
if (!pay.payComputerCosts((AIPlayer)ai, game)) {
|
if (!pay.payComputerCosts((AIPlayer)ai, ai.getGame())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -458,7 +455,6 @@ public class ComputerUtilMana {
|
|||||||
|
|
||||||
//This method is currently used by AI to estimate human's available mana
|
//This method is currently used by AI to estimate human's available mana
|
||||||
private static List<Card> getAvailableMana(final Player ai, final boolean checkPlayable) {
|
private static List<Card> getAvailableMana(final Player ai, final boolean checkPlayable) {
|
||||||
final GameState game = Singletons.getModel().getGame();
|
|
||||||
final List<Card> list = ai.getCardsIn(ZoneType.Battlefield);
|
final List<Card> list = ai.getCardsIn(ZoneType.Battlefield);
|
||||||
list.addAll(ai.getCardsIn(ZoneType.Hand));
|
list.addAll(ai.getCardsIn(ZoneType.Hand));
|
||||||
final List<Card> manaSources = CardLists.filter(list, new Predicate<Card>() {
|
final List<Card> manaSources = CardLists.filter(list, new Predicate<Card>() {
|
||||||
@@ -523,7 +519,7 @@ public class ComputerUtilMana {
|
|||||||
// ability
|
// ability
|
||||||
m.setActivatingPlayer(ai);
|
m.setActivatingPlayer(ai);
|
||||||
if (cost != null) {
|
if (cost != null) {
|
||||||
if (!ComputerUtilCost.canPayAdditionalCosts(m, ai, game)) {
|
if (!ComputerUtilCost.canPayAdditionalCosts(m, ai)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1152,7 +1152,7 @@ public class CombatUtil {
|
|||||||
|
|
||||||
ability.setActivatingPlayer(c.getController());
|
ability.setActivatingPlayer(c.getController());
|
||||||
if (c.getController().isHuman()) {
|
if (c.getController().isHuman()) {
|
||||||
if ( GameActionUtil.payCostDuringAbilityResolve(c.getController(), ability, attackCost, null, game) ) {
|
if ( GameActionUtil.payCostDuringAbilityResolve(ability, attackCost, null, game) ) {
|
||||||
if (!crd.hasKeyword("Vigilance")) { crd.tap(); }
|
if (!crd.hasKeyword("Vigilance")) { crd.tap(); }
|
||||||
} else {
|
} else {
|
||||||
game.getCombat().removeFromCombat(crd);
|
game.getCombat().removeFromCombat(crd);
|
||||||
|
|||||||
@@ -171,6 +171,7 @@ public class Upkeep extends Phase {
|
|||||||
final Card c = list.get(i);
|
final Card c = list.get(i);
|
||||||
if (c.hasStartOfKeyword("(Echo unpaid)")) {
|
if (c.hasStartOfKeyword("(Echo unpaid)")) {
|
||||||
final Ability blankAbility = Upkeep.BlankAbility(c, c.getEchoCost());
|
final Ability blankAbility = Upkeep.BlankAbility(c, c.getEchoCost());
|
||||||
|
blankAbility.setActivatingPlayer(c.getController());
|
||||||
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Echo for ").append(c).append("\n");
|
sb.append("Echo for ").append(c).append("\n");
|
||||||
@@ -182,7 +183,7 @@ public class Upkeep extends Phase {
|
|||||||
Player controller = c.getController();
|
Player controller = c.getController();
|
||||||
if (controller.isHuman()) {
|
if (controller.isHuman()) {
|
||||||
Cost cost = new Cost(c, c.getEchoCost().trim(), true);
|
Cost cost = new Cost(c, c.getEchoCost().trim(), true);
|
||||||
if ( !GameActionUtil.payCostDuringAbilityResolve(controller, blankAbility, cost, null, game) )
|
if ( !GameActionUtil.payCostDuringAbilityResolve(blankAbility, cost, null, game) )
|
||||||
game.getAction().sacrifice(c, null);;
|
game.getAction().sacrifice(c, null);;
|
||||||
|
|
||||||
} else { // computer
|
} else { // computer
|
||||||
@@ -324,7 +325,7 @@ public class Upkeep extends Phase {
|
|||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
if (controller.isHuman()) {
|
if (controller.isHuman()) {
|
||||||
if ( !GameActionUtil.payCostDuringAbilityResolve(controller, blankAbility, blankAbility.getPayCosts(), this, game))
|
if ( !GameActionUtil.payCostDuringAbilityResolve(blankAbility, blankAbility.getPayCosts(), this, game))
|
||||||
game.getAction().sacrifice(c, null);
|
game.getAction().sacrifice(c, null);
|
||||||
} else { // computer
|
} else { // computer
|
||||||
if (ComputerUtilCost.shouldPayCost(controller, c, upkeepCost) && ComputerUtilCost.canPayCost(blankAbility, controller)) {
|
if (ComputerUtilCost.shouldPayCost(controller, c, upkeepCost) && ComputerUtilCost.canPayCost(blankAbility, controller)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user