@hieuzest/koishi-plugin-riichi-city 0.4.6 → 0.5.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.
package/lib/api.d.ts CHANGED
@@ -95,7 +95,7 @@ export declare class RiichiCityApi {
95
95
  limit?: number;
96
96
  skip?: number;
97
97
  }): Promise<types.Paipu[]>;
98
- getRoomData(roomId: string): Promise<types.RoomData>;
98
+ getRoomData(roomId: string, isObserve?: boolean): Promise<types.RoomData>;
99
99
  getGameData(roomId: string, eventStartPos: number): Promise<types.GameData>;
100
100
  }
101
101
  export declare namespace RiichiCityApi {
package/lib/api.js CHANGED
@@ -284,8 +284,8 @@ var RiichiCityApi = class _RiichiCityApi {
284
284
  const res = await this.post("/record/readPaiPuList", { limit, skip, ...options });
285
285
  return res.data;
286
286
  }
287
- async getRoomData(roomId) {
288
- const res = await this.post("/record/getRoomData", { isObserve: true, keyValue: roomId });
287
+ async getRoomData(roomId, isObserve = true) {
288
+ const res = await this.post("/record/getRoomData", { isObserve, keyValue: roomId });
289
289
  return res.data;
290
290
  }
291
291
  async getGameData(roomId, eventStartPos) {
package/lib/dhs.d.ts CHANGED
@@ -30,6 +30,7 @@ export declare namespace RiichiCityDHS {
30
30
  interface Config {
31
31
  forceFourPlayer: boolean;
32
32
  extraHelp: string;
33
+ adminAccountId: number;
33
34
  notifyInterval: number;
34
35
  notifyIdle: number;
35
36
  notifySendInterval: number;
package/lib/index.js CHANGED
@@ -38,12 +38,12 @@ var require_zh_CN = __commonJS({
38
38
  });
39
39
 
40
40
  // src/index.ts
41
- var src_exports = {};
42
- __export(src_exports, {
41
+ var index_exports = {};
42
+ __export(index_exports, {
43
43
  RiichiCity: () => RiichiCity,
44
- default: () => src_default
44
+ default: () => index_default
45
45
  });
46
- module.exports = __toCommonJS(src_exports);
46
+ module.exports = __toCommonJS(index_exports);
47
47
  var import_koishi3 = require("koishi");
48
48
  var import_api2 = require("./api");
49
49
 
@@ -329,7 +329,7 @@ ${config.extraHelp}`.trim();
329
329
  }
330
330
  async getDHS(id) {
331
331
  if (!(id in this.contests)) {
332
- const c = new import_lobby.RiichiCityLobby(this.api, id);
332
+ const c = new import_lobby.RiichiCityLobby(this.api, id, { adminAccountId: this.config.adminAccountId });
333
333
  try {
334
334
  await c.init();
335
335
  } catch (e) {
@@ -362,6 +362,7 @@ ${config.extraHelp}`.trim();
362
362
  RiichiCityDHS2.Config = import_koishi.Schema.object({
363
363
  forceFourPlayer: import_koishi.Schema.boolean().default(false),
364
364
  extraHelp: import_koishi.Schema.string().default(""),
365
+ adminAccountId: import_koishi.Schema.natural().default(0),
365
366
  notifyInterval: import_koishi.Schema.natural().default(60),
366
367
  notifyIdle: import_koishi.Schema.natural().default(200),
367
368
  notifySendInterval: import_koishi.Schema.natural().default(20),
@@ -439,7 +440,8 @@ var RiichiCity = class extends import_koishi3.Service {
439
440
  nickname: "string",
440
441
  updatedAt: "unsigned"
441
442
  }, {
442
- primary: "userId"
443
+ primary: "userId",
444
+ indexes: ["nickname"]
443
445
  });
444
446
  this.api = new import_api2.RiichiCityApi(ctx, config);
445
447
  ctx.on("ready", async () => {
@@ -492,7 +494,7 @@ var RiichiCity = class extends import_koishi3.Service {
492
494
  })
493
495
  ]);
494
496
  })(RiichiCity || (RiichiCity = {}));
495
- var src_default = RiichiCity;
497
+ var index_default = RiichiCity;
496
498
  // Annotate the CommonJS export names for ESM import in node:
497
499
  0 && (module.exports = {
498
500
  RiichiCity
package/lib/lobby.d.ts CHANGED
@@ -51,12 +51,17 @@ export declare class Paipu extends Game {
51
51
  export declare class RiichiCityLobby {
52
52
  readonly api: RiichiCityApi;
53
53
  readonly id: number;
54
+ extra: {
55
+ adminAccountId: number;
56
+ };
54
57
  classifyID?: string;
55
58
  details?: LobbyDetails;
56
59
  notify?: Disposable;
57
60
  notifyIdle: number;
58
61
  notifyCache?: string[];
59
- constructor(api: RiichiCityApi, id: number);
62
+ constructor(api: RiichiCityApi, id: number, extra: {
63
+ adminAccountId: number;
64
+ });
60
65
  init(): Promise<void>;
61
66
  listAllowedPlayers(): Promise<RiichiCityApi.Identity[]>;
62
67
  addAllowedPlayers(ids: number[]): Promise<void>;
package/lib/lobby.js CHANGED
@@ -31,6 +31,7 @@ __export(lobby_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(lobby_exports);
33
33
  var import_koishi = require("koishi");
34
+ var import_api = require("./api");
34
35
  var BOT_NAME = "電腦";
35
36
  var DHSError = class extends import_koishi.SessionError {
36
37
  static {
@@ -122,9 +123,10 @@ var Paipu = class extends Game {
122
123
  }
123
124
  };
124
125
  var RiichiCityLobby = class {
125
- constructor(api, id) {
126
+ constructor(api, id, extra) {
126
127
  this.api = api;
127
128
  this.id = id;
129
+ this.extra = extra;
128
130
  }
129
131
  static {
130
132
  __name(this, "RiichiCityLobby");
@@ -148,7 +150,13 @@ var RiichiCityLobby = class {
148
150
  await this.api.removeAllowedPlayers(this.id, ids);
149
151
  }
150
152
  async listGames(playing = true) {
151
- return this.api.listGames({ classifyID: this.classifyID }).then((l) => l.filter((x) => !playing === true || !x.isEnd).map((x) => new Game(this, x.roomId, x.players.map((p) => new Player(p.nickname, 0, p.userId)), { isEnd: x.isEnd, isPause: x.isPause })));
153
+ return this.api.listGames({ classifyID: this.classifyID }).then(
154
+ (l) => l.filter((x) => !playing === true || !x.isEnd).map((x) => new Game(this, x.roomId, x.players.map((p) => new Player(p.nickname, 0, p.userId)), { isEnd: x.isEnd, isPause: x.isPause })),
155
+ (e) => {
156
+ if (e instanceof import_api.RiichiCityError && e.code === 228) throw new import_koishi.SessionError(`无管理权限,请将【${this.extra.adminAccountId}】设置为管理员。`);
157
+ else throw e;
158
+ }
159
+ );
152
160
  }
153
161
  async listPlayers(ready = true) {
154
162
  return this.api.listPlayers(this.id).then((l) => Object.fromEntries(l.filter((x) => ready === void 0 || ready && x.status === 2 || !ready && x.status === 1).map((p) => [p.nickname, p.userID])));
package/lib/types.d.ts CHANGED
@@ -13,6 +13,61 @@ export interface UserBaseData {
13
13
  stagePt?: number;
14
14
  titleID?: number;
15
15
  }
16
+ export interface UserDetailStats {
17
+ addUpYiManCount?: number;
18
+ beiManCount?: number;
19
+ chiHuTotalCount?: number;
20
+ chongCardList?: any;
21
+ chongFuLouCount?: number;
22
+ chongLiZhiCount?: number;
23
+ chongMoTingCount?: number;
24
+ chongTotalCount?: number;
25
+ chongTotalScore?: number;
26
+ existFuLouCount?: number;
27
+ existLiZhiCount?: number;
28
+ fangList?: any;
29
+ firstTimes?: number;
30
+ flowCount?: number;
31
+ fourFangCount?: number;
32
+ fourthTimes?: number;
33
+ gameCount?: number;
34
+ heFuLouCount?: number;
35
+ heLiZhiCount?: number;
36
+ heMoTingCount?: number;
37
+ huCardList?: any;
38
+ huRoundTotal?: number;
39
+ huTotalCount?: number;
40
+ huTotalScore?: number;
41
+ huangFuLouCount?: number;
42
+ huangLiZhiCount?: number;
43
+ huangMoTingCount?: number;
44
+ keepLoseCount?: number;
45
+ keepWinCount?: number;
46
+ liZhiChiCount?: number;
47
+ liZhiSuccessCount?: number;
48
+ liZhiZiMoCount?: number;
49
+ manGuanCount?: number;
50
+ maxChongPoints?: number;
51
+ maxDealerCount?: number;
52
+ mingChiCount?: number;
53
+ mingZiMoCount?: number;
54
+ minusCount?: number;
55
+ moTingHuCount?: number;
56
+ oneFangCount?: number;
57
+ qingChiCount?: number;
58
+ qingZiMoCount?: number;
59
+ round?: number;
60
+ secondTimes?: number;
61
+ thirdTimes?: number;
62
+ threeBeiManCount?: number;
63
+ threeFangCount?: number;
64
+ tiaoManCount?: number;
65
+ totalEndTimes?: number;
66
+ twoFangCount?: number;
67
+ yiFaTotalCount?: number;
68
+ yiManCount?: number;
69
+ ziMoCount?: number;
70
+ }
16
71
  export interface UserBrief {
17
72
  certificated?: boolean;
18
73
  championNum?: number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hieuzest/koishi-plugin-riichi-city",
3
3
  "description": "",
4
- "version": "0.4.6",
4
+ "version": "0.5.0",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [