mirror of
https://github.com/correl/mage.git
synced 2024-11-24 19:19:56 +00:00
* Fixed a bug that prevented players from paying costs during spell resolution (e.g. Mana Leak) - (fixes #3715).
This commit is contained in:
parent
a9e2303f7e
commit
878ba90625
2 changed files with 119 additions and 64 deletions
|
@ -140,7 +140,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (action.getString() != null
|
||||
&& action.getString().equals("resolveStack")) {
|
||||
action = actionQueue.poll();
|
||||
if (action == null) return false;
|
||||
if (action == null) {
|
||||
return false;
|
||||
}
|
||||
sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, game, null);
|
||||
}
|
||||
synchronized (response) {
|
||||
|
@ -188,7 +190,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
Map<String, Serializable> options = new HashMap<>();
|
||||
options.put("UI.left.btn.text", "Mulligan");
|
||||
options.put("UI.right.btn.text", "Keep");
|
||||
if(!isExecutingMacro()) game.fireAskPlayerEvent(playerId, new MessageToClient(message), null, options);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireAskPlayerEvent(playerId, new MessageToClient(message), null, options);
|
||||
}
|
||||
waitForResponse(game);
|
||||
} while (response.getBoolean() == null && !abort);
|
||||
if (!abort) {
|
||||
|
@ -228,7 +232,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (messageToClient.getSecondMessage() == null) {
|
||||
messageToClient.setSecondMessage(getRelatedObjectName(source, game));
|
||||
}
|
||||
if(!isExecutingMacro()) game.fireAskPlayerEvent(playerId, messageToClient, source, options);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireAskPlayerEvent(playerId, messageToClient, source, options);
|
||||
}
|
||||
waitForResponse(game);
|
||||
} while (response.getBoolean() == null && !abort);
|
||||
if (!abort) {
|
||||
|
@ -287,7 +293,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
replacementEffectChoice.setKeyChoices(rEffects);
|
||||
|
||||
while (!abort) {
|
||||
if(!isExecutingMacro()) game.fireChooseChoiceEvent(playerId, replacementEffectChoice);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireChooseChoiceEvent(playerId, replacementEffectChoice);
|
||||
}
|
||||
updateGameStatePriority("chooseEffect", game);
|
||||
waitForResponse(game);
|
||||
logger.debug("Choose effect: " + response.getString());
|
||||
|
@ -322,7 +330,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
updateGameStatePriority("choose(3)", game);
|
||||
while (!abort) {
|
||||
if(!isExecutingMacro()) game.fireChooseChoiceEvent(playerId, choice);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireChooseChoiceEvent(playerId, choice);
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getString() != null) {
|
||||
choice.setChoice(response.getString());
|
||||
|
@ -364,7 +374,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
List<UUID> chosen = target.getTargets();
|
||||
options.put("chosen", (Serializable) chosen);
|
||||
|
||||
if(!isExecutingMacro()) game.fireSelectTargetEvent(getId(), new MessageToClient(target.getMessage(), getRelatedObjectName(sourceId, game)), targetIds, required, getOptions(target, options));
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireSelectTargetEvent(getId(), new MessageToClient(target.getMessage(), getRelatedObjectName(sourceId, game)), targetIds, required, getOptions(target, options));
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
if (!targetIds.contains(response.getUUID())) {
|
||||
|
@ -429,7 +441,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
required = false;
|
||||
}
|
||||
|
||||
if(!isExecutingMacro()) game.fireSelectTargetEvent(getId(), new MessageToClient(target.getMessage(), getRelatedObjectName(source, game)), possibleTargets, required, getOptions(target, null));
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireSelectTargetEvent(getId(), new MessageToClient(target.getMessage(), getRelatedObjectName(source, game)), possibleTargets, required, getOptions(target, null));
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
if (target.getTargets().contains(response.getUUID())) {
|
||||
|
@ -497,7 +511,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
options.put("choosable", (Serializable) choosable);
|
||||
}
|
||||
|
||||
if(!isExecutingMacro()) game.fireSelectTargetEvent(playerId, new MessageToClient(target.getMessage()), cards, required, options);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireSelectTargetEvent(playerId, new MessageToClient(target.getMessage()), cards, required, options);
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
if (target.canTarget(response.getUUID(), cards, game)) {
|
||||
|
@ -556,7 +572,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (!choosable.isEmpty()) {
|
||||
options.put("choosable", (Serializable) choosable);
|
||||
}
|
||||
if(!isExecutingMacro()) game.fireSelectTargetEvent(playerId, new MessageToClient(target.getMessage(), getRelatedObjectName(source, game)), cards, required, options);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireSelectTargetEvent(playerId, new MessageToClient(target.getMessage(), getRelatedObjectName(source, game)), cards, required, options);
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
if (target.getTargets().contains(response.getUUID())) { // if already included remove it
|
||||
|
@ -583,10 +601,12 @@ public class HumanPlayer extends PlayerImpl {
|
|||
public boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game) {
|
||||
updateGameStatePriority("chooseTargetAmount", game);
|
||||
while (!abort) {
|
||||
if(!isExecutingMacro()) game.fireSelectTargetEvent(playerId, new MessageToClient(target.getMessage() + "\n Amount remaining:" + target.getAmountRemaining(), getRelatedObjectName(source, game)),
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireSelectTargetEvent(playerId, new MessageToClient(target.getMessage() + "\n Amount remaining:" + target.getAmountRemaining(), getRelatedObjectName(source, game)),
|
||||
target.possibleTargets(source == null ? null : source.getSourceId(), playerId, game),
|
||||
target.isRequired(source),
|
||||
getOptions(target, null));
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
if (target.canTarget(response.getUUID(), source, game)) {
|
||||
|
@ -721,7 +741,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
while (canRespond()) {
|
||||
updateGameStatePriority("priority", game);
|
||||
holdingPriority = false;
|
||||
if(!isExecutingMacro()) game.firePriorityEvent(playerId);
|
||||
if (!isExecutingMacro()) {
|
||||
game.firePriorityEvent(playerId);
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (game.executingRollback()) {
|
||||
return true;
|
||||
|
@ -840,7 +862,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
macroTriggeredSelectionFlag = true;
|
||||
updateGameStatePriority("chooseTriggeredAbility", game);
|
||||
if(!isExecutingMacro()) game.fireSelectTargetTriggeredAbilityEvent(playerId, "Pick triggered ability (goes to the stack first)", abilitiesWithNoOrderSet);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireSelectTargetTriggeredAbilityEvent(playerId, "Pick triggered ability (goes to the stack first)", abilitiesWithNoOrderSet);
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
for (TriggeredAbility ability : abilitiesWithNoOrderSet) {
|
||||
|
@ -874,7 +898,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
protected boolean playManaHandling(Ability abilityToCast, ManaCost unpaid, String promptText, Game game) {
|
||||
updateGameStatePriority("playMana", game);
|
||||
Map<String, Serializable> options = new HashMap<>();
|
||||
if(!isExecutingMacro()) game.firePlayManaEvent(playerId, "Pay " + promptText, options);
|
||||
if (!isExecutingMacro()) {
|
||||
game.firePlayManaEvent(playerId, "Pay " + promptText, options);
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (!this.canRespond()) {
|
||||
return false;
|
||||
|
@ -934,7 +960,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
int xValue = 0;
|
||||
updateGameStatePriority("announceXMana", game);
|
||||
do {
|
||||
if(!isExecutingMacro()) game.fireGetAmountEvent(playerId, message, min, max);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireGetAmountEvent(playerId, message, min, max);
|
||||
}
|
||||
waitForResponse(game);
|
||||
} while (response.getInteger() == null
|
||||
&& !abort);
|
||||
|
@ -950,7 +978,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
int xValue = 0;
|
||||
updateGameStatePriority("announceXCost", game);
|
||||
do {
|
||||
if(!isExecutingMacro()) game.fireGetAmountEvent(playerId, message, min, max);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireGetAmountEvent(playerId, message, min, max);
|
||||
}
|
||||
waitForResponse(game);
|
||||
} while (response.getInteger() == null
|
||||
&& !abort);
|
||||
|
@ -968,7 +998,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
return;
|
||||
}
|
||||
Spell spell = game.getStack().getSpell(abilityToCast.getSourceId());
|
||||
if (spell != null
|
||||
if (spell != null && !spell.isResolving()
|
||||
&& spell.isDoneActivatingManaAbilities()) {
|
||||
game.informPlayer(this, "You can no longer use activated mana abilities to pay for the current spell. Cancel and recast the spell and activate mana abilities first.");
|
||||
return;
|
||||
|
@ -1014,7 +1044,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
options.put(Constants.Option.SPECIAL_BUTTON, (Serializable) "All attack");
|
||||
}
|
||||
|
||||
if(!isExecutingMacro()) game.fireSelectEvent(playerId, "Select attackers", options);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireSelectEvent(playerId, "Select attackers", options);
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getString() != null
|
||||
&& response.getString().equals("special")) { // All attack
|
||||
|
@ -1174,7 +1206,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
return;
|
||||
}
|
||||
while (!abort) {
|
||||
if(!isExecutingMacro()) game.fireSelectEvent(playerId, "Select blockers");
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireSelectEvent(playerId, "Select blockers");
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getBoolean() != null) {
|
||||
return;
|
||||
|
@ -1204,7 +1238,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
public UUID chooseAttackerOrder(List<Permanent> attackers, Game game) {
|
||||
updateGameStatePriority("chooseAttackerOrder", game);
|
||||
while (!abort) {
|
||||
if(!isExecutingMacro()) game.fireSelectTargetEvent(playerId, "Pick attacker", attackers, true);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireSelectTargetEvent(playerId, "Pick attacker", attackers, true);
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
for (Permanent perm : attackers) {
|
||||
|
@ -1221,7 +1257,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
public UUID chooseBlockerOrder(List<Permanent> blockers, CombatGroup combatGroup, List<UUID> blockerOrder, Game game) {
|
||||
updateGameStatePriority("chooseBlockerOrder", game);
|
||||
while (!abort) {
|
||||
if(!isExecutingMacro()) game.fireSelectTargetEvent(playerId, "Pick blocker", blockers, true);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireSelectTargetEvent(playerId, "Pick blocker", blockers, true);
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
for (Permanent perm : blockers) {
|
||||
|
@ -1237,8 +1275,10 @@ public class HumanPlayer extends PlayerImpl {
|
|||
protected void selectCombatGroup(UUID defenderId, UUID blockerId, Game game) {
|
||||
updateGameStatePriority("selectCombatGroup", game);
|
||||
TargetAttackingCreature target = new TargetAttackingCreature();
|
||||
if(!isExecutingMacro()) game.fireSelectTargetEvent(playerId, new MessageToClient("Select attacker to block", getRelatedObjectName(blockerId, game)),
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireSelectTargetEvent(playerId, new MessageToClient("Select attacker to block", getRelatedObjectName(blockerId, game)),
|
||||
target.possibleTargets(null, playerId, game), false, getOptions(target, null));
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getBoolean() != null) {
|
||||
// do nothing
|
||||
|
@ -1287,7 +1327,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
public int getAmount(int min, int max, String message, Game game) {
|
||||
updateGameStatePriority("getAmount", game);
|
||||
do {
|
||||
if(!isExecutingMacro()) game.fireGetAmountEvent(playerId, message, min, max);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireGetAmountEvent(playerId, message, min, max);
|
||||
}
|
||||
waitForResponse(game);
|
||||
} while (response.getInteger() == null && !abort);
|
||||
if (response != null && response.getInteger() != null) {
|
||||
|
@ -1316,7 +1358,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
LinkedHashMap<UUID, SpecialAction> specialActions = game.getState().getSpecialActions().getControlledBy(playerId, false);
|
||||
if (!specialActions.isEmpty()) {
|
||||
updateGameStatePriority("specialAction", game);
|
||||
if(!isExecutingMacro()) game.fireGetChoiceEvent(playerId, name, null, new ArrayList<>(specialActions.values()));
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireGetChoiceEvent(playerId, name, null, new ArrayList<>(specialActions.values()));
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
if (specialActions.containsKey(response.getUUID())) {
|
||||
|
@ -1330,7 +1374,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
LinkedHashMap<UUID, SpecialAction> specialActions = game.getState().getSpecialActions().getControlledBy(playerId, true);
|
||||
if (!specialActions.isEmpty()) {
|
||||
updateGameStatePriority("specialAction", game);
|
||||
if(!isExecutingMacro()) game.fireGetChoiceEvent(playerId, name, null, new ArrayList<>(specialActions.values()));
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireGetChoiceEvent(playerId, name, null, new ArrayList<>(specialActions.values()));
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
if (specialActions.containsKey(response.getUUID())) {
|
||||
|
@ -1373,7 +1419,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
}
|
||||
|
||||
if(!isExecutingMacro()) game.fireGetChoiceEvent(playerId, name, object, new ArrayList<>(abilities.values()));
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireGetChoiceEvent(playerId, name, object, new ArrayList<>(abilities.values()));
|
||||
}
|
||||
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null && isInGame()) {
|
||||
|
@ -1411,7 +1459,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
return (SpellAbility) useableAbilities.values().iterator().next();
|
||||
} else if (useableAbilities != null
|
||||
&& !useableAbilities.isEmpty()) {
|
||||
if(!isExecutingMacro()) game.fireGetChoiceEvent(playerId, name, object, new ArrayList<>(useableAbilities.values()));
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireGetChoiceEvent(playerId, name, object, new ArrayList<>(useableAbilities.values()));
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
if (useableAbilities.containsKey(response.getUUID())) {
|
||||
|
@ -1461,7 +1511,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (!modeMap.isEmpty()) {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
if(!isExecutingMacro()) game.fireGetModeEvent(playerId, "Choose Mode", modeMap);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireGetModeEvent(playerId, "Choose Mode", modeMap);
|
||||
}
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
for (Mode mode : modes.getAvailableModes(source, game)) {
|
||||
|
@ -1488,7 +1540,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
public boolean choosePile(Outcome outcome, String message, List<? extends Card> pile1, List<? extends Card> pile2, Game game) {
|
||||
updateGameStatePriority("choosePile", game);
|
||||
do {
|
||||
if(!isExecutingMacro()) game.fireChoosePileEvent(playerId, message, pile1, pile2);
|
||||
if (!isExecutingMacro()) {
|
||||
game.fireChoosePileEvent(playerId, message, pile1, pile2);
|
||||
}
|
||||
waitForResponse(game);
|
||||
} while (response.getBoolean() == null && !abort);
|
||||
if (!abort) {
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
*/
|
||||
package mage.game.stack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
|
@ -59,16 +63,6 @@ import mage.players.Player;
|
|||
import mage.util.GameLog;
|
||||
import mage.util.SubTypeList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -90,6 +84,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
private boolean copiedSpell;
|
||||
private boolean faceDown;
|
||||
private boolean countered;
|
||||
private boolean resolving = false;
|
||||
|
||||
private boolean doneActivatingManaAbilities; // if this is true, the player is no longer allowed to pay the spell costs with activating of mana abilies
|
||||
|
||||
|
@ -196,6 +191,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
this.resolving = true;
|
||||
if (this.isInstant() || this.isSorcery()) {
|
||||
int index = 0;
|
||||
result = false;
|
||||
|
@ -262,7 +258,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
if (permanent != null && permanent instanceof PermanentCard) {
|
||||
permanent.setSpellAbility(ability); // otherwise spell ability without bestow will be set
|
||||
card.addCardType(CardType.CREATURE);
|
||||
card.getSubtype(game).remove("Aura");
|
||||
card.getSubtype(game).remove(SubType.AURA);
|
||||
}
|
||||
}
|
||||
return ability.resolve(game);
|
||||
|
@ -279,7 +275,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null && permanent instanceof PermanentCard) {
|
||||
((PermanentCard) permanent).getCard().addCardType(CardType.CREATURE);
|
||||
((PermanentCard) permanent).getCard().getSubtype(game).remove("Aura");
|
||||
((PermanentCard) permanent).getCard().getSubtype(game).remove(SubType.AURA);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -907,6 +903,10 @@ public class Spell extends StackObjImpl implements Card {
|
|||
return countered;
|
||||
}
|
||||
|
||||
public boolean isResolving() {
|
||||
return resolving;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkForCountersToAdd(Permanent permanent, Game game) {
|
||||
card.checkForCountersToAdd(permanent, game);
|
||||
|
@ -927,5 +927,6 @@ public class Spell extends StackObjImpl implements Card {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void setIsAllCreatureTypes(boolean value){}
|
||||
public void setIsAllCreatureTypes(boolean value) {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue