koishi-plugin-noah 2.2.3 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/lib/drawer/sdvx/index.d.ts +1 -1
  2. package/lib/games/sdvx/adapters/asphyxia.d.ts +18 -0
  3. package/lib/games/sdvx/adapters/index.d.ts +6 -0
  4. package/lib/games/sdvx/adapters/mao.d.ts +19 -0
  5. package/lib/games/sdvx/adapters/official.d.ts +14 -0
  6. package/lib/games/sdvx/command.d.ts +1 -1
  7. package/lib/games/sdvx/commands/calculate.d.ts +1 -1
  8. package/lib/games/sdvx/commands/chart.d.ts +1 -1
  9. package/lib/games/sdvx/commands/info.d.ts +1 -1
  10. package/lib/games/sdvx/commands/radar.d.ts +1 -1
  11. package/lib/games/sdvx/commands/recent.d.ts +1 -1
  12. package/lib/games/sdvx/commands/sync.d.ts +1 -1
  13. package/lib/games/sdvx/commands/vf.d.ts +1 -1
  14. package/lib/games/sdvx/config.d.ts +1 -2
  15. package/lib/games/sdvx/services/music-service.d.ts +1 -1
  16. package/lib/games/sdvx/types/config.d.ts +10 -0
  17. package/lib/games/sdvx/types/index.d.ts +16 -0
  18. package/lib/index.cjs +1316 -1382
  19. package/lib/servers/Asphyxia/index.d.ts +0 -4
  20. package/lib/servers/Asphyxia/utils/xml.d.ts +2 -0
  21. package/lib/servers/Mao/index.d.ts +0 -4
  22. package/lib/servers/Official/index.d.ts +0 -4
  23. package/lib/servers/index.d.ts +4 -17
  24. package/lib/types/config.d.ts +2 -12
  25. package/lib/types/index.d.ts +0 -67
  26. package/package.json +1 -1
  27. package/lib/servers/Asphyxia/services/sdvx-service.d.ts +0 -26
  28. package/lib/servers/Mao/services/sdvx-service.d.ts +0 -39
  29. package/lib/servers/Official/services/sdvx-service.d.ts +0 -25
  30. package/lib/servers/utils/grade.d.ts +0 -8
  31. package/lib/servers/utils/xml.d.ts +0 -13
  32. /package/lib/{servers → games/sdvx}/utils/difficulty.d.ts +0 -0
@@ -7,8 +7,4 @@ export declare class Asphyxia implements IServer {
7
7
  [key in TGame]?: GameService;
8
8
  };
9
9
  logger: Logger;
10
- /**
11
- * 初始化各个游戏服务实例
12
- */
13
- constructor();
14
10
  }
@@ -0,0 +1,2 @@
1
+ export declare const xmlToJson: (xml: string) => Promise<any>;
2
+ export declare const jsonToXml: (json: any) => string;
@@ -7,8 +7,4 @@ export declare class Mao implements IServer {
7
7
  [key in TGame]?: GameService;
8
8
  };
9
9
  logger: Logger;
10
- /**
11
- * 初始化SDVX游戏服务实例
12
- */
13
- constructor();
14
10
  }
@@ -7,8 +7,4 @@ export declare class Official implements IServer {
7
7
  [key in TGame]?: GameService;
8
8
  };
9
9
  logger: Logger;
10
- /**
11
- * 初始化SDVX游戏服务实例
12
- */
13
- constructor();
14
10
  }
@@ -1,29 +1,16 @@
1
1
  import { Context } from 'koishi';
2
- import { TServer, TGame } from '../types';
2
+ import { TServer, TGame, GameService } from '../types';
3
3
  import type { AppConfig } from '../types/config';
4
4
  export declare const name = "Noah-Server";
5
5
  export declare const inject: string[];
