koishi-plugin-noah 1.0.4 → 1.0.12

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/index.js CHANGED
@@ -360,8 +360,7 @@ var CardService = class {
360
360
  */
361
361
  async getCardById(id) {
362
362
  const rows = await this.ctx.database.get(this.tableName, id);
363
- if (!rows[0])
364
- return null;
363
+ if (!rows[0]) return null;
365
364
  return {
366
365
  ...rows[0],
367
366
  defaultServerId: rows[0].defaultServerId ?? 0
@@ -372,8 +371,7 @@ var CardService = class {
372
371
  */
373
372
  async getCardByCode(code) {
374
373
  const rows = await this.ctx.database.get(this.tableName, { code });
375
- if (!rows[0])
376
- return null;
374
+ if (!rows[0]) return null;
377
375
  return {
378
376
  ...rows[0],
379
377
  defaultServerId: rows[0].defaultServerId ?? 0
@@ -384,8 +382,7 @@ var CardService = class {
384
382
  */
385
383
  async getCardByName(name11) {
386
384
  const rows = await this.ctx.database.get(this.tableName, { name: name11 });
387
- if (!rows[0])
388
- return null;
385
+ if (!rows[0]) return null;
389
386
  return {
390
387
  ...rows[0],
391
388
  defaultServerId: rows[0].defaultServerId ?? 0
@@ -430,6 +427,16 @@ var CardService = class {
430
427
  */
431
428
  async removeCard(id) {
432
429
  await this.ctx.database.remove(this.tableName, id);
430
+ await this.ctx.database.remove("user_card", { cid: id });
431
+ const userRes = await this.ctx.database.get("user", { defaultCardId: id });
432
+ for (const user of userRes) {
433
+ const userCardRes = await this.ctx.database.get("user_card", { uid: user.id });
434
+ if (userCardRes.length > 0) {
435
+ await this.ctx.database.set("user", { id: user.id }, { defaultCardId: userCardRes[0].cid });
436
+ } else {
437
+ await this.ctx.database.set("user", { id: user.id }, { defaultCardId: 0 });
438
+ }
439
+ }
433
440
  }
434
441
  };
435
442
 
@@ -475,8 +482,7 @@ function bind(ctx, config) {
475
482
  if (!cardCode) {
476
483
  await session.send(session.text(".prompt"));
477
484
  cardCode = await session.prompt();
478
- if (!cardCode)
479
- return session.text("commands.timeout");
485
+ if (!cardCode) return session.text("commands.timeout");
480
486
  }
481
487
  cardCode = processInputCardCode(cardCode);
482
488
  switch (classifyCardId(cardCode)) {
@@ -485,14 +491,11 @@ function bind(ctx, config) {
485
491
  case "konamiid":
486
492
  cardCode = toUid(cardCode);
487
493
  }
488
- if (await cardService.getCardByCode(cardCode) != null)
489
- return session.text(".duplicate");
494
+ if (await cardService.getCardByCode(cardCode) != null) return session.text(".duplicate");
490
495
  await session.send(session.text(".name"));
491
496
  const cardName = await session.prompt();
492
- if (!cardName)
493
- return session.text("commands.timeout");
494
- if (cardName.includes(" "))
495
- return session.text(".invalid-name");
497
+ if (!cardName) return session.text("commands.timeout");
498
+ if (cardName.includes(" ")) return session.text(".invalid-name");
496
499
  const res = await cardService.createCard(session.user.id, cardCode, cardName);
497
500
  if (session.user.defaultCardId === 0) {
498
501
  await userService.updateUserDefaultCard(session.user.id, res.id);
@@ -595,6 +598,32 @@ var ServerService = class {
595
598
  */
596
599
  async removeServer(id) {
597
600
  await this.ctx.database.remove(this.tableName, id);
601
+ await this.ctx.database.remove("user_server", { sid: id });
602
+ await this.ctx.database.remove("channel_server", { sid: id });
603
+ const userRes = await this.ctx.database.get("user", { defaultServerId: id });
604
+ for (const user of userRes) {
605
+ const userServerRes = await this.ctx.database.get("user_server", { uid: user.id });
606
+ if (userServerRes.length > 0) {
607
+ await this.ctx.database.set("user", { id: user.id }, { defaultServerId: userServerRes[0].sid });
608
+ } else {
609
+ await this.ctx.database.set("user", { id: user.id }, { defaultServerId: 0 });
610
+ }
611
+ }
612
+ const channelRes = await this.ctx.database.get("channel", { defaultServerId: id });
613
+ for (const channel of channelRes) {
614
+ const channelServerRes = await this.ctx.database.get("channel_server", { cid: channel.id });
615
+ if (channelServerRes.length > 0) {
616
+ await this.ctx.database.set("channel", { id: channel.id }, { defaultServerId: channelServerRes[0].sid });
617
+ } else {
618
+ await this.ctx.database.set("channel", { id: channel.id }, { defaultServerId: 0 });
619
+ }
620
+ }
621
+ const cardRes = await this.ctx.database.get("card", { defaultServerId: id });
622
+ for (const card2 of cardRes) {
623
+ if (card2.defaultServerId !== void 0 && card2.defaultServerId !== 0) {
624
+ await this.ctx.database.set("card", { id: card2.id }, { defaultServerId: 0 });
625
+ }
626
+ }
598
627
  }
599
628
  };
600
629
 
@@ -632,10 +661,8 @@ async function showCardSelectMenu(ctx, session, cardService, serverService, user
632
661
  const msg = import_koishi.h.unescape(session.text(".menu-select", { card_list: cardListMsg })).replace("< 默认卡片", "&lt; 默认卡片");
633
662
  await session.send(msg);
634
663
  const select = await session.prompt();
635
- if (!select)
636
- return session.text("commands.timeout");
637
- if (select === "q")
638
- return session.text(".quit");
664
+ if (!select) return session.text("commands.timeout");
665
+ if (select === "q") return session.text(".quit");
639
666
  const selectNum = parseInt(select, 10);
640
667
  if (isNaN(selectNum) || selectNum < 0 || selectNum > res.length) {
641
668
  return session.text(".invalid-select");
@@ -655,10 +682,8 @@ async function showCardMenu(ctx, session, card2, cardService, serverService, use
655
682
  await session.send(session.text(".menu", card2));
656
683
  }
657
684
  const select = await session.prompt();
658
- if (!select)
659
- return session.text("commands.timeout");
660
- if (select === "q")
661
- return session.text(".quit");
685
+ if (!select) return session.text("commands.timeout");
686
+ if (select === "q") return session.text(".quit");
662
687
  const selectNum = parseInt(select, 10);
663
688
  if (isNaN(selectNum) || selectNum < 0 || selectNum > 5) {
664
689
  return await session.text(".invalid-select");
@@ -667,20 +692,16 @@ async function showCardMenu(ctx, session, card2, cardService, serverService, use
667
692
  return await showCardSelectMenu(ctx, session, cardService, serverService, userService, uid, userDefaultCardId, userDefaultServerId, cid, channelDefaultServerId);
668
693
  }
669
694
  if (selectNum === 1) {
670
- if (userDefaultCardId === card2.id)
671
- return session.text(".menu-1-error-duplicate");
695
+ if (userDefaultCardId === card2.id) return session.text(".menu-1-error-duplicate");
672
696
  await userService.updateUserDefaultCard(uid, card2.id);
673
697
  return session.text(".menu-1-success");
674
698
  }
675
699
  if (selectNum === 2) {
676
700
  await session.send(session.text(".menu-2-prompt", card2));
677
701
  let cardCode = await session.prompt();
678
- if (!cardCode)
679
- return session.text("commands.timeout");
680
- if (cardCode === "0")
681
- return showCardMenu(ctx, session, card2, cardService, serverService, userService, uid, userDefaultCardId, userDefaultServerId, cid, channelDefaultServerId);
682
- if (cardCode === "q")
683
- return session.text(".quit");
702
+ if (!cardCode) return session.text("commands.timeout");
703
+ if (cardCode === "0") return showCardMenu(ctx, session, card2, cardService, serverService, userService, uid, userDefaultCardId, userDefaultServerId, cid, channelDefaultServerId);
704
+ if (cardCode === "q") return session.text(".quit");
684
705
  cardCode = processInputCardCode(cardCode);
685
706
  switch (classifyCardId(cardCode)) {
686
707
  case "invalid":
@@ -688,8 +709,7 @@ async function showCardMenu(ctx, session, card2, cardService, serverService, use
688
709
  case "konamiid":
689
710
  cardCode = toUid(cardCode);
690
711
  }
691
- if (await cardService.getCardByCode(cardCode) != null)
692
- return session.text(".duplicate");
712
+ if (await cardService.getCardByCode(cardCode) != null) return session.text(".duplicate");
693
713
  await cardService.updateCard(card2.id, { code: cardCode });
694
714
  return session.text(".menu-2-success");
695
715
  }
@@ -708,12 +728,9 @@ async function showCardMenu(ctx, session, card2, cardService, serverService, use
708
728
  if (selectNum === 4) {
709
729
  await session.send(session.text(".menu-4-prompt"));
710
730
  const cardName = await session.prompt();
711
- if (!cardName)
712
- return session.text("commands.timeout");
713
- if (cardName === "q")
714
- return session.text(".quit");
715
- if (cardName.includes(" "))
716
- return session.text(".menu-4-error-invalid-name");
731
+ if (!cardName) return session.text("commands.timeout");
732
+ if (cardName === "q") return session.text(".quit");
733
+ if (cardName.includes(" ")) return session.text(".menu-4-error-invalid-name");
717
734
  await cardService.updateCard(card2.id, { name: cardName });
718
735
  return session.text(".menu-4-success");
719
736
  }
@@ -734,14 +751,12 @@ async function showCardMenu(ctx, session, card2, cardService, serverService, use
734
751
  const msg = import_koishi.h.unescape(session.text(".menu-5", { server_list: serverListMsg })).replace("< 你的默认服务器", "&lt; 你的默认服务器").replace("< 群组默认服务器", "&lt; 群组默认服务器");
735
752
  await session.send(msg);
736
753
  const select2 = await session.prompt();
737
- if (!select2)
738
- return session.text("commands.timeout");
754
+ if (!select2) return session.text("commands.timeout");
739
755
  const selectNum2 = parseInt(select2, 10);
740
756
  if (isNaN(selectNum2) || selectNum2 < 1 || selectNum2 > res.length) {
741
757
  return session.text(".invalid-select");
742
758
  }
743
- if (card2.defaultServerId === res[selectNum2 - 1].id)
744
- return session.text(".menu-5-error-duplicate");
759
+ if (card2.defaultServerId === res[selectNum2 - 1].id) return session.text(".menu-5-error-duplicate");
745
760
  await cardService.updateCard(card2.id, { defaultServerId: res[selectNum2 - 1].id });
746
761
  return session.text(".menu-5-success");
747
762
  }
@@ -783,8 +798,7 @@ function server(ctx, config) {
783
798
  const serverService = new ServerService(ctx);
784
799
  const userService = new UserService(ctx);
785
800
  if (options.channel) {
786
- if (!hasPermission(isGuildAdmin(session), isPluginAdmin(session, config)))
787
- return session.text(".no-auth");
801
+ if (!hasPermission(isGuildAdmin(session), isPluginAdmin(session, config))) return session.text(".no-auth");
788
802
  return await showChannelServerSelectMenu(
789
803
  ctx,
790
804
  session,
@@ -822,10 +836,8 @@ async function showChannelServerSelectMenu(ctx, session, serverService, userServ
822
836
  const msg = import_koishi2.h.unescape(session.text(".menu-select", { server_list: serverListMsg })).replace("< 群聊默认服务器", "&lt; 群聊默认服务器");
823
837
  await session.send(msg);
824
838
  const select = await session.prompt();
825
- if (!select)
826
- return session.text("commands.timeout");
827
- if (select === "q")
828
- return session.text(".quit");
839
+ if (!select) return session.text("commands.timeout");
840
+ if (select === "q") return session.text(".quit");
829
841
  const selectNum = parseInt(select, 10);
830
842
  if (isNaN(selectNum) || selectNum < 0 || selectNum > res.length) {
831
843
  return session.text(".invalid-select");
@@ -850,10 +862,8 @@ async function showUserServerSelectMenu(ctx, session, serverService, userService
850
862
  const msg = import_koishi2.h.unescape(session.text(".menu-select", { server_list: serverListMsg })).replace("< 默认服务器", "&lt; 默认服务器");
851
863
  await session.send(msg);
852
864
  const select = await session.prompt();
853
- if (!select)
854
- return session.text("commands.timeout");
855
- if (select === "q")
856
- return session.text(".quit");
865
+ if (!select) return session.text("commands.timeout");
866
+ if (select === "q") return session.text(".quit");
857
867
  const selectNum = parseInt(select, 10);
858
868
  if (isNaN(selectNum) || selectNum < 0 || selectNum > res.length) {
859
869
  return session.text(".invalid-select");
@@ -868,28 +878,22 @@ __name(showUserServerSelectMenu, "showUserServerSelectMenu");
868
878
  async function showServerMenu(ctx, session, serverService, userService, server2, from, uid, userDefaultServerId, cid, channelDefaultServerId) {
869
879
  await session.send(session.text(".menu", server2));
870
880
  const select = await session.prompt();
871
- if (!select)
872
- return session.text("commands.timeout");
873
- if (select === "q")
874
- return session.text(".quit");
881
+ if (!select) return session.text("commands.timeout");
882
+ if (select === "q") return session.text(".quit");
875
883
  const selectNum = parseInt(select, 10);
876
884
  if (isNaN(selectNum) || selectNum < 0 || selectNum > 4) {
877
885
  return session.text(".invalid-select");
878
886
  }
879
887
  if (selectNum === 0) {
880
- if (from === "user")
881
- return await showUserServerSelectMenu(ctx, session, serverService, userService, uid, userDefaultServerId, cid, channelDefaultServerId);
882
- else
883
- return await showChannelServerSelectMenu(ctx, session, serverService, userService, uid, userDefaultServerId, cid, channelDefaultServerId);
888
+ if (from === "user") return await showUserServerSelectMenu(ctx, session, serverService, userService, uid, userDefaultServerId, cid, channelDefaultServerId);
889
+ else return await showChannelServerSelectMenu(ctx, session, serverService, userService, uid, userDefaultServerId, cid, channelDefaultServerId);
884
890
  }
885
891
  if (selectNum === 1) {
886
892
  if (from === "user") {
887
- if (userDefaultServerId === server2.id)
888
- return session.text(".menu-1-error-duplicate");
893
+ if (userDefaultServerId === server2.id) return session.text(".menu-1-error-duplicate");
889
894
  await userService.updateUserDefaultServer(uid, server2.id);
890
895
  } else {
891
- if (channelDefaultServerId === server2.id)
892
- return session.text(".menu-1-error-duplicate");
896
+ if (channelDefaultServerId === server2.id) return session.text(".menu-1-error-duplicate");
893
897
  await userService.updateChannelDefaultServer(session.platform, cid, server2.id);
894
898
  }
895
899
  return session.text(".menu-1-success");
@@ -897,12 +901,9 @@ async function showServerMenu(ctx, session, serverService, userService, server2,
897
901
  if (selectNum === 2) {
898
902
  await session.send(session.text(".menu-2-prompt", server2));
899
903
  let url = await session.prompt();
900
- if (!url)
901
- return session.text("commands.timeout");
902
- if (url === "0")
903
- return showServerMenu(ctx, session, serverService, userService, server2, from, uid, userDefaultServerId, cid, channelDefaultServerId);
904
- if (url === "q")
905
- return session.text(".quit");
904
+ if (!url) return session.text("commands.timeout");
905
+ if (url === "0") return showServerMenu(ctx, session, serverService, userService, server2, from, uid, userDefaultServerId, cid, channelDefaultServerId);
906
+ if (url === "q") return session.text(".quit");
906
907
  await serverService.updateServer(server2.id, { baseUrl: url });
907
908
  return session.text(".menu-2-success");
908
909
  }
@@ -932,14 +933,10 @@ async function showServerMenu(ctx, session, serverService, userService, server2,
932
933
  if (selectNum === 4) {
933
934
  await session.send(session.text(".menu-4-prompt"));
934
935
  const serverName = await session.prompt();
935
- if (!serverName)
936
- return session.text("commands.timeout");
937
- if (serverName === "0")
938
- return showServerMenu(ctx, session, serverService, userService, server2, from, uid, userDefaultServerId, cid, channelDefaultServerId);
939
- if (serverName === "q")
940
- return session.text(".quit");
941
- if (serverName.includes(" "))
942
- return session.text(".menu-4-error-invalid-name");
936
+ if (!serverName) return session.text("commands.timeout");
937
+ if (serverName === "0") return showServerMenu(ctx, session, serverService, userService, server2, from, uid, userDefaultServerId, cid, channelDefaultServerId);
938
+ if (serverName === "q") return session.text(".quit");
939
+ if (serverName.includes(" ")) return session.text(".menu-4-error-invalid-name");
943
940
  await serverService.updateServer(server2.id, { name: serverName });
944
941
  return session.text(".menu-4-success");
945
942
  }
@@ -953,10 +950,8 @@ async function addServer(ctx, session, serverService, userService, from, uid, us
953
950
  const msg = import_koishi2.h.unescape(session.text(".add-type", { server_type_list: serverTypeListMsg }));
954
951
  await session.send(msg);
955
952
  const select = await session.prompt();
956
- if (!select)
957
- return session.text("commands.timeout");
958
- if (select === "q")
959
- return session.text(".quit");
953
+ if (!select) return session.text("commands.timeout");
954
+ if (select === "q") return session.text(".quit");
960
955
  const selectNum = parseInt(select, 10);
961
956
  if (isNaN(selectNum) || selectNum < 1 || selectNum > serverValues.length) {
962
957
  return session.text(".invalid-select");
@@ -964,18 +959,13 @@ async function addServer(ctx, session, serverService, userService, from, uid, us
964
959
  const serverType = serverValues[selectNum - 1];
965
960
  await session.send(session.text(".add-url"));
966
961
  const url = await session.prompt();
967
- if (!url)
968
- return session.text("commands.timeout");
969
- if (url === "q")
970
- return session.text(".quit");
962
+ if (!url) return session.text("commands.timeout");
963
+ if (url === "q") return session.text(".quit");
971
964
  await session.send(session.text(".add-name"));
972
965
  const serverName = await session.prompt();
973
- if (!serverName)
974
- return session.text("commands.timeout");
975
- if (serverName === "q")
976
- return session.text(".quit");
977
- if (serverName.includes(" "))
978
- return session.text(".add-invalid-name");
966
+ if (!serverName) return session.text("commands.timeout");
967
+ if (serverName === "q") return session.text(".quit");
968
+ if (serverName.includes(" ")) return session.text(".add-invalid-name");
979
969
  if (from === "user") {
980
970
  const res = await serverService.createServerForUser({
981
971
  type: serverType,
@@ -1036,7 +1026,7 @@ var import_koishi8 = require("koishi");
1036
1026
  var en_US_default2 = { _config: { $desc: "SDVX Module Settings", default_model: "<p>Default model value (e.g. `2024110700`)</p>" }, commands: { vf: { description: "Show Noah help information", messages: { "card-not-found": "<p>You haven't bound a card yet, go bind a card first~</p>", "server-not-found": "<p>No available servers, add one yourself~</p>", "no-scores-found": "<p>No scores found, please check your data.</p>", error: "<p>An error occurred(っ °Д °;)っ</p>", drawing: "<p>Noah is drawing, please wait patiently~</p>" } } } };
1037
1027
 
1038
1028
  // src/games/sdvx/locales/zh-CN.yml
1039
- var zh_CN_default2 = { _config: { $desc: "SDVX 模块设置", default_model: "<p>默认的 model 值(如 `2024110700`)</p>" }, commands: { vf: { description: "查询 SDVX VOLFORCE", messages: { "card-not-found": "<p>你还没绑卡,去绑个卡再来吧~</p>", "server-not-found": "<p>没有可用的服务器哦,自己添加一个吧~</p>", "no-scores-found": "<p>没有找到你的分数数据哦~</p>", error: "<p>遇到了错误(っ °Д °;)っ</p>", drawing: "<p>Noah 正在画啦,请耐心等待~</p>" } }, recent: { description: "查询 SDVX 最近分数", messages: { "card-not-found": "<p>你还没绑卡,去绑个卡再来吧~</p>", "server-not-found": "<p>没有可用的服务器哦,自己添加一个吧~</p>", "no-scores-found": "<p>没有找到你的分数数据哦~</p>", error: "<p>遇到了错误(っ °Д °;)っ</p>", drawing: "<p>Noah 正在画啦,请耐心等待~</p>" } } } };
1029
+ var zh_CN_default2 = { _config: { $desc: "SDVX 模块设置", default_model: "<p>默认的 model 值(如 `2024110700`)</p>" }, commands: { vf: { description: "查询 SDVX VOLFORCE", messages: { "card-not-found": "<p>你还没绑卡,去绑个卡再来吧~</p>", "server-not-found": "<p>没有可用的服务器哦,自己添加一个吧~</p>", "no-scores-found": "<p>没有找到你的分数数据哦~</p>", error: "<p>Noah 遇到了错误(っ °Д °;)っ</p>", drawing: "<p>Noah 正在画啦,请耐心等待~</p>", "menu-select": "<p>请选择你要使用的卡片:</p>\n{card_list}\n<p>q. 退出</p>", "invalid-select": "<p>没有该选项!</p>", quit: "<p>已退出~</p>" } }, recent: { description: "查询 SDVX 最近分数", messages: { "card-not-found": "<p>你还没绑卡,去绑个卡再来吧~</p>", "server-not-found": "<p>没有可用的服务器哦,自己添加一个吧~</p>", "no-scores-found": "<p>没有找到你的分数数据哦~</p>", error: "<p>Noah 遇到了错误(っ °Д °;)っ</p>", drawing: "<p>Noah 正在画啦,请耐心等待~</p>" } } } };
1040
1030
 
1041
1031
  // src/games/sdvx/database.ts
1042
1032
  var database_exports2 = {};
@@ -1215,24 +1205,15 @@ var import_koishi5 = require("koishi");
1215
1205
 
1216
1206
  // src/servers/utils/grade.ts
1217
1207
  function getSDVXGrade(score) {
1218
- if (score > 99e5)
1219
- return "S";
1220
- if (score >= 98e5)
1221
- return "AAA+";
1222
- if (score >= 97e5)
1223
- return "AAA";
1224
- if (score >= 95e5)
1225
- return "AA+";
1226
- if (score >= 93e5)
1227
- return "AA";
1228
- if (score >= 9e6)
1229
- return "A+";
1230
- if (score >= 87e5)
1231
- return "A";
1232
- if (score >= 75e5)
1233
- return "B";
1234
- if (score >= 65e5)
1235
- return "C";
1208
+ if (score > 99e5) return "S";
1209
+ if (score >= 98e5) return "AAA+";
1210
+ if (score >= 97e5) return "AAA";
1211
+ if (score >= 95e5) return "AA+";
1212
+ if (score >= 93e5) return "AA";
1213
+ if (score >= 9e6) return "A+";
1214
+ if (score >= 87e5) return "A";
1215
+ if (score >= 75e5) return "B";
1216
+ if (score >= 65e5) return "C";
1236
1217
  return "D";
1237
1218
  }
1238
1219
  __name(getSDVXGrade, "getSDVXGrade");
@@ -1785,7 +1766,7 @@ var BaseDrawer = class {
1785
1766
  }
1786
1767
  };
1787
1768
 
1788
- // src/drawer/Core/index.ts
1769
+ // src/drawer/core/index.ts
1789
1770
  var CoreDrawer = class extends BaseDrawer {
1790
1771
  constructor(ctx) {
1791
1772
  super(ctx);
@@ -1820,7 +1801,7 @@ var CoreDrawer = class extends BaseDrawer {
1820
1801
  }
1821
1802
  };
1822
1803
 
1823
- // src/drawer/SDVX/index.ts
1804
+ // src/drawer/sdvx/index.ts
1824
1805
  var import_path = require("path");
1825
1806
  var fs = __toESM(require("fs"));
1826
1807
  var SDVXDrawer = class extends BaseDrawer {
@@ -1918,8 +1899,7 @@ var SDVXDrawer = class extends BaseDrawer {
1918
1899
  * Draw score cards on the canvas
1919
1900
  */
1920
1901
  async drawScoreCards(ctx, scores, cardBgImage, loadImage, config) {
1921
- if (scores.length === 0)
1922
- return;
1902
+ if (scores.length === 0) return;
1923
1903
  const startX = 144;
1924
1904
  const startY = 692;
1925
1905
  const cardsPerRow = 5;
@@ -1981,26 +1961,16 @@ var SDVXDrawer = class extends BaseDrawer {
1981
1961
  const y = startY + row * (cardHeight + cardVerticalSpacing);
1982
1962
  const vf2 = score.extra.volforce;
1983
1963
  let vfClass = 1;
1984
- if (vf2 >= 20)
1985
- vfClass = 10;
1986
- else if (vf2 >= 19)
1987
- vfClass = 9;
1988
- else if (vf2 >= 18)
1989
- vfClass = 8;
1990
- else if (vf2 >= 17)
1991
- vfClass = 7;
1992
- else if (vf2 >= 16)
1993
- vfClass = 6;
1994
- else if (vf2 >= 15)
1995
- vfClass = 5;
1996
- else if (vf2 >= 14)
1997
- vfClass = 4;
1998
- else if (vf2 >= 12)
1999
- vfClass = 3;
2000
- else if (vf2 >= 10)
2001
- vfClass = 2;
2002
- else
2003
- vfClass = 1;
1964
+ if (vf2 >= 20) vfClass = 10;
1965
+ else if (vf2 >= 19) vfClass = 9;
1966
+ else if (vf2 >= 18) vfClass = 8;
1967
+ else if (vf2 >= 17) vfClass = 7;
1968
+ else if (vf2 >= 16) vfClass = 6;
1969
+ else if (vf2 >= 15) vfClass = 5;
1970
+ else if (vf2 >= 14) vfClass = 4;
1971
+ else if (vf2 >= 12) vfClass = 3;
1972
+ else if (vf2 >= 10) vfClass = 2;
1973
+ else vfClass = 1;
2004
1974
  if (circleImages[vfClass]) {
2005
1975
  ctx.drawImage(circleImages[vfClass], x + 628, y - 42);
2006
1976
  }
@@ -2244,8 +2214,7 @@ var SDVXDrawer = class extends BaseDrawer {
2244
2214
  * Calculate the average volforce from best 50 scores
2245
2215
  */
2246
2216
  calculateAverageVF(scores) {
2247
- if (scores.length === 0)
2248
- return 0;
2217
+ if (scores.length === 0) return 0;
2249
2218
  const sortedScores = [...scores].sort(
2250
2219
  (a, b) => b.extra.volforce - a.extra.volforce
2251
2220
  ).slice(0, 50);
@@ -2272,10 +2241,8 @@ var SDVXDrawer = class extends BaseDrawer {
2272
2241
  return lines;
2273
2242
  }
2274
2243
  roundRect(ctx, x, y, width, height, radius) {
2275
- if (width < 2 * radius)
2276
- radius = width / 2;
2277
- if (height < 2 * radius)
2278
- radius = height / 2;
2244
+ if (width < 2 * radius) radius = width / 2;
2245
+ if (height < 2 * radius) radius = height / 2;
2279
2246
  ctx.beginPath();
2280
2247
  ctx.moveTo(x + radius, y);
2281
2248
  ctx.arcTo(x + width, y, x + width, y + height, radius);
@@ -2286,7 +2253,7 @@ var SDVXDrawer = class extends BaseDrawer {
2286
2253
  }
2287
2254
  };
2288
2255
 
2289
- // src/drawer/IIDX/index.ts
2256
+ // src/drawer/iidx/index.ts
2290
2257
  var IIDXDrawer = class extends BaseDrawer {
2291
2258
  constructor(ctx) {
2292
2259
  super(ctx);
@@ -2410,36 +2377,46 @@ __name(apply6, "apply");
2410
2377
 
2411
2378
  // src/games/sdvx/commands/vf.ts
2412
2379
  function vf(ctx, config) {
2413
- ctx.command("vf").userFields(["defaultCardId", "defaultServerId", "id"]).channelFields(["defaultServerId", "id"]).option("lossless", "-l").option("card", "-c <cardName>").action(async ({ session, options }) => {
2380
+ ctx.command("vf").userFields(["defaultCardId", "defaultServerId", "id"]).channelFields(["defaultServerId", "id"]).option("lossless", "-l").option("card", "-c").action(async ({ session, options }) => {
2414
2381
  const model = config.default_model;
2415
2382
  const cardService = new CardService(ctx);
2416
2383
  const serverService = new ServerService(ctx);
2417
2384
  const userCards = await cardService.getCardsByUid(session.user.id);
2418
- if (userCards.length === 0)
2419
- return session.text(".card-not-found");
2385
+ if (userCards.length === 0) return session.text(".card-not-found");
2420
2386
  const userRes = await serverService.getServersByUid(session.user.id);
2421
2387
  const channelRes = await serverService.getServersByCid(session.channel.id);
2422
2388
  const serverRes = channelRes.concat(userRes);
2423
- if (serverRes.length === 0)
2424
- return session.text(".server-not-found");
2389
+ if (serverRes.length === 0) return session.text(".server-not-found");
2425
2390
  let cardCode = "";
2426
2391
  if (!options.card) {
2427
2392
  const cardRes = await cardService.getCardById(session.user.defaultCardId);
2428
2393
  cardCode = cardRes.code;
2429
2394
  } else {
2430
- const cardRes = await cardService.getCardByName(options.card);
2431
- if (!cardRes)
2432
- return session.text(".card-not-found");
2433
- cardCode = cardRes.code;
2395
+ let cardListMsg = "";
2396
+ for (let i = 0; i < userCards.length; i++) {
2397
+ if (userCards[i].id === session.user.defaultCardId) {
2398
+ cardListMsg += `<p>${i + 1}. ${userCards[i].name} < 默认卡片</p>`;
2399
+ } else {
2400
+ cardListMsg += `<p>${i + 1}. ${userCards[i].name}</p>`;
2401
+ }
2402
+ }
2403
+ const msg = import_koishi7.h.unescape(session.text(".menu-select", { card_list: cardListMsg })).replace("< 默认卡片", "&lt; 默认卡片");
2404
+ await session.send(msg);
2405
+ const select = await session.prompt();
2406
+ if (!select) return session.text("commands.timeout");
2407
+ if (select === "q") return session.text(".quit");
2408
+ const selectNum = parseInt(select, 10);
2409
+ if (isNaN(selectNum) || selectNum < 1 || selectNum > userCards.length) {
2410
+ return session.text(".invalid-select");
2411
+ }
2412
+ cardCode = userCards[selectNum - 1].code;
2434
2413
  }
2435
2414
  const card2 = await cardService.getCardByCode(cardCode);
2436
2415
  let server2;
2437
- if (card2.defaultServerId != 0)
2438
- server2 = await serverService.getServerById(card2.defaultServerId);
2439
- else if (session.channel.defaultServerId != 0)
2440
- server2 = await serverService.getServerById(session.channel.defaultServerId);
2441
- else if (session.user.defaultServerId != 0)
2442
- server2 = await serverService.getServerById(session.user.defaultServerId);
2416
+ if (card2.defaultServerId != void 0 && card2.defaultServerId != 0) server2 = await serverService.getServerById(card2.defaultServerId);
2417
+ else if (session.channel.defaultServerId != void 0 && session.channel.defaultServerId != 0) server2 = await serverService.getServerById(session.channel.defaultServerId);
2418
+ else if (session.user.defaultServerId != void 0 && session.user.defaultServerId != 0) server2 = await serverService.getServerById(session.user.defaultServerId);
2419
+ else return session.text(".server-not-found");
2443
2420
  const serverManager = ServerManager.getInstance();
2444
2421
  const sdvxService = serverManager.getGameService(server2.type, "sdvx");
2445
2422
  const scoreService = ScoreService.getInstance();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-noah",
3
- "version": "1.0.4",
3
+ "version": "1.0.12",
4
4
  "contributors": [
5
5
  "Logthm <logthm@outlook.com>"
6
6
  ],
@@ -44,6 +44,7 @@
44
44
  "@ltxhhz/koishi-plugin-skia-canvas": "^0.0.8",
45
45
  "@types/xml2js": "^0",
46
46
  "koishi": "^4.18.7",
47
- "typescript": "^5.8.2"
47
+ "typescript": "^5.9.0-dev.20250412",
48
+ "yml-register": "^1.2.5"
48
49
  }
49
50
  }
package/readme.md CHANGED
@@ -1,5 +1,3 @@
1
1
  # koishi-plugin-noah
2
2
 
3
- [![npm](https://img.shields.io/npm/v/koishi-plugin-noah?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-noah)
4
-
5
- undefined
3
+ Tool bot for arcade music games.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes