mirror of
https://github.com/TriM-Organization/LiteyukiBot-TriM.git
synced 2024-11-11 01:27:29 +08:00
😎更好的猜成语/接龙体验,新增困难模式
This commit is contained in:
parent
907740172b
commit
5ef4657805
File diff suppressed because it is too large
Load Diff
@ -75,7 +75,11 @@ def game_not_running(user_id: UserId) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
handle = on_alconna(
|
handle = on_alconna(
|
||||||
Alconna("handle", Option("-s|--strict", default=False, action=store_true)),
|
Alconna(
|
||||||
|
"handle",
|
||||||
|
Option("-s|--strict", default=False, action=store_true),
|
||||||
|
Option("-d|--hard", default=False, action=store_true),
|
||||||
|
),
|
||||||
aliases=("猜成语",),
|
aliases=("猜成语",),
|
||||||
rule=to_me() & game_not_running,
|
rule=to_me() & game_not_running,
|
||||||
use_cmd_start=True,
|
use_cmd_start=True,
|
||||||
@ -168,9 +172,10 @@ async def _(
|
|||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
user_id: UserId,
|
user_id: UserId,
|
||||||
strict: Query[bool] = AlconnaQuery("strict.value", False),
|
strict: Query[bool] = AlconnaQuery("strict.value", False),
|
||||||
|
hard: Query[bool] = AlconnaQuery("hard.value", False),
|
||||||
):
|
):
|
||||||
is_strict = handle_config.handle_strict_mode or strict.result
|
is_strict = handle_config.handle_strict_mode or strict.result
|
||||||
idiom, explanation = random_idiom()
|
idiom, explanation = random_idiom(hard.result)
|
||||||
game = Handle(idiom, explanation, strict=is_strict)
|
game = Handle(idiom, explanation, strict=is_strict)
|
||||||
|
|
||||||
games[user_id] = game
|
games[user_id] = game
|
||||||
|
73010
src/plugins/trimo_plugin_handle/resources/data/answers_hard.json
Normal file
73010
src/plugins/trimo_plugin_handle/resources/data/answers_hard.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -17,13 +17,18 @@ fonts_dir = resource_dir / "fonts"
|
|||||||
data_dir = resource_dir / "data"
|
data_dir = resource_dir / "data"
|
||||||
idiom_path = data_dir / "idioms.txt"
|
idiom_path = data_dir / "idioms.txt"
|
||||||
answer_path = data_dir / "answers.json"
|
answer_path = data_dir / "answers.json"
|
||||||
|
answer_hard_path = data_dir / "answers_hard.json"
|
||||||
|
|
||||||
|
|
||||||
LEGAL_PHRASES = [
|
LEGAL_PHRASES = [
|
||||||
idiom.strip() for idiom in idiom_path.open("r", encoding="utf-8").readlines()
|
idiom.strip() for idiom in idiom_path.open("r", encoding="utf-8").readlines()
|
||||||
]
|
]
|
||||||
ANSWER_PHRASES: List[Dict[str, str]] = json.load(answer_path.open("r", encoding="utf-8"))
|
ANSWER_PHRASES: List[Dict[str, str]] = json.load(
|
||||||
|
answer_path.open("r", encoding="utf-8")
|
||||||
|
)
|
||||||
|
HARD_ANSWER_PHRASES: List[Dict[str, str]] = json.load(
|
||||||
|
answer_hard_path.open("r", encoding="utf-8")
|
||||||
|
)
|
||||||
|
|
||||||
# class LegalPhrasesModifiedHandler(FileSystemEventHandler):
|
# class LegalPhrasesModifiedHandler(FileSystemEventHandler):
|
||||||
# """
|
# """
|
||||||
@ -57,8 +62,8 @@ def legal_idiom(word: str) -> bool:
|
|||||||
return word in LEGAL_PHRASES
|
return word in LEGAL_PHRASES
|
||||||
|
|
||||||
|
|
||||||
def random_idiom() -> Tuple[str, str]:
|
def random_idiom(is_hard: bool = False) -> Tuple[str, str]:
|
||||||
answer = random.choice(ANSWER_PHRASES)
|
answer = random.choice(HARD_ANSWER_PHRASES if is_hard else ANSWER_PHRASES)
|
||||||
return answer["word"], answer["explanation"]
|
return answer["word"], answer["explanation"]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user