Skip to content

Commit cef0995

Browse files
committed
feat: add hints
1 parent 730f7a3 commit cef0995

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

public/global.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ button {
9191
color: #505152;
9292
}
9393

94-
button:hover, button.swal2-styled:hover, .moe-component:hover {
94+
button:hover, button.swal2-styled:hover, .moe-component:not(:disabled):hover {
9595
box-shadow: var(--elevation-1);
9696
filter: brightness(90%);
9797
}

src/components/CryptogramSolver.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
5959
{#if problem}
6060
<p>Solve this quote by {problem.author}</p>
61+
{#if problem.hint}
62+
<p>HINT: The first word is {problem.hint}</p>
63+
{/if}
6164
<div class="cryptogram" class:solved>
6265
{#each words as word}
6366
<Word

src/components/Game.svelte

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
} from '@/js/quotes.js';
1616
import { isHivemindBrain, hivemindBrain } from '@/js/constants.js';
1717
import {
18+
hintEnabled,
1819
patristocratEnabled,
1920
progress,
2021
gameProblem,
@@ -26,10 +27,12 @@
2627
const getNewQuote = getQuoteGenerator();
2728
2829
/** @type {typeof toAristocratCipher} */
29-
const createProblem = (quote) =>
30-
$patristocratEnabled
30+
const createProblem = (quote) => {
31+
const problem = $patristocratEnabled
3132
? toPatristocratCipher(toAristocratCipher(quote))
3233
: toAristocratCipher(quote);
34+
return $hintEnabled ? problem : { ...problem, hint: undefined };
35+
};
3336
3437
const newProblem = () => {
3538
getNewQuote().then((quote) => gameProblem.set(createProblem(quote)));
@@ -52,6 +55,12 @@
5255
bind:checked={$patristocratEnabled}
5356
disabled={$gameProblem !== null}
5457
/>
58+
<Checkbox
59+
id="hint-option"
60+
label="Hint"
61+
bind:checked={$hintEnabled}
62+
disabled={$gameProblem !== null}
63+
/>
5564
</div>
5665
</Panel>
5766
</div>

src/js/quotes.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ export const toAristocratCipher = (quote) => {
5353
.map((char) => encryptionAlphabet[alphabet.indexOf(char)] ?? char)
5454
.join('');
5555

56-
return { ...quote, plaintext, ciphertext, start: Date.now() };
56+
return {
57+
...quote,
58+
plaintext,
59+
ciphertext,
60+
start: Date.now(),
61+
hint: splitQuote(plaintext)[0],
62+
};
5763
};
5864

5965
/** @type {(text: string) => string} */
@@ -70,7 +76,6 @@ export const toPatristocratCipher = (quote) => ({
7076
...quote,
7177
plaintext: patristify(quote.plaintext),
7278
ciphertext: patristify(quote.ciphertext),
73-
hint: splitQuote(quote.plaintext)[0],
7479
});
7580

7681
/** @type {(text: string) => string[]} */

src/js/store.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const name = lswritable(
2828
`person-${Math.floor(Math.random() * 10000)}`
2929
);
3030
export const patristocratEnabled = lswritable('patristocrat', false);
31+
export const hintEnabled = lswritable('hint', false);
3132
export const hivemindConnection = writable(
3233
/** @type {Connection | null} */ (null)
3334
);

0 commit comments

Comments
 (0)