mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
* Fixed a bug that the win method for a player did not handle the range correctly and did erroneously end the game while still multiple players alive (related to #6553).
This commit is contained in:
parent
365754b6f7
commit
d2b8928e60
3 changed files with 76 additions and 8 deletions
|
|
@ -2526,12 +2526,14 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
opponent.lostForced(game);
|
||||
}
|
||||
}
|
||||
// if no more opponents alive, you win and the game ends
|
||||
// if no more opponents alive (independant from range), you win and the game ends
|
||||
int opponentsAlive = 0;
|
||||
for (UUID opponentId : game.getOpponents(playerId)) {
|
||||
Player opponent = game.getPlayer(opponentId);
|
||||
if (opponent != null && !opponent.hasLost()) {
|
||||
opponentsAlive++;
|
||||
for (UUID playerIdToCheck : game.getPlayerList()) {
|
||||
if (game.isOpponent(this, playerIdToCheck)) { // Check without range
|
||||
Player opponent = game.getPlayer(playerIdToCheck);
|
||||
if (opponent != null && !opponent.hasLost()) {
|
||||
opponentsAlive++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (opponentsAlive == 0 && !hasWon()) {
|
||||
|
|
@ -2541,7 +2543,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
game.end();
|
||||
}
|
||||
} else {
|
||||
logger.debug("player won -> but already lost before: " + this.getName());
|
||||
logger.debug("player won -> but already lost before or other players still alive: " + this.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue