mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
AI won't gain priority during UNTAP step
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package forge;
|
package forge;
|
||||||
|
|
||||||
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
@@ -103,6 +104,17 @@ public class FThreads {
|
|||||||
getCachedPool().execute(toRun);
|
getCachedPool().execute(toRun);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void dumpStackTrace(PrintStream stream) {
|
||||||
|
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
|
||||||
|
stream.printf("%s > %s called from %s%n", debugGetCurrThreadId(), trace[2].getClassName()+"."+trace[2].getMethodName(), trace[3].toString());
|
||||||
|
int i = 0;
|
||||||
|
for(StackTraceElement se : trace) {
|
||||||
|
if(i<2) i++;
|
||||||
|
else stream.println(se.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void invokeInNewThread(final Runnable proc, boolean lockUI) {
|
public static void invokeInNewThread(final Runnable proc, boolean lockUI) {
|
||||||
Runnable toRun = proc;
|
Runnable toRun = proc;
|
||||||
final InputQueue iq = Singletons.getControl().getMatch().getInput();
|
final InputQueue iq = Singletons.getControl().getMatch().getInput();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package forge.control.input;
|
|||||||
|
|
||||||
import java.util.concurrent.BlockingDeque;
|
import java.util.concurrent.BlockingDeque;
|
||||||
import java.util.concurrent.LinkedBlockingDeque;
|
import java.util.concurrent.LinkedBlockingDeque;
|
||||||
|
|
||||||
import forge.game.GameAge;
|
import forge.game.GameAge;
|
||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
import forge.game.phase.PhaseHandler;
|
import forge.game.phase.PhaseHandler;
|
||||||
@@ -134,7 +135,6 @@ public class InputQueue extends MyObservable implements java.io.Serializable {
|
|||||||
throw new RuntimeException("No player has priority!");
|
throw new RuntimeException("No player has priority!");
|
||||||
PlayerController pc = priority.getController();
|
PlayerController pc = priority.getController();
|
||||||
|
|
||||||
|
|
||||||
// If the Phase we're in doesn't allow for Priority, move to next phase
|
// If the Phase we're in doesn't allow for Priority, move to next phase
|
||||||
if (!handler.isPlayerPriorityAllowed()) {
|
if (!handler.isPlayerPriorityAllowed()) {
|
||||||
return pc.getAutoPassPriorityInput();
|
return pc.getAutoPassPriorityInput();
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
|
|
||||||
import forge.Constant.Preferences;
|
import forge.Constant.Preferences;
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
@@ -23,6 +21,7 @@ import forge.game.player.LobbyPlayer;
|
|||||||
import forge.game.player.LobbyPlayerHuman;
|
import forge.game.player.LobbyPlayerHuman;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.player.PlayerStatistics;
|
import forge.game.player.PlayerStatistics;
|
||||||
|
import forge.gui.GuiDialog;
|
||||||
import forge.gui.framework.EDocID;
|
import forge.gui.framework.EDocID;
|
||||||
import forge.gui.framework.SDisplayUtil;
|
import forge.gui.framework.SDisplayUtil;
|
||||||
import forge.gui.match.CMatchUI;
|
import forge.gui.match.CMatchUI;
|
||||||
@@ -365,22 +364,25 @@ public class MatchController {
|
|||||||
private Player determineFirstTurnPlayer(final GameOutcome lastGameOutcome, final GameState game) {
|
private Player determineFirstTurnPlayer(final GameOutcome lastGameOutcome, final GameState game) {
|
||||||
// Only cut/coin toss if it's the first game of the match
|
// Only cut/coin toss if it's the first game of the match
|
||||||
Player goesFirst = null;
|
Player goesFirst = null;
|
||||||
Player humanPlayer = Singletons.getControl().getPlayer();
|
final String message;
|
||||||
|
//Player humanPlayer = Singletons.getControl().getPlayer();
|
||||||
boolean isFirstGame = lastGameOutcome == null;
|
boolean isFirstGame = lastGameOutcome == null;
|
||||||
if (isFirstGame) {
|
if (isFirstGame) {
|
||||||
goesFirst = seeWhoPlaysFirstDice(game);
|
goesFirst = seeWhoPlaysFirstDice(game);
|
||||||
|
message = goesFirst + " has won the coin toss.";
|
||||||
} else {
|
} else {
|
||||||
for(Player p : game.getPlayers()) {
|
for(Player p : game.getPlayers()) {
|
||||||
if(lastGameOutcome.isWinner(p.getLobbyPlayer())) {
|
if(!lastGameOutcome.isWinner(p.getLobbyPlayer())) {
|
||||||
goesFirst = p.getOpponent();
|
goesFirst = p;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
message = goesFirst + " lost the last game.";
|
||||||
}
|
}
|
||||||
String message = goesFirst + ( isFirstGame ? " has won the coin toss." : " lost the last game.");
|
|
||||||
boolean willPlay = goesFirst.getController().getWillPlayOnFirstTurn(message);
|
boolean willPlay = goesFirst.getController().getWillPlayOnFirstTurn(message);
|
||||||
if ( goesFirst != humanPlayer ) {
|
if ( goesFirst != FControl.SINGLETON_INSTANCE.getPlayer() ) {
|
||||||
JOptionPane.showMessageDialog(null, message + "\nComputer Going First", "You are drawing", JOptionPane.INFORMATION_MESSAGE);
|
GuiDialog.message(message + "\nComputer Going First");
|
||||||
}
|
}
|
||||||
goesFirst = willPlay ? goesFirst : goesFirst.getOpponent();
|
goesFirst = willPlay ? goesFirst : goesFirst.getOpponent();
|
||||||
game.getPhaseHandler().setPlayerTurn(goesFirst);
|
game.getPhaseHandler().setPlayerTurn(goesFirst);
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
|||||||
switch(this.getPhase()) {
|
switch(this.getPhase()) {
|
||||||
case UNTAP:
|
case UNTAP:
|
||||||
//SDisplayUtil.showTab(EDocID.REPORT_STACK.getDoc());
|
//SDisplayUtil.showTab(EDocID.REPORT_STACK.getDoc());
|
||||||
|
game.getPhaseHandler().setPlayersPriorityPermission(false);
|
||||||
updateObservers();
|
updateObservers();
|
||||||
PhaseUtil.handleUntap(game);
|
PhaseUtil.handleUntap(game);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ public class PhaseUtil {
|
|||||||
// phase is skipped
|
// phase is skipped
|
||||||
|
|
||||||
if (PhaseUtil.skipUntap(turn)) {
|
if (PhaseUtil.skipUntap(turn)) {
|
||||||
game.getPhaseHandler().setPlayersPriorityPermission(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,8 +111,6 @@ public class PhaseUtil {
|
|||||||
|
|
||||||
// otherwise land seems to stay tapped when it is really untapped
|
// otherwise land seems to stay tapped when it is really untapped
|
||||||
// AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers();
|
// AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers();
|
||||||
|
|
||||||
game.getPhaseHandler().setPlayersPriorityPermission(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user