mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
- Attempt to implement a basic team victory
This commit is contained in:
@@ -1056,7 +1056,8 @@ public class GameAction {
|
||||
public void checkGameOverCondition() {
|
||||
// award loses as SBE
|
||||
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
|
||||
// Run triggers
|
||||
if (losers == null) {
|
||||
@@ -1100,13 +1101,24 @@ public class GameAction {
|
||||
}
|
||||
|
||||
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) {
|
||||
reason = GameEndReason.AllOpponentsLost;
|
||||
}
|
||||
else if (cntNotLost == 0) {
|
||||
reason = GameEndReason.Draw;
|
||||
}
|
||||
else if (teams.size() == 1) {
|
||||
reason = GameEndReason.AllOpposingTeamsLost;
|
||||
}
|
||||
else {
|
||||
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.*/
|
||||
AllHumansLost,
|
||||
|
||||
/** Team win. */
|
||||
AllOpposingTeamsLost,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user