Archived
0
0
This commit is contained in:
2025-12-16 21:28:53 +08:00
parent 11d130c3fd
commit 1e534e5fe5
37 changed files with 428 additions and 207 deletions

View File

@@ -15,12 +15,14 @@ from typing import TypedDict
logger = get_logger(__name__)
class Setting(TypedDict):
__origin__: str
__hint__: str
text: str
delimiter: str
min_denominator: str
min_denominator: str
class ClozePuzzle(BasePuzzleWidget):
@@ -58,7 +60,7 @@ class ClozePuzzle(BasePuzzleWidget):
min_denominator=int(setting["min_denominator"]),
)
self.puzzle.refresh()
self.ans = copy.copy(self.puzzle.answer) # 乱序
self.ans = copy.copy(self.puzzle.answer) # 乱序
random.shuffle(self.ans)
def compose(self):
@@ -78,7 +80,6 @@ class ClozePuzzle(BasePuzzleWidget):
preview = self.query_one("#inputpreview")
preview.update(f"当前输入: {self.inputlist}") # type: ignore
def on_button_pressed(self, event: Button.Pressed) -> None:
button_id = event.button.id
@@ -87,16 +88,22 @@ class ClozePuzzle(BasePuzzleWidget):
self.inputlist.pop()
self.update_display()
else:
answer_text = self.hashmap[button_id[7:]] # type: ignore
answer_text = self.hashmap[button_id[7:]] # type: ignore
self.inputlist.append(answer_text)
self.update_display()
if len(self.inputlist) >= len(self.puzzle.answer):
is_correct = self.inputlist == self.puzzle.answer
rating = 4 if is_correct else 2
self.screen.rating = rating # type: ignore
self.handler(rating)
self.screen.rating = rating # type: ignore
if not is_correct:
self.inputlist = []
self.update_display()
def handler(self, rating):
if self.atom.lock():
pass
else:
self.atom.minimize(rating)