From 8823b3172620cdf1f6f8d476adb0972f46ed06be Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Wed, 14 Dec 2016 21:14:46 +0100 Subject: Fix default nbPlayers in the settings --- src/main/java/org/luxons/sevenwonders/game/Settings.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/java/org') diff --git a/src/main/java/org/luxons/sevenwonders/game/Settings.java b/src/main/java/org/luxons/sevenwonders/game/Settings.java index 30e779df..b70caa71 100644 --- a/src/main/java/org/luxons/sevenwonders/game/Settings.java +++ b/src/main/java/org/luxons/sevenwonders/game/Settings.java @@ -6,7 +6,7 @@ import org.luxons.sevenwonders.game.wonders.WonderSide; public class Settings { - private int nbPlayers = 4; + private int nbPlayers = -1; private int initialGold = 3; @@ -14,11 +14,15 @@ public class Settings { private WonderSide wonderSide = WonderSide.A; + // will default to nbPlayers + 2 private Integer nbGuildCards = null; private long randomSeedForTests = 0; public int getNbPlayers() { + if (nbPlayers < 0) { + throw new IllegalStateException("The number of players has not been initialized"); + } return nbPlayers; } @@ -51,7 +55,7 @@ public class Settings { } public int getNbGuildCards() { - return nbGuildCards == null ? nbPlayers + 2 : nbGuildCards; + return nbGuildCards == null ? getNbPlayers() + 2 : nbGuildCards; } public void setNbGuildCards(int nbGuildCards) { -- cgit