mirror of
https://github.com/Kugelschieber/breach.git
synced 2026-01-18 12:00:25 +00:00
Added game state to all components, renamed timeout to timeoutMilliseconds, removed score from savegame.
This commit is contained in:
@@ -12,7 +12,7 @@ describe("GameState", () => {
|
||||
const unlimitedTime = 999 * 1000
|
||||
|
||||
test("getting size works", () => {
|
||||
expect((new Game({ matrix: ["00"], sequences: [["AA"]], maxBufferLength: unrestrictedBuffer, timeout: unlimitedTime })).size).toEqual(1)
|
||||
expect((new Game({ matrix: ["00"], sequences: [["AA"]], maxBufferLength: unrestrictedBuffer, timeoutMilliseconds: unlimitedTime })).size).toEqual(1)
|
||||
expect((new Game({
|
||||
matrix: [
|
||||
"00", "01",
|
||||
@@ -20,7 +20,7 @@ describe("GameState", () => {
|
||||
],
|
||||
sequences: [],
|
||||
maxBufferLength: unrestrictedBuffer,
|
||||
timeout: unlimitedTime,
|
||||
timeoutMilliseconds: unlimitedTime,
|
||||
})).size).toEqual(2)
|
||||
});
|
||||
|
||||
@@ -29,14 +29,14 @@ describe("GameState", () => {
|
||||
matrix: threeByThreeMatrix,
|
||||
sequences: [["AA"]],
|
||||
maxBufferLength: unrestrictedBuffer,
|
||||
timeout: unlimitedTime,
|
||||
timeoutMilliseconds: unlimitedTime,
|
||||
});
|
||||
expect(game.getCell(0, 2)).toEqual({ value: "02", isUsed: false })
|
||||
});
|
||||
|
||||
describe("picking", () => {
|
||||
test("starts with free pick", () => {
|
||||
const game = new Game({ matrix: [], sequences: [["AA"]], maxBufferLength: 1, timeout: unlimitedTime });
|
||||
const game = new Game({ matrix: [], sequences: [["AA"]], maxBufferLength: 1, timeoutMilliseconds: unlimitedTime });
|
||||
expect(game.state).toEqual({ selectionMode: SelectionMode.FreePick })
|
||||
});
|
||||
|
||||
@@ -45,7 +45,7 @@ describe("GameState", () => {
|
||||
matrix: threeByThreeMatrix,
|
||||
sequences: [["AA"]],
|
||||
maxBufferLength: unrestrictedBuffer,
|
||||
timeout: unlimitedTime,
|
||||
timeoutMilliseconds: unlimitedTime,
|
||||
});
|
||||
game.pick(0, 0);
|
||||
expect(game.state).toEqual({ selectionMode: SelectionMode.RowPick, column: 0 });
|
||||
@@ -60,7 +60,7 @@ describe("GameState", () => {
|
||||
matrix: threeByThreeMatrix,
|
||||
sequences: [["AA"]],
|
||||
maxBufferLength: unrestrictedBuffer,
|
||||
timeout: unlimitedTime,
|
||||
timeoutMilliseconds: unlimitedTime,
|
||||
});
|
||||
game.pick(0, 0);
|
||||
expect(() => game.pick(0, 0)).toThrow();
|
||||
@@ -71,7 +71,7 @@ describe("GameState", () => {
|
||||
matrix: threeByThreeMatrix,
|
||||
sequences: [],
|
||||
maxBufferLength: unrestrictedBuffer,
|
||||
timeout: unlimitedTime,
|
||||
timeoutMilliseconds: unlimitedTime,
|
||||
});
|
||||
expect(() => game.pick(-1, 0)).toThrow();
|
||||
expect(() => game.pick(0, -1)).toThrow();
|
||||
@@ -85,7 +85,7 @@ describe("GameState", () => {
|
||||
matrix: threeByThreeMatrix,
|
||||
sequences: [simpleSequence],
|
||||
maxBufferLength: unrestrictedBuffer,
|
||||
timeout: unlimitedTime,
|
||||
timeoutMilliseconds: unlimitedTime,
|
||||
});
|
||||
expect(game.getSequences()).toEqual([{ sequence: simpleSequence, numberOfFulfilled: 0 }])
|
||||
game.pick(0, 0);
|
||||
@@ -107,7 +107,7 @@ describe("GameState", () => {
|
||||
],
|
||||
sequences: [sequence],
|
||||
maxBufferLength: unrestrictedBuffer,
|
||||
timeout: unlimitedTime,
|
||||
timeoutMilliseconds: unlimitedTime,
|
||||
});
|
||||
expect(game.getSequences()).toEqual([{ sequence: sequence, numberOfFulfilled: 0 }])
|
||||
game.pick(0, 0);
|
||||
@@ -133,7 +133,7 @@ describe("GameState", () => {
|
||||
],
|
||||
sequences: [["AA", "BB", "CC"]],
|
||||
maxBufferLength: 3,
|
||||
timeout: unlimitedTime,
|
||||
timeoutMilliseconds: unlimitedTime,
|
||||
})
|
||||
game.pick(0, 0)
|
||||
game.pick(2, 0)
|
||||
@@ -151,7 +151,7 @@ describe("GameState", () => {
|
||||
],
|
||||
sequences: [["AA", "BB", "CC"]],
|
||||
maxBufferLength: 3,
|
||||
timeout: unlimitedTime,
|
||||
timeoutMilliseconds: unlimitedTime,
|
||||
})
|
||||
game.pick(0, 0)
|
||||
game.pick(1, 0)
|
||||
@@ -186,7 +186,7 @@ describe("GameState", () => {
|
||||
],
|
||||
sequences: [["AA"]],
|
||||
maxBufferLength: 3,
|
||||
timeout: 10_000,
|
||||
timeoutMilliseconds: 10_000,
|
||||
})
|
||||
fakeTimeProgress(1_000)
|
||||
expect(game.remainingMilliseconds).toEqual(9_000)
|
||||
@@ -208,7 +208,7 @@ describe("GameState", () => {
|
||||
],
|
||||
sequences: [["AA"]],
|
||||
maxBufferLength: unrestrictedBuffer,
|
||||
timeout: 10_000,
|
||||
timeoutMilliseconds: 10_000,
|
||||
}
|
||||
)
|
||||
fakeTimeProgress(1_000)
|
||||
|
||||
Reference in New Issue
Block a user