From a99467dfbf7b8d6aca4367b595e7c4448fe25404 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 10 May 2024 19:03:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0ruaa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ica-rs/plugins/md5/.gitignore | 3 ++- ica-rs/plugins/md5/md5-api.js | 7 ++++--- ica-rs/plugins/md5/md5-api.ts | 6 ++++-- ica-rs/plugins/md5/md5.js | 24 ++++++++++++++++++++++++ ica-rs/plugins/namerena.py | 2 +- 5 files changed, 35 insertions(+), 7 deletions(-) diff --git a/ica-rs/plugins/md5/.gitignore b/ica-rs/plugins/md5/.gitignore index 1cebf05..8b1d088 100644 --- a/ica-rs/plugins/md5/.gitignore +++ b/ica-rs/plugins/md5/.gitignore @@ -1,3 +1,4 @@ input.txt node_modules -package.json \ No newline at end of file +package.json +package-lock.json \ No newline at end of file diff --git a/ica-rs/plugins/md5/md5-api.js b/ica-rs/plugins/md5/md5-api.js index c8657e3..eea10b8 100644 --- a/ica-rs/plugins/md5/md5-api.js +++ b/ica-rs/plugins/md5/md5-api.js @@ -47,7 +47,7 @@ function fight(names) { case 0: // 检查一下输入是否合法 // 比如里面有没有 !test! - if (names.startsWith("!test!")) { + if (names.indexOf("!test!") !== -1) { throw new Error("你怎么在对战输入里加 !test!(恼)\n${names}"); } return [4 /*yield*/, md5_module.fight(names)]; @@ -164,10 +164,11 @@ function main() { fs = require("fs"); path = require("path"); names = fs.readFileSync(path.resolve(__dirname, "input.txt"), "utf-8"); - return [4 /*yield*/, fight(names)]; + return [4 /*yield*/, md5_module.run_any(names, 50000)]; case 1: result = _a.sent(); - console.log("\u8D62\u5BB6:|".concat(result.source_plr, "|")); + // console.log(`赢家:|${result.source_plr}|`); + console.log(result); return [2 /*return*/]; } }); diff --git a/ica-rs/plugins/md5/md5-api.ts b/ica-rs/plugins/md5/md5-api.ts index 6d3bc4a..6e3df0a 100644 --- a/ica-rs/plugins/md5/md5-api.ts +++ b/ica-rs/plugins/md5/md5-api.ts @@ -156,8 +156,10 @@ async function main() { const path = require("path"); const names = fs.readFileSync(path.resolve(__dirname, "input.txt"), "utf-8"); - const result = await fight(names); - console.log(`赢家:|${result.source_plr}|`); + // const result = await fight(names); + const result = await md5_module.run_any(names, 50000); + // console.log(`赢家:|${result.source_plr}|`); + console.log(result); } main(); diff --git a/ica-rs/plugins/md5/md5.js b/ica-rs/plugins/md5/md5.js index e69a501..13662c6 100644 --- a/ica-rs/plugins/md5/md5.js +++ b/ica-rs/plugins/md5/md5.js @@ -21845,6 +21845,30 @@ const runner = { }); }); }, + run_any: (names, round) => { + return new Promise((resolve, reject) => { + let data = []; + // 三种情况都带上 + finish_trigger.on("done_fight", (data) => { + resolve(fmt_RunUpdate(data)); + }); + finish_trigger.on("win_rate", (run_round, win_count) => { + data.push({ round: run_round, win_count: win_count }); + if (run_round >= round) { + stop_bomb = true; + resolve({ score: win_count, raw_data: data }); + } + }); + finish_trigger.on("score_report", (run_round, score) => { + data.push({ round: run_round, score: score }); + if (run_round >= round) { + stop_bomb = true; + resolve({ score: score, raw_data: data }); + } + }); + main(names); + }) + } }; if (run_env.from_code) { diff --git a/ica-rs/plugins/namerena.py b/ica-rs/plugins/namerena.py index f0bbd85..e3ca0e2 100644 --- a/ica-rs/plugins/namerena.py +++ b/ica-rs/plugins/namerena.py @@ -15,7 +15,7 @@ else: IcaNewMessage = TypeVar("NewMessage") IcaClient = TypeVar("IcaClient") -_version_ = "0.3.0" +_version_ = "0.4.0" COMMAND = "/namerena"