fix no confeti if win in wordle!
This commit is contained in:
parent
aadcab9fd7
commit
41941f98e8
2 changed files with 11 additions and 2 deletions
|
@ -2,14 +2,19 @@
|
|||
import Keyboard from "./game/keyboard.svelte";
|
||||
import Display from "./game/display.svelte";
|
||||
import { onMount } from "svelte";
|
||||
import { handleKey } from "./logic.svelte.js";
|
||||
import { handleKey,jsConfetti } from "./logic.svelte.js";
|
||||
import Right from "./InfoAndSetings/main.svelte";
|
||||
import { OpenTab } from "./InfoAndSetings/main.svelte";
|
||||
import { data } from "./logic.svelte";
|
||||
|
||||
import JSConfetti from "js-confetti";
|
||||
|
||||
|
||||
onMount(() => {
|
||||
window.addEventListener("keydown", handleKey);
|
||||
|
||||
jsConfetti.v = new JSConfetti();
|
||||
|
||||
data.value = JSON.parse(localStorage.getItem("WordleGamesData")) || {
|
||||
3: [],
|
||||
4: [],
|
||||
|
|
|
@ -2,6 +2,8 @@ import wordExists from "word-exists";
|
|||
import { generate } from "random-words";
|
||||
import toast from "svelte-5-french-toast";
|
||||
|
||||
export let jsConfetti = $state({ v: null });
|
||||
|
||||
export let WordLegnth = $state({ v: 5 });
|
||||
|
||||
let CorrectWord = generate({
|
||||
|
@ -88,6 +90,8 @@ export function newGame() {
|
|||
function GameWin() {
|
||||
toast.success("You win!");
|
||||
|
||||
jsConfetti.v.addConfetti();
|
||||
|
||||
data.value[WordLegnth.v].push(words.v.length);
|
||||
localStorage.setItem("WordleGamesData", JSON.stringify(data.value));
|
||||
newGame();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue