From bbb74607230529b308ebd51708ad703c7d30ebcc Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Mon, 21 Mar 2022 22:15:58 +0100 Subject: [PATCH] Cleaned up sharing --- src/composables/sharing.ts | 41 +++++++++++--------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/src/composables/sharing.ts b/src/composables/sharing.ts index 407aa7a..e7f71ed 100644 --- a/src/composables/sharing.ts +++ b/src/composables/sharing.ts @@ -1,43 +1,26 @@ import { i18n } from '@/i18n' -import { percentageDiff, setDailyPRNG, shuffle } from '@/utils' import { isHardMode, numberOfGamesSinceStart, operations, - plaquettes, result, } from './game-state' import { showToast } from './toast-manager' function getSharingText(): string { - setDailyPRNG() - const baseSymbols = shuffle(['๐ŸŸข', '๐Ÿ”ด', '๐ŸŸ ', '๐ŸŸก', '๐ŸŸฃ', '๐Ÿ”ต']) - const resultSymbols = shuffle(['๐ŸŸฉ', '๐ŸŸฅ', '๐ŸŸง', '๐ŸŸจ', '๐ŸŸช', '๐ŸŸฆ']) - - for (const item of plaquettes.value) { - item.symbol = item.original ? baseSymbols.shift() : resultSymbols.pop() - } - - // ร— รท + - const endResult = operations[operations.length - 1].result?.value ?? 0 + const success = result.value === endResult + + const allSymbols = ['๐Ÿ„ฐ', '๐Ÿ„ฑ', '๐Ÿ„ฒ', '๐Ÿ„ณ', '๐Ÿ„ด', '๐Ÿ„ต', '๐Ÿ„ถ', '๐Ÿ„ท', '๐Ÿ„ธ', '๐Ÿ„น'] + const squares = ['๐ŸŸฆ', '๐ŸŸฉ', '๐ŸŸจ', '๐ŸŸง', '๐ŸŸฅ'] + const lines: string[] = [] for (const op of operations) { - // let s = '' - // switch (op.operator) { - // case '*': - // s = 'โœ–' - // break - // case '/': - // s = 'โž—' - // break - // case '-': - // s = 'โž–' - // break - // case '+': - // s = 'โž•' - // break - // } + op.left!.symbol = op.left!.symbol ?? allSymbols.shift() + op.right!.symbol = op.right!.symbol ?? allSymbols.shift() + op.result!.symbol = op.result!.symbol ?? allSymbols.shift() + let s = '' switch (op.operator) { case '*': @@ -47,21 +30,21 @@ function getSharingText(): string { s = 'รท' break case '-': - s = '-' + s = 'โˆ’' break case '+': s = '+' break } lines.push( - `${op.left?.symbol} ${s} ${op.right?.symbol} = ${ + `${squares.shift()} ${op.left?.symbol} ${s} ${op.right?.symbol} = ${ op.result?.value === endResult ? endResult : op.result?.symbol }`, ) } return `N0mbers #${numberOfGamesSinceStart()} - ${isHardMode.value ? 'Advanced' : 'Normal'} -${lines.join('\n')} ${result.value === endResult ? 'โœ”' : 'โŒ'} +${lines.join('\n')} ${success ? 'โœ”' : 'โŒ'} https://n0mbers.scambier.xyz` }