Skip to content

Commit

Permalink
Merge pull request #83 from MyXiaoNan/dev
Browse files Browse the repository at this point in the history
合并 Dev 变更
  • Loading branch information
PackageInstaller authored Oct 22, 2024
2 parents 912fc11 + a735720 commit 67d4049
Show file tree
Hide file tree
Showing 26 changed files with 664 additions and 214 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ venv.bak/
.mypy_cache/
.dmypy.json
dmypy.json
*.json

# Pyre type checker
.pyre/

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ _✨ QQ群聊修仙文字游戏✨_

1、修复了许多Bug,报错与原版相比少很多,以及更多功能优化

2、新增了更多指令,例如:合成武器,仙途奇缘(新手灵石礼包),轮回重修等等
2、新增了更多指令,例如:合成系统,仙途奇缘(新手灵石礼包),轮回重修等等

3、支持全部转图片发送,支持图片压缩率等等,并且可以在配置文件中更改

Expand Down
15 changes: 0 additions & 15 deletions data/xiuxian/丹药/礼包.json

This file was deleted.

44 changes: 44 additions & 0 deletions data/xiuxian/礼包/礼包.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"15050": {
"name": "感谢大礼包",
"type": "礼包",
"buff_1": 15103,
"type_1": "丹药",
"name_1": "菩提证道丹",
"amount_1": 1,
"buff_2": 15006,
"type_2": "神物",
"name_2": "双子莲",
"amount_2": 2,
"buff_3": 1998,
"type_3": "丹药",
"name_3": "渡厄金丹",
"amount_3": 2
},
"15051": {
"name": "新手大礼包",
"type": "礼包",
"buff_1": 9937,
"type_1": "功法",
"name_1": "一气化三清",
"amount_1": 1,
"buff_2": 8932,
"type_2": "神通",
"name_2": "星宿劫",
"amount_2": 1,
"buff_3": 15408,
"type_3": "辅修功法",
"name_3": "斗战诀",
"amount_3": 1,
"buff_4": 7085,
"type_4": "法器",
"name_4": "冲天槊",
"amount_4": 1,
"buff_5": 15050,
"type_5": "礼包",
"name_5": "感谢大礼包",
"amount_5": 99,
"name_6": "灵石",
"amount_6": 9999999999999
}
}
40 changes: 37 additions & 3 deletions data/xiuxian/装备/法器.json
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,17 @@
"mp_buff": 0,
"rank": -5,
"level": "无上仙器",
"type": "装备"
"type": "装备",
"fusion": {
"need_item": {
"7098": 1,
"7099": 1
},
"need_rank": "祭道境圆满",
"need_exp": "0",
"need_stone": "0",
"limit": 1
}
},
"7085": {
"name": "冲天槊",
Expand Down Expand Up @@ -768,7 +778,7 @@
"type": "装备"
},
"15459": {
"name": "穿心枪盖博尔格",
"name": "穿心枪·盖博尔格",
"atk_buff": 0.5,
"crit_buff": 0.5,
"def_buff": 0,
Expand Down Expand Up @@ -840,7 +850,7 @@
"type": "装备"
},
"15465": {
"name": "圣剑瑟尼欧里斯",
"name": "圣剑·瑟尼欧里斯",
"atk_buff": 0.5,
"crit_buff": 0.8,
"def_buff": 0,
Expand All @@ -850,5 +860,29 @@
"rank": -5,
"level": "无上仙器",
"type": "装备"
},
"15466": {
"name": "少姜",
"atk_buff": 1,
"crit_buff": 1,
"def_buff": 1,
"critatk": 1,
"zw": 0,
"mp_buff": 1,
"rank": -5,
"level": "无上仙器",
"type": "装备",
"fusion": {
"need_item": {
"7084": 1,
"15507": 1,
"7085": 1,
"6099": 2
},
"need_rank": "祭道境圆满",
"need_exp": "10000000000",
"need_stone": "10000000000",
"limit": 1
}
}
}
79 changes: 51 additions & 28 deletions nonebot_plugin_xiuxian_2/xiuxian/xiuxian_back/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,13 @@ async def set_auction_by_scheduler_():
for idx, (auction_id, user_id, group_id, item_type, final_price, quantity) in enumerate(auction_results):
item_name = items.get_data_by_item_id(auction_id)['name']
final_user_info = sql_message.get_user_info_with_id(user_id)
if user_id and (final_user_info['stone'] >= (int(final_price) * quantity)):
sql_message.update_ls(user_id, int(final_price) * quantity, 2)
sql_message.send_back(user_id, auction_id, item_name, item_type, quantity)
end_msg += f"{idx + 1}号拍卖品:{item_name}x{quantity}由群{group_id}{final_user_info['user_name']}道友成功拍下\n"
if user_id:
if final_user_info['stone'] < (int(final_price) * quantity):
end_msg += f"{idx + 1}号拍卖品:{item_name}x{quantity} - 道友{final_user_info['user_name']}的灵石不足,流拍了\n"
else:
sql_message.update_ls(user_id, int(final_price) * quantity, 2)
sql_message.send_back(user_id, auction_id, item_name, item_type, quantity)
end_msg += f"{idx + 1}号拍卖品:{item_name}x{quantity}由群{group_id}{final_user_info['user_name']}道友成功拍下\n"

