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

@@ -51,11 +51,15 @@ class MemScreen(Screen):
def puzzle_widget(self):
try:
#print(self.phaser.state)
# print(self.phaser.state)
print("---debug---")
print(self.procession.cursor)
print(self.procession.current_atom)
self.fission = Fission(self.procession.current_atom, self.phaser.state)
# print(1)
print("---debug---")
puzzle_info = next(self.fission.generate())
#print(puzzle_info)
print(puzzle_info)
return shim.puzzle2widget[puzzle_info["puzzle"]](
atom=self.procession.current_atom, alia=puzzle_info["alia"]
)
@@ -92,7 +96,8 @@ class MemScreen(Screen):
if forwards:
ret = self.procession.forward(1)
if ret == 0:
self.procession = self.phaser.current_procession() # type: ignore
self.procession = self.phaser.current_procession() # type: ignore
print(f"NEWPROC {self.procession.cursor}")
self.load_puzzle()
def action_play_voice(self):

View File

@@ -40,7 +40,7 @@ class SyncScreen(Screen):
def on_button_pressed(self, event: Button.Pressed) -> None:
event.stop()
def action_go_back(self):
self.app.pop_screen()

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: