mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
Prompt when passing priority if mana in your mana pool would be lost
This commit is contained in:
@@ -92,6 +92,28 @@ public class ManaPool implements Iterable<Mana> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* willManaBeLostAtEndOfPhase.
|
||||
*
|
||||
* @return - whether floating mana will be lost if the current phase ended right now
|
||||
* </p>
|
||||
*/
|
||||
public final boolean willManaBeLostAtEndOfPhase() {
|
||||
if (floatingMana.isEmpty() ||
|
||||
owner.getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.manapoolsDontEmpty) ||
|
||||
owner.hasKeyword("Convert unused mana to Colorless")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (owner.hasKeyword("Green mana doesn't empty from your mana pool as steps and phases end.") &&
|
||||
getAmountOfColor(MagicColor.GREEN) == totalMana()) {
|
||||
return false; //won't lose floating mana if all mana is green and green mana isn't going to be emptied
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* clearPool.
|
||||
@@ -101,14 +123,14 @@ public class ManaPool implements Iterable<Mana> {
|
||||
*/
|
||||
public final int clearPool(boolean isEndOfPhase) {
|
||||
// isEndOfPhase parameter: true = end of phase, false = mana drain effect
|
||||
if (this.floatingMana.isEmpty()) { return 0; }
|
||||
if (floatingMana.isEmpty()) { return 0; }
|
||||
|
||||
if (isEndOfPhase && owner.getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.manapoolsDontEmpty)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int numRemoved = 0;
|
||||
boolean keepGreenMana = isEndOfPhase && this.owner.hasKeyword("Green mana doesn't empty from your mana pool as steps and phases end.");
|
||||
boolean keepGreenMana = isEndOfPhase && owner.hasKeyword("Green mana doesn't empty from your mana pool as steps and phases end.");
|
||||
boolean convertToColorless = owner.hasKeyword("Convert unused mana to Colorless");
|
||||
|
||||
List<Byte> keys = Lists.newArrayList(floatingMana.keySet());
|
||||
@@ -122,7 +144,7 @@ public class ManaPool implements Iterable<Mana> {
|
||||
for (Byte b : keys) {
|
||||
if (isEndOfPhase && !owner.getGame().getPhaseHandler().is(PhaseType.CLEANUP)) {
|
||||
final List<Mana> pMana = new ArrayList<Mana>();
|
||||
for (final Mana mana : this.floatingMana.get(b)) {
|
||||
for (final Mana mana : floatingMana.get(b)) {
|
||||
if (mana.getManaAbility()!= null && mana.getManaAbility().isPersistentMana()) {
|
||||
pMana.add(mana);
|
||||
}
|
||||
|
||||
@@ -17,12 +17,18 @@
|
||||
*/
|
||||
package forge.match.input;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.game.Game;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.util.ITriggerEvent;
|
||||
import forge.util.ThreadUtil;
|
||||
import forge.util.gui.SOptionPane;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -61,7 +67,12 @@ public class InputPassPriority extends InputSyncronizedBase {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected final void onOk() {
|
||||
stop();
|
||||
passPriority(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@@ -69,11 +80,38 @@ public class InputPassPriority extends InputSyncronizedBase {
|
||||
protected final void onCancel() {
|
||||
if (!MatchUtil.undoLastAction()) { //undo if possible
|
||||
//otherwise end turn
|
||||
player.getController().autoPassUntil(PhaseType.CLEANUP);
|
||||
stop();
|
||||
passPriority(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.getController().autoPassUntil(PhaseType.CLEANUP);
|
||||
stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void passPriority(final Runnable runnable) {
|
||||
//if gui player has mana floating that will be lost if phase ended right now, prompt before passing priority
|
||||
Game game = GuiBase.getInterface().getGame();
|
||||
Player player = game.getPhaseHandler().getPriorityPlayer();
|
||||
if (player != null && player.getManaPool().willManaBeLostAtEndOfPhase() && player.getLobbyPlayer() == GuiBase.getInterface().getGuiPlayer()) {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() { //must invoke in game thread so dialog can be shown on mobile game
|
||||
@Override
|
||||
public void run() {
|
||||
String message = "You have mana floating in your mana pool that will be lost if you pass priority now.";
|
||||
if (FModel.getPreferences().getPrefBoolean(FPref.UI_MANABURN)) {
|
||||
message += " You will take mana burn damage equal to the amount of floating mana.";
|
||||
}
|
||||
if (SOptionPane.showOptionDialog(message, "Mana Floating", SOptionPane.WARNING_ICON, new String[]{"OK", "Cancel"}) == 0) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
runnable.run(); //just pass priority immediately if no mana floating that would be lost
|
||||
}
|
||||
|
||||
public SpellAbility getChosenSa() { return chosenSa; }
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user