diff options
6 files changed, 6 insertions, 9 deletions
diff --git a/backend/src/main/kotlin/org/luxons/sevenwonders/repositories/LobbyRepository.kt b/backend/src/main/kotlin/org/luxons/sevenwonders/repositories/LobbyRepository.kt index 261f723c..7ca78233 100644 --- a/backend/src/main/kotlin/org/luxons/sevenwonders/repositories/LobbyRepository.kt +++ b/backend/src/main/kotlin/org/luxons/sevenwonders/repositories/LobbyRepository.kt @@ -10,8 +10,6 @@ import java.util.HashMap @Repository class LobbyRepository @Autowired constructor() { - private val gameDefinitionLoader: GameDefinitionLoader = GameDefinitionLoader() - private val lobbies = HashMap<Long, Lobby>() private var lastGameId: Long = 0 @@ -20,7 +18,7 @@ class LobbyRepository @Autowired constructor() { fun create(gameName: String, owner: Player): Lobby { val id = lastGameId++ - val lobby = Lobby(id, gameName, owner, gameDefinitionLoader.gameDefinition) + val lobby = Lobby(id, gameName, owner, GameDefinitionLoader.gameDefinition) lobbies[id] = lobby return lobby } diff --git a/backend/src/test/kotlin/org/luxons/sevenwonders/lobby/LobbyTest.kt b/backend/src/test/kotlin/org/luxons/sevenwonders/lobby/LobbyTest.kt index 3abdde3b..84cef934 100644 --- a/backend/src/test/kotlin/org/luxons/sevenwonders/lobby/LobbyTest.kt +++ b/backend/src/test/kotlin/org/luxons/sevenwonders/lobby/LobbyTest.kt @@ -223,7 +223,7 @@ class LobbyTest { @JvmStatic @BeforeClass fun loadDefinition() { - gameDefinition = GameDefinitionLoader().gameDefinition + gameDefinition = GameDefinitionLoader.gameDefinition } } } diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionLoader.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionLoader.kt index 103adcae..e0f82c2b 100644 --- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionLoader.kt +++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionLoader.kt @@ -21,7 +21,7 @@ import org.luxons.sevenwonders.game.resources.Production import org.luxons.sevenwonders.game.resources.ResourceType import org.luxons.sevenwonders.game.resources.Resources -class GameDefinitionLoader { +object GameDefinitionLoader { val gameDefinition: GameDefinition by lazy { load() } diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt index fb232d9e..135f701d 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt @@ -38,7 +38,7 @@ class GameTest { private fun createGame(nbPlayers: Int): Game { val settings = testCustomizableSettings() - return GameDefinitionLoader().gameDefinition.initGame(0, settings, nbPlayers) + return GameDefinitionLoader.gameDefinition.initGame(0, settings, nbPlayers) } private fun playTurn(nbPlayers: Int, game: Game, ageToCheck: Int, handSize: Int) { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionLoaderTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionLoaderTest.kt index 468ee5de..c312c12f 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionLoaderTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionLoaderTest.kt @@ -7,8 +7,7 @@ class GameDefinitionLoaderTest { @Test fun successfulLoad() { - val loader = GameDefinitionLoader() - val gameDefinition = loader.gameDefinition + val gameDefinition = GameDefinitionLoader.gameDefinition assertNotNull(gameDefinition) } } diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionTest.kt index 3f010123..162af7a3 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/data/GameDefinitionTest.kt @@ -9,7 +9,7 @@ class GameDefinitionTest { @Test fun successfulGameInit() { - val gameDefinition = GameDefinitionLoader().gameDefinition + val gameDefinition = GameDefinitionLoader.gameDefinition assertNotNull(gameDefinition) assertEquals(3, gameDefinition.minPlayers.toLong()) assertEquals(7, gameDefinition.maxPlayers.toLong()) |