user_auction_info = get_user_auction_price_by_id(auction_id)
if user_auction_info:
Expand Down Expand Up @@ -844,7 +847,7 @@ async def goods_re_root_(bot: Bot, event: GroupMessageEvent, args: Message = Com
num = int(args[1])
except:
num = 1
price = int(6000000 - get_item_msg_rank(goods_id) * 100000) * num
price = int((convert_rank('江湖好手')[0] + 5) * 100000 - get_item_msg_rank(goods_id) * 100000) * num
if price <= 0:
msg = f"物品:{goods_name}炼金失败,凝聚{price}枚灵石,记得通知晓楠!"
if XiuConfig().img:
Expand Down Expand Up @@ -1337,31 +1340,50 @@ async def use_(bot: Bot, event: GroupMessageEvent, args: Message = CommandArg())
await use.finish()
except ValueError:
num = 1

goods_info = items.get_data_by_item_id(goods_id)
user_info = sql_message.get_user_info_with_id(user_id)
user_rank = convert_rank(user_info['level'])[0]
goods_name = goods_info['name']
goods_id1 = goods_info['buff_1']
goods_id2 = goods_info['buff_2']
goods_id3 = goods_info['buff_3']
goods_name1 = goods_info['name_1']
goods_name2 = goods_info['name_2']
goods_name3 = goods_info['name_3']
goods_type1 = goods_info['type_1']
goods_type2 = goods_info['type_2']
goods_type3 = goods_info['type_3']

sql_message.send_back(user_id, goods_id1, goods_name1, goods_type1, 1 * num, 1)# 增加用户道具
sql_message.send_back(user_id, goods_id2, goods_name2, goods_type2, 2 * num, 1)
sql_message.send_back(user_id, goods_id3, goods_name3, goods_type3, 2 * num, 1)

msg_parts = []
i = 1
while True:
buff_key = f'buff_{i}'
name_key = f'name_{i}'
type_key = f'type_{i}'
amount_key = f'amount_{i}'

if name_key not in goods_info:
break

goods_name = goods_info[name_key]
goods_amount = goods_info.get(amount_key, 1) * num

if goods_name == "灵石":
key = 1 if goods_amount > 0 else 2
sql_message.update_ls(user_id, abs(goods_amount), key)
if goods_amount > 0:
msg_parts.append(f"获得灵石{number_to(goods_amount)}枚!\n")
else:
msg_parts.append(f"灵石被收走了{number_to(abs(goods_amount))}枚!\n")
else:
buff_id = goods_info.get(buff_key)
goods_type = goods_info.get(type_key)
if buff_id is not None:
sql_message.send_back(user_id, buff_id, goods_name, goods_type, goods_amount, 1)
msg_parts.append(f"获得{goods_name}{goods_amount}\n")

i += 1

sql_message.update_back_j(user_id, goods_id, num, 0)
msg = f"道友打开了{num}{goods_name},里面居然是{goods_name1}{int(1 * num)}个、{goods_name2}{int(2 * num)}个、{goods_name3}{int(2 * num)}个"
msg = f"道友打开了{num}{goods_info['name']}:\n" + "".join(msg_parts)

if XiuConfig().img:
pic = await get_msg_pic(f"@{event.sender.nickname}\n" + msg)
await bot.send_group_msg(group_id=int(send_group_id), message=MessageSegment.image(pic))
else:
await bot.send_group_msg(group_id=int(send_group_id), message=msg)
await use.finish()
await use.finish()

elif goods_type == "聚灵旗":
msg = get_use_jlq_msg(user_id, goods_id)
Expand Down Expand Up @@ -1475,7 +1497,7 @@ async def creat_auction_(bot: Bot, event: GroupMessageEvent):

# 系统拍卖品
auction_id_list = get_auction_id_list()
auction_count = random.randint(3, 8) # 随机挑选系统拍卖品数量
auction_count = random.randint(1, 2) # 随机挑选系统拍卖品数量
auction_ids = random.sample(auction_id_list, auction_count)
for auction_id in auction_ids:
item_info = items.get_data_by_item_id(auction_id)
Expand Down Expand Up @@ -1617,14 +1639,16 @@ async def creat_auction_(bot: Bot, event: GroupMessageEvent):

# 拍卖会结算
end_msg = f"本场拍卖会结束!感谢各位道友的参与。\n拍卖结果整理如下:\n"
print(auction_results)
for idx, (auction_id, user_id, group_id, item_type, final_price, quantity) in enumerate(auction_results):
item_name = items.get_data_by_item_id(auction_id)['name']
final_user_info = sql_message.get_user_info_with_id(user_id)
if user_id and (final_user_info['stone'] >= (int(final_price) * quantity)):
sql_message.update_ls(user_id, int(final_price) * quantity, 2)
sql_message.send_back(user_id, auction_id, item_name, item_type, quantity)
end_msg += f"{idx + 1}号拍卖品:{item_name}x{quantity}由群{group_id}{final_user_info['user_name']}道友成功拍下\n"
if user_id:
if final_user_info['stone'] < (int(final_price) * quantity):
end_msg += f"{idx + 1}号拍卖品:{item_name}x{quantity} - 道友{final_user_info['user_name']}的灵石不足,流拍了\n"
else:
sql_message.update_ls(user_id, int(final_price) * quantity, 2)
sql_message.send_back(user_id, auction_id, item_name, item_type, quantity)
end_msg += f"{idx + 1}号拍卖品:{item_name}x{quantity}由群{group_id}{final_user_info['user_name']}道友成功拍下\n"

user_auction_info = get_user_auction_price_by_id(auction_id)
if user_auction_info:
Expand Down Expand Up @@ -1744,7 +1768,6 @@ async def offer_auction_(bot: Bot, event: GroupMessageEvent, args: Message = Com
else:
await bot.send_group_msg(group_id=int(group_id), message=msg)
except ActionFailed:
error_msg = f"消息发送失败,可能被风控,当前拍卖物品金额为:{auction['now_price']}!"
continue
logger.opt(colors=True).info(
f"<green>有人拍卖,拍卖标志:{auction_offer_flag},当前等待时间:{auction_offer_all_count * AUCTIONOFFERSLEEPTIME},总计拍卖次数:{auction_offer_time_count}</green>")
Expand Down
27 changes: 24 additions & 3 deletions nonebot_plugin_xiuxian_2/xiuxian/xiuxian_back/back_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
except ImportError:
import json
from ..xiuxian_utils.item_json import Items
from ..xiuxian_utils.utils import number_to
from ..xiuxian_utils.xiuxian2_handle import (
XiuxianDateManage, UserBuffDate,
get_weapon_info_msg, get_armor_info_msg,
Expand Down Expand Up @@ -422,6 +423,19 @@ def get_item_msg(goods_id):

else:
msg = '不支持的物品'

if 'fusion' in item_info:
fusion_info = item_info['fusion']
msg += "\n合成相关信息:\n"
needed_items = fusion_info.get('need_item', {})
for item_id, amount_needed in needed_items.items():
item_name = items.get_data_by_item_id(int(item_id))['name']
msg += f"需要{amount_needed}{item_name}\n"
msg += f"需要灵石:{number_to(int(fusion_info.get('need_stone', 0)))}\n"
msg += f"需要境界:{fusion_info.get('need_rank', '无')}\n"
msg += f"需要修为:{number_to(int(fusion_info.get('need_exp', 0)))}\n"
msg += f"数量限制:{fusion_info.get('limit', '无')}"

return msg


Expand Down Expand Up @@ -465,7 +479,9 @@ def check_use_elixir(user_id, goods_id, num):
goods_rank = goods_info['rank']
goods_name = goods_info['name']
back = sql_message.get_item_by_good_id_and_user_id(user_id, goods_id)
goods_all_num = back['all_num']
goods_all_num = back['all_num'] # 数据库里的使用数量
remaining_limit = goods_info['all_num'] - goods_all_num # 剩余可用数量

if goods_info['buff_type'] == "level_up_rate": # 增加突破概率的丹药
if goods_rank < user_rank: # 最低使用限制
msg = f"丹药:{goods_name}的最低使用境界为{goods_info['境界']},道友不满足使用条件"
Expand All @@ -482,10 +498,15 @@ def check_use_elixir(user_id, goods_id, num):
else:
if goods_all_num >= goods_info['all_num']:
msg = f"道友使用的丹药:{goods_name}已经达到丹药的耐药性上限!已经无法使用该丹药了!"
else: # 检查完毕
else:
if num > remaining_limit:
num = remaining_limit
msg = f"道友使用的数量超过了耐药性上限呢,仅使用了{num}颗!"
else:
msg = f"道友成功使用丹药:{goods_name}{num}颗, 下一次突破的成功概率提高{goods_info['buff'] * num}%!"

sql_message.update_back_j(user_id, goods_id, num, 1)
sql_message.update_levelrate(user_id, user_info['level_up_rate'] + goods_info['buff'] * num)
msg = f"道友成功使用丹药:{goods_name}{num}颗,下一次突破的成功概率提高{goods_info['buff'] * num}%!"

elif goods_info['buff_type'] == "hp": # 回复状态的丹药
if user_info['root'] == "器师":
Expand Down
9 changes: 5 additions & 4 deletions nonebot_plugin_xiuxian_2/xiuxian/xiuxian_base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
23、仙途奇缘:发送 仙途奇缘帮助 获取
24、轮回重修:发送 轮回重修帮助 获取
25、境界帮助、灵根帮助、品阶帮助:获取对应帮助信息
26、仙器合成:发送 合成xx 获取,目前开放合成的仙器为天罪
26、物品合成:发送 合成帮助 获取
27、金银阁:发送 金银阁帮助 获取
""".strip()

Expand Down Expand Up @@ -128,7 +128,8 @@
6.替换数据库元组为字典返回,替换USERRANK为convert_rank函数
7.群拍卖会可以依次拍卖多个物品了
8.支持用户提交拍卖品了,拍卖时优先拍卖用户的拍卖品
9.逐步实现体力系统
9.实现简单的体力系统
10.重构合成系统
""".strip()

__level_help__ = f"""
Expand Down Expand Up @@ -1402,7 +1403,7 @@ async def rob_stone_(bot: Bot, event: GroupMessageEvent, args: Message = Command
await bot.send_group_msg(group_id=int(send_group_id), message=msg)
await rob_stone.finish()

impart_data_1 = xiuxian_impart.get_user_info_with_id(user_id)
impart_data_1 = xiuxian_impart.get_user_impart_info_with_id(user_id)
player1['user_id'] = user_info['user_id']
player1['道号'] = user_info['user_name']
player1['气血'] = user_info['hp']
Expand All @@ -1420,7 +1421,7 @@ async def rob_stone_(bot: Bot, event: GroupMessageEvent, args: Message = Command
def_buff = 0
player1['防御'] = def_buff

impart_data_2 = xiuxian_impart.get_user_info_with_id(user_2['user_id'])
impart_data_2 = xiuxian_impart.get_user_impart_info_with_id(user_2['user_id'])
player2['user_id'] = user_2['user_id']
player2['道号'] = user_2['user_name']
player2['气血'] = user_2['hp']
Expand Down
Loading

0 comments on commit 67d4049

Please sign in to comment.