mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
- Attempt to implement a basic team victory
This commit is contained in:
@@ -1056,7 +1056,8 @@ 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;
|
||||||
for (Player p : this.game.getPlayers()) {
|
List<Player> allPlayers = this.game.getPlayers();
|
||||||
|
for (Player p : allPlayers) {
|
||||||
if (p.checkLoseCondition()) { // this will set appropriate outcomes
|
if (p.checkLoseCondition()) { // this will set appropriate outcomes
|
||||||
// Run triggers
|
// Run triggers
|
||||||
if (losers == null) {
|
if (losers == null) {
|
||||||
@@ -1100,13 +1101,24 @@ public class GameAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (reason == null) {
|
if (reason == null) {
|
||||||
int cntNotLost = Iterables.size(Iterables.filter(game.getPlayers(), Player.Predicates.NOT_LOST));
|
List<Player> notLost = new ArrayList<Player>();
|
||||||
|
Set<Integer> teams = new HashSet<Integer>();
|
||||||
|
for (Player p : allPlayers) {
|
||||||
|
if (p.getOutcome() == null || p.getOutcome().hasWon()) {
|
||||||
|
notLost.add(p);
|
||||||
|
teams.add(p.getTeam());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int cntNotLost = notLost.size();
|
||||||
if (cntNotLost == 1) {
|
if (cntNotLost == 1) {
|
||||||
reason = GameEndReason.AllOpponentsLost;
|
reason = GameEndReason.AllOpponentsLost;
|
||||||
}
|
}
|
||||||
else if (cntNotLost == 0) {
|
else if (cntNotLost == 0) {
|
||||||
reason = GameEndReason.Draw;
|
reason = GameEndReason.Draw;
|
||||||
}
|
}
|
||||||
|
else if (teams.size() == 1) {
|
||||||
|
reason = GameEndReason.AllOpposingTeamsLost;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,4 +35,7 @@ public enum GameEndReason {
|
|||||||
|
|
||||||
/** Used to end multiplayer games where the all humans have lost or conceded while AIs cannot end match by themselves.*/
|
/** Used to end multiplayer games where the all humans have lost or conceded while AIs cannot end match by themselves.*/
|
||||||
AllHumansLost,
|
AllHumansLost,
|
||||||
|
|
||||||
|
/** Team win. */
|
||||||
|
AllOpposingTeamsLost,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,6 +174,8 @@ public class ViewWinLose {
|
|||||||
Player winner = outcome.getWinningPlayer();
|
Player winner = outcome.getWinningPlayer();
|
||||||
if (winner == null) {
|
if (winner == null) {
|
||||||
return "It's a draw!";
|
return "It's a draw!";
|
||||||
|
} else if (winningTeam != -1) {
|
||||||
|
return "Team " + winner.getTeam() + " Won!";
|
||||||
} else {
|
} else {
|
||||||
return winner.getName() + " Won!";
|
return winner.getName() + " Won!";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user