mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
renamed InputYesOrNo, removed static methods from it, added a method to confirmPayment to PlayerController
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -15364,6 +15364,7 @@ forge-gui/src/main/java/forge/gui/input/Input.java -text
|
|||||||
forge-gui/src/main/java/forge/gui/input/InputAttack.java svneol=native#text/plain
|
forge-gui/src/main/java/forge/gui/input/InputAttack.java svneol=native#text/plain
|
||||||
forge-gui/src/main/java/forge/gui/input/InputBase.java svneol=native#text/plain
|
forge-gui/src/main/java/forge/gui/input/InputBase.java svneol=native#text/plain
|
||||||
forge-gui/src/main/java/forge/gui/input/InputBlock.java svneol=native#text/plain
|
forge-gui/src/main/java/forge/gui/input/InputBlock.java svneol=native#text/plain
|
||||||
|
forge-gui/src/main/java/forge/gui/input/InputConfirm.java -text
|
||||||
forge-gui/src/main/java/forge/gui/input/InputConfirmMulligan.java svneol=native#text/plain
|
forge-gui/src/main/java/forge/gui/input/InputConfirmMulligan.java svneol=native#text/plain
|
||||||
forge-gui/src/main/java/forge/gui/input/InputLockUI.java -text
|
forge-gui/src/main/java/forge/gui/input/InputLockUI.java -text
|
||||||
forge-gui/src/main/java/forge/gui/input/InputPassPriority.java svneol=native#text/plain
|
forge-gui/src/main/java/forge/gui/input/InputPassPriority.java svneol=native#text/plain
|
||||||
@@ -15382,7 +15383,6 @@ forge-gui/src/main/java/forge/gui/input/InputSelectManyBase.java -text
|
|||||||
forge-gui/src/main/java/forge/gui/input/InputSelectTargets.java -text
|
forge-gui/src/main/java/forge/gui/input/InputSelectTargets.java -text
|
||||||
forge-gui/src/main/java/forge/gui/input/InputSynchronized.java -text
|
forge-gui/src/main/java/forge/gui/input/InputSynchronized.java -text
|
||||||
forge-gui/src/main/java/forge/gui/input/InputSyncronizedBase.java -text
|
forge-gui/src/main/java/forge/gui/input/InputSyncronizedBase.java -text
|
||||||
forge-gui/src/main/java/forge/gui/input/InputYesOrNo.java -text
|
|
||||||
forge-gui/src/main/java/forge/gui/input/package-info.java svneol=native#text/plain
|
forge-gui/src/main/java/forge/gui/input/package-info.java svneol=native#text/plain
|
||||||
forge-gui/src/main/java/forge/gui/match/CMatchUI.java -text
|
forge-gui/src/main/java/forge/gui/match/CMatchUI.java -text
|
||||||
forge-gui/src/main/java/forge/gui/match/ControlWinLose.java -text
|
forge-gui/src/main/java/forge/gui/match/ControlWinLose.java -text
|
||||||
|
|||||||
@@ -910,5 +910,9 @@ public class AiController {
|
|||||||
}
|
}
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean confirmPayment(CostPart costPart) {
|
||||||
|
throw new UnsupportedOperationException("AI is not supposed to reach this code at the moment");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
|
|
||||||
import forge.card.ColorSet;
|
import forge.card.ColorSet;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.GameType;
|
import forge.game.GameType;
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
@@ -121,8 +120,7 @@ public class CostAddMana extends CostPart {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
Integer c = this.convertAmount();
|
Integer c = this.convertAmount();
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
|
|||||||
@@ -20,12 +20,11 @@ package forge.game.cost;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.gui.input.InputYesOrNo;
|
import forge.gui.input.InputConfirm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CostChooseCreatureType.
|
* The Class CostChooseCreatureType.
|
||||||
@@ -62,15 +61,15 @@ public class CostChooseCreatureType extends CostPart {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player payer) {
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
|
InputConfirm inp = new InputConfirm("Choose a creature type for " + source.getName() + "?");
|
||||||
if (!InputYesOrNo.ask("Choose a creature type for " + source.getName() + "?")) {
|
inp.showAndWait();
|
||||||
|
if (!inp.getResult()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String choice = activator.getController().chooseSomeType("Creature", ability, new ArrayList<String>(CardType.getCreatureTypes()), new ArrayList<String>());
|
String choice = payer.getController().chooseSomeType("Creature", ability, new ArrayList<String>(CardType.getCreatureTypes()), new ArrayList<String>());
|
||||||
source.setChosenType(choice);
|
source.setChosenType(choice);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
package forge.game.cost;
|
package forge.game.cost;
|
||||||
|
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.gui.input.InputYesOrNo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CostPayLife.
|
* The Class CostPayLife.
|
||||||
@@ -76,9 +74,8 @@ public class CostDamage extends CostPart {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
final int life = activator.getLife();
|
final int life = activator.getLife();
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
|
|
||||||
@@ -94,7 +91,7 @@ public class CostDamage extends CostPart {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activator.canPayLife(c) && InputYesOrNo.ask("Pay " + c + " Life?")) {
|
if (activator.canPayLife(c) && activator.getController().confirmPayment(this, "Pay " + c + " Life?")) {
|
||||||
activator.addDamage(c, source);
|
activator.addDamage(c, source);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import java.util.List;
|
|||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
|
||||||
import forge.ai.AiController;
|
import forge.ai.AiController;
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
@@ -162,11 +161,10 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player payer) {
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
|
|
||||||
List<Card> handList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Hand));
|
List<Card> handList = new ArrayList<Card>(payer.getCardsIn(ZoneType.Hand));
|
||||||
String discardType = this.getType();
|
String discardType = this.getType();
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
|
|
||||||
@@ -179,7 +177,7 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (discardType.equals("LastDrawn")) {
|
if (discardType.equals("LastDrawn")) {
|
||||||
final Card lastDrawn = activator.getLastDrawnCard();
|
final Card lastDrawn = payer.getLastDrawnCard();
|
||||||
return handList.contains(lastDrawn) && executePayment(ability, lastDrawn);
|
return handList.contains(lastDrawn) && executePayment(ability, lastDrawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +199,7 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
}
|
}
|
||||||
if (discardType.contains("+WithSameName")) {
|
if (discardType.contains("+WithSameName")) {
|
||||||
String type = discardType.replace("+WithSameName", "");
|
String type = discardType.replace("+WithSameName", "");
|
||||||
handList = CardLists.getValidCards(handList, type.split(";"), activator, source);
|
handList = CardLists.getValidCards(handList, type.split(";"), payer, source);
|
||||||
final List<Card> landList2 = handList;
|
final List<Card> landList2 = handList;
|
||||||
handList = CardLists.filter(handList, new Predicate<Card>() {
|
handList = CardLists.filter(handList, new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -235,7 +233,7 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
else {
|
else {
|
||||||
String type = new String(discardType);
|
String type = new String(discardType);
|
||||||
final String[] validType = type.split(";");
|
final String[] validType = type.split(";");
|
||||||
handList = CardLists.getValidCards(handList, validType, activator, source);
|
handList = CardLists.getValidCards(handList, validType, payer, source);
|
||||||
|
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
final String sVar = ability.getSVar(amount);
|
final String sVar = ability.getSVar(amount);
|
||||||
|
|||||||
@@ -20,12 +20,10 @@ package forge.game.cost;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.gui.input.InputYesOrNo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CostPayLife.
|
* The Class CostPayLife.
|
||||||
@@ -104,9 +102,9 @@ public class CostDraw extends CostPart {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player payer) {
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
final List<Player> players = getPotentialPlayers(ability.getActivatingPlayer(), ability.getSourceCard());
|
final List<Player> players = getPotentialPlayers(payer, ability.getSourceCard());
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
|
|
||||||
Integer c = this.convertAmount();
|
Integer c = this.convertAmount();
|
||||||
@@ -114,7 +112,7 @@ public class CostDraw extends CostPart {
|
|||||||
c = AbilityUtils.calculateAmount(source, amount, ability);
|
c = AbilityUtils.calculateAmount(source, amount, ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InputYesOrNo.ask("Draw " + c + " Card" + (c == 1 ? "" : "s"))) {
|
if (!payer.getController().confirmPayment(this, "Draw " + c + " Card" + (c == 1 ? "" : "s"))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import forge.game.zone.ZoneType;
|
|||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
import forge.gui.input.InputSelectCards;
|
import forge.gui.input.InputSelectCards;
|
||||||
import forge.gui.input.InputSelectCardsFromList;
|
import forge.gui.input.InputSelectCardsFromList;
|
||||||
import forge.gui.input.InputYesOrNo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CostExile.
|
* The Class CostExile.
|
||||||
@@ -214,10 +213,10 @@ public class CostExile extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
final Player activator = ability.getActivatingPlayer();
|
final Game game = activator.getGame();
|
||||||
|
|
||||||
Integer c = this.convertAmount();
|
Integer c = this.convertAmount();
|
||||||
String type = this.getType();
|
String type = this.getType();
|
||||||
@@ -242,9 +241,9 @@ public class CostExile extends CostPartWithList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.payCostFromSource()) {
|
if (this.payCostFromSource()) {
|
||||||
return source.getZone() == activator.getZone(from) &&
|
return source.getZone() == activator.getZone(from)
|
||||||
InputYesOrNo.ask("Exile " + source.getName() + "?") &&
|
&& activator.getController().confirmPayment(this, "Exile " + source.getName() + "?")
|
||||||
executePayment(ability, source);
|
&& executePayment(ability, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.equals("All")) {
|
if (type.equals("All")) {
|
||||||
@@ -274,7 +273,7 @@ public class CostExile extends CostPartWithList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.from == ZoneType.Stack) { return exileFromStack(ability, c); }
|
if (this.from == ZoneType.Stack) { return exileFromStack(ability, c); }
|
||||||
if (this.from == ZoneType.Library) { return exileFromTop(ability, c); }
|
if (this.from == ZoneType.Library) { return exileFromTop(ability, activator, c); }
|
||||||
if (fromTopGrave) { return exileFromTopGraveType(ability, c, list); }
|
if (fromTopGrave) { return exileFromTopGraveType(ability, c, list); }
|
||||||
if (!this.sameZone) { return exileFromMiscZone(ability, c, list); }
|
if (!this.sameZone) { return exileFromMiscZone(ability, c, list); }
|
||||||
|
|
||||||
@@ -391,17 +390,17 @@ public class CostExile extends CostPartWithList {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean exileFromTop(final SpellAbility sa, final int nNeeded) {
|
private boolean exileFromTop(final SpellAbility sa, final Player payer, final int nNeeded) {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Exile ").append(nNeeded).append(" cards from the top of your library?");
|
sb.append("Exile ").append(nNeeded).append(" cards from the top of your library?");
|
||||||
final List<Card> list = sa.getActivatingPlayer().getCardsIn(ZoneType.Library, nNeeded);
|
final List<Card> list = payer.getCardsIn(ZoneType.Library, nNeeded);
|
||||||
|
|
||||||
if (list.size() > nNeeded) {
|
if (list.size() > nNeeded) {
|
||||||
// I don't believe this is possible
|
// I don't believe this is possible
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InputYesOrNo.ask("Exile " + nNeeded + " card" + (nNeeded == 1 ? "" : "s") +
|
if (!payer.getController().confirmPayment(this, "Exile " + nNeeded + " card" + (nNeeded == 1 ? "" : "s") +
|
||||||
" from the top of your library?")) {
|
" from the top of your library?")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import forge.ai.ComputerUtilCard;
|
import forge.ai.ComputerUtilCard;
|
||||||
import forge.ai.ComputerUtilCost;
|
import forge.ai.ComputerUtilCost;
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
@@ -93,8 +92,8 @@ public class CostExileAndPay extends CostPartWithList {
|
|||||||
* @see forge.card.cost.CostPart#payHuman(forge.card.spellability.SpellAbility, forge.game.GameState)
|
* @see forge.card.cost.CostPart#payHuman(forge.card.spellability.SpellAbility, forge.game.GameState)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean payHuman(SpellAbility ability, Game game) {
|
public boolean payHuman(SpellAbility ability, Player payer) {
|
||||||
List<Card> validGrave = CardLists.getValidCards(ability.getActivatingPlayer().getZone(ZoneType.Graveyard), "Creature", ability.getActivatingPlayer(), ability.getSourceCard());
|
List<Card> validGrave = CardLists.getValidCards(payer.getZone(ZoneType.Graveyard), "Creature", payer, ability.getSourceCard());
|
||||||
|
|
||||||
Card selectedCard = GuiChoose.oneOrNone("Choose a creature card to exile.", validGrave);
|
Card selectedCard = GuiChoose.oneOrNone("Choose a creature card to exile.", validGrave);
|
||||||
if(selectedCard == null)
|
if(selectedCard == null)
|
||||||
@@ -127,7 +126,7 @@ public class CostExileAndPay extends CostPartWithList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final CostPayment pay = new CostPayment(selectedCost, ability);
|
final CostPayment pay = new CostPayment(selectedCost, ability);
|
||||||
pay.payCost(game);
|
pay.payCost(payer);
|
||||||
if(!pay.isFullyPaid())
|
if(!pay.isFullyPaid())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
@@ -115,7 +114,7 @@ public class CostExiledMoveToGrave extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player payer) {
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
Integer c = this.convertAmount();
|
Integer c = this.convertAmount();
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package forge.game.cost;
|
package forge.game.cost;
|
||||||
|
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.ability.effects.FlipCoinEffect;
|
import forge.game.ability.effects.FlipCoinEffect;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
@@ -67,7 +66,7 @@ public class CostFlipCoin extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
Integer c = this.convertAmount();
|
Integer c = this.convertAmount();
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package forge.game.cost;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
@@ -94,20 +93,19 @@ public class CostGainControl extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player payer) {
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
Integer c = this.convertAmount();
|
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
final List<Card> list = activator.getGame().getCardsIn(ZoneType.Battlefield);
|
|
||||||
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
|
|
||||||
|
|
||||||
|
Integer c = this.convertAmount();
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
c = AbilityUtils.calculateAmount(source, amount, ability);
|
c = AbilityUtils.calculateAmount(source, amount, ability);
|
||||||
}
|
}
|
||||||
List<Card> validCards = CardLists.getValidCards(list, this.getType().split(";"), activator, source);
|
final List<Card> list = payer.getCardsIn(ZoneType.Battlefield);
|
||||||
|
List<Card> validCards = CardLists.getValidCards(list, this.getType().split(";"), payer, source);
|
||||||
|
|
||||||
InputSelectCards inp = new InputSelectCardsFromList(c, c, validCards);
|
InputSelectCards inp = new InputSelectCardsFromList(c, c, validCards);
|
||||||
|
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
|
||||||
inp.setMessage("Gain control of %d " + desc);
|
inp.setMessage("Gain control of %d " + desc);
|
||||||
inp.showAndWait();
|
inp.showAndWait();
|
||||||
if (inp.hasCancelled()) {
|
if (inp.hasCancelled()) {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package forge.game.cost;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
@@ -117,10 +116,10 @@ public class CostGainLife extends CostPart {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
final int life = activator.getLife();
|
final int life = activator.getLife();
|
||||||
|
|
||||||
Integer c = this.convertAmount();
|
Integer c = this.convertAmount();
|
||||||
|
|||||||
@@ -19,14 +19,12 @@ package forge.game.cost;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.zone.PlayerZone;
|
import forge.game.zone.PlayerZone;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.input.InputYesOrNo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is for the "Mill" Cost. Putting cards from the top of your library into
|
* This is for the "Mill" Cost. Putting cards from the top of your library into
|
||||||
@@ -88,11 +86,11 @@ public class CostMill extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
Integer c = this.convertAmount();
|
Integer c = this.convertAmount();
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
|
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
final String sVar = ability.getSVar(amount);
|
final String sVar = ability.getSVar(amount);
|
||||||
@@ -104,7 +102,7 @@ public class CostMill extends CostPartWithList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InputYesOrNo.ask("Mill " + c + " card" + (c == 1 ? "" : "s") + " from your library?")) {
|
if (!activator.getController().confirmPayment(this, "Mill " + c + " card" + (c == 1 ? "" : "s") + " from your library?")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package forge.game.cost;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
@@ -193,7 +192,7 @@ public abstract class CostPart {
|
|||||||
* @param game
|
* @param game
|
||||||
* @return true, if successful
|
* @return true, if successful
|
||||||
*/
|
*/
|
||||||
public abstract boolean payHuman(SpellAbility ability, Game game);
|
public abstract boolean payHuman(SpellAbility ability, Player humanPayer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import forge.ai.ComputerUtilMana;
|
|||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.mana.ManaCost;
|
import forge.card.mana.ManaCost;
|
||||||
import forge.card.mana.ManaCostShard;
|
import forge.card.mana.ManaCostShard;
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.mana.ManaCostBeingPaid;
|
import forge.game.mana.ManaCostBeingPaid;
|
||||||
@@ -106,7 +105,7 @@ public class CostPartMana extends CostPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
ManaCostBeingPaid toPay = new ManaCostBeingPaid(getManaToPay(), restriction);
|
ManaCostBeingPaid toPay = new ManaCostBeingPaid(getManaToPay(), restriction);
|
||||||
|
|
||||||
@@ -161,7 +160,7 @@ public class CostPartMana extends CostPart {
|
|||||||
System.out.println("Finishing up Offering");
|
System.out.println("Finishing up Offering");
|
||||||
final Card offering = ability.getSacrificedAsOffering();
|
final Card offering = ability.getSacrificedAsOffering();
|
||||||
offering.setUsedToPay(false);
|
offering.setUsedToPay(false);
|
||||||
game.getAction().sacrifice(offering, ability);
|
activator.getGame().getAction().sacrifice(offering, ability);
|
||||||
ability.resetSacrificedAsOffering();
|
ability.resetSacrificedAsOffering();
|
||||||
}
|
}
|
||||||
if (ability.getTappedForConvoke() != null) {
|
if (ability.getTappedForConvoke() != null) {
|
||||||
|
|||||||
@@ -17,12 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
package forge.game.cost;
|
package forge.game.cost;
|
||||||
|
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.gui.input.InputYesOrNo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CostPayLife.
|
* The Class CostPayLife.
|
||||||
@@ -111,10 +109,9 @@ public class CostPayLife extends CostPart {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
final int life = activator.getLife();
|
final int life = activator.getLife();
|
||||||
|
|
||||||
Integer c = this.convertAmount();
|
Integer c = this.convertAmount();
|
||||||
@@ -133,7 +130,7 @@ public class CostPayLife extends CostPart {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activator.canPayLife(c) && InputYesOrNo.ask("Pay " + c + " Life?")) {
|
if (activator.canPayLife(c) && activator.getController().confirmPayment(this, "Pay " + c + " Life?")) {
|
||||||
activator.payLife(c, null);
|
activator.payLife(c, null);
|
||||||
paidAmount = c;
|
paidAmount = c;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -104,9 +104,9 @@ public class CostPayment {
|
|||||||
*
|
*
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public boolean payCost(final Game game) {
|
public boolean payCost(final Player payer) {
|
||||||
for (final CostPart part : this.cost.getCostParts()) {
|
for (final CostPart part : this.cost.getCostParts()) {
|
||||||
if ( false == part.payHuman(this.ability, game) ) {
|
if ( false == part.payHuman(this.ability, payer) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -207,16 +207,15 @@ public class CostPutCardToLib extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
Integer c = this.convertAmount();
|
Integer c = this.convertAmount();
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
|
|
||||||
List<Card> list;
|
List<Card> list;
|
||||||
|
|
||||||
if (this.sameZone) {
|
if (this.sameZone) {
|
||||||
list = new ArrayList<Card>(game.getCardsIn(this.getFrom()));
|
list = new ArrayList<Card>(activator.getGame().getCardsIn(this.getFrom()));
|
||||||
} else {
|
} else {
|
||||||
list = new ArrayList<Card>(activator.getCardsIn(this.getFrom()));
|
list = new ArrayList<Card>(activator.getCardsIn(this.getFrom()));
|
||||||
}
|
}
|
||||||
@@ -242,7 +241,7 @@ public class CostPutCardToLib extends CostPartWithList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.sameZone){
|
if (this.sameZone){
|
||||||
List<Player> players = game.getPlayers();
|
List<Player> players = activator.getGame().getPlayers();
|
||||||
List<Player> payableZone = new ArrayList<Player>();
|
List<Player> payableZone = new ArrayList<Player>();
|
||||||
for (Player p : players) {
|
for (Player p : players) {
|
||||||
List<Card> enoughType = CardLists.filter(list, CardPredicates.isOwner(p));
|
List<Card> enoughType = CardLists.filter(list, CardPredicates.isOwner(p));
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import forge.ai.ComputerUtilCard;
|
import forge.ai.ComputerUtilCard;
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
@@ -254,7 +253,7 @@ public class CostPutCounter extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
Integer c = getNumberOfCounters(ability);
|
Integer c = getNumberOfCounters(ability);
|
||||||
|
|
||||||
@@ -264,8 +263,8 @@ public class CostPutCounter extends CostPartWithList {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// Cards to use this branch: Scarscale Ritual, Wandering Mage - each adds only one counter
|
// Cards to use this branch: Scarscale Ritual, Wandering Mage - each adds only one counter
|
||||||
final Player actor = ability.getActivatingPlayer();
|
|
||||||
List<Card> typeList = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), getType().split(";"), actor, ability.getSourceCard());
|
List<Card> typeList = CardLists.getValidCards(activator.getCardsIn(ZoneType.Battlefield), getType().split(";"), activator, ability.getSourceCard());
|
||||||
|
|
||||||
InputSelectCardToPutCounter inp = new InputSelectCardToPutCounter(c, typeList);
|
InputSelectCardToPutCounter inp = new InputSelectCardToPutCounter(c, typeList);
|
||||||
inp.setMessage("Put %d " + getCounter().getName() + " counter on " + getDescriptiveType());
|
inp.setMessage("Put %d " + getCounter().getName() + " counter on " + getDescriptiveType());
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import forge.ai.ComputerUtil;
|
import forge.ai.ComputerUtil;
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
@@ -109,11 +108,10 @@ public class CostRemoveAnyCounter extends CostPartWithList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
Integer c = this.convertAmount();
|
Integer c = this.convertAmount();
|
||||||
final String type = this.getType();
|
final String type = this.getType();
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
|
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
c = AbilityUtils.calculateAmount(source, this.getAmount(), ability);
|
c = AbilityUtils.calculateAmount(source, this.getAmount(), ability);
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
@@ -116,12 +115,11 @@ public class CostRemoveCounter extends CostPartWithList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
Integer c = this.convertAmount();
|
Integer c = this.convertAmount();
|
||||||
final String type = this.getType();
|
final String type = this.getType();
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
|
|
||||||
String sVarAmount = ability.getSVar(amount);
|
String sVarAmount = ability.getSVar(amount);
|
||||||
cntRemoved = 1;
|
cntRemoved = 1;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import forge.ai.ComputerUtil;
|
import forge.ai.ComputerUtil;
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
@@ -30,7 +29,6 @@ import forge.game.spellability.SpellAbility;
|
|||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.input.InputSelectCards;
|
import forge.gui.input.InputSelectCards;
|
||||||
import forge.gui.input.InputSelectCardsFromList;
|
import forge.gui.input.InputSelectCardsFromList;
|
||||||
import forge.gui.input.InputYesOrNo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CostReturn.
|
* The Class CostReturn.
|
||||||
@@ -120,12 +118,12 @@ public class CostReturn extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player payer) {
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
Integer c = this.convertAmount();
|
Integer c = this.convertAmount();
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
final List<Card> list = activator.getCardsIn(ZoneType.Battlefield);
|
final List<Card> list = payer.getCardsIn(ZoneType.Battlefield);
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
final String sVar = ability.getSVar(amount);
|
final String sVar = ability.getSVar(amount);
|
||||||
// Generalize this
|
// Generalize this
|
||||||
@@ -137,8 +135,8 @@ public class CostReturn extends CostPartWithList {
|
|||||||
}
|
}
|
||||||
if (this.payCostFromSource()) {
|
if (this.payCostFromSource()) {
|
||||||
final Card card = ability.getSourceCard();
|
final Card card = ability.getSourceCard();
|
||||||
if (card.getController() == ability.getActivatingPlayer() && card.isInPlay()) {
|
if (card.getController() == payer && card.isInPlay()) {
|
||||||
return InputYesOrNo.ask("Return " + card.getName() + " to hand?") && executePayment(ability, card);
|
return payer.getController().confirmPayment(this, "Return " + card.getName() + " to hand?") && executePayment(ability, card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import com.google.common.base.Predicate;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import forge.ai.AiController;
|
import forge.ai.AiController;
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
@@ -161,8 +160,7 @@ public class CostReveal extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import forge.ai.ComputerUtil;
|
import forge.ai.ComputerUtil;
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
@@ -30,7 +29,6 @@ import forge.game.spellability.SpellAbility;
|
|||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.input.InputSelectCards;
|
import forge.gui.input.InputSelectCards;
|
||||||
import forge.gui.input.InputSelectCardsFromList;
|
import forge.gui.input.InputSelectCardsFromList;
|
||||||
import forge.gui.input.InputYesOrNo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CostSacrifice.
|
* The Class CostSacrifice.
|
||||||
@@ -129,11 +127,11 @@ public class CostSacrifice extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
final String type = this.getType();
|
final String type = this.getType();
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
List<Card> list = new ArrayList<Card>(activator.getCardsIn(ZoneType.Battlefield));
|
List<Card> list = new ArrayList<Card>(activator.getCardsIn(ZoneType.Battlefield));
|
||||||
list = CardLists.getValidCards(list, type.split(";"), activator, source);
|
list = CardLists.getValidCards(list, type.split(";"), activator, source);
|
||||||
if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
|
if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
|
||||||
@@ -142,7 +140,7 @@ public class CostSacrifice extends CostPartWithList {
|
|||||||
|
|
||||||
if (this.payCostFromSource()) {
|
if (this.payCostFromSource()) {
|
||||||
if (source.getController() == ability.getActivatingPlayer() && source.isInPlay()) {
|
if (source.getController() == ability.getActivatingPlayer() && source.isInPlay()) {
|
||||||
return InputYesOrNo.ask("Sacrifice " + source.getName() + "?") && executePayment(ability, source);
|
return activator.getController().confirmPayment(this, "Sacrifice " + source.getName() + "?") && executePayment(ability, source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (amount.equals("All")) {
|
else if (amount.equals("All")) {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package forge.game.cost;
|
package forge.game.cost;
|
||||||
|
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
@@ -93,7 +92,7 @@ public class CostTap extends CostPart {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
// if (!canPay(ability, source, ability.getActivatingPlayer(),
|
// if (!canPay(ability, source, ability.getActivatingPlayer(),
|
||||||
// payment.getCost()))
|
// payment.getCost()))
|
||||||
// return false;
|
// return false;
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import java.util.List;
|
|||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
|
||||||
import forge.ai.ComputerUtil;
|
import forge.ai.ComputerUtil;
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
@@ -172,8 +171,8 @@ public class CostTapType extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
List<Card> typeList = new ArrayList<Card>(ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield));
|
List<Card> typeList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Battlefield));
|
||||||
String type = this.getType();
|
String type = this.getType();
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
@@ -193,7 +192,7 @@ public class CostTapType extends CostPartWithList {
|
|||||||
type = type.replace("+withTotalPowerGE" + totalP, "");
|
type = type.replace("+withTotalPowerGE" + totalP, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
typeList = CardLists.getValidCards(typeList, type.split(";"), ability.getActivatingPlayer(), ability.getSourceCard());
|
typeList = CardLists.getValidCards(typeList, type.split(";"), activator, ability.getSourceCard());
|
||||||
typeList = CardLists.filter(typeList, Presets.UNTAPPED);
|
typeList = CardLists.filter(typeList, Presets.UNTAPPED);
|
||||||
if (c == null && !amount.equals("Any")) {
|
if (c == null && !amount.equals("Any")) {
|
||||||
final String sVar = ability.getSVar(amount);
|
final String sVar = ability.getSVar(amount);
|
||||||
|
|||||||
@@ -19,12 +19,10 @@ package forge.game.cost;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.gui.input.InputYesOrNo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CostUnattach.
|
* The Class CostUnattach.
|
||||||
@@ -96,11 +94,11 @@ public class CostUnattach extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
Player activator = ability.getActivatingPlayer();
|
|
||||||
Card cardToUnattach = findCardToUnattach(source, activator, ability);
|
Card cardToUnattach = findCardToUnattach(source, activator, ability);
|
||||||
if (cardToUnattach != null && InputYesOrNo.ask("Unattach " + cardToUnattach.getName() + "?")) {
|
if (cardToUnattach != null && activator.getController().confirmPayment(this, "Unattach " + cardToUnattach.getName() + "?")) {
|
||||||
return executePayment(ability, cardToUnattach);
|
return executePayment(ability, cardToUnattach);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package forge.game.cost;
|
package forge.game.cost;
|
||||||
|
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
@@ -84,7 +83,7 @@ public class CostUntap extends CostPart {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player activator) {
|
||||||
// if (!canPay(ability, source, ability.getActivatingPlayer(),
|
// if (!canPay(ability, source, ability.getActivatingPlayer(),
|
||||||
// payment.getCost()))
|
// payment.getCost()))
|
||||||
// return false;
|
// return false;
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package forge.game.cost;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import forge.ai.ComputerUtil;
|
import forge.ai.ComputerUtil;
|
||||||
import forge.game.Game;
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
@@ -131,9 +130,9 @@ public class CostUntapType extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean payHuman(final SpellAbility ability, final Game game) {
|
public final boolean payHuman(final SpellAbility ability, final Player payer) {
|
||||||
List<Card> typeList = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), this.getType().split(";"),
|
List<Card> typeList = CardLists.getValidCards(payer.getGame().getCardsIn(ZoneType.Battlefield), this.getType().split(";"),
|
||||||
ability.getActivatingPlayer(), ability.getSourceCard());
|
payer, ability.getSourceCard());
|
||||||
typeList = CardLists.filter(typeList, Presets.TAPPED);
|
typeList = CardLists.filter(typeList, Presets.TAPPED);
|
||||||
final Card source = ability.getSourceCard();
|
final Card source = ability.getSourceCard();
|
||||||
if (!canUntapSource) {
|
if (!canUntapSource) {
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ import forge.gui.input.InputPayManaExecuteCommands;
|
|||||||
import forge.gui.input.InputPayManaSimple;
|
import forge.gui.input.InputPayManaSimple;
|
||||||
import forge.gui.input.InputSelectCards;
|
import forge.gui.input.InputSelectCards;
|
||||||
import forge.gui.input.InputSelectCardsFromList;
|
import forge.gui.input.InputSelectCardsFromList;
|
||||||
import forge.gui.input.InputYesOrNo;
|
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -305,12 +304,12 @@ public class HumanPlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (parts.isEmpty() || (costPart.getAmount().equals("0") && parts.size() < 2)) {
|
if (parts.isEmpty() || (costPart.getAmount().equals("0") && parts.size() < 2)) {
|
||||||
return InputYesOrNo.ask("Do you want to pay {0}?" + orString);
|
return p.getController().confirmPayment(costPart, "Do you want to pay {0}?" + orString);
|
||||||
}
|
}
|
||||||
// 0 mana costs were slipping through because CostPart.getAmount returns 1
|
// 0 mana costs were slipping through because CostPart.getAmount returns 1
|
||||||
else if (costPart instanceof CostPartMana && parts.size() < 2) {
|
else if (costPart instanceof CostPartMana && parts.size() < 2) {
|
||||||
if (((CostPartMana) costPart).getManaToPay().isZero()) {
|
if (((CostPartMana) costPart).getManaToPay().isZero()) {
|
||||||
return InputYesOrNo.ask("Do you want to pay {0}?" + orString);
|
return p.getController().confirmPayment(costPart, "Do you want to pay {0}?" + orString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +323,7 @@ public class HumanPlay {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InputYesOrNo.ask("Do you want to pay " + amount + " life?" + orString)) {
|
if (!p.getController().confirmPayment(part, "Do you want to pay " + amount + " life?" + orString)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,7 +354,7 @@ public class HumanPlay {
|
|||||||
}
|
}
|
||||||
sb.append("?" + orString);
|
sb.append("?" + orString);
|
||||||
|
|
||||||
if (!InputYesOrNo.ask(sb.toString())) {
|
if (!p.getController().confirmPayment(part,sb.toString())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,17 +363,15 @@ public class HumanPlay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (part instanceof CostGainLife) {
|
else if (part instanceof CostGainLife) {
|
||||||
if (!part.payHuman(sourceAbility, p.getGame())) {
|
if (!part.payHuman(sourceAbility, p)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (part instanceof CostAddMana) {
|
else if (part instanceof CostAddMana) {
|
||||||
if (!InputYesOrNo.ask("Do you want to add "
|
if (!p.getController().confirmPayment(part, "Do you want to add " + ((CostAddMana) part).toString() + " to your mana pool?" + orString)) {
|
||||||
+ ((CostAddMana) part).toString()
|
|
||||||
+ " to your mana pool?" + orString)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!part.payHuman(sourceAbility, p.getGame())) {
|
if (!part.payHuman(sourceAbility, p)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -382,8 +379,7 @@ public class HumanPlay {
|
|||||||
final int amount = getAmountFromPart(part, source, sourceAbility);
|
final int amount = getAmountFromPart(part, source, sourceAbility);
|
||||||
final List<Card> list = p.getCardsIn(ZoneType.Library);
|
final List<Card> list = p.getCardsIn(ZoneType.Library);
|
||||||
if (list.size() < amount) { return false; }
|
if (list.size() < amount) { return false; }
|
||||||
if (!InputYesOrNo.ask("Do you want to mill " + amount +
|
if (!p.getController().confirmPayment(part, "Do you want to mill " + amount + " card" + (amount == 1 ? "" : "s") + "?" + orString)) {
|
||||||
" card" + (amount == 1 ? "" : "s") + "?" + orString)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
List<Card> listmill = p.getCardsIn(ZoneType.Library, amount);
|
List<Card> listmill = p.getCardsIn(ZoneType.Library, amount);
|
||||||
@@ -391,8 +387,7 @@ public class HumanPlay {
|
|||||||
}
|
}
|
||||||
else if (part instanceof CostFlipCoin) {
|
else if (part instanceof CostFlipCoin) {
|
||||||
final int amount = getAmountFromPart(part, source, sourceAbility);
|
final int amount = getAmountFromPart(part, source, sourceAbility);
|
||||||
if (!InputYesOrNo.ask("Do you want to flip " + amount +
|
if (!p.getController().confirmPayment(part, "Do you want to flip " + amount + " coin" + (amount == 1 ? "" : "s") + "?" + orString)) {
|
||||||
" coin" + (amount == 1 ? "" : "s") + "?" + orString)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int n = FlipCoinEffect.getFilpMultiplier(p);
|
final int n = FlipCoinEffect.getFilpMultiplier(p);
|
||||||
@@ -406,7 +401,7 @@ public class HumanPlay {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InputYesOrNo.ask("Do you want " + source + " to deal " + amount + " damage to you?")) {
|
if (!p.getController().confirmPayment(part, "Do you want " + source + " to deal " + amount + " damage to you?")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,7 +417,7 @@ public class HumanPlay {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InputYesOrNo.ask("Do you want to put " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " on " + source + "?")) {
|
if (!p.getController().confirmPayment(part, "Do you want to put " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " on " + source + "?")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,7 +427,7 @@ public class HumanPlay {
|
|||||||
List<Card> list = p.getGame().getCardsIn(ZoneType.Battlefield);
|
List<Card> list = p.getGame().getCardsIn(ZoneType.Battlefield);
|
||||||
list = CardLists.getValidCards(list, part.getType().split(";"), p, source);
|
list = CardLists.getValidCards(list, part.getType().split(";"), p, source);
|
||||||
if (list.isEmpty()) { return false; }
|
if (list.isEmpty()) { return false; }
|
||||||
if (!InputYesOrNo.ask("Do you want to put " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " on " + part.getTypeDescription() + "?")) {
|
if (!p.getController().confirmPayment(part, "Do you want to put " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " on " + part.getTypeDescription() + "?")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
while (amount > 0) {
|
while (amount > 0) {
|
||||||
@@ -457,7 +452,7 @@ public class HumanPlay {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InputYesOrNo.ask("Do you want to remove " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " from " + source + "?")) {
|
if (!p.getController().confirmPayment(part, "Do you want to remove " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " from " + source + "?")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,7 +469,7 @@ public class HumanPlay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (allCounters < amount) { return false; }
|
if (allCounters < amount) { return false; }
|
||||||
if (!InputYesOrNo.ask("Do you want to remove counters from " + part.getDescriptiveType() + " ?")) {
|
if (!p.getController().confirmPayment(part, "Do you want to remove counters from " + part.getDescriptiveType() + " ?")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,7 +511,7 @@ public class HumanPlay {
|
|||||||
}
|
}
|
||||||
else if (part instanceof CostExile) {
|
else if (part instanceof CostExile) {
|
||||||
if ("All".equals(part.getType())) {
|
if ("All".equals(part.getType())) {
|
||||||
if (!InputYesOrNo.ask("Do you want to exile all cards in your graveyard?")) {
|
if (!p.getController().confirmPayment(part, "Do you want to exile all cards in your graveyard?")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -534,7 +529,7 @@ public class HumanPlay {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (from == ZoneType.Library) {
|
if (from == ZoneType.Library) {
|
||||||
if (!InputYesOrNo.ask("Do you want to exile " + nNeeded +
|
if (!p.getController().confirmPayment(part, "Do you want to exile " + nNeeded +
|
||||||
" card" + (nNeeded == 1 ? "" : "s") + " from your library?")) {
|
" card" + (nNeeded == 1 ? "" : "s") + " from your library?")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import forge.game.card.Card;
|
|||||||
import forge.game.card.CounterType;
|
import forge.game.card.CounterType;
|
||||||
import forge.game.combat.Combat;
|
import forge.game.combat.Combat;
|
||||||
import forge.game.cost.Cost;
|
import forge.game.cost.Cost;
|
||||||
|
import forge.game.cost.CostPart;
|
||||||
import forge.game.mana.Mana;
|
import forge.game.mana.Mana;
|
||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.replacement.ReplacementEffect;
|
import forge.game.replacement.ReplacementEffect;
|
||||||
@@ -188,4 +189,6 @@ public abstract class PlayerController {
|
|||||||
public abstract PaperCard chooseSinglePaperCard(SpellAbility sa, String message, Predicate<PaperCard> cpp, String name);
|
public abstract PaperCard chooseSinglePaperCard(SpellAbility sa, String message, Predicate<PaperCard> cpp, String name);
|
||||||
public abstract List<String> chooseColors(String message, SpellAbility sa, int min, int max, List<String> options);
|
public abstract List<String> chooseColors(String message, SpellAbility sa, int min, int max, List<String> options);
|
||||||
public abstract CounterType chooseCounterType(Collection<CounterType> options, SpellAbility sa, String prompt);
|
public abstract CounterType chooseCounterType(Collection<CounterType> options, SpellAbility sa, String prompt);
|
||||||
|
|
||||||
|
public abstract boolean confirmPayment(CostPart costPart, String string);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import forge.game.card.CardPredicates;
|
|||||||
import forge.game.card.CounterType;
|
import forge.game.card.CounterType;
|
||||||
import forge.game.combat.Combat;
|
import forge.game.combat.Combat;
|
||||||
import forge.game.cost.Cost;
|
import forge.game.cost.Cost;
|
||||||
|
import forge.game.cost.CostPart;
|
||||||
import forge.game.mana.Mana;
|
import forge.game.mana.Mana;
|
||||||
import forge.game.replacement.ReplacementEffect;
|
import forge.game.replacement.ReplacementEffect;
|
||||||
import forge.game.spellability.Ability;
|
import forge.game.spellability.Ability;
|
||||||
@@ -574,4 +575,9 @@ public class PlayerControllerAi extends PlayerController {
|
|||||||
// find first nonzero counter on target
|
// find first nonzero counter on target
|
||||||
return Iterables.getFirst(options, null);
|
return Iterables.getFirst(options, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean confirmPayment(CostPart costPart, String prompt) {
|
||||||
|
return brains.confirmPayment(costPart); // AI is expected to know what it is paying for at the moment (otherwise add another parameter to this method)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import forge.game.card.Card;
|
|||||||
import forge.game.card.CounterType;
|
import forge.game.card.CounterType;
|
||||||
import forge.game.combat.Combat;
|
import forge.game.combat.Combat;
|
||||||
import forge.game.cost.Cost;
|
import forge.game.cost.Cost;
|
||||||
|
import forge.game.cost.CostPart;
|
||||||
import forge.game.mana.Mana;
|
import forge.game.mana.Mana;
|
||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.replacement.ReplacementEffect;
|
import forge.game.replacement.ReplacementEffect;
|
||||||
@@ -62,7 +63,7 @@ import forge.gui.input.InputPassPriority;
|
|||||||
import forge.gui.input.InputPlayOrDraw;
|
import forge.gui.input.InputPlayOrDraw;
|
||||||
import forge.gui.input.InputSelectCards;
|
import forge.gui.input.InputSelectCards;
|
||||||
import forge.gui.input.InputSelectCardsFromList;
|
import forge.gui.input.InputSelectCardsFromList;
|
||||||
import forge.gui.input.InputYesOrNo;
|
import forge.gui.input.InputConfirm;
|
||||||
import forge.gui.match.CMatchUI;
|
import forge.gui.match.CMatchUI;
|
||||||
import forge.gui.match.controllers.CPrompt;
|
import forge.gui.match.controllers.CPrompt;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
@@ -435,7 +436,9 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return InputYesOrNo.ask(buildQuestion.toString());
|
InputConfirm inp = new InputConfirm(buildQuestion.toString());
|
||||||
|
inp.showAndWait();
|
||||||
|
return inp.getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -924,4 +927,11 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
}
|
}
|
||||||
return GuiChoose.one(prompt, options);
|
return GuiChoose.one(prompt, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean confirmPayment(CostPart costPart, String question) {
|
||||||
|
InputConfirm inp = new InputConfirm(question);
|
||||||
|
inp.showAndWait();
|
||||||
|
return inp.getResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public class HumanPlaySpellAbility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void playAbility(boolean mayChooseTargets, boolean isFree, boolean skipStack) {
|
public final void playAbility(boolean mayChooseTargets, boolean isFree, boolean skipStack) {
|
||||||
|
final Player human = ability.getActivatingPlayer();
|
||||||
final Game game = ability.getActivatingPlayer().getGame();
|
final Game game = ability.getActivatingPlayer().getGame();
|
||||||
|
|
||||||
// used to rollback
|
// used to rollback
|
||||||
@@ -73,7 +74,7 @@ public class HumanPlaySpellAbility {
|
|||||||
boolean prerequisitesMet = this.announceValuesLikeX()
|
boolean prerequisitesMet = this.announceValuesLikeX()
|
||||||
&& this.announceType()
|
&& this.announceType()
|
||||||
&& (!mayChooseTargets || setupTargets()) // if you can choose targets, then do choose them.
|
&& (!mayChooseTargets || setupTargets()) // if you can choose targets, then do choose them.
|
||||||
&& (isFree || this.payment.payCost(game));
|
&& (isFree || this.payment.payCost(human));
|
||||||
|
|
||||||
if (!prerequisitesMet) {
|
if (!prerequisitesMet) {
|
||||||
if (!ability.isTrigger()) {
|
if (!ability.isTrigger()) {
|
||||||
|
|||||||
@@ -27,43 +27,28 @@ import forge.view.ButtonUtil;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id: InputConfirmMulligan.java 21647 2013-05-24 22:31:11Z Max mtg $
|
* @version $Id: InputConfirmMulligan.java 21647 2013-05-24 22:31:11Z Max mtg $
|
||||||
*/
|
*/
|
||||||
public class InputYesOrNo extends InputSyncronizedBase {
|
public class InputConfirm extends InputSyncronizedBase {
|
||||||
private static final long serialVersionUID = -3591794991788531626L;
|
private static final long serialVersionUID = -3591794991788531626L;
|
||||||
|
|
||||||
public static boolean ask(String message0) {
|
|
||||||
return ask(message0, "Yes", "No", true);
|
|
||||||
}
|
|
||||||
public static boolean ask(String message0, boolean defaultYes0) {
|
|
||||||
return ask(message0, "Yes", "No", defaultYes0);
|
|
||||||
}
|
|
||||||
public static boolean ask(String message0, String yesButtonText0, String noButtonText0) {
|
|
||||||
return ask(message0, yesButtonText0, noButtonText0, true);
|
|
||||||
}
|
|
||||||
public static boolean ask(String message0, String yesButtonText0, String noButtonText0, boolean defaultYes0) {
|
|
||||||
InputYesOrNo inp = new InputYesOrNo(message0, yesButtonText0, noButtonText0, defaultYes0);
|
|
||||||
inp.showAndWait();
|
|
||||||
return inp.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
private final String message;
|
private final String message;
|
||||||
private final String yesButtonText;
|
private final String yesButtonText;
|
||||||
private final String noButtonText;
|
private final String noButtonText;
|
||||||
private final boolean defaultYes;
|
private final boolean defaultYes;
|
||||||
private boolean result;
|
private boolean result;
|
||||||
|
|
||||||
public InputYesOrNo(String message0) {
|
public InputConfirm(String message0) {
|
||||||
this(message0, "Yes", "No", true);
|
this(message0, "Yes", "No", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputYesOrNo(String message0, boolean defaultYes0) {
|
public InputConfirm(String message0, boolean defaultYes0) {
|
||||||
this(message0, "Yes", "No", defaultYes0);
|
this(message0, "Yes", "No", defaultYes0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputYesOrNo(String message0, String yesButtonText0, String noButtonText0) {
|
public InputConfirm(String message0, String yesButtonText0, String noButtonText0) {
|
||||||
this(message0, yesButtonText0, noButtonText0, true);
|
this(message0, yesButtonText0, noButtonText0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputYesOrNo(String message0, String yesButtonText0, String noButtonText0, boolean defaultYes0) {
|
public InputConfirm(String message0, String yesButtonText0, String noButtonText0, boolean defaultYes0) {
|
||||||
this.message = message0;
|
this.message = message0;
|
||||||
this.yesButtonText = yesButtonText0;
|
this.yesButtonText = yesButtonText0;
|
||||||
this.noButtonText = noButtonText0;
|
this.noButtonText = noButtonText0;
|
||||||
@@ -73,7 +58,7 @@ public class InputYesOrNo extends InputSyncronizedBase {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final void showMessage() {
|
protected final void showMessage() {
|
||||||
ButtonUtil.setButtonText(this.yesButtonText, this.noButtonText);
|
ButtonUtil.setButtonText(this.yesButtonText, this.noButtonText);
|
||||||
if (this.defaultYes) {
|
if (this.defaultYes) {
|
||||||
ButtonUtil.enableAllFocusOk();
|
ButtonUtil.enableAllFocusOk();
|
||||||
@@ -30,6 +30,7 @@ import forge.game.card.CounterType;
|
|||||||
import forge.game.combat.Combat;
|
import forge.game.combat.Combat;
|
||||||
import forge.game.combat.CombatUtil;
|
import forge.game.combat.CombatUtil;
|
||||||
import forge.game.cost.Cost;
|
import forge.game.cost.Cost;
|
||||||
|
import forge.game.cost.CostPart;
|
||||||
import forge.game.mana.Mana;
|
import forge.game.mana.Mana;
|
||||||
import forge.game.player.HumanPlay;
|
import forge.game.player.HumanPlay;
|
||||||
import forge.game.player.LobbyPlayer;
|
import forge.game.player.LobbyPlayer;
|
||||||
@@ -461,4 +462,9 @@ public class PlayerControllerForTests extends PlayerController {
|
|||||||
public CounterType chooseCounterType(Collection<CounterType> options, SpellAbility sa, String prompt) {
|
public CounterType chooseCounterType(Collection<CounterType> options, SpellAbility sa, String prompt) {
|
||||||
return Iterables.getFirst(options, CounterType.P1P1);
|
return Iterables.getFirst(options, CounterType.P1P1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean confirmPayment(CostPart costPart, String string) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user