Archived
0
0

fix: 完善

This commit is contained in:
2025-12-14 23:36:19 +08:00
parent 4f054ed2e5
commit ef5ef6bbca
6 changed files with 28 additions and 16 deletions

View File

@@ -3,9 +3,7 @@ from textual.widgets import (
Label,
Button,
)
from textual.containers import (
Container
)
from textual.containers import Container
from textual.widget import Widget
import heurams.kernel.particles as pt
import heurams.kernel.puzzles as pz
@@ -14,6 +12,7 @@ from typing import TypedDict
from bidict import bidict
from heurams.services.hasher import hash
class Setting(TypedDict):
__origin__: str
__hint__: str
@@ -53,12 +52,14 @@ class MCQPuzzle(BasePuzzleWidget):
def _load(self):
cfg = self.atom.registry["orbital"]["puzzles"][self.alia]
self.puzzle = pz.MCQPuzzle(
cfg["mapping"], cfg["jammer"], cfg["max_riddles_num"], cfg["prefix"]
cfg["mapping"], cfg["jammer"], int(cfg["max_riddles_num"]), cfg["prefix"]
)
self.puzzle.refresh()
def compose(self):
setting: Setting = self.atom.registry["nucleon"].metadata["orbital"]["puzzle"][self.alia]
setting: Setting = self.atom.registry["nucleon"].metadata["orbital"]["puzzle"][
self.alia
]
yield Label(setting["primary"], id="sentence")
yield Label(self.puzzle.wording[len(self.inputlist)], id="puzzle")
yield Label(f"当前输入: {self.inputlist}", id="inputpreview")
@@ -93,7 +94,7 @@ class MCQPuzzle(BasePuzzleWidget):
self.inputlist.pop()
self.refresh_buttons()
self.update_display()
elif button_id.startswith("select"): # type: ignore
# 选项选择处理
answer_text = self.hashmap[button_id[7:]] # type: ignore
@@ -104,7 +105,7 @@ class MCQPuzzle(BasePuzzleWidget):
is_correct = self.inputlist == self.puzzle.answer
rating = 4 if is_correct else 2
self.screen.rating = rating # type: ignore
self.screen.rating = rating # type: ignore
# 重置输入(如果回答错误)
if not is_correct: