Merge remote-tracking branch 'gitea/main'

# Conflicts:
#	node_run/child.js
This commit is contained in:
shenjack 2024-03-19 01:05:21 +08:00
commit e72e23f4a2
Signed by: shenjack
GPG Key ID: 7B1134A979775551
2 changed files with 117 additions and 41 deletions

View File

@ -3,59 +3,125 @@ const chalk = require('chalk');
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
// 创建一个简单的localStorage模拟
const localStorageMock = {
setItem: function (key, value) {
this[key] = value;
},
getItem: function (key) {
return this[key] || null;
},
removeItem: function (key) {
delete this[key];
},
clear: function () {
for (const key in this) {
if (this.hasOwnProperty(key) && key !== 'setItem' && key !== 'getItem' && key !== 'removeItem' && key !== 'clear') {
delete this[key];
}
}
}
};
const config = JSON.parse(fs.readFileSync('./config.json')); const config = JSON.parse(fs.readFileSync('./config.json'));
const testString = { const testString = {
QP: '!test!\n!\n\n$name', QP: '!test!\n!\n\n$name',
QD: '!test!\n!\n\n$name\n$name', QD: '!test!\n!\n\n$name\n$name',
PP: '!test!\n\n$name', PP: '!test!\n\n$name',
PD: '!test!\n\n$name\n$name', PD: '!test!\n\n$name\n$name',
CQD:'!test!\n\n$name1\n\n$name2',
} }
const id = process.argv[2]; const id = process.argv[2];
const cqd_name_list=[
'VIMYKPJ@Stellar',
'29gvF!x@Miracle',
'Bishop ARFXGATH@Miracle',
'5UWSX0DGRE5pTA9@新纪元',
'YKOQFMNYLNPVWWD@SZ',
'余烬OYXo7e7y4@SZ',
'Mriiwm@frisk',
'AYdcjm@mwh_',
'公主 #07648027020@星光水晶焰',
'gnHHXmi@TigerStar',
'ddlezlmx@Helias',
'<input><br>ce0Y2rz@powerless',
'HQWWJYUHIGAVNP@霛雲',
'2EHKR7OYZ1JVY1@霛雲',
'vRuH:z@耗子尾汁',
'千矢 ZJUCVBFW@琪拉拉',
'大油包 #PXDHVJAT@暗黑突击',
'风史莱姆 #NQLTZLWD@暗黑突击',
'史莱德 #XPMTVPKY@暗黑突击',
'咲恋 ZPSFFQXQ@公主连结',
'Paloma SFCHPFOCH@Nostalgia',
'StezenFieven CPpISxdaSs@Nostalgia',
'光Yvxf2hGRv1Vf@fAIgFUL',
'RXuW4iX@fAIgFUL',
'm@fAIgFUL',
'飑Wcajsvb92asO@Squall',
'江DuDSKcYnD3nB@Squall',
'光YLqKf5rv9EU9lnc@Squall',
'对立IwncPEvanX1cFCl@Squall',
'风花雪月mrEm6W2F@酸橙',
'空 #b4WkVBd1t@酸橙',
'y_xbgL@酸橙',
'朔晖BLIPVEXGA@涵虚',
'星垂TTTNBWYUM@涵虚',
'月涌PDDYWVQSV@涵虚',
'震泽IZIGCSOIU@涵虚',
'iqYDJWy@cyclone',
'Iwn<Zo@nan',
'U>7D3Ol7uWKIfTC@XJ联队'
]
console.log(chalk`{gray child {bold ${id}} started.}`); console.log(chalk`{gray child {bold ${id}} started.}`);
process.on('message', ([mode, name]) => { process.on('message', ([mode, name]) => {
try { try {
console.log(chalk`{magentaBright [${id}] ${name} ${mode} started.}`) console.log(chalk`{magentaBright [${id}] ${name} ${mode} started.}`)
if(mode != "CQD"){
// 创建一个简单的localStorage模拟 new JSDOM(fs.readFileSync(path.join(__dirname, 'static/md5.html'), 'utf-8'), {
const localStorageMock = { url: 'file://' + path.join(__dirname, 'static/'),
setItem: function (key, value) { runScripts: 'dangerously',
this[key] = value; resources: 'usable',
}, beforeParse(window) {
getItem: function (key) { window.FakelocalStorage = localStorageMock;
return this[key] || null; window.config = config[mode].thresholds;
}, window.name_input = testString[mode].replace(/\$name/g, name);
removeItem: function (key) { window.stage = 0;
delete this[key]; window.skillData = [];
}, window.resolve = (...args) => {
clear: function () { process.send(args);
for (const key in this) { window.close();
if (this.hasOwnProperty(key) && key !== 'setItem' && key !== 'getItem' && key !== 'removeItem' && key !== 'clear') { }
delete this[key];
} }
});
}else if(mode == "CQD"){
var results=[]
for(i=0;i<cqd_name_list.length;i++){
var opponent=cqd_name_list[i]
new JSDOM(fs.readFileSync(path.join(__dirname, 'static/md5.html'), 'utf-8'), {
url: 'file://' + path.join(__dirname, 'static/'),
runScripts: 'dangerously',
resources: 'usable',
beforeParse(window) {
window.FakelocalStorage = localStorageMock;
window.config = config[mode].thresholds;
window.name_input = testString[mode].replace(/\$name1/g, name).replace(/\$name2/g, opponent);
window.stage = 0;
window.skillData = [];
window.resolve = (...args) => {
console.log(results)
results.push(args[2]);
window.close();
}
}
});
} }
}
};
new JSDOM(fs.readFileSync(path.join(__dirname, 'static/md5.html'), 'utf-8'), { console.log(results)
url: 'file://' + path.join(__dirname, 'static/'), }
runScripts: 'dangerously',
resources: 'usable',
beforeParse(window) {
window.FakelocalStorage = localStorageMock;
window.config = config[mode].thresholds;
window.name_input = testString[mode].replace(/\$name/g, name);
window.stage = 0;
window.skillData = [];
window.resolve = (...args) => {
process.send(args);
window.close();
};
window.output = (...message) => {
console.log('page:', message);
};
}
});
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }

View File

@ -1,8 +1,18 @@
{ {
"备注": "//mode只有preliminary是测其它任何字段都是不测 //count应该是测多少次的意思//score是个分数限制低于这个就认为失败不记录", "备注": "//mode只有preliminary是测其它任何字段都是不测 //count应该是测多少次的意思//score是个分数限制低于这个就认为失败不记录",
"threads": 2, "threads": 1,
"QP": { "CQD": {
"mode": "preliminary", "mode": "preliminary",
"thresholds": [
{
"score": 0,
"count": 100
}
]
},
"QP": {
"mode": "disabled",
"thresholds": [ "thresholds": [
{ {
"score": 5500, "score": 5500,
@ -15,7 +25,7 @@
] ]
}, },
"QD": { "QD": {
"mode": "preliminary", "mode": "disabled",
"thresholds": [ "thresholds": [
{ {
"score": 5500, "score": 5500,