shufflecom-calculations 4.2.2 → 4.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/games/floor-is-lava/floor-is-lava-board.d.ts +2 -1
- package/lib/games/floor-is-lava/floor-is-lava-board.js +5 -2
- package/lib/games/floor-is-lava/floor-is-lava-board.js.map +1 -1
- package/lib/games/floor-is-lava/floor-is-lava.d.ts +2 -2
- package/lib/games/floor-is-lava/floor-is-lava.js +5 -6
- package/lib/games/floor-is-lava/floor-is-lava.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/games/floor-is-lava/floor-is-lava-board.spec.ts +8 -8
- package/src/games/floor-is-lava/floor-is-lava-board.ts +6 -2
- package/src/games/floor-is-lava/floor-is-lava.spec.ts +6 -6
- package/src/games/floor-is-lava/floor-is-lava.ts +8 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shufflecom-calculations",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
},
|
|
15
15
|
"author": "",
|
|
16
16
|
"license": "ISC",
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "960432bd15457f63bcd0e4b8c8f8cb0400aa4463"
|
|
18
18
|
}
|
|
@@ -20,15 +20,15 @@ describe('FloorIsLavaBoard.draw', () => {
|
|
|
20
20
|
|
|
21
21
|
const board = FloorIsLavaBoard.draw(new FixedSequenceRng(raw));
|
|
22
22
|
|
|
23
|
-
expect(board.
|
|
24
|
-
expect(board.
|
|
25
|
-
expect(board.
|
|
23
|
+
expect(board.tilesThatSurviveLevel(0, BOARD_SIZE)).toEqual(ASCENDING_BOARD);
|
|
24
|
+
expect(board.tilesThatSurviveLevel(1, BOARD_SIZE)).toEqual([...ASCENDING_BOARD].reverse());
|
|
25
|
+
expect(board.tilesThatSurviveLevel(2, BOARD_SIZE)).toEqual(ASCENDING_BOARD);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
it('draws independently per level - no leakage across levels', () => {
|
|
29
29
|
const board = boardFromLevelBoards(ASCENDING_BOARD, [...ASCENDING_BOARD].reverse(), ASCENDING_BOARD);
|
|
30
30
|
|
|
31
|
-
expect(board.
|
|
31
|
+
expect(board.tilesThatSurviveLevel(0, BOARD_SIZE)).not.toEqual(board.tilesThatSurviveLevel(1, BOARD_SIZE));
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
34
|
|
|
@@ -48,14 +48,14 @@ describe('FloorIsLavaBoard.tilesDroppedInRound', () => {
|
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
describe('FloorIsLavaBoard.
|
|
51
|
+
describe('FloorIsLavaBoard.tilesThatSurviveLevel', () => {
|
|
52
52
|
const board = boardFromLevelBoards(ASCENDING_BOARD, ASCENDING_BOARD, ASCENDING_BOARD);
|
|
53
53
|
|
|
54
|
-
it('returns
|
|
55
|
-
expect(board.
|
|
54
|
+
it('returns the last x tiles of the level board, not everything past a drop count', () => {
|
|
55
|
+
expect(board.tilesThatSurviveLevel(0, 7)).toEqual([42, 43, 44, 45, 46, 47, 48]);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
it('reads from the requested level band', () => {
|
|
59
|
-
expect(board.
|
|
59
|
+
expect(board.tilesThatSurviveLevel(2, 4)).toEqual([45, 46, 47, 48]);
|
|
60
60
|
});
|
|
61
61
|
});
|
|
@@ -11,6 +11,10 @@ const assertValidLevel = (level: number): void => {
|
|
|
11
11
|
export class FloorIsLavaBoard {
|
|
12
12
|
private readonly levelBoards: [number[], number[], number[]];
|
|
13
13
|
|
|
14
|
+
get boards(): [number[], number[], number[]] {
|
|
15
|
+
return this.levelBoards;
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
private constructor(generator: RandomNumberGenerator) {
|
|
15
19
|
const raw = generator.getRandomIntsWithoutReplacement({
|
|
16
20
|
min: 0,
|
|
@@ -34,8 +38,8 @@ export class FloorIsLavaBoard {
|
|
|
34
38
|
return this.levelBoards[level].slice(roundIndex * dropsPerRound, (roundIndex + 1) * dropsPerRound);
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
public
|
|
41
|
+
public tilesThatSurviveLevel(level: number, survivingTilesCount: number): number[] {
|
|
38
42
|
assertValidLevel(level);
|
|
39
|
-
return this.levelBoards[level].slice(
|
|
43
|
+
return this.levelBoards[level].slice(-survivingTilesCount);
|
|
40
44
|
}
|
|
41
45
|
}
|
|
@@ -201,7 +201,7 @@ describe('FloorIsLava.next', () => {
|
|
|
201
201
|
const result = expectOk(gameAtState(FloorIsLavaDifficulty.EASY, 0, 0).next(5, board, EDGE_BPS));
|
|
202
202
|
|
|
203
203
|
expect(result).toMatchObject({
|
|
204
|
-
|
|
204
|
+
survivingTilesCount: SURVIVING_TILES_MAP[FloorIsLavaDifficulty.EASY],
|
|
205
205
|
gameAction: {
|
|
206
206
|
phase: 'PICK',
|
|
207
207
|
level: 0,
|
|
@@ -219,7 +219,7 @@ describe('FloorIsLava.next', () => {
|
|
|
219
219
|
|
|
220
220
|
expect(result).toMatchObject({
|
|
221
221
|
multiplier: new BigNumber(0),
|
|
222
|
-
|
|
222
|
+
survivingTilesCount: SURVIVING_TILES_MAP[FloorIsLavaDifficulty.EASY],
|
|
223
223
|
gameAction: {
|
|
224
224
|
phase: 'PICK',
|
|
225
225
|
level: 0,
|
|
@@ -238,7 +238,7 @@ describe('FloorIsLava.next', () => {
|
|
|
238
238
|
|
|
239
239
|
const result = expectOk(gameAtState(FloorIsLavaDifficulty.EASY, 0, 2).next(30, board, EDGE_BPS));
|
|
240
240
|
|
|
241
|
-
expect(result).toMatchObject({
|
|
241
|
+
expect(result).toMatchObject({ survivingTilesCount: SURVIVING_TILES_MAP[FloorIsLavaDifficulty.EASY], gameAction: { droppedTiles: thisRound } });
|
|
242
242
|
expect(result.multiplier.isEqualTo(expectedMultiplier(FloorIsLavaDifficulty.EASY, 0, 28))).toBe(true);
|
|
243
243
|
});
|
|
244
244
|
|
|
@@ -276,7 +276,7 @@ describe('FloorIsLava.next', () => {
|
|
|
276
276
|
const result = expectOk(gameAtState(difficulty, 0, roundsPerLevel - 1).next(35, board, EDGE_BPS));
|
|
277
277
|
|
|
278
278
|
expect(result).toMatchObject({
|
|
279
|
-
|
|
279
|
+
survivingTilesCount: SURVIVING_TILES_MAP[difficulty],
|
|
280
280
|
gameAction: { phase: 'PICK', level: 0, gameStatus: 'LEVEL_COMPLETE', selectedTile: 35, droppedTiles: lastRoundDrops },
|
|
281
281
|
});
|
|
282
282
|
expect(result.multiplier.isEqualTo(expectedMultiplier(difficulty, 0, SURVIVING_TILES_MAP[difficulty]))).toBe(true);
|
|
@@ -292,7 +292,7 @@ describe('FloorIsLava.next', () => {
|
|
|
292
292
|
const result = expectOk(gameAtState(difficulty, LEVELS_PER_DIFFICULTY - 1, roundsPerLevel - 1).next(35, board, EDGE_BPS));
|
|
293
293
|
|
|
294
294
|
expect(result).toMatchObject({
|
|
295
|
-
|
|
295
|
+
survivingTilesCount: SURVIVING_TILES_MAP[difficulty],
|
|
296
296
|
gameAction: {
|
|
297
297
|
phase: 'PICK',
|
|
298
298
|
level: LEVELS_PER_DIFFICULTY - 1,
|
|
@@ -379,7 +379,7 @@ describe('FloorIsLava.cashout', () => {
|
|
|
379
379
|
const tilesRemainingInLevel = FloorIsLavaRules.tilesRemaining(rounds, dropsPerRound);
|
|
380
380
|
expect(result.multiplier.isEqualTo(expectedMultiplier(difficulty, levelsCleared, tilesRemainingInLevel))).toBe(true);
|
|
381
381
|
expect(result.gameAction).toEqual({ phase: FloorIsLavaActionPhase.CASHOUT, level: levelsCleared, multiplier: result.multiplier });
|
|
382
|
-
expect(result.
|
|
382
|
+
expect(result.survivingTilesCount).toBe(SURVIVING_TILES_MAP[difficulty]);
|
|
383
383
|
});
|
|
384
384
|
|
|
385
385
|
it('returns no-tiles-selected with zero rounds survived at level 0', () => {
|
|
@@ -13,18 +13,19 @@ import {
|
|
|
13
13
|
FloorIsLavaRules,
|
|
14
14
|
FloorIsLavaStartAction,
|
|
15
15
|
LEVELS_PER_DIFFICULTY,
|
|
16
|
+
SURVIVING_TILES_MAP,
|
|
16
17
|
} from './floor-is-lava-rules';
|
|
17
18
|
|
|
18
19
|
export type FloorIsLavaNextError = 'tile-already-dropped' | 'no-tiles-remaining' | 'invalid-tile';
|
|
19
20
|
|
|
20
21
|
export type FloorIsLavaNextResult =
|
|
21
|
-
| { ok: true; multiplier: BigNumber; gameAction: FloorIsLavaPickAction;
|
|
22
|
+
| { ok: true; multiplier: BigNumber; gameAction: FloorIsLavaPickAction; survivingTilesCount: number }
|
|
22
23
|
| { ok: false; error: FloorIsLavaNextError };
|
|
23
24
|
|
|
24
25
|
export type FloorIsLavaCashoutError = 'no-tiles-selected';
|
|
25
26
|
|
|
26
27
|
export type FloorIsLavaCashoutResult =
|
|
27
|
-
| { ok: true; multiplier: BigNumber; gameAction: FloorIsLavaCashoutAction;
|
|
28
|
+
| { ok: true; multiplier: BigNumber; gameAction: FloorIsLavaCashoutAction; survivingTilesCount: number }
|
|
28
29
|
| { ok: false; error: FloorIsLavaCashoutError };
|
|
29
30
|
|
|
30
31
|
export class FloorIsLava {
|
|
@@ -72,7 +73,7 @@ export class FloorIsLava {
|
|
|
72
73
|
|
|
73
74
|
const droppedTiles = board.tilesDroppedInRound(currentLevel, dropsPerRound, roundsSurvivedInCurrentLevel);
|
|
74
75
|
const isLoss = droppedTiles.includes(selectedTile);
|
|
75
|
-
const
|
|
76
|
+
const survivingTilesCount = SURVIVING_TILES_MAP[difficulty];
|
|
76
77
|
|
|
77
78
|
if (isLoss) {
|
|
78
79
|
return {
|
|
@@ -86,7 +87,7 @@ export class FloorIsLava {
|
|
|
86
87
|
gameStatus: FloorIsLavaGameStatus.LOST,
|
|
87
88
|
multiplier: BigNumber(0),
|
|
88
89
|
},
|
|
89
|
-
|
|
90
|
+
survivingTilesCount,
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
93
|
|
|
@@ -115,7 +116,7 @@ export class FloorIsLava {
|
|
|
115
116
|
gameStatus,
|
|
116
117
|
multiplier: nextMultiplier,
|
|
117
118
|
},
|
|
118
|
-
|
|
119
|
+
survivingTilesCount,
|
|
119
120
|
};
|
|
120
121
|
}
|
|
121
122
|
|
|
@@ -124,15 +125,14 @@ export class FloorIsLava {
|
|
|
124
125
|
return { ok: false, error: 'no-tiles-selected' };
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
const { currentLevel,
|
|
128
|
-
const { dropsPerRound } = DIFFICULTY_LEVEL_MAP[difficulty];
|
|
128
|
+
const { currentLevel, difficulty } = this.state;
|
|
129
129
|
const { currentMultiplier } = FloorIsLavaRules.multipliers(this.state, edge);
|
|
130
130
|
|
|
131
131
|
return {
|
|
132
132
|
ok: true,
|
|
133
133
|
multiplier: currentMultiplier,
|
|
134
134
|
gameAction: { phase: FloorIsLavaActionPhase.CASHOUT, level: currentLevel, multiplier: currentMultiplier },
|
|
135
|
-
|
|
135
|
+
survivingTilesCount: SURVIVING_TILES_MAP[difficulty],
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
}
|