心 态 爆 炸

This commit is contained in:
shenjack 2024-08-14 18:39:44 +08:00
parent 0b23379efd
commit 837806f9cb
Signed by: shenjack
GPG Key ID: 7B1134A979775551
11 changed files with 307 additions and 56 deletions

View File

@ -589,11 +589,7 @@
if (customlanpos > 0) {
lanfile = decodeURIComponent(window.location.search.substring(customlanpos + 2));
}
// for (let key in ls) {
// if (key.indexOf('e_e') === 6 && ls[key].length % 100 === 0) {
// adfile = '.' + adfile;
// }
// }
reqO = new XMLHttpRequest();
reqO.open("GET", adfile);
reqO.send();
@ -632,7 +628,6 @@
<!-- 左上角一个用于标记版本号的 div, 默认状况下不显示, 部署时使用脚本替换内容, 颜色同理 -->
<img src="thumb.jpg" width="0" height="0" />
<div class='ad_h'></div>
<div class='ad_v'></div>
<div class='body'>
<iframe src='md5.html' class='mdframe'></iframe>
<div class="panels">

View File

@ -589,11 +589,6 @@
if (customlanpos > 0) {
lanfile = decodeURIComponent(window.location.search.substring(customlanpos + 2));
}
// for (let key in ls) {
// if (key.indexOf('e_e') === 6 && ls[key].length % 100 === 0) {
// adfile = '.' + adfile;
// }
// }
reqO = new XMLHttpRequest();
reqO.open("GET", adfile);
reqO.send();
@ -632,7 +627,6 @@
<!-- 左上角一个用于标记版本号的 div, 默认状况下不显示, 部署时使用脚本替换内容, 颜色同理 -->
<img src="thumb.jpg" width="0" height="0" />
<div class='ad_h'></div>
<div class='ad_v'></div>
<div class='body'>
<iframe src='md5.html' class='mdframe'></iframe>
<div class="panels">

View File

