Skip to content

Commit eb2072a

Browse files
committed
Adjust the length of individual levels.
1 parent 82ba161 commit eb2072a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/levels.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ import type { Piece } from "./nodes/Deck";
1919
export interface Level {
2020
randomQubit: () => Qubit;
2121
deal: () => Piece[];
22+
// Base multiplier for the score.
2223
scoreBase: number;
24+
// Number needed to advance to the next level.
25+
count: number;
2326
}
2427

2528
// TODO use this for more balanced dealing?
@@ -36,6 +39,7 @@ const gateRotations = [Math.PI / 2, Math.PI, Math.PI * (3 / 2)];
3639
function primaryLevel(axis: Axis): Level {
3740
return {
3841
scoreBase: 100,
42+
count: 16,
3943
randomQubit: () => choice(quartet(axis)),
4044
deal: () => {
4145
const random = () => choice(quartet(axis));
@@ -59,6 +63,7 @@ export const primaryLevels: Level[] = [
5963
primaryLevel("Z"),
6064
{
6165
scoreBase: 150,
66+
count: 24,
6267
randomQubit: () => choice(qubitBases),
6368
deal: () => {
6469
const random = () => choice(qubitBases);
@@ -80,6 +85,7 @@ export const primaryLevels: Level[] = [
8085
function secondaryLevel(axis: Axis): Level {
8186
return {
8287
scoreBase: 250,
88+
count: 20,
8389
randomQubit: () => choice(octet(axis)),
8490
deal: () => {
8591
const random = () => choice(octet(axis));
@@ -103,6 +109,7 @@ export const secondaryLevels: Level[] = [
103109
secondaryLevel("Z"),
104110
{
105111
scoreBase: 300,
112+
count: 28,
106113
randomQubit: () => choice(secondaryQubits),
107114
deal: () => {
108115
const random = () => choice(secondaryQubits);
@@ -123,6 +130,7 @@ export const secondaryLevels: Level[] = [
123130

124131
export const freeMode: Level = {
125132
scoreBase: 500,
133+
count: 16,
126134
randomQubit: () => randomQubit(),
127135
deal: () => {
128136
let buffer = [];
@@ -142,6 +150,7 @@ export const freeMode: Level = {
142150
export const campaign: Level[] = [
143151
{
144152
scoreBase: 50,
153+
count: 12,
145154
randomQubit: () => choice([ZERO, ONE]),
146155
deal: () => {
147156
const random = () => choice([ZERO, ONE]);

src/nodes/Player.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const INITIAL_STEP_RATE = 1000;
3333
const INPUT_POLL_RATE = 120;
3434

3535
const rateMultiplier = 0.9;
36-
const levelCount = 16;
3736

3837
const BOARD_OFFSET_Y = 80;
3938

@@ -254,6 +253,8 @@ export default class Player extends GameNode {
254253
this.board.current.outline.alpha = 1;
255254
}
256255
// Increase level
256+
const levelCount =
257+
campaign[Math.min(this.level, campaign.length - 1)].count;
257258
if (this.pieceCount > levelCount) {
258259
this.level++;
259260
playSound("levelUp");

0 commit comments

Comments
 (0)