Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions forge-gui/src/main/java/forge/gamemodes/match/AbstractGuiGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.collect.*;
import forge.game.GameEntityView;
import forge.game.GameEndReason;
import forge.game.GameLog;
import forge.game.GameView;
import forge.game.card.CardView;
Expand Down Expand Up @@ -375,6 +376,9 @@ public boolean concede() {
return false;
}
} else {
if (!ignoreConcedeChain && !isNetGame() && forceEndGameForRemainingAIs()) {
return false;
}
return !ignoreConcedeChain;
}
if (isNetGame()) {
Expand Down Expand Up @@ -409,6 +413,32 @@ public boolean concede() {
}
}

private boolean forceEndGameForRemainingAIs() {
final GameView gameView = getGameView();
if (gameView == null) {
return false;
Comment thread
Madwand99 marked this conversation as resolved.
}

boolean hasRemainingAi = false;
for (PlayerView player : gameView.getPlayers()) {
if (!player.getHasLost() && player.isAI()) {
hasRemainingAi = true;
break;
}
}

if (!hasRemainingAi) {
return false;
}

gameView.getGame().getAction().invoke(() -> {
if (!gameView.getGame().isGameOver()) {
gameView.getGame().setGameOver(GameEndReason.AllHumansLost);
}
});
return true;
}

public String getConcedeCaption() {
if (hasLocalPlayers()) {
return Localizer.getInstance().getMessage("lblConcede");
Expand Down
Loading