mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Improve can't win/lose effects for multiplayer
Fixes: core-developers/forge#170 Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>
This commit is contained in:
@@ -1206,6 +1206,7 @@ public class GameAction {
|
||||
public void checkGameOverCondition() {
|
||||
// award loses as SBE
|
||||
List<Player> losers = null;
|
||||
|
||||
FCollectionView<Player> allPlayers = game.getPlayers();
|
||||
for (Player p : allPlayers) {
|
||||
if (p.checkLoseCondition()) { // this will set appropriate outcomes
|
||||
@@ -1219,14 +1220,14 @@ public class GameAction {
|
||||
|
||||
GameEndReason reason = null;
|
||||
// Has anyone won by spelleffect?
|
||||
for (Player p : game.getPlayers()) {
|
||||
for (Player p : allPlayers) {
|
||||
if (!p.hasWon()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// then the rest have lost!
|
||||
reason = GameEndReason.WinsGameSpellEffect;
|
||||
for (Player pl : game.getPlayers()) {
|
||||
for (Player pl : allPlayers) {
|
||||
if (pl.equals(p)) {
|
||||
continue;
|
||||
}
|
||||
@@ -1243,6 +1244,23 @@ public class GameAction {
|
||||
break;
|
||||
}
|
||||
|
||||
// loop through all the non-losing players that can't win
|
||||
// see if all of their opponents are in that "about to lose" collection
|
||||
if (losers != null) {
|
||||
for (Player p : allPlayers) {
|
||||
if (losers.contains(p)) {
|
||||
continue;
|
||||
}
|
||||
if (p.cantWin()) {
|
||||
if (losers.containsAll(p.getOpponents())) {
|
||||
// what to do here?!?!?!
|
||||
System.err.println(p.toString() + " is about to win, but can't!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// need a separate loop here, otherwise ConcurrentModificationException is raised
|
||||
if (losers != null) {
|
||||
for (Player p : losers) {
|
||||
|
||||
@@ -1825,7 +1825,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
if (getOutcome() != null && getOutcome().lossState == GameLossReason.Conceded) {
|
||||
return false;
|
||||
}
|
||||
return (hasKeyword("You can't lose the game.") || Iterables.any(getOpponents(), PlayerPredicates.CANT_WIN));
|
||||
return hasKeyword("You can't lose the game.");
|
||||
}
|
||||
|
||||
public final boolean cantLoseForZeroOrLessLife() {
|
||||
|
||||
Reference in New Issue
Block a user