6
6
  export declare class ServerManager {
7
7
  private static instance;
8
8
  private factory;
9
+ private externalServices;
9
10
  private constructor();
10
- /**
11
- * 获取服务器管理器实例
12
- * @returns 服务器管理器的唯一实例
13
- */
14
11
  static getInstance(): ServerManager;
15
- /**
16
- * 根据服务器类型获取对应的服务器实例
17
- * @param serverType - 服务器类型
18
- * @returns 对应的服务器实例
19
- */
20
12
  getServer(serverType: TServer): import("../types").IServer;
21
- /**
22
- * 根据服务器类型和游戏类型获取对应的游戏服务实例
23
- * @param serverType - 服务器类型
24
- * @param gameType - 游戏类型
25
- * @returns 对应的游戏服务实例
26
- */
27
- getGameService(serverType: TServer, gameType: TGame): import("../types").GameService;
13
+ registerGameService(serverType: TServer, gameType: TGame, service: GameService): void;
14
+ getGameService(serverType: TServer, gameType: TGame): GameService;
28
15
  }
29
16
  export declare function apply(ctx: Context, config: AppConfig): void;
@@ -1,4 +1,6 @@
1
1
  import { MessageReply } from '../fun/poke/types';
2
+ import { SDVXConfig } from '../games/sdvx/types/config';
3
+ export { SDVXConfig };
2
4
  /**
3
5
  * 基础配置接口
4
6
  * 所有配置接口的基础接口
@@ -37,18 +39,6 @@ export interface CoreConfig extends BaseConfig {
37
39
  /** 群名片列表 */
38
40
  guildNameCards?: string[];
39
41
  }
40
- /**
41
- * SDVX 游戏配置接口
42
- * 包含 SDVX 游戏相关的配置项
43
- */
44
- export interface SDVXConfig extends BaseConfig {
45
- /** 默认模型名称 */
46
- default_model: string;
47
- /** SDVX 数据 URL */
48
- sdvx_data_url: string;
49
- /** SDVX 搜索 URL */
50
- sdvx_search_url: string;
51
- }
52
42
  /**
53
43
  * 戳一戳功能配置接口
54
44
  * 包含戳一戳功能相关的配置项
@@ -1,6 +1,4 @@
1
1
  import { Context, Logger } from 'koishi';
2
- import { SDVXScore } from '../games/sdvx/types';
3
- import { SDVXConfig } from './config';
4
2
  /** 服务器类型 */
5
3
  export type TServer = 'asphyxia' | 'mao' | 'official';
6
4
  /** 服务器类型可选值列表 */
@@ -17,70 +15,6 @@ export interface GameService {
17
15
  /** 服务专用的日志记录器实例 */
18
16
  logger: Logger;
19
17
  }
