diff --git a/package.json b/package.json index da3d3b9..4fa47fa 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore" }, "dependencies": { - "pinia": "^2.0.11", "vue": "^3.2.30", "vue-router": "^4.0.12" }, diff --git a/src/algo.ts b/src/algo.ts index 2c26789..95ceea1 100644 --- a/src/algo.ts +++ b/src/algo.ts @@ -1,12 +1,13 @@ import { reactive, ref, watch } from 'vue' import { operators, pool } from './globals' -import { Operation, OperatorType } from './types' +import { Operation, OperatorType, Plaquette } from './types' import { randRange } from './utils' type HistoryType = { a: number; b: number; op: OperatorType }[] export const operations = reactive([]) +export const plaquettes = ref([]) export function isOperationResultValid(op: Operation): boolean { return ( @@ -30,13 +31,13 @@ export function isOperationReady(op: Operation): boolean { ) } -export function pushEmptyOperation(): void { - operations.push({ +export function getEmptyOperation(): Operation { + return { left: null, right: null, operator: null, - executed: false, - }) + result: null, + } } export function operate( @@ -64,7 +65,6 @@ export function isSolvable(result: number, plaquettes: number[]): boolean { `${item.a} ${item.op} ${item.b} = ${operate(item.op, item.a, item.b)}`, ) } - console.log() } function loopOperations(plaquettes: number[], history: HistoryType): void { @@ -135,8 +135,6 @@ export function isSolvable(result: number, plaquettes: number[]): boolean { if (histories.length) { printHistory(histories[0]) } - console.log(new Date().getTime() - startTime.getTime() + 'ms') - console.log(found) return found // histories.sort((a, b) => a.length - b.length) diff --git a/src/components/OperationsList.vue b/src/components/OperationsList.vue index 9607019..108c69f 100644 --- a/src/components/OperationsList.vue +++ b/src/components/OperationsList.vue @@ -3,6 +3,7 @@
@@ -55,11 +56,12 @@ diff --git a/src/globals.ts b/src/globals.ts index 7df4041..0680a23 100644 --- a/src/globals.ts +++ b/src/globals.ts @@ -2,3 +2,9 @@ export const operators = ['+', '-', 'x', '/'] as const export const pool = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 25, 50, 75, 100, ] as const + +export enum GameState { + Playing, + Lost, + Won, +} diff --git a/src/types.ts b/src/types.ts index 548b149..9f4b9d4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -9,5 +9,5 @@ export type Operation = { left: Plaquette | null right: Plaquette | null operator: OperatorType | null - executed: boolean + result: Plaquette | null } diff --git a/src/views/GameView.vue b/src/views/GameView.vue index 5ee424a..e4e9f37 100644 --- a/src/views/GameView.vue +++ b/src/views/GameView.vue @@ -49,44 +49,46 @@