Make end turn button automatically pass priority if possible, and otherwise not end turn

This commit is contained in:
drdev
2014-01-08 01:33:02 +00:00
parent 764310e08b
commit 1c6ccbb20a
3 changed files with 41 additions and 19 deletions

View File

@@ -64,7 +64,7 @@ public abstract class PlayerController {
protected final Game game;
private PhaseType autoPassUntil = null;
private PhaseType autoPassUntilPhase = null;
protected final Player player;
protected final LobbyPlayer lobbyPlayer;
@@ -75,21 +75,21 @@ public abstract class PlayerController {
}
/**
* TODO: Write javadoc for this method.
* @param cleanup
* Automatically pass priority until reaching the given phase of the current turn
* @param phase
*/
public void autoPassTo(PhaseType cleanup) {
autoPassUntil = cleanup;
public void autoPassUntil(PhaseType phase) {
autoPassUntilPhase = phase;
}
public void autoPassCancel() {
autoPassUntil = null;
autoPassUntilPhase = null;
}
public boolean mayAutoPass(PhaseType phase) {
return phase.isBefore(autoPassUntil);
return phase.isBefore(autoPassUntilPhase);
}
// Triggers preliminary choice: ask, decline or play
private Map<Integer, Boolean> triggersAlwaysAccept = new HashMap<Integer, Boolean>();
@@ -214,8 +214,4 @@ public abstract class PlayerController {
// These 2 are for AI
public List<Card> cheatShuffle(List<Card> list) { return list; }
public Collection<? extends PaperCard> complainCardsCantPlayWell(Deck myDeck) { return null; }
}

View File

@@ -29,6 +29,8 @@ import forge.game.card.Card;
import forge.game.player.Player;
import forge.game.spellability.SpellAbility;
import forge.gui.input.Input;
import forge.gui.input.InputPassPriority;
import forge.gui.toolbox.FOptionPane;
/**
* <p>
@@ -51,6 +53,22 @@ public class InputProxy implements Observer {
Singletons.getControl().getInputQueue().addObserver(this);
}
public boolean passPriority() {
Input inp = getInput();
if (inp != null && inp instanceof InputPassPriority) {
inp.selectButtonOK();
return true;
}
FThreads.invokeInEdtNowOrLater(new Runnable() {
@Override
public void run() {
FOptionPane.showMessageDialog("Cannot pass priority at this time.");
}
});
return false;
}
@Override
public final void update(final Observable observable, final Object obj) {
final Input nextInput = Singletons.getControl().getInputQueue().getActualInput(game);
@@ -79,9 +97,10 @@ public class InputProxy implements Observer {
*/
public final void selectButtonOK() {
Input inp = getInput();
if ( null != inp )
if (inp != null) {
inp.selectButtonOK();
}
}
/**
* <p>
@@ -90,9 +109,10 @@ public class InputProxy implements Observer {
*/
public final void selectButtonCancel() {
Input inp = getInput();
if ( null != inp )
if (inp != null) {
inp.selectButtonCancel();
}
}
/**
* <p>
@@ -104,9 +124,10 @@ public class InputProxy implements Observer {
*/
public final void selectPlayer(final Player player, final MouseEvent triggerEvent) {
Input inp = getInput();
if ( null != inp )
if (inp != null) {
inp.selectPlayer(player, triggerEvent);
}
}
/**
* <p>
@@ -119,15 +140,17 @@ public class InputProxy implements Observer {
*/
public final void selectCard(final Card card, final MouseEvent triggerEvent) {
Input inp = getInput();
if ( null != inp )
if (inp != null) {
inp.selectCard(card, triggerEvent);
}
}
public final void selectAbility(SpellAbility ab) {
Input inp = getInput();
if ( null != inp )
if (inp != null) {
inp.selectAbility(ab);
}
}
/** {@inheritDoc} */
@Override

View File

@@ -80,7 +80,10 @@ public enum CDock implements ICDoc {
Player p = findAffectedPlayer();
if (p != null) {
p.getController().autoPassTo(PhaseType.CLEANUP);
p.getController().autoPassUntil(PhaseType.CLEANUP);
if (!CPrompt.SINGLETON_INSTANCE.getInputControl().passPriority()) {
p.getController().autoPassCancel();
}
}
}