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