copy game rules on game creation
This commit is contained in:
parent
6f643f7070
commit
04a84785f6
@ -130,7 +130,7 @@ export default class Session extends EventTarget {
|
|||||||
/** Add another round if there is no current one. */
|
/** Add another round if there is no current one. */
|
||||||
anotherGame() {
|
anotherGame() {
|
||||||
if (this.#currentGame === null) {
|
if (this.#currentGame === null) {
|
||||||
this.#currentGame = new Game(this.rules);
|
this.#currentGame = new Game(new GameRules(this.#rules));
|
||||||
this.#currentGame.addEventListener(
|
this.#currentGame.addEventListener(
|
||||||
Game.EVENT_CHANGE, this.#boundHandleGameChange);
|
Game.EVENT_CHANGE, this.#boundHandleGameChange);
|
||||||
this.#changed();
|
this.#changed();
|
||||||
|
|||||||
@ -60,6 +60,17 @@ export default function() {
|
|||||||
assert.notStrictEqual(session.currentGame, null, "game in progress");
|
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) {
|
QUnit.test("single game finished", function(assert) {
|
||||||
let session = new Session();
|
let session = new Session();
|
||||||
session.anotherGame();
|
session.anotherGame();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user