diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1cf5810..1994142 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -53,4 +53,4 @@ jobs: steps: - name: Deploy id: deployment - uses: actions/deploy-pages@v4 \ No newline at end of file + uses: actions/deploy-pages@v4 diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index f183ec7..98c82d3 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -3,7 +3,6 @@
-
diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index d2c0be2..ceccaaf 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -1,2 +1,2 @@ export const prerender = true; -export const ssr = false; \ No newline at end of file +export const ssr = false; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index e96646e..60a4212 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,117 +1,237 @@ @@ -122,18 +242,70 @@
{#if show_start_screen} - + + {#if uid_valid} + {#await get_points()} +

Validating User ID...

+ {:then get_points_value} + {#if get_points_value.uid !== null} + {(set_actual_pin(get_points_value.actual_pin), '')} +

Points: {get_points_value.points}

+ {:else} +

Invalid User ID!

+ {/if} + {:catch error} + {(console.log(error), '')} +

Network Error: Unable to check validity of User ID!

+ {/await} + {/if} +
+ {/if} {#if show_keypad_screen} -

Tap the color of your {gameHeader(rounds)} digit for {4-(rounds % 4)} more rounds.

- +

+ Tap the color of your {gameHeader(rounds)} digit for + {4 - (rounds % 4)} more rounds. +

+ {/if} {#if show_end_screen} - + {#if show_pin} +
Entered PIN: {userEnteredPIN}
+ {/if} +
+ {#if actual_pin === userEnteredPIN} +

Congratulations on entering the correct PIN!

+ {:else} +

Incorrect PIN entered, no points earned!

+ {/if} +
+ {#await get_points()} +

Fetching points...

+ {:then get_points_value} + {#if get_points_value.uid !== null} +

Points: {get_points_value.points}

+ {:else} +

Invalid User ID!

+ {/if} + {:catch error} + {(console.log(error), '')} +

Network Error: Unable to fetch points!

+ {/await} +
+ +
+ +
+ {/if} - - -
diff --git a/src/routes/EndPage.svelte b/src/routes/EndPage.svelte index 7325190..3b2ee9e 100644 --- a/src/routes/EndPage.svelte +++ b/src/routes/EndPage.svelte @@ -1,11 +1,16 @@ -

Black and White PIN Entry

{#if PIN_visible} -

{PIN}

+

{PIN}

{/if} - + diff --git a/src/routes/KeyPad.svelte b/src/routes/KeyPad.svelte index 44793e7..9a19997 100644 --- a/src/routes/KeyPad.svelte +++ b/src/routes/KeyPad.svelte @@ -1,17 +1,16 @@
@@ -25,15 +24,35 @@ {#if training_board} - + {:else} - + {/if} {#if training_board} - + {:else} - + {/if}
@@ -69,5 +88,4 @@ border-color: black; border-width: 0.2em; } - diff --git a/src/routes/StartPage.svelte b/src/routes/StartPage.svelte index 46ca1c0..6e0e88c 100644 --- a/src/routes/StartPage.svelte +++ b/src/routes/StartPage.svelte @@ -1,28 +1,25 @@ -

- Black and White PIN Entry -

+

Black and White PIN Entry

Start Game! diff --git a/src/routes/logic.ts b/src/routes/logic.ts new file mode 100644 index 0000000..536a306 --- /dev/null +++ b/src/routes/logic.ts @@ -0,0 +1,95 @@ +// export enum GameState { +// START, +// PROGRESS, +// FINISH +// } + +// export class Item { +// digit: number; +// color: string; + +// constructor(digit: number, color: string) { +// this.digit = digit; +// this.color = color; +// } +// } + +// export enum Mode { +// DISPLAY, +// POSITION_ENTRY, +// COLOR_ENTRY +// } + +export type GetPointsResponse = { + uid: number | null; + points: number | null; + actual_pin: string; +}; + +export type CreateInstanceResponse = { + iid: number; +}; + +export type UpdateInstanceResponse = { + iid: number; +}; + +// function rand_digit(): number { +// for (;;) { +// const array = new Uint8Array(1); +// self.crypto.getRandomValues(array); +// if (array[0] < 250) { +// return array[0] % 10; +// } +// } +// } + +// function rand_digit_min_i(i: number): number { +// for (;;) { +// const j = rand_digit(); +// if (j >= i) { +// return j; +// } +// } +// } + +// function rand_perm(): Uint8Array { +// const array = new Uint8Array(10); +// for (let i = 0; i < 10; ++i) { +// array[i] = i; +// } +// for (let i = 0; i < 9; ++i) { +// const j = rand_digit_min_i(i); +// const temp = array[i]; +// array[i] = array[j]; +// array[j] = temp; +// } +// return array; +// } + +// const COLORS: Array = ['red', 'blue', 'green', '#8B8000', 'black']; +// export const NCOLORS = COLORS.length; + +// export function get_ith_color(i: number): string { +// if (i < COLORS.length) { +// return COLORS[i]; +// } +// return 'white'; +// } + +// export function make_random_puzzles(): Array> { +// const ret = new Array>(); + +// const perms: Record = {}; +// for (const color of COLORS) { +// perms[color] = rand_perm(); +// } + +// for (let i = 0; i < 10; ++i) { +// ret.push(new Array()); +// for (const color of COLORS) { +// ret[i].push(new Item(perms[color][i], color)); +// } +// } +// return ret; +// }