Added skip-all-turns-and-actions feature. Bound to F9.

This commit is contained in:
magenoxx 2012-07-18 10:15:50 +04:00
parent 391b1893da
commit ed0af0faee
6 changed files with 38 additions and 8 deletions

View file

@ -739,6 +739,17 @@ public class GamePanel extends javax.swing.JPanel {
}
});
KeyStroke ks8 = KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0);
this.getInputMap(c).put(ks8, "F9_PRESS");
this.getActionMap().put("F9_PRESS", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
if (feedbackPanel != null && FeedbackMode.SELECT.equals(feedbackPanel.getMode())) {
session.sendPlayerInteger(gameId, -9999);
}
}
});
KeyStroke ksAltShift = KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK);
this.getInputMap(c).put(ksAltShift, "ENLARGE");
this.getActionMap().put("ENLARGE", new AbstractAction() {

View file

@ -371,6 +371,10 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
public boolean priority(Game game) {
passed = false;
if (!abort) {
if (passedAllTurns) {
pass();
return false;
}
if (passedTurn && game.getStack().isEmpty()) {
pass();
return false;
@ -382,6 +386,9 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
pass();
return false;
} else if (response.getInteger() != null) {
if (response.getInteger() == -9999) {
passedAllTurns = true;
}
pass();
passedTurn = true;
return false;

View file

@ -28,12 +28,7 @@
package mage.game;
import mage.Constants.CardType;
import mage.Constants.MultiplayerAttackOption;
import mage.Constants.Outcome;
import mage.Constants.PhaseStep;
import mage.Constants.RangeOfInfluence;
import mage.Constants.Zone;
import mage.Constants.*;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
@ -55,9 +50,9 @@ import mage.cards.decks.Deck;
import mage.choices.Choice;
import mage.counters.CounterType;
import mage.filter.Filter;
import mage.filter.Filter.ComparisonScope;
import mage.filter.common.*;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.combat.Combat;
import mage.game.command.CommandObject;
import mage.game.command.Emblem;
@ -85,7 +80,6 @@ import org.apache.log4j.Logger;
import java.io.IOException;
import java.io.Serializable;
import java.util.*;
import mage.filter.predicate.mageobject.SubtypePredicate;
public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializable {
@ -462,6 +456,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
fireInformEvent("Turn " + Integer.toString(state.getTurnNum()));
if (checkStopOnTurnOption()) return;
state.setActivePlayerId(player.getId());
player.becomesActivePlayer();
state.getTurn().play(this, player.getId());
if (isPaused() || isGameOver())
break;

View file

@ -256,4 +256,9 @@ public interface Player extends MageItem, Copyable<Player> {
public List<UUID> getAttachments();
public boolean addAttachment(UUID permanentId, Game game);
public boolean removeAttachment(UUID permanentId, Game game);
/**
* Signals that the player becomes active player in this turn.
*/
public void becomesActivePlayer();
}

View file

@ -97,6 +97,11 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
protected ManaPool manaPool;
protected boolean passed;
protected boolean passedTurn;
/**
* This indicates that player passed all turns until his own turn starts.
* Note! This differs from passedTurn as it doesn't care about spells and abilities in the stack and will pass them as well.
*/
protected boolean passedAllTurns;
protected boolean left;
protected RangeOfInfluence range;
protected Set<UUID> inRange = new HashSet<UUID>();
@ -152,6 +157,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
this.manaPool = player.manaPool.copy();
this.passed = player.passed;
this.passedTurn = player.passedTurn;
this.passedAllTurns = player.passedAllTurns;
this.left = player.left;
this.range = player.range;
this.canGainLife = player.canGainLife;
@ -188,6 +194,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
this.left = false;
this.passed = false;
this.passedTurn = false;
this.passedAllTurns = false;
this.canGainLife = true;
this.canLoseLife = true;
game.getState().getWatchers().add(new BloodthirstWatcher(playerId));
@ -1445,4 +1452,9 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
public boolean autoLoseGame() {
return false;
}
@Override
public void becomesActivePlayer() {
this.passedAllTurns = false;
}
}