Add GAME_GOAL game rule

This commit is contained in:
Daniel Saukel 2020-03-13 23:50:49 +01:00
parent c6454057f4
commit 49b94f8c82
2 changed files with 9 additions and 7 deletions

View File

@ -63,6 +63,10 @@ public class GameRule<V> {
* If the Lobby is disabled. This applies only to Dungeons that have to be solved alone and where there are no classes to choose from.
*/
public static final GameRule<Boolean> IS_LOBBY_DISABLED = new GameRule<>(Boolean.class, "isLobbyDisabled", false);
/**
* The goal of the game that defines what makes it end.
*/
public static final GameRule<GameGoal> GAME_GOAL = new GameRule<>(GameGoal.class, "gameGoal", GameGoal.END);
/**
* The game mode.
*/

View File

@ -752,7 +752,8 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer {
event.setDeathMessage(null);
}
if (game.getRules().getState(GameRule.KEEP_INVENTORY_ON_DEATH)) {
GameRuleContainer rules = game.getRules();
if (rules.getState(GameRule.KEEP_INVENTORY_ON_DEATH)) {
event.setKeepInventory(true);
event.getDrops().clear();
event.setKeepLevel(true);
@ -792,12 +793,9 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer {
kill();
}
GameType gameType = game.getType();
if (gameType != null && gameType != GameTypeDefault.CUSTOM) {
if (gameType.getGameGoal() == GameGoal.LAST_MAN_STANDING) {
if (game.getGroups().size() == 1) {
((DGroup) game.getGroups().get(0)).winGame();
}
if (rules.getState(GameRule.GAME_GOAL) == GameGoal.LAST_MAN_STANDING) {
if (game.getGroups().size() == 1) {
((DGroup) game.getGroups().get(0)).winGame();
}
}
}