Fix (now really, I hope) ai vs ai matches in quest tournament mode.

This commit is contained in:
elcnesh
2015-02-23 10:03:41 +00:00
parent 14a80531a1
commit eedb76c31e
3 changed files with 11 additions and 26 deletions

View File

@@ -19,16 +19,13 @@ package forge.screens.match;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import forge.LobbyPlayer;
import forge.Singletons;
import forge.assets.FSkinProp;
import forge.game.GameView;
import forge.game.player.PlayerView;
import forge.gui.SOverlayUtils;
import forge.gui.framework.FScreen;
import forge.match.NextGameDecision;
import forge.model.FModel;
import forge.player.GamePlayerUtil;
import forge.quest.QuestController;
import forge.quest.QuestDraftUtils;
import forge.screens.home.quest.CSubmenuChallenges;
@@ -75,34 +72,18 @@ public class QuestDraftWinLose extends ControlWinLose {
@Override
public final boolean populateCustomPanel() {
QuestController quest = FModel.getQuest();
final LobbyPlayer questLobbyPlayer = GamePlayerUtil.getQuestPlayer();
final Iterable<PlayerView> players = lastGame.getPlayers();
boolean gameHadHumanPlayer = false;
for (final PlayerView p : players) {
if (p.isLobbyPlayer(questLobbyPlayer)) {
gameHadHumanPlayer = true;
break;
}
}
final boolean gameHadHumanPlayer = matchUI.hasLocalPlayers();
if (lastGame.isMatchOver()) {
String winner = lastGame.getWinningPlayer().getName();
final String winner = lastGame.getWinningPlayer().getName();
quest.getAchievements().getCurrentDraft().setWinner(winner);
quest.save();
}
if (!gameHadHumanPlayer) {
if (lastGame.isMatchOver()) {
this.actionOnQuitMatch();
QuestDraftUtils.matchInProgress = false;
QuestDraftUtils.update(matchUI);
}
else {
this.actionOnContinue();
QuestDraftUtils.update(matchUI);
}
return false;
}

View File

@@ -223,11 +223,15 @@ public class HostedMatch {
match.startGame(game);
// After game is over...
if (match.isMatchOver() && humanCount == 0) {
if (humanCount == 0) {
// ... if no human players, let AI decide next game
if (match.isMatchOver()) {
addNextGameDecision(null, NextGameDecision.QUIT);
} else {
addNextGameDecision(null, NextGameDecision.CONTINUE);
}
}
}
});
}

View File

@@ -196,7 +196,7 @@ public class QuestDraftUtils {
rules.canCloneUseTargetsImage = FModel.getPreferences().getPrefBoolean(FPref.UI_CLONE_MODE_SOURCE);
final HostedMatch newMatch = GuiBase.getInterface().hostMatch();
newMatch.startMatch(rules, null, nextMatch.matchStarter, nextMatch.humanPlayer, gui);
newMatch.startMatch(rules, null, nextMatch.matchStarter, nextMatch.humanPlayer, GuiBase.getInterface().getNewGuiGame());
}
public static void continueMatches(final IGuiGame gui) {