From 7801ef928348d8d2bd74eef40a236b383b97bc11 Mon Sep 17 00:00:00 2001 From: NikolajDanger Date: Wed, 23 Jul 2025 17:51:20 +0200 Subject: [PATCH] :sparkles: --- data.json | 4 +++- main.py | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/data.json b/data.json index f6b825c..030547e 100644 --- a/data.json +++ b/data.json @@ -37,6 +37,7 @@ ["dragon", 1], ["dwarf", 1], ["elf", 1], + ["fight", 1], ["giant", 1], ["guard", 1], ["human", 1], @@ -127,7 +128,8 @@ ], [ "The Plan", - "The party [trick/3] [Valindis/0+6] [Half-ear/0] by having [Cynthia/0] \"[capture/3]\" [Nix/0+6] [McGalloway/0] [disguised/3] as [Adrian/0+6] [Goldenleaf/0]." + "The party [trick/3] [Valindis/0+6] [Half-ear/0] by having [Cynthia/0] \"[capture/3]\" [Nix/0+6] [McGalloway/0] [disguised/3] as [Adrian/0+6] [Goldenleaf/0].", + "A [fight/1] starts, and they [kill/3] every member of the [purple/2] [rose/1]." ] ] } \ No newline at end of file diff --git a/main.py b/main.py index 1e4e49c..e9a32e2 100644 --- a/main.py +++ b/main.py @@ -101,6 +101,8 @@ class Page(): slots: list[tuple[list[str],WordSlot]] def solved(self): + # print([s for s in self.slots]) + if any([s[1].word is None for s in self.slots]): return SolvedState.NotFinished elif all([s[1].word.word in s[0] for s in self.slots]): @@ -110,6 +112,10 @@ class Page(): else: return SolvedState.Wrong + def solve(self): + for answers, slot in self.slots: + slot.word = Word(answers[0],slot.colors[0],self,slot.position,slot) + @dataclass class Word(): word: str @@ -542,7 +548,7 @@ def main(data: dict): if event.type == pygame.MOUSEBUTTONDOWN: click_slot() i = focused() - if isinstance(i,int): + if isinstance(i,int) and pages[i-1].solved() == SolvedState.Correct: page_sound = pygame.mixer.Sound("page.wav") page_sound.set_volume(0.7) page_sound.play() @@ -552,6 +558,12 @@ def main(data: dict): elif event.type == pygame.QUIT: running = False + key_state = pygame.key.get_pressed() + if key_state[pygame.K_SPACE] and key_state[pygame.K_LCTRL]: + pages[visible_page].solve() + for _,slot in pages[visible_page].slots: + words.append(slot.word) + # fill the screen with a color to wipe away anything from last frame drawer.fill("#4d2905") @@ -586,6 +598,9 @@ def main(data: dict): # drawing tabs for i in range(len(pages)-1): + if i != 0 and pages[i].solved() != SolvedState.Correct: + break + draw_tab(i,drawer,font,visible_page==i+1) # drawing held word