This commit is contained in:
2026-01-20 19:41:40 +08:00
parent af565b166f
commit d60a9b0d8f
2 changed files with 101 additions and 84 deletions
+60 -54
View File
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
class BcmTool {
constructor() {
this.attributes = new Map([
['年龄', -100],
['速度', 1],
['力量', 2],
['内攻', 3],
@@ -81,52 +80,52 @@ class BcmTool {
console.log(form);
g_game.tools.CopyStrToClipboard(form.ToString());
}
BulkSearchMarket(searchStr, maxIterate = 100) {
searchStr = searchStr.replace(/ /g, '');
const strs = searchStr.split('&&');
const operators = ['>', '<', '=='];
const handlers = [
(id, attri, value) => {
return this.QueryInfo(id, attri) > value;
},
(id, attri, value) => {
return this.QueryInfo(id, attri) < value;
},
(id, attri, value) => {
return Math.floor(this.QueryInfo(id, attri)) == value;
},
(id, attri, value) => {
return this.QueryInfo(id, attri) >= value;
},
(id, attri, value) => {
return this.QueryInfo(id, attri) <= value;
},
];
const conditions = [];
const requireAttributes = [];
const requireSearch = [];
const requireValues = [];
for (let i = 0; i != strs.length; ++i) {
const str = strs[i];
const operator = operators.find(e => str.search(e) != -1);
if (operator == null) {
console.log('条件解析失败', str);
continue;
BulkSearchMarket(searchStr_1) {
return __awaiter(this, arguments, void 0, function* (searchStr, maxIterate = 100) {
searchStr = searchStr.replace(/ /g, '');
const strs = searchStr.split('&&');
const operators = ['>', '<', '=='];
const handlers = [
(id, attri, value) => {
return this.QueryInfo(id, attri) > value;
},
(id, attri, value) => {
return this.QueryInfo(id, attri) < value;
},
(id, attri, value) => {
return Math.floor(this.QueryInfo(id, attri)) == value;
},
(id, attri, value) => {
return this.QueryInfo(id, attri) >= value;
},
(id, attri, value) => {
return this.QueryInfo(id, attri) <= value;
},
];
const conditions = [];
const requireAttributes = [];
const requireSearch = [];
const requireValues = [];
for (let i = 0; i != strs.length; ++i) {
const str = strs[i];
const operator = operators.find(e => str.search(e) != -1);
if (operator == null) {
console.log('条件解析失败', str);
continue;
}
const handler = handlers[operators.indexOf(operator)];
const requires = str.split(operator);
const attribute = this.attributes.get(requires[0]);
const value = Number(requires[1]);
if (attribute == null || handler == null) {
console.log('条件解析失败', str);
continue;
}
conditions.push(handler);
requireAttributes.push(attribute);
requireValues.push(value);
requireSearch.push(requires[0]);
}
const handler = handlers[operators.indexOf(operator)];
const requires = str.split(operator);
const attribute = this.attributes.get(requires[0]);
const value = Number(requires[1]);
if (attribute == null || handler == null) {
console.log('条件解析失败', str);
continue;
}
conditions.push(handler);
requireAttributes.push(attribute);
requireValues.push(value);
requireSearch.push(requires[0]);
}
this.mgrMarket.SendSynOpenMarketInfoByFilter(() => __awaiter(this, void 0, void 0, function* () {
var results = [];
const ids = Object.keys(this.mgrMarket._map_player_infos);
for (const id of ids) {
@@ -134,23 +133,26 @@ class BcmTool {
break;
}
const info = this.mgrMarket._map_player_infos[id];
yield this.RefreshPlayerInTransaction(info.teamId, info.playerId);
if (!this.CheckInfo(info.playerId)) {
yield this.RefreshPlayerInTransaction(info.teamId, info.playerId);
yield this.Wait(100);
maxIterate -= 1;
}
if (conditions.every((e, i) => e(info.playerId, requireAttributes[i], requireValues[i]))) {
results.push(info);
}
maxIterate -= 1;
}
const displays = new Set(requireAttributes);
for (const result of results) {
const displayStr = [...displays].map(e => {
const idx = requireAttributes.indexOf(e);
const search = requireSearch[idx];
const value = result.GetSingleAttribute(e, true);
const value = this.QueryInfo(result.playerId, requireAttributes[idx]);
return `${search}:${value}`;
});
console.log(result.playerName, ...displayStr);
console.log(`${result.playerName}(${result.playerAge})`, ...displayStr);
}
}));
});
}
RefreshPlayerInTransaction(teamId, playerId) {
return new Promise(resolve => {
@@ -172,9 +174,6 @@ class BcmTool {
}
QueryInfo(playerId, attri) {
const data = this.mgrTeamInfo.GetPlayerData(playerId);
if (attri == -100) {
return data.playerAge;
}
return data.GetSingleAttribute(attri);
}
GetPlayerIds() {
@@ -191,6 +190,13 @@ class BcmTool {
console.log(this.mgrMarket._map_player_infos);
});
}
Wait(time) {
return new Promise(resolve => {
setTimeout(() => {
resolve();
}, time);
});
}
}
class Logger {
constructor() {