Improved sharing
This commit is contained in:
parent
5ef3abb66e
commit
cada72746a
|
@ -17,7 +17,7 @@ export const operations = reactive<Operation[]>([getEmptyOperation()])
|
|||
export const plaquettes = ref<Plaquette[]>([])
|
||||
export const result = ref(0)
|
||||
|
||||
// #region Difficulty-related constants
|
||||
// #region Difficulty-related values
|
||||
|
||||
export const gameDifficulty = ref(GameDifficultyType.Normal)
|
||||
|
||||
|
@ -29,6 +29,10 @@ export const startingNumberOfPlaquettes = computed(() =>
|
|||
gameDifficulty.value === GameDifficultyType.Hard ? 6 : 5,
|
||||
)
|
||||
|
||||
export const isHardMode = computed(
|
||||
() => gameDifficulty.value === GameDifficultyType.Hard,
|
||||
)
|
||||
|
||||
// #endregion Difficulty-related constants
|
||||
|
||||
export const currentOperation = computed(
|
||||
|
|
|
@ -1,50 +1,67 @@
|
|||
import { i18n } from '@/i18n'
|
||||
import { percentageDiff, setDailyPRNG, shuffle } from '@/utils'
|
||||
|
||||
import { numberOfGamesSinceStart, operations, result } from './game-state'
|
||||
import {
|
||||
isHardMode,
|
||||
numberOfGamesSinceStart,
|
||||
operations,
|
||||
plaquettes,
|
||||
result,
|
||||
} from './game-state'
|
||||
import { showToast } from './toast-manager'
|
||||
|
||||
const squareSymbols = ['🟦', '🟨', '🟫', '🟧', '🟥', '🟩', '🟪']
|
||||
const roundSymbols = ['🔵', '🟡', '🟤', '🟠', '🔴', '🟢', '🟣']
|
||||
|
||||
export function shuffleSymbols(): void {
|
||||
function getSharingText(): string {
|
||||
setDailyPRNG()
|
||||
shuffle(squareSymbols)
|
||||
shuffle(roundSymbols)
|
||||
const baseSymbols = shuffle(['🟢', '🔴', '🟠', '🟡', '🟣', '🔵'])
|
||||
const resultSymbols = shuffle(['🟩', '🟥', '🟧', '🟨', '🟪', '🟦'])
|
||||
|
||||
for (const item of plaquettes.value) {
|
||||
item.symbol = item.original ? baseSymbols.shift() : resultSymbols.pop()
|
||||
}
|
||||
|
||||
function getSharingText(): string {
|
||||
console.log(squareSymbols)
|
||||
console.log(roundSymbols)
|
||||
// × ÷ + -
|
||||
const endResult = operations[operations.length - 1].result?.value ?? 0
|
||||
|
||||
const lines: string[] = []
|
||||
for (const op of operations) {
|
||||
if (op.left && !op.left.symbol) {
|
||||
op.left.symbol = op.left.original
|
||||
? squareSymbols.pop()
|
||||
: roundSymbols.pop()
|
||||
// let s = ''
|
||||
// switch (op.operator) {
|
||||
// case '*':
|
||||
// s = '✖'
|
||||
// break
|
||||
// case '/':
|
||||
// s = '➗'
|
||||
// break
|
||||
// case '-':
|
||||
// s = '➖'
|
||||
// break
|
||||
// case '+':
|
||||
// s = '➕'
|
||||
// break
|
||||
// }
|
||||
let s = ''
|
||||
switch (op.operator) {
|
||||
case '*':
|
||||
s = '×'
|
||||
break
|
||||
case '/':
|
||||
s = '÷'
|
||||
break
|
||||
case '-':
|
||||
s = '-'
|
||||
break
|
||||
case '+':
|
||||
s = '+'
|
||||
break
|
||||
}
|
||||
if (op.right && !op.right.symbol) {
|
||||
op.right.symbol = op.right.original
|
||||
? squareSymbols.pop()
|
||||
: roundSymbols.pop()
|
||||
}
|
||||
if (op.result && !op.result.symbol) {
|
||||
op.result.symbol = roundSymbols.pop()
|
||||
}
|
||||
}
|
||||
for (const op of operations) {
|
||||
lines.push(
|
||||
`${op.left?.symbol} ${op.operator} ${op.right?.symbol} = ${op.result?.value === endResult ? endResult : op.result?.symbol}`,
|
||||
`${op.left?.symbol} ${s} ${op.right?.symbol} = ${
|
||||
op.result?.value === endResult ? endResult : op.result?.symbol
|
||||
}`,
|
||||
)
|
||||
}
|
||||
|
||||
return `N0mbers #${numberOfGamesSinceStart()}
|
||||
|
||||
return `N0mbers #${numberOfGamesSinceStart()} - ${isHardMode ? 'Advanced' : 'Normal'}
|
||||
${lines.join('\n')} ${result.value === endResult ? '✔' : '❌'}
|
||||
|
||||
https://n0mbers.scambier.xyz`
|
||||
}
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ import {
|
|||
gameIsRunning,
|
||||
gameState,
|
||||
isEndGame,
|
||||
isHardMode,
|
||||
isResultPerfect,
|
||||
operations,
|
||||
plaquettes,
|
||||
|
@ -133,9 +134,6 @@ const { t } = useI18n() // call `useI18n`, and spread `t` from `useI18n` return
|
|||
const poolType = ref<1 | 2 | 3>(1)
|
||||
const cmpPlaquettes = ref<InstanceType<typeof PlaquettesList> | null>(null)
|
||||
|
||||
const isHardMode = computed(
|
||||
() => gameDifficulty.value === GameDifficultyType.Hard,
|
||||
)
|
||||
const isPracticeMode = ref(false)
|
||||
const shownPlaquettes = computed(() =>
|
||||
gameIsRunning.value ? plaquettes.value : [],
|
||||
|
|
Loading…
Reference in New Issue
Block a user