Fix 1 Spectator N AI games in seemingly endless loop (#6337)

This commit is contained in:
SomeTroglodyte
2022-03-13 21:38:11 +01:00
committed by GitHub
parent 877dedaa89
commit c51f3b47de
3 changed files with 18 additions and 12 deletions

View File

@ -214,7 +214,7 @@ class GameInfo {
//check is important or else switchTurn
//would skip a turn if an AI civ calls nextTurn
//this happens when resigning a multiplayer game
if (thisPlayer.isPlayerCivilization()){
if (thisPlayer.isPlayerCivilization()) {
switchTurn()
}
@ -223,7 +223,7 @@ class GameInfo {
|| turns < simulateMaxTurns && simulateUntilWin
// For multiplayer, if there are 3+ players and one is defeated or spectator,
// we'll want to skip over their turn
|| gameParameters.isOnlineMultiplayer && (thisPlayer.isDefeated() || thisPlayer.isSpectator())
|| gameParameters.isOnlineMultiplayer && (thisPlayer.isDefeated() || thisPlayer.isSpectator() && thisPlayer.playerId != UncivGame.Current.settings.userId)
) {
if (!thisPlayer.isDefeated() || thisPlayer.isBarbarian()) {
NextTurnAutomation.automateCivMoves(thisPlayer)

View File

@ -489,11 +489,12 @@ class CivilizationInfo {
diplomacy[otherCiv.civName] = DiplomacyManager(this, otherCiv.civName)
.apply { diplomaticStatus = DiplomaticStatus.Peace }
otherCiv.popupAlerts.add(PopupAlert(AlertType.FirstContact, civName))
if (!otherCiv.isSpectator())
otherCiv.popupAlerts.add(PopupAlert(AlertType.FirstContact, civName))
if (isCurrentPlayer())
UncivGame.Current.settings.addCompletedTutorialTask("Meet another civilization")
if (!(isCityState() && otherCiv.isMajorCiv())) return
if (warOnContact || otherCiv.isMinorCivAggressor()) return // No gift if they are bad people, or we are just about to be at war

View File

@ -60,14 +60,6 @@ class NewGameScreen(
rightSideButton.enable()
rightSideButton.setText("Start game!".tr())
rightSideButton.onClick {
if (gameSetupInfo.gameParameters.players.none { it.playerType == PlayerType.Human }) {
val noHumanPlayersPopup = Popup(this)
noHumanPlayersPopup.addGoodSizedLabel("No human players selected!".tr()).row()
noHumanPlayersPopup.addCloseButton()
noHumanPlayersPopup.open()
return@onClick
}
if (gameSetupInfo.gameParameters.isOnlineMultiplayer) {
for (player in gameSetupInfo.gameParameters.players.filter { it.playerType == PlayerType.Human }) {
try {
@ -82,6 +74,19 @@ class NewGameScreen(
}
}
if (gameSetupInfo.gameParameters.players.none {
it.playerType == PlayerType.Human &&
// do not allow multiplayer with only remote spectator(s) and AI(s) - non-MP that works
!(it.chosenCiv == Constants.spectator && gameSetupInfo.gameParameters.isOnlineMultiplayer &&
it.playerId != UncivGame.Current.settings.userId)
}) {
val noHumanPlayersPopup = Popup(this)
noHumanPlayersPopup.addGoodSizedLabel("No human players selected!".tr()).row()
noHumanPlayersPopup.addCloseButton()
noHumanPlayersPopup.open()
return@onClick
}
Gdx.input.inputProcessor = null // remove input processing - nothing will be clicked!
if (mapOptionsTable.mapTypeSelectBox.selected.value == MapType.custom) {