20
- /**
21
- * Sound Voltex (SDVX) 游戏服务接口
22
- * 扩展基础游戏服务接口,添加 SDVX 特定的功能
23
- */
24
- export interface SDVXService extends GameService {
25
- /**
26
- * 获取指定卡片的所有分数记录
27
- * @param ctx - Koishi 上下文对象
28
- * @param url - SDVX 服务的基础 URL
29
- * @param cardId - 玩家卡片 ID
30
- * @param config - SDVX 配置设置
31
- * @returns Promise 解析为 SDVX 分数记录数组
32
- * @throws 当获取操作失败时抛出错误
33
- */
34
- getAllScore(ctx: Context, url: string, cardId: string, config: SDVXConfig): Promise<SDVXScore[]>;
35
- /**
36
- * 获取指定音乐 ID 的分数记录
37
- * @param ctx - Koishi 上下文对象
38
- * @param url - SDVX 服务的基础 URL
39
- * @param cardId - 玩家卡片 ID
40
- * @param musicId - 音乐曲目 ID
41
- * @param config - SDVX 配置设置
42
- * @returns Promise 解析为单个 SDVX 分数记录
43
- * @throws 当获取操作失败时抛出错误
44
- */
45
- getScore(ctx: Context, url: string, cardId: string, musicId: number, config: SDVXConfig): Promise<SDVXScore>;
46
- /**
47
- * 获取卡片的最近分数记录
48
- * @param ctx - Koishi 上下文对象
49
- * @param url - SDVX 服务的基础 URL
50
- * @param cardId - 玩家卡片 ID
51
- * @param config - SDVX 配置设置(可选)
52
- * @param count - 要获取的最近分数记录数量(可选,默认为 1)
53
- * @returns Promise 解析为最近 SDVX 分数记录数组
54
- * @throws 当获取操作失败时抛出错误
55
- */
56
- getRecentScores(ctx: Context, url: string, cardId: string, config?: SDVXConfig, count?: number): Promise<SDVXScore[]>;
57
- /**
58
- * 从服务器响应中获取用户名/ID
59
- * @param ctx - Koishi 上下文对象
60
- * @param url - API 的基础 URL
61
- * @param cardId - 玩家卡片 ID
62
- * @returns 玩家 ID
63
- */
64
- getUserName(ctx: Context, url: string, cardId: string): Promise<string>;
65
- /**
66
- * 校验 PIN 码
67
- * @param ctx - Koishi 上下文对象
68
- * @param url - API 基础 URL
69
- * @param cardId - 玩家卡片 ID
70
- * @param pin - 四位数字 PIN
71
- * @returns 是否验证通过
72
- */
73
- verifyPin?(ctx: Context, url: string, cardId: string, pin: string): Promise<boolean>;
74
- /**
75
- * 上传分数数据
76
- * @param ctx - Koishi 上下文对象
77
- * @param url - API 基础 URL
78
- * @param cardId - 玩家卡片 ID
79
- * @param scorePayload - 待上传的分数数据
80
- * @returns 上传是否成功
81
- */
82
- uploadScore?(ctx: Context, url: string, cardId: string, scores: SDVXScore[]): Promise<boolean>;
83
- }
84
18
  /**
85
19
  * 服务器接口
86
20
  * 定义服务器的基本属性和功能
@@ -105,4 +39,3 @@ export interface IDrawer {
105
39
  /** 用于使用 Koishi 功能的上下文对象 */
106
40
  ctx: Context;
107
41
  }
108
- export { SDVXScore };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-noah",
3
- "version": "2.2.3",
3
+ "version": "2.3.0",
4
4
  "contributors": [
5
5
  "Logthm <logthm@outlook.com>"
6
6
  ],
