Skip to content

Commit

Permalink
fix:修复了链接卡查询出错的问题
Browse files Browse the repository at this point in the history
perf:默认添加先行卡池
feat:猜卡反馈语句可选择(需要编辑)
  • Loading branch information
fireinsect committed Jul 8, 2023
1 parent 43387f1 commit 6e406ad
Show file tree
Hide file tree
Showing 12 changed files with 1,003 additions and 630 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,5 @@ pyrightconfig.json
!.vscode/*.code-snippets
/data/
/nonebot_plugin_ocgbot_v2/libraries/test.py
/nonebot_plugin_ocgbot_v2/static/decks/*
!/nonebot_plugin_ocgbot_v2/static/decks/.json
36 changes: 18 additions & 18 deletions nonebot_plugin_ocgbot_v2/guess_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def verifySid(sid: str):
# gm.UpdateLastSend(sessionId)
# await aiGuessCard.send([
# MessageSegment.at(user_id=event.sender.user_id),
# MessageSegment.text(text="臭欧尼酱,你有三次机会哟~(输入跳过结束游戏)"),
# MessageSegment.text(text=get_named()",你有三次机会哟~(输入跳过结束游戏)"),
# MessageSegment.image(f"base64://{str(image_to_base64(image), encoding='utf-8')}")
# ])
# except Exception as e:
Expand All @@ -117,7 +117,7 @@ def verifySid(sid: str):
# if name == "不知道" or name == "跳过":
# await aiGuessCard.finish([
# MessageSegment.at(user_id=event.sender.user_id),
# MessageSegment.text(text=guess_skip[random.randint(0, len(guess_skip) - 1)].format(card.name)),
# MessageSegment.text(text=guess_skip().format(card.name)),
# MessageSegment.image(f"base64://{str(image_to_base64(state['image']), encoding='utf-8')}")
# ])
#
Expand All @@ -127,30 +127,30 @@ def verifySid(sid: str):
# if state['time'] == 1:
# await aiGuessCard.finish([
# MessageSegment.at(user_id=event.sender.user_id),
# MessageSegment.text(text=guess_lose[random.randint(0, len(guess_lose) - 1)].format(card.name)),
# MessageSegment.text(text=guess_lose().format(card.name)),
# MessageSegment.image(f"base64://{str(image_to_base64(state['image']), encoding='utf-8')}")
# ])
# else:
# if state['time'] == 3:
# hint = MessageSegment.text(
# text=guess_tips[random.randint(0, len(guess_tips) - 1)].format("是" + card.mainType + "卡"))
# text=guess_tips().format("是" + card.mainType + "卡"))
# elif state['time'] == 2:
# if card.mainType == '怪兽':
# ran = random.randint(0, 2)
# if ran == 0:
# hint = MessageSegment.text(
# text=guess_tips[random.randint(0, len(guess_tips) - 1)].format("种族是" + card.zz))
# text=guess_tips().format("种族是" + card.zz))
#
# elif ran == 1:
# hint = MessageSegment.text(
# text=guess_tips[random.randint(0, len(guess_tips) - 1)].format("属性是" + card.attribute))
# text=guess_tips().format("属性是" + card.attribute))
#
# else:
# hint = MessageSegment.text(
# text=guess_tips[random.randint(0, len(guess_tips) - 1)].format("完整类型是" + card.type))
# text=guess_tips().format("完整类型是" + card.type))
# else:
# hint = MessageSegment.text(
# text=guess_tips[random.randint(0, len(guess_tips) - 1)].format("完整类型是" + card.type))
# text=guess_tips().format("完整类型是" + card.type))
# state['time'] = state['time'] - 1
# await aiGuessCard.reject([
# MessageSegment.at(user_id=event.sender.user_id),
Expand All @@ -160,7 +160,7 @@ def verifySid(sid: str):
# else:
# await aiguessCard.finish([
# MessageSegment.at(user_id=event.sender.user_id),
# MessageSegment.text(text=guess_win[random.randint(0, len(guess_win) - 1)].format(card.name)),
# MessageSegment.text(text=guess_win().format(card.name)),
# MessageSegment.image(f"base64://{str(image_to_base64(state['image']), encoding='utf-8')}")
# ])

Expand Down Expand Up @@ -204,7 +204,7 @@ async def _(bot: Bot, event: GroupMessageEvent, state: T_State):
gm.UpdateLastSend(sessionId)
await guessCard.send([
MessageSegment.at(user_id=event.sender.user_id),
MessageSegment.text(text="臭欧尼酱,你有三次机会哟~(输入跳过结束游戏)"),
MessageSegment.text(text=get_named()+"臭欧尼酱,你有三次机会哟~(输入跳过结束游戏)"),
MessageSegment.image(f"base64://{str(image_to_base64(image), encoding='utf-8')}")
])
except Exception as e:
Expand All @@ -218,36 +218,36 @@ async def test_(bot: Bot, event: GroupMessageEvent, state: T_State):
if name == "不知道" or name == "跳过":
await guessCard.finish([
MessageSegment.at(user_id=event.sender.user_id),
MessageSegment.text(text=guess_skip[random.randint(0, len(guess_skip) - 1)].format(card.name)),
MessageSegment.text(text=guess_skip().format(card.name)),
MessageSegment.image(f"base64://{str(image_to_base64(state['image']), encoding='utf-8')}")
])
js = getCard(name)
if js.cards is None or isGuessWin(js, card.name, name):
if state['time'] == 1:
await guessCard.finish([
MessageSegment.at(user_id=event.sender.user_id),
MessageSegment.text(text=guess_lose[random.randint(0, len(guess_lose) - 1)].format(card.name)),
MessageSegment.text(text=guess_lose().format(card.name)),
MessageSegment.image(f"base64://{str(image_to_base64(state['image']), encoding='utf-8')}")
])
else:
if state['time'] == 3:
hint = MessageSegment.text(
text=guess_tips[random.randint(0, len(guess_tips) - 1)].format("是" + card.mainType + "卡"))
text=guess_tips().format("是" + card.mainType + "卡"))
elif state['time'] == 2:
if card.mainType == '怪兽':
ran = random.randint(0, 2)
if ran == 0:
hint = MessageSegment.text(
text=guess_tips[random.randint(0, len(guess_tips) - 1)].format("种族是" + card.zz))
text=guess_tips().format("种族是" + card.zz))
elif ran == 1:
hint = MessageSegment.text(
text=guess_tips[random.randint(0, len(guess_tips) - 1)].format("属性是" + card.attribute))
text=guess_tips().format("属性是" + card.attribute))
else:
hint = MessageSegment.text(
text=guess_tips[random.randint(0, len(guess_tips) - 1)].format("完整类型是" + card.type))
text=guess_tips().format("完整类型是" + card.type))
else:
hint = MessageSegment.text(
text=guess_tips[random.randint(0, len(guess_tips) - 1)].format("完整类型是" + card.type))
text=guess_tips().format("完整类型是" + card.type))
state['time'] = state['time'] - 1
await guessCard.reject([
MessageSegment.at(user_id=event.sender.user_id),
Expand All @@ -257,7 +257,7 @@ async def test_(bot: Bot, event: GroupMessageEvent, state: T_State):
else:
await guessCard.finish([
MessageSegment.at(user_id=event.sender.user_id),
MessageSegment.text(text=guess_win[random.randint(0, len(guess_win) - 1)].format(card.name)),
MessageSegment.text(text=guess_win().format(card.name)),
MessageSegment.image(f"base64://{str(image_to_base64(state['image']), encoding='utf-8')}")
])

Expand Down
5 changes: 4 additions & 1 deletion nonebot_plugin_ocgbot_v2/libraries/Card.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,13 @@ def __getattribute__(self, item):
if item == "atk":
if types[0] == "怪兽":
return str(self[item]) if str(self[item]) != "-2" else "?"
else:
return None
if item == "deff":
if types[0] == "怪兽" and "连接" not in types:
return str(self['def']) if str(self['def']) != "-2" else "?"
else:
return None
if item == "attribute":
return getAttribute(str(hex(self['attribute'])))

Expand Down Expand Up @@ -171,7 +175,6 @@ def getCard(name: str, page="1") -> CardResult:
cards = searchByName(name) # 这里写name获取方法
else:
cards = searchByName(name) # 这里写name获取方法
print(cards)
return getCardResult(cards, pageint) # 这里写分页算法


Expand Down
223 changes: 180 additions & 43 deletions nonebot_plugin_ocgbot_v2/libraries/globalMessage.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
import os.path
import pathlib
from random import choice

import nonebot
from nonebot import Config, logger

random_sendwitchoutcd=[
"臭欧尼酱!慢点啦!",
"前面的区域之后再来探索吧~",
"臭欧尼酱又在抽卡哦~休息一下好不好~",
"臭欧尼酱小蓝不让你抽卡了(叉腰)~",
"抽多了对身体不好❤️~臭哥哥受不了的~",
"杂鱼又在抽卡呀,天天只会抽卡,真是飞舞❤️~",
"笨蛋大叔,着什么急❤️~笨蛋❤️笨蛋",
"臭大叔,不给你抽了!生气了吗?嘻嘻❤️~"
]
guess_sendwitchoutcd=[
"打咩❤️!",
"前面的区域之后再来探索吧~",
"臭欧尼酱!慢点啦!",
"臭欧尼酱小蓝不让你猜卡了(叉腰)~",
"臭欧尼酱又在猜卡哦~休息一下好不好~",
"杂鱼又在猜卡呀,天天只会猜卡,真是飞舞❤️~",
"笨蛋大叔,着什么急❤️~笨蛋❤️笨蛋",
"臭大叔,不给你猜了!生气吗?生气吗❤️?"
]
noSearchText = [
"没找到捏~ 欧尼酱~",
"咦?这张卡不存在呢",
Expand All @@ -43,31 +24,187 @@
"今天堆点什么捏?",
"嘟嘟嘟,小蓝警长"
]
guess_tips = [
"\r\n呃啊~臭哥哥❤~这都不会?我偷偷告诉你这张卡{0}。",
"\r\n杂鱼❤~杂鱼❤~,这张卡{0}~",
"\r\n杂鱼哥哥真好捉弄❤~。这张卡{0}~",
"\r\n好❤恶❤心~,连这张卡{0}都不知道❤~",
"\r\n杂❤~鱼❤~这张卡是{0}~"
]
guess_lose = [
"\r\n这都猜不到,臭哥哥就是弱哎❤,答案是{0}",
"\r\n略略略❤~猜不到吧,答案是{0}",
"\r\n笨蛋哥哥果然是杂❤鱼,连这个是{0}都猜不到?",
"\r\n弱哎❤~这就不行了,答案是{0}哎~"
]
guess_skip = [
"\r\n略略略❤~臭哥哥这就不行了?答案是{0}",
"\r\n就这❤~就这❤~答案是{0}",
"\r\n杂鱼哥哥这就结束了❤?答案是{0}",
"\r\n弱哎❤~哥哥好弱❤~答案是{0}"

mess_type_choose = 1

message_type = [
{
'guess': {
'sendwitchoutcd': [
"打咩❤️!",
"前面的区域之后再来探索吧~",
"##!慢点啦!",
"##,小蓝不让你猜卡了(叉腰)~",
"##又在猜卡哦~休息一下好不好~",
"##又在猜卡呀,天天只会猜卡,真是飞舞❤️~",
"笨蛋##,着什么急❤️~笨蛋❤️笨蛋",
"##,不给你猜了!生气吗?生气吗❤️?"
],
'tips': [
"呃啊~##❤~这都不会?我偷偷告诉你这张卡{0}。",
"##❤~##❤~,这张卡{0}~",
"##真好捉弄❤~。这张卡{0}~",
"好❤恶❤心~,连这张卡{0}都不知道❤~",
"杂❤~鱼❤~这张卡是{0}~",
"哎~这么简单的题都不会,这张卡是{0}❤~",
"行不行啊~##❤~连这张卡是{0}都不知道~",
"这张卡小蓝三岁就会了,##连它是{0}都不知道❤~",
"呐❤~呐❤~呐❤~##不会是笨蛋吧,这张卡是{0}呀~",
],
'lose': [
"这都猜不到,##就是弱哎❤,答案是{0}",
"略略略❤~猜不到吧,答案是{0}",
"##果然是杂❤鱼,连这个是{0}都猜不到?",
"弱哎❤~这就不行了,答案是{0}哎~",
"行不行啊❤~##,连{0}都猜不到~",
"不是吧❤~这都猜不到❤~,答案是{0}",
"##❤~##❤~答案是{0}~",
"就这啊~##❤~答案是{0}哦~",
"##❤~连{0}都答不上来~真是飞舞❤~",
"不会吧❤不会吧❤不会有人连{0}都猜不到吧❤",
"##!告诉你答案吧!是{0}!"
],
'skip': [
"略略略❤##这就不行了?答案是{0}",
"就这❤~就这❤~答案是{0}",
"##这就结束了❤?答案是{0}",
"弱哎❤~##好弱❤~答案是{0}",
"就这啊~##❤~答案是{0}哦~",
"不会吧❤不会吧❤不会有人连{0}都猜不到吧❤",
"##也太❤弱❤了❤吧,答案是{0}耶~",
"##❤~连{0}都答不上来~真是飞舞❤~",
"行不行啊❤~##,连{0}都猜不到~",
],
'win': [
"哎,竟然答对了吗?真无聊❤~答案就是{0}啦",
"##竟然答对了❤~答案是{0}",
"好吧,好吧,算你对了啦❤~答案就是{0}",
"恶心!变态!竟然答对了❤~答案是{0}",
"答错...好吧,##竟然答对了{0}(生气)",
"呐❤呐❤呐❤,##竟然答对了{0},##不会作弊了吧❤~"
],
}

},

{
'guess': {
'sendwitchoutcd': [
"打咩️!",
"前面的区域之后再来探索吧~",
"##!慢点啦!",
"##,小蓝不让你猜卡了(叉腰)~",
"##又在猜卡哦~休息一下好不好~",
"##又在猜卡呀,不要猜卡了好不好~",
"##,稍等一下,小蓝在准备卡组~",
"##,不要猜卡啦,让小蓝休息一下吧QAQ",
"洗衣服中(勿扰)"
],
'tips': [
"##答不出来吗,小蓝提醒你一下这张卡{0}。",
"##!##!这张卡{0}啦!",
"唔...这张卡{0}小蓝偷偷告诉##,不要告诉别人哦~",
"嘟嘟嘟~这张卡{0}哦~",
"(翻阅卡表)这张卡是{0}哦~(叉腰)",
"呀!好像题目有点难,小蓝提醒一下##吧,这张卡是{0}~",
"哎~##猜不到吗?这张卡是{0}",
"这张卡{0}!快猜快猜,猜完小蓝要去洗衣服了",
],
'lose': [
"啊!##没猜出来吗!答案是{0}啦",
"##!##!错了啦!答案是{0}啦",
"(翻阅卡表)答案好像是{0}哎?##没猜出来,好可惜哦~",
"嘟嘟嘟,答案新鲜出炉!是{0}哒~",
"答案是{0}哦~,##再接再厉吧~",
],
'skip': [
"啊!##猜不到吗!答案是{0}啦",
"##!##!!答案是{0}啦",
"(翻阅卡表)答案好像是{0}哎?##没猜出来,好可惜哦~",
"嘟嘟嘟,答案新鲜出炉!是{0}哒~",
"答案是{0}哦~,##再接再厉吧~",
"QWQ既然##不会,那么小蓝告诉你答案吧,是{0}哦~"
],
'win': [
"##好厉害!答案就是{0}啦",
"##答对了!(崇拜眼)答案是{0}",
"哇!欧尼酱答对啦!好厉害鸭!答案就是{0}",
"呼呼呼!##答对啦,答案是{0},下次小蓝要出更难的题(比拳头)",
"好耶,##答对了{0}!小蓝可以去洗衣服啦",
"嘿嘿嘿,##好厉害,小蓝都不会呢,答案就是{0}哦"
],
}

},
]
guess_win = [
"\r\n哎,竟然答对了吗?真无聊❤~答案就是{0}啦",
"\r\n杂鱼哥哥竟然答对了❤~答案是{0}",
"\r\n好吧,好吧,算你对了啦❤~答案就是{0}",
"\r\n恶心!变态!竟然答对了❤~答案是{0}"

random_sendwitchoutcd = [
"臭欧尼酱!慢点啦!",
"前面的区域之后再来探索吧~",
"臭欧尼酱又在抽卡哦~休息一下好不好~",
"臭欧尼酱小蓝不让你抽卡了(叉腰)~",
"抽多了对身体不好❤️~臭哥哥受不了的~",
"杂鱼又在抽卡呀,天天只会抽卡,真是飞舞❤️~",
"笨蛋大叔,着什么急❤️~笨蛋❤️笨蛋",
"臭大叔,不给你抽了!生气了吗?嘻嘻❤️~"
]


def guess_sendwitchoutcd() -> str:
arr = message_type[mess_type_choose]['guess']['sendwitchoutcd']
return choice(arr).replace("##", get_named())


# guess_tips = [
# "这张卡{0}。",
# ]

# ##字当作称呼的替换符
def guess_tips() -> str:
arr = arr = message_type[mess_type_choose]['guess']['tips']
return "\r\n" + choice(arr).replace("##", get_named())


def guess_lose() -> str:
arr = arr = message_type[mess_type_choose]['guess']['lose']
return "\r\n" + choice(arr).replace("##", get_named())


def guess_skip() -> str:
arr = arr = message_type[mess_type_choose]['guess']['skip']
return "\r\n" + choice(arr).replace("##", get_named())


def guess_win() -> str:
arr = arr = message_type[mess_type_choose]['guess']['win']
return "\r\n" + choice(arr).replace("##", get_named())


#

def get_named() -> str:
arr = [
[
"臭哥哥",
"哥哥",
"臭欧尼酱",
"欧尼酱",
"杂鱼",
"臭杂鱼",
"杂鱼哥哥",
"大叔",
"臭大叔"
],
[
"欧尼酱",
"哥哥",
"哥哥大人",
]

]
return choice(arr[mess_type_choose])


# 猜卡难度
guess_diff = [
{
Expand Down
Loading

0 comments on commit 6e406ad

Please sign in to comment.