mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
ManaPay no longer hangs when mana is paid from pool, method to resolve mana abilities removed from GameActionPlay
This commit is contained in:
@@ -1,14 +1,12 @@
|
|||||||
package forge.control.input;
|
package forge.control.input;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
|
import forge.FThreads;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
@@ -129,6 +127,7 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
|
|||||||
this.manaCost = mp.payManaFromPool(saPaidFor, manaCost, manaStr);
|
this.manaCost = mp.payManaFromPool(saPaidFor, manaCost, manaStr);
|
||||||
|
|
||||||
onManaAbilityPlayed(null);
|
onManaAbilityPlayed(null);
|
||||||
|
showMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -280,15 +279,7 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SpellAbility chosen = abilities.get(0);
|
final SpellAbility chosen = abilities.size() > 1 && choice ? GuiChoose.one("Choose mana ability", abilities) : abilities.get(0);
|
||||||
if ((1 < abilities.size()) && choice) {
|
|
||||||
final Map<String, SpellAbility> ability = new HashMap<String, SpellAbility>();
|
|
||||||
for (final SpellAbility am : abilities) {
|
|
||||||
ability.put(am.toString(), am);
|
|
||||||
}
|
|
||||||
chosen = GuiChoose.one("Choose mana ability", abilities);
|
|
||||||
}
|
|
||||||
|
|
||||||
SpellAbility subchosen = chosen;
|
SpellAbility subchosen = chosen;
|
||||||
while(subchosen.getManaPart() == null)
|
while(subchosen.getManaPart() == null)
|
||||||
{
|
{
|
||||||
@@ -298,18 +289,19 @@ public abstract class InputPayManaBase extends InputSyncronizedBase implements I
|
|||||||
// save off color needed for use by any mana and reflected mana
|
// save off color needed for use by any mana and reflected mana
|
||||||
subchosen.getManaPart().setExpressChoice(colorsNeeded);
|
subchosen.getManaPart().setExpressChoice(colorsNeeded);
|
||||||
|
|
||||||
final SpellAbility finallyChosen = chosen;
|
|
||||||
// System.out.println("Chosen sa=" + chosen + " of " + chosen.getSourceCard() + " to pay mana");
|
// System.out.println("Chosen sa=" + chosen + " of " + chosen.getSourceCard() + " to pay mana");
|
||||||
Player p = chosen.getActivatingPlayer();
|
Runnable proc = new Runnable() {
|
||||||
p.getGame().getActionPlay().playManaAbilityAsPayment(finallyChosen, p, new Runnable( ) {
|
@Override
|
||||||
@Override public void run() {
|
public void run() {
|
||||||
onManaAbilityPlayed(finallyChosen);
|
final Player p = chosen.getActivatingPlayer();
|
||||||
|
p.getGame().getActionPlay().playSpellAbility(chosen, p);
|
||||||
|
onManaAbilityPlayed(chosen);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
// EDT that removes lockUI from stack will call our showMessage() method
|
FThreads.invokeInNewThread(proc, true);
|
||||||
|
// EDT that removes lockUI from input stack will call our showMessage() method
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void onManaAbilityPlayed(final SpellAbility saPaymentSrc) {
|
public void onManaAbilityPlayed(final SpellAbility saPaymentSrc) {
|
||||||
if ( saPaymentSrc != null) // null comes when they've paid from pool
|
if ( saPaymentSrc != null) // null comes when they've paid from pool
|
||||||
this.manaCost = whoPays.getManaPool().payManaFromAbility(saPaidFor, manaCost, saPaymentSrc);
|
this.manaCost = whoPays.getManaPool().payManaFromAbility(saPaidFor, manaCost, saPaymentSrc);
|
||||||
|
|||||||
@@ -508,23 +508,4 @@ public class GameActionPlay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this method.
|
|
||||||
* @param chosen
|
|
||||||
* @param p
|
|
||||||
* @param inputPayManaBase
|
|
||||||
* @param manaCost
|
|
||||||
* @param saPaidFor
|
|
||||||
*/
|
|
||||||
public void playManaAbilityAsPayment(final SpellAbility chosen, final Player p, final Runnable beforeUnlock) {;
|
|
||||||
Runnable proc = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
playSpellAbility(chosen, p);
|
|
||||||
beforeUnlock.run();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
FThreads.invokeInNewThread(proc, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user