Skip to content

Commit

Permalink
<jx3>[feat]arena_record
Browse files Browse the repository at this point in the history
  • Loading branch information
HornCopper committed Aug 20, 2024
1 parent 5e1305f commit 20b4361
Show file tree
Hide file tree
Showing 12 changed files with 434 additions and 92 deletions.
6 changes: 3 additions & 3 deletions src/plugins/jx3/achievement/v1_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from src.tools.generate import generate, get_uuid
from src.tools.basic.jx3 import gen_ts, format_body, gen_xsk

from src.plugins.jx3.bind import getPlayerLocalData
from src.plugins.jx3.bind import get_player_local_data
from src.plugins.jx3.dungeon.api import get_map, zone_mapping, mode_mapping

import json
Expand Down Expand Up @@ -51,7 +51,7 @@ async def achi_v2(server: str = None, name: str = None, achievement: str = None,
server = server_mapping(server, group_id)
if not server:
return [PROMPT.ServerNotExist]
personal_data_request = await getPlayerLocalData(roleName=name, serverName=server)
personal_data_request = await get_player_local_data(role_name=name, server_name=server)
personal_data = personal_data_request.format_jx3api()
if personal_data["code"] != 200:
guid = ""
Expand Down Expand Up @@ -120,7 +120,7 @@ async def zone_achi(server: str = None, name: str = None, zone: str = None, mode
mode = mode_mapping(mode)
if zone is False or mode is False:
return ["唔……难度或名称输入有误。"]
personal_data_request = await getPlayerLocalData(roleName=name, serverName=server)
personal_data_request = await get_player_local_data(role_name=name, server_name=server)
personal_data = personal_data_request.format_jx3api()
if personal_data["code"] != 200:
guid = ""
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/jx3/affection/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from src.tools.basic.data_server import getGroupServer
from src.tools.utils.path import ASSETS, CACHE, VIEWS

from src.plugins.jx3.bind import getPlayerLocalData
from src.plugins.jx3.bind import get_player_local_data
from src.plugins.jx3.rank.school_rank import colors

import random
Expand Down Expand Up @@ -40,7 +40,7 @@ def checkUinStatus(uin: int):
return False

async def getSchool(name: str, server: str):
data = await getPlayerLocalData(roleName=name, serverName=server)
data = await get_player_local_data(role_name=name, server_name=server)
data = data.format_jx3api()
if data["code"] != 200:
return False
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/jx3/attributes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from src.tools.utils.path import ASSETS, CACHE, PLUGINS
from src.tools.basic.jx3 import gen_ts, format_body, gen_xsk

from src.plugins.jx3.bind import getPlayerLocalData
from src.plugins.jx3.bind import get_player_local_data

import os
import json
Expand All @@ -24,7 +24,7 @@

async def get_uid(server, id):
token = Config.jx3.api.token
data = await getPlayerLocalData(roleName=id, serverName=server)
data = await get_player_local_data(role_name=id, server_name=server)
data = data.format_jx3api()
if data["code"] != 200:
return False
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/jx3/attributes/v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from src.tools.generate import get_uuid, generate
from src.tools.utils.path import ASSETS, CACHE, PLUGINS, VIEWS

from src.plugins.jx3.bind import getPlayerLocalData
from src.plugins.jx3.bind import get_player_local_data
from src.plugins.jx3.affection import getColor

from .api import kungfu_mapping, enchant_mapping, find_qx
Expand All @@ -35,7 +35,7 @@
</tr>"""

async def get_basic_info(server: str, name: str):
data = await getPlayerLocalData(roleName=name, serverName=server)
data = await get_player_local_data(role_name=name, server_name=server)
data = data.format_jx3api()
if data["code"] != 200:
return 404
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/jx3/bind/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ def format_jx3api(self):

from src.tools.utils.request import get_api

async def getPlayerLocalData(roleName: str = "", roleId: str = "", serverName: str = None):
player_data = group_db.where_one(RoleData(), "roleName = ? OR roleId = ? AND serverName = ?", roleName, roleId, serverName, default=None)
async def get_player_local_data(role_name: str = "", role_id: str = "", server_name: str = None):
player_data = group_db.where_one(RoleData(), "roleName = ? OR roleId = ? AND serverName = ?", role_name, role_id, server_name, default=None)
if player_data is None:
uid = await get_uid(roleName=roleName, serverName=serverName)
uid = await get_uid(roleName=role_name, serverName=server_name)
if uid == None:
return Player()
await getRoleData(uid, serverName)
return await getPlayerLocalData(roleName=roleName, roleId=uid)
await getRoleData(uid, server_name)
return await get_player_local_data(role_name=role_name, role_id=uid)
else:
return Player(**player_data.dump())
6 changes: 3 additions & 3 deletions src/plugins/jx3/detail/detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from src.tools.basic.msg import PROMPT
from src.tools.basic.data_server import server_mapping

from src.plugins.jx3.bind import getPlayerLocalData
from src.plugins.jx3.bind import get_player_local_data

import json

Expand Down Expand Up @@ -46,7 +46,7 @@ async def get_tuilan_data(url: str, params: Union[dict, None] = None):


async def get_guid(server: str, name: str):
data = await getPlayerLocalData(roleName=name, serverName=server)
data = await get_player_local_data(role_name=name, server_name=server)
data = data.format_jx3api()
if data["code"] != 200:
return False
Expand Down Expand Up @@ -185,7 +185,7 @@ async def generate_zd_image(server: str, id: str):
"""

async def get_personal_guid(server: str, id: str):
data = await getPlayerLocalData(roleName=name, serverName=server)
data = await get_player_local_data(role_name=name, server_name=server)
data = data.format_jx3api()
if data["code"] != 200:
return False
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/jx3/dungeon/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from src.tools.utils.common import convert_time, getCurrentTime, getRelateTime
from src.tools.file import read, write

from src.plugins.jx3.bind import getPlayerLocalData
from src.plugins.jx3.bind import get_player_local_data
from src.plugins.jx3.attributes import Zone_mapping

import json
Expand Down Expand Up @@ -370,7 +370,7 @@ async def generater(map, mode, boss):

async def zone_v2(server, id):
server = server_mapping(server)
data = await getPlayerLocalData(roleName=id, serverName=server)
data = await get_player_local_data(role_name=id, server_name=server)
details_data = data.format_jx3api()
if details_data["code"] != 200:
guid = ""
Expand Down
98 changes: 58 additions & 40 deletions src/plugins/jx3/pvp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent, MessageSegment as ms

from src.tools.basic.msg import PROMPT
from src.tools.utils.request import get_content
from src.tools.file import get_content_local

from .leader import *
Expand All @@ -14,72 +13,91 @@

@arena_re.handle()
async def _(bot: Bot, event: GroupMessageEvent, args: Message = CommandArg()):
if args.extract_plain_text() == "":
return
if args.extract_plain_text() == "":
return
arg = args.extract_plain_text().split(" ")
if len(arg) not in [1, 2, 3]:
# 1 -> 战绩 xxx
# 2 -> 战绩 srv xx / 战绩 xx 22(33or55)
# 3 -> 战绩 srv xx 22(33or55)
if len(arg) not in [1, 2]:
await arena_re.finish(PROMPT.ArgumentCountInvalid)
if len(arg) == 1:
server = None
name = arg[0]
id = arg[0]
elif len(arg) == 2:
if arg[-1] not in ["22", "33", "55"]:
server = arg[0]
name = arg[1]
else:
server = None
name = arg[0]
mode = arg[1]
else:
server = arg[0]
name = arg[1]
mode = arg[2]
data = await arena_record(server=server, name=name, group_id=event.group_id)
id = arg[1]
data = await arena_record(server, id, group_id=str(event.group_id))
if isinstance(data, list):
await arena_re.finish(data[0])
else:
data = await get_content(data)
data = get_content_local(data)
await arena_re.finish(ms.image(data))
# arg = args.extract_plain_text().split(" ")
# if len(arg) not in [1, 2, 3]:
# # 1 -> 战绩 xxx
# # 2 -> 战绩 srv xx / 战绩 xx 22(33or55)
# # 3 -> 战绩 srv xx 22(33or55)
# await arena_re.finish(PROMPT.ArgumentCountInvalid)
# if len(arg) == 1:
# server = None
# name = arg[0]
# elif len(arg) == 2:
# if arg[-1] not in ["22", "33", "55"]:
# server = arg[0]
# name = arg[1]
# else:
# server = None
# name = arg[0]
# mode = arg[1]
# else:
# server = arg[0]
# name = arg[1]
# mode = arg[2]
# data = await arena_record(server=server, name=name, group_id=event.group_id)
# if isinstance(data, list):
# await arena_re.finish(data[0])
# else:
# data = await get_content(data)
# await arena_re.finish(ms.image(data))

arena_ra = on_command("jx3_arena_rank", aliases={"排行"}, force_whitespace=True, priority=5)

@arena_ra.handle()
async def _(bot: Bot, event: GroupMessageEvent, args: Message = CommandArg()):
if args.extract_plain_text() == "":
return
arg = args.extract_plain_text().split(" ")
if arg[0] not in ["22", "33", "55"]:
await arena_ra.finish("唔……名剑模式只接受22、33、55!")
data = await arena_rank(mode=arg[0])
if isinstance(data, list):
await arena_ra.finish(data[0])
else:
data = await get_content(data)
await arena_ra.finish(ms.image(data))
# arg = args.extract_plain_text().split(" ")
# if arg[0] not in ["22", "33", "55"]:
# await arena_ra.finish("唔……名剑模式只接受22、33、55!")
# data = await arena_rank(mode=arg[0])
# if isinstance(data, list):
# await arena_ra.finish(data[0])
# else:
# data = await get_content(data)
# await arena_ra.finish(ms.image(data))

arena_s = on_command("jx3_arena_stastic", aliases={"统计"}, force_whitespace=True, priority=5)

@arena_s.handle()
async def _(bot: Bot, event: GroupMessageEvent, args: Message = CommandArg()):
if args.extract_plain_text() == "":
return
arg = args.extract_plain_text().split(" ")
if arg[0] not in ["22", "33", "55"]:
await arena_s.finish("唔……名剑模式只接受22、33、55!")
data = await arena_stastic(mode=arg[0])
if isinstance(data, list):
await arena_s.finish(data[0])
else:
data = await get_content(data)
await arena_s.finish(ms.image(data))
# arg = args.extract_plain_text().split(" ")
# if arg[0] not in ["22", "33", "55"]:
# await arena_s.finish("唔……名剑模式只接受22、33、55!")
# data = await arena_stastic(mode=arg[0])
# if isinstance(data, list):
# await arena_s.finish(data[0])
# else:
# data = await get_content(data)
# await arena_s.finish(ms.image(data))

lks = on_command("jx3_lks", aliases={"烂柯山"}, force_whitespace=True, priority=5)

@lks.handle()
async def _(event: GroupMessageEvent):
img = await getLKSImage()
data = get_content_local(img)
await lks.finish(ms.image(data))
async def _(event: GroupMessageEvent, args: Message = CommandArg()):
if args.extract_plain_text() != "":
return
# img = await getLKSImage()
# data = get_content_local(img)
# await lks.finish(ms.image(data))
Loading

0 comments on commit 20b4361

Please sign in to comment.