ruaaa
This commit is contained in:
parent
b25253ebb8
commit
cf5742a4df
@ -23,7 +23,7 @@ type WinRate = {
|
||||
* 胜率的数据结构
|
||||
*/
|
||||
type WinRateResult = {
|
||||
souce: number;
|
||||
win_count: number;
|
||||
raw_data: WinRate[];
|
||||
};
|
||||
|
||||
@ -63,7 +63,7 @@ type ScoreCallback = (run_round: number, score: number) => boolean;
|
||||
async function fight(names: string): Promise<FightResult> {
|
||||
// 检查一下输入是否合法
|
||||
// 比如里面有没有 !test!
|
||||
if (names.startsWith("!test!")) {
|
||||
if (names.indexOf("!test!") !== -1) {
|
||||
throw new Error("你怎么在对战输入里加 !test!(恼)\n${names}");
|
||||
}
|
||||
return await md5_module.fight(names);
|
||||
@ -75,7 +75,7 @@ async function fight(names: string): Promise<FightResult> {
|
||||
* @returns
|
||||
*/
|
||||
function test_check(names: string): boolean {
|
||||
const have_test = names.startsWith("!test!");
|
||||
const have_test = names.trim().startsWith("!test!");
|
||||
|
||||
return have_test;
|
||||
}
|
||||
@ -134,6 +134,11 @@ async function score_callback(
|
||||
return await md5_module.score_callback(names, callback);
|
||||
}
|
||||
|
||||
async function run_any(names: string, round: number): Promise<FightResult | WinRateResult | ScoreResult> {
|
||||
return await md5_module.run_any(names, round);
|
||||
}
|
||||
|
||||
|
||||
export {
|
||||
FightResult,
|
||||
WinRate,
|
||||
@ -147,4 +152,5 @@ export {
|
||||
win_rate_callback,
|
||||
score,
|
||||
score_callback,
|
||||
run_any,
|
||||
};
|
@ -21795,7 +21795,7 @@ const runner = {
|
||||
// 如果数据长度等于 round,说明数据已经全部返回
|
||||
if (run_round >= target_round) {
|
||||
stop_bomb = true;
|
||||
resolve({ score: win_count, raw_data: win_datas });
|
||||
resolve({ win_count: win_count, raw_data: win_datas });
|
||||
}
|
||||
});
|
||||
main(names);
|
||||
@ -21811,7 +21811,7 @@ const runner = {
|
||||
let result = callback(run_round, win_count);
|
||||
if (!result) {
|
||||
stop_bomb = true;
|
||||
resolve({ score: win_count, raw_data: win_datas });
|
||||
resolve({ win_count: win_count, raw_data: win_datas });
|
||||
}
|
||||
});
|
||||
main(names);
|
||||
@ -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({ win_count: 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) {
|
||||
|
Loading…
Reference in New Issue
Block a user