@@ -1,26 +0,0 @@
1
- import { Context, Logger } from 'koishi';
2
- import { SDVXScore } from '../../../games/sdvx/types';
3
- import { GameService } from '../../../types';
4
- import { SDVXConfig } from '../../../types/config';
5
- export declare class SDVXService implements GameService {
6
- private static instance;
7
- logger: Logger;
8
- private constructor();
9
- static getInstance(logger: Logger): SDVXService;
10
- /**
11
- * 获取 refid
12
- */
13
- getRefid(ctx: Context, url: string, model: string, cardId: string): Promise<string>;
14
- /**
15
- * 获取用户名
16
- */
17
- getUserName(ctx: Context, url: string, cardId: string, model?: string): Promise<string>;
18
- /**
19
- * 获取所有分数
20
- */
21
- getAllScore(ctx: Context, url: string, cardId: string, config: SDVXConfig, model?: string): Promise<SDVXScore[]>;
22
- /**
23
- * 难度字符串映射
24
- */
25
- private getDifficultyString;
26
- }
@@ -1,39 +0,0 @@
1
- import { Context, Logger } from 'koishi';
2
- import { SDVXScore } from '../../../games/sdvx/types';
3
- import { SDVXService as ISDVXService } from '../../../types';
4
- import { SDVXConfig } from '../../../types/config';
5
- export declare class SDVXService implements ISDVXService {
6
- private static instance;
7
- logger: Logger;
8
- private constructor();
9
- static getInstance(logger: Logger): SDVXService;
10
- /**
11
- * Get the difficulty string based on the difficulty type number
12
- * @param diffType Difficulty type
13
- * @returns The difficulty string (novice, advanced, exhaust, infinite, maximum)
14
- */
15
- private getDifficultyString;
16
- /**
17
- * Get the user name/ID from the server response
18
- * @param ctx Context object
19
- * @param url Base URL for the API
20
- * @param cardId Card ID of the player
21
- * @returns The player ID (e.g., "ED*")
22
- */
23
- getUserName(ctx: Context, url: string, cardId: string): Promise<string>;
24
- /**
25
- * 验证猫网 PIN 码
26
- * @param ctx - Koishi 上下文对象
27
- * @param url - 猫网基础 URL
28
- * @param cardId - 卡号
29
- * @param pin - 四位数字 PIN
30
- * @returns 验证是否通过
31
- */
32
- verifyPin(ctx: Context, url: string, cardId: string, pin: string): Promise<boolean>;
33
- private clearTypeToNum;
34
- private diffNameToMusicType;
35
- uploadScore(ctx: Context, url: string, cardId: string, scores: SDVXScore[]): Promise<boolean>;
36
- getAllScore(ctx: Context, url: string, cardId: string, config: SDVXConfig): Promise<SDVXScore[]>;
37
- getScore(ctx: Context, url: string, cardId: string, musicId: number, config: SDVXConfig): Promise<SDVXScore>;
38
- getRecentScores(ctx: Context, url: string, cardId: string, config: SDVXConfig, count?: number): Promise<SDVXScore[]>;
39
- }
@@ -1,25 +0,0 @@
1
- import { Context, Logger } from 'koishi';
2
- import { SDVXScore } from '../../../games/sdvx/types';
3
- import { SDVXService as ISDVXService } from '../../../types';
4
- import { SDVXConfig } from '../../../types/config';
5
- export declare class SDVXService implements ISDVXService {
6
- private static instance;
7
- logger: Logger;
8
- private constructor();
9
- static getInstance(logger: Logger): SDVXService;
10
- /**
11
- * 映射 mark 到 SDVXClearType
12
- */
13
- private mapClearType;
14
- /**
15
- * Get the user name/ID from the server response
16
- * @param ctx Context object
17
- * @param url Base Official Support URL for the API
18
- * @param player_id Player ID of the player (SV-xxxx-xxxx format)
19
- * @returns The player name
20
- */
21
- getUserName(ctx: Context, url: string, player_id: string): Promise<string>;
22
- getAllScore(ctx: Context, url: string, player_id: string, config: SDVXConfig): Promise<SDVXScore[]>;
23
- getScore(ctx: Context, url: string, player_id: string, musicId: number, config: SDVXConfig): Promise<SDVXScore>;
24
- getRecentScores(ctx: Context, url: string, player_id: string, config: SDVXConfig, count?: number): Promise<SDVXScore[]>;
25
- }
@@ -1,8 +0,0 @@
1
- import { SDVXClearType } from '../../games/sdvx/types';
2
- export { getGradeByScore as getSDVXGrade } from '../../games/sdvx/constants';
3
- /**
4
- * 根据通关类型编号获取SDVX通关类型名称
5
- * @param clearType - 通关类型编号
6
- * @returns SDVX通关类型
7
- */
8
- export declare function getSDVXClearType(clearType: number): SDVXClearType;
@@ -1,13 +0,0 @@
1
- /**
2
- * 将 XML 字符串转换为 JSON
3
- * @param xml - XML 格式的字符串
4
- * @returns 解析后的 JSON 对象
5
- * @throws 解析 XML 失败时抛出异常
6
- */
7
- export declare const xmlToJson: (xml: string) => Promise<any>;
8
- /**
9
- * 将 JSON 对象转换为 XML 字符串
10
- * @param json - 要转换的 JavaScript 对象
11
- * @returns XML 格式的字符串
12
- */
13
- export declare const jsonToXml: (json: any) => string;