diff --git a/dist/bcm_tool.js b/dist/bcm_tool.js index 7b6703f..06211b8 100644 --- a/dist/bcm_tool.js +++ b/dist/bcm_tool.js @@ -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() { diff --git a/src/bcm_tool.ts b/src/bcm_tool.ts index 7c02d70..5f5b3e4 100644 --- a/src/bcm_tool.ts +++ b/src/bcm_tool.ts @@ -2,7 +2,6 @@ class BcmTool { private attributes = new Map([ - ['年龄', -100], ['速度', 1], ['力量', 2], ['内攻', 3], @@ -78,7 +77,7 @@ class BcmTool g_game.tools.CopyStrToClipboard(form.ToString()); } - public BulkSearchMarket(searchStr: string, maxIterate = 100) + public async BulkSearchMarket(searchStr: string, maxIterate = 100) { searchStr = searchStr.replace(/ /g, ''); const strs = searchStr.split('&&'); @@ -134,37 +133,43 @@ class BcmTool requireSearch.push(requires[0]); } - this.mgrMarket.SendSynOpenMarketInfoByFilter(async () => + var results: CPlayerData[] = []; + const ids = Object.keys(this.mgrMarket._map_player_infos); + for (const id of ids) { - var results: CPlayerData[] = []; - const ids = Object.keys(this.mgrMarket._map_player_infos); - for (const id of ids) + if (maxIterate < 0) + { + break; + } + const info = this.mgrMarket._map_player_infos[id]; + if (!this.CheckInfo(info.playerId)) { - if (maxIterate < 0) - { - break; - } - const info = this.mgrMarket._map_player_infos[id]; await this.RefreshPlayerInTransaction(info.teamId, info.playerId); - if (conditions.every((e, i) => e(info.playerId, requireAttributes[i], requireValues[i]))) - { - results.push(info); - } + await this.Wait(100); maxIterate -= 1; } - const displays = new Set(requireAttributes); - for (const result of results) + if (conditions.every((e, i) => e(info.playerId, requireAttributes[i], requireValues[i]))) { - const displayStr = [...displays].map(e => - { - const idx = requireAttributes.indexOf(e); - const search = requireSearch[idx]; - const value = result.GetSingleAttribute(e, true); - return `${search}:${value}`; - }); - console.log(result.playerName, ...displayStr); + results.push(info); } - }); + } + 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 = this.QueryInfo(result.playerId, requireAttributes[idx]); + return `${search}:${value}`; + }); + // TODO TeamName + console.log(`${result.playerName}(${result.playerAge})`, ...displayStr); + } + } + + public QuickOpenPlayer(name:string) { + } private RefreshPlayerInTransaction(teamId: string, playerId: string) @@ -198,10 +203,6 @@ class BcmTool public QueryInfo(playerId: string, attri: number) { const data = this.mgrTeamInfo.GetPlayerData(playerId); - if (attri == -100) - { - return data.playerAge; - } return data.GetSingleAttribute(attri); } @@ -227,6 +228,16 @@ class BcmTool }); } + public Wait(time: number) + { + return new Promise(resolve => + { + setTimeout(() => + { + resolve(); + }, time) + }); + } } class Logger