This commit is contained in:
2025-07-23 17:51:20 +02:00
parent 9d70dff982
commit 7801ef9283
2 changed files with 19 additions and 2 deletions

View File

@@ -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]."
]
]
}

17
main.py
View File

@@ -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