@ -134,7 +134,10 @@ async function score_callback(
return await md5_module.score_callback(names, callback);
}
async function run_any(names: string, round: number): Promise<FightResult | WinRateResult | ScoreResult> {
async function run_any(
names: string,
round: number,
): Promise<FightResult | WinRateResult | ScoreResult> {
return await md5_module.run_any(names, round);
}
@ -142,59 +145,58 @@ const out_limit: number = 1000;
async function wrap_any(names: string, round: number): Promise<string> {
const result = await run_any(names, round);
if ('message' in result) {
if ("message" in result) {
// 对战结果
return `赢家:|${result.source_plr}|`;
} else if ('win_count' in result) {
}
if ("win_count" in result) {
// 胜率结果
const win_rate = result.win_count * 100 / round;
let win_rate_str = win_rate.toFixed(4);
const win_rate = (result.win_count * 100) / round;
const win_rate_str = win_rate.toFixed(4);
let output_str = `最终胜率:|${win_rate_str}%|(${round}轮)`;
// 每 500 轮, 输出一次
if (round > out_limit) {
// 把所有要找的数据拿出来
let output_datas: WinRate[] = [];
const output_datas: WinRate[] = [];
result.raw_data.forEach((data, index) => {
if (data.round % out_limit === 0) {
output_datas.push(data);
}
});
output_datas.forEach((data, index) => {
const win_rate = data.win_count * 100 / data.round;
const win_rate = (data.win_count * 100) / data.round;
output_str += `\n${win_rate.toFixed(2)}%(${data.round})`;
});
}
return output_str;
// } else if ('score' in result) {
} else {
}
// 分数结果其实还是个胜率, 不过需要 * 100
const win_rate = (result.score * 10000 / round).toFixed(2);
const win_rate = ((result.score * 10000) / round).toFixed(2);
let output_str = `分数:|${win_rate}|(${round}轮)`;
if (round > out_limit) {
// 把所有要找的数据拿出来
let output_datas: Score[] = [];
const output_datas: Score[] = [];
result.raw_data.forEach((data, index) => {
if (data.round % out_limit === 0) {
output_datas.push(data);
}
});
output_datas.forEach((data, index) => {
const win_rate = (data.score / data.round * 10000).toFixed(2);
const win_rate = ((data.score / data.round) * 10000).toFixed(2);
output_str += `\n${win_rate}(${data.round})`;
});
}
return output_str;
}
}
export {
FightResult,
WinRate,
WinRateResult,
WinRateCallback,
Score,
ScoreResult,
ScoreCallback,
type FightResult,
type WinRate,
type WinRateResult,
type WinRateCallback,
type Score,
type ScoreResult,
type ScoreCallback,
fight,
win_rate,
win_rate_callback,

View File

@ -43,7 +43,7 @@ async function test() {
if (result.source_plr === profile.winner) {
console.log("pass");
} else {
throw new Error("fail" + result.source_plr + " " + profile.winner + " " + profile.test);
throw new Error(`fail${result.source_plr} ${profile.winner} ${profile.test}`);
}
}
for (const profile of test_profiles.win_chance) {
@ -56,14 +56,14 @@ async function test() {
if (rate === profile.round_10) {
console.log("pass");
} else {
throw new Error("fail" + rate + " " + profile.round_10);
throw new Error(`fail${rate} ${profile.round_10}`);
}
} else if (data.round === 100 * 100) {
const rate = data.win_count / data.round;
if (rate === profile.round_100) {
console.log("pass");
} else {
throw new Error("fail" + rate + " " + profile.round_100);
throw new Error(`fail${rate} ${profile.round_100}`);
}
}
}
@ -77,13 +77,13 @@ async function test() {
if (data.score * 10 === profile.round_10) {
console.log("pass");
} else {
throw new Error("fail" + data.score + " " + profile.round_10);
throw new Error(`fail${data.score} ${profile.round_10}`);
}
} else if (data.round === 100 * 100) {
if (data.score === profile.round_100) {
console.log("pass");
} else {
throw new Error("fail" + data.score + " " + profile.round_100);
throw new Error(`fail${data.score} ${profile.round_100}`);
}
}
}

View File

@ -591,11 +591,7 @@
if (customlanpos > 0) {
lanfile = decodeURIComponent(window.location.search.substring(customlanpos + 2));
}
// for (let key in ls) {
// if (key.indexOf('e_e') === 6 && ls[key].length % 100 === 0) {
// adfile = '.' + adfile;
// }
// }
reqO = new XMLHttpRequest();
reqO.open("GET", adfile);
reqO.send();
@ -634,7 +630,6 @@
<!-- 左上角一个用于标记版本号的 div, 默认状况下不显示, 部署时使用脚本替换内容, 颜色同理 -->
<img src="thumb.jpg" width="0" height="0" />
<div class='ad_h'></div>
<div class='ad_v'></div>
<div class='body'>
<iframe src='md5.html' class='mdframe'></iframe>
<div class="panels">

1
info/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
book

6
info/book.toml Normal file
View File

@ -0,0 +1,6 @@
[book]
authors = ["shenjack"]
language = "zh"
multilingual = false
src = "src"
title = "namerena"

4
info/src/SUMMARY.md Normal file
View File

@ -0,0 +1,4 @@
# 目录
- [介绍](./start.md)
- [开箱用法](./use.md)

34
info/src/start.md Normal file
View File

@ -0,0 +1,34 @@
# 介绍
欢迎来到 [fast-namerna](https://fast-namerena.pages.dev/), 一个由 shenjack 和 超导体元素 构建的 namerena 镜像 + 修改版
## 特性
- 基于 [deepmess.com/namerena](https://deepmess.com/namerena/) 的 namerena 版本构建
- 去除了所有的广告
- 有多种 (目前其实就两种) 特化分支
- 完全开源 [GitHub](https://github.com/shenjackyuanjie/fast-namerena)
## 分支
### main
- 最稳定的版本
- 保证能用
- 支持 DIY 功能
- 通过跳过 delay 来加速
### fight
- 通过去掉了 delay 来加速
- 只支持战斗加速
- 当然, 战斗加速也是最快的
- 不支持 DIY
- 不支持其他功能 (测号, 开箱)
### latest
- 最新的版本
- 有可能会出现问题
- 支持 DIY 功能
- 通过跳过 delay 来加速

12
info/src/use.md Normal file
View File

@ -0,0 +1,12 @@
# 开箱用法
## 需求
你需要:
- 你的脑子
- 你的手
- 你的电脑
- 安装好 nodejs/bun (bun 更好)
- 安装好 python (如果你需要写点脚本)
- 下载好所需要的

208
md5-api.ts Normal file
View File

@ -0,0 +1,208 @@
const md5_module = require("./md5.js");
/**
*
* source_plr ,
*/
type FightResult = {
message: string;
source_plr: string;
target_plr: string;
affect: string | number;
};
/**
*
*/
type WinRate = {
round: number;
win_count: number;
};
/**
*
*/
type WinRateResult = {
win_count: number;
raw_data: WinRate[];
};
/**
*
* bool, true , false
*/
type WinRateCallback = (run_round: number, win_count: number) => boolean;
/**
*
*/
type Score = {
round: number;
score: number;
};
/**
*
*/
type ScoreResult = {
score: number;
raw_data: Score[];
};
/**
*
* bool, true , false
*/
type ScoreCallback = (run_round: number, score: number) => boolean;
/**
*
* @param names
* @returns
*/
async function fight(names: string): Promise<FightResult> {
// 检查一下输入是否合法
// 比如里面有没有 !test!
if (names.indexOf("!test!") !== -1) {
throw new Error("你怎么在对战输入里加 !test!(恼)\n${names}");
}
return await md5_module.fight(names);
}
/**
* /
* @param names
* @returns
*/
function test_check(names: string): boolean {
const have_test = names.trim().startsWith("!test!");
return have_test;
}
/**
*
* @param names
* @param round
* @returns
*/
async function win_rate(names: string, round: number): Promise<WinRateResult> {
// 检查 round 是否合法
if (round <= 0) {
throw new Error("round 必须大于 0");
}
if (!test_check(names)) {
throw new Error("你怎么在胜率输入里丢了 !test!(恼)\n${names}");
}
return await md5_module.win_rate(names, round);
}
/**
*
* @param names
* @param callback
* @returns
*/
async function win_rate_callback(
names: string,
callback: WinRateCallback,
): Promise<WinRateResult> {
if (!test_check(names)) {
throw new Error("你怎么在胜率输入里丢了 !test!(恼)\n${names}");
}
return await md5_module.win_rate_callback(names, callback);
}
async function score(names: string, round: number): Promise<ScoreResult> {
// 检查 round 是否合法
if (round <= 0) {
throw new Error("round 必须大于 0");
}
if (!test_check(names)) {
throw new Error("你怎么在分数输入里丢了 !test!(恼)\n${names}");
}
return await md5_module.score(names, round);
}
async function score_callback(
names: string,
callback: ScoreCallback,
): Promise<ScoreResult> {
if (!test_check(names)) {
throw new Error("你怎么在分数输入里加 !test!(恼)\n${names}");
}
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);
}
const out_limit: number = 1000;
async function wrap_any(names: string, round: number): Promise<string> {
const result = await run_any(names, round);
if ("message" in result) {
// 对战结果
return `赢家:|${result.source_plr}|`;
}
if ("win_count" in result) {
// 胜率结果
const win_rate = (result.win_count * 100) / round;
const win_rate_str = win_rate.toFixed(4);
let output_str = `最终胜率:|${win_rate_str}%|(${round}轮)`;
// 每 500 轮, 输出一次
if (round > out_limit) {
// 把所有要找的数据拿出来
const output_datas: WinRate[] = [];
result.raw_data.forEach((data, index) => {
if (data.round % out_limit === 0) {
output_datas.push(data);
}
});
output_datas.forEach((data, index) => {
const win_rate = (data.win_count * 100) / data.round;
output_str += `\n${win_rate.toFixed(2)}%(${data.round})`;
});
}
return output_str;
// } else if ('score' in result) {
}
// 分数结果其实还是个胜率, 不过需要 * 100
const win_rate = ((result.score * 10000) / round).toFixed(2);
let output_str = `分数:|${win_rate}|(${round}轮)`;
if (round > out_limit) {
// 把所有要找的数据拿出来
const output_datas: Score[] = [];
result.raw_data.forEach((data, index) => {
if (data.round % out_limit === 0) {
output_datas.push(data);
}
});
output_datas.forEach((data, index) => {
const win_rate = ((data.score / data.round) * 10000).toFixed(2);
output_str += `\n${win_rate}(${data.round})`;
});
}
return output_str;
}
export {
type FightResult,
type WinRate,
type WinRateResult,
type WinRateCallback,
type Score,
type ScoreResult,
type ScoreCallback,
fight,
win_rate,
win_rate_callback,
score,
score_callback,
run_any,
wrap_any,
};