mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +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() {
|
public void checkGameOverCondition() {
|
||||||
// award loses as SBE
|
// award loses as SBE
|
||||||
List<Player> losers = null;
|
List<Player> losers = null;
|
||||||
|
|
||||||
FCollectionView<Player> allPlayers = game.getPlayers();
|
FCollectionView<Player> allPlayers = game.getPlayers();
|
||||||
for (Player p : allPlayers) {
|
for (Player p : allPlayers) {
|
||||||
if (p.checkLoseCondition()) { // this will set appropriate outcomes
|
if (p.checkLoseCondition()) { // this will set appropriate outcomes
|
||||||
@@ -1219,14 +1220,14 @@ public class GameAction {
|
|||||||
|
|
||||||
GameEndReason reason = null;
|
GameEndReason reason = null;
|
||||||
// Has anyone won by spelleffect?
|
// Has anyone won by spelleffect?
|
||||||
for (Player p : game.getPlayers()) {
|
for (Player p : allPlayers) {
|
||||||
if (!p.hasWon()) {
|
if (!p.hasWon()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// then the rest have lost!
|
// then the rest have lost!
|
||||||
reason = GameEndReason.WinsGameSpellEffect;
|
reason = GameEndReason.WinsGameSpellEffect;
|
||||||
for (Player pl : game.getPlayers()) {
|
for (Player pl : allPlayers) {
|
||||||
if (pl.equals(p)) {
|
if (pl.equals(p)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1243,6 +1244,23 @@ public class GameAction {
|
|||||||
break;
|
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
|
// need a separate loop here, otherwise ConcurrentModificationException is raised
|
||||||
if (losers != null) {
|
if (losers != null) {
|
||||||
for (Player p : losers) {
|
for (Player p : losers) {
|
||||||
|
|||||||
@@ -1825,7 +1825,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
if (getOutcome() != null && getOutcome().lossState == GameLossReason.Conceded) {
|
if (getOutcome() != null && getOutcome().lossState == GameLossReason.Conceded) {
|
||||||
return false;
|
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() {
|
public final boolean cantLoseForZeroOrLessLife() {
|
||||||
|
|||||||
Reference in New Issue
Block a user