diff --git a/models/session.js b/models/session.js index 3a07a88..f101a5a 100644 --- a/models/session.js +++ b/models/session.js @@ -130,7 +130,7 @@ export default class Session extends EventTarget { /** Add another round if there is no current one. */ anotherGame() { if (this.#currentGame === null) { - this.#currentGame = new Game(this.rules); + this.#currentGame = new Game(new GameRules(this.#rules)); this.#currentGame.addEventListener( Game.EVENT_CHANGE, this.#boundHandleGameChange); this.#changed(); diff --git a/models/session.test.js b/models/session.test.js index b727450..b444e6f 100644 --- a/models/session.test.js +++ b/models/session.test.js @@ -60,6 +60,17 @@ export default function() { assert.notStrictEqual(session.currentGame, null, "game in progress"); }); + QUnit.test("session rule change doesn't affect games", function(assert) { + let session = new Session(); + session.anotherGame(); + session.rules.goal = 7; + assert.notStrictEqual( + session.currentGame.rules.goal, + session.rules.goal, + "game rules have been copied", + ); + }); + QUnit.test("single game finished", function(assert) { let session = new Session(); session.anotherGame();