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:
Jamin W. Collins
2018-03-15 09:19:17 -06:00
parent 6ed064eca6
commit f270213bb7
2 changed files with 21 additions and 3 deletions

View File

@@ -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) {

View File

@@ -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() {