"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; class BcmTool { constructor() { this.attributes = new Map([ ['*后仰倾向', 28], ['*造防守犯规', 37], ['*造进攻犯规', 33], ['*假动作', 40], ['*进攻犯规', 24], ['*防守犯规', 25], ['*进攻IQ', 17], ['*防守IQ', 18], ['*反应时间', 30], ['速度', 1], ['力量', 2], ['内攻', 3], ['中投', 4], ['三分', 5], ['三分急停跳投倾向', 6], ['内线防守能力', 7], ['外线防守能力', 8], ['突破能力', 9], ['上篮能力', 10], ['控球能力', 11], ['传球能力', 12], ['传球视野', 13], ['干扰投篮', 14], ['篮板能力', 15], ['*出手时间', 16], ['体能', 19], ['卡位能力', 20], ['罚球能力', 21], ['抢断能力', 22], ['盖帽能力', 23], ['扣篮能力', 26], ['勾手倾向', 27], ['打板倾向', 29], ['拉开空间', 31], ['补防、协防', 32], ['快下', 34], ['无球跑动', 35], ['挡拆', 36], ['无球掩护', 38], ['进攻篮板', 39], ['攻转守', 41], ['进攻技能', 44], ['防守技能', 48], ['身体素质', 50], ]); this.mgrPlayers = g_game.mgr.mgr_team_player_team_info; this.mgrMarket = g_game.mgr.mgr_market; } ExportPlayerInfo(playersToQuery) { const lstAttributes = [...this.attributes]; const form = new Form(); form.SetCell(0, 0, "姓名"); form.SetCell(0, 1, "球队"); form.SetCell(0, 2, "年龄"); for (let i = 0; i != lstAttributes.length; ++i) { form.SetCell(0, i + 3, lstAttributes[i][0]); } for (let i = 0; i != playersToQuery.length; ++i) { const playerId = playersToQuery[i]; if (!this.CheckInfo(playerId)) { console.log('找不到id', playerId); continue; } form.SetCell(i + 1, 0, this.QueryName(playerId)); form.SetCell(i + 1, 1, this.QueryOwner(playerId)); form.SetCell(i + 1, 2, this.QueryAge(playerId).toString()); for (let j = 0; j != lstAttributes.length; ++j) { const record = this.QueryInfo(playerId, lstAttributes[j][1]); form.SetCell(i + 1, j + 3, record.toString()); } } console.log(form); g_game.tools.CopyStrToClipboard(form.ToString()); } 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]); } var results = []; const ids = Object.keys(this.mgrMarket._map_player_infos); for (const id of ids) { if (maxIterate < 0) { break; } const info = this.mgrMarket.GetSellPlayer(id); if (!this.CheckInfo(info.playerId)) { yield this.OpenPlayerInTransaction(info.teamId, info.playerId); yield this.Wait(100); maxIterate -= 1; if (!this.CheckInfo(info.playerId)) { continue; } } if (conditions.every((e, i) => e(info.playerId, requireAttributes[i], requireValues[i]))) { 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}`; // }); // console.log(`${result.playerName}(${this.QueryOwner(result.playerId)})`, ...displayStr); // } this.ExportPlayerInfo(results.map(e => e.playerId)); }); } OpenPlayerInTransaction(teamId, playerId) { return new Promise(resolve => { this.mgrPlayers.OpenPlayerDetailInTransaction(teamId, playerId, e => { resolve(); return true; }, e => { resolve(); }); }); } CheckInfo(playerId) { const data = this.mgrPlayers.GetPlayerData(playerId); return data != null; } QueryName(playerId) { const data = this.mgrPlayers.GetPlayerData(playerId); return data === null || data === void 0 ? void 0 : data.playerName; } QueryInfo(playerId, attri) { const data = this.mgrPlayers.GetPlayerData(playerId); return data === null || data === void 0 ? void 0 : data.GetSingleAttribute(attri, true); } QueryOwner(playerId) { const data = this.mgrPlayers.GetPlayerData(playerId); return data === null || data === void 0 ? void 0 : data.teamName; } QueryAge(playerId) { const data = this.mgrPlayers.GetPlayerData(playerId); return data === null || data === void 0 ? void 0 : data.playerAge; } GetPlayerIds() { return Object.keys(this.mgrPlayers._map_player_detail); } ListPlayers() { const ids = Object.keys(this.mgrPlayers._map_player_detail); for (const id of ids) { console.log(this.QueryName(id), id); } } ListMarketPlayers() { this.mgrMarket.SendSynOpenMarketInfoByFilter(() => { console.log(this.mgrMarket._map_player_infos); }); } Wait(time) { return new Promise(resolve => { setTimeout(() => { resolve(); }, time); }); } } class Logger { constructor() { this.msgs = ''; } Info(...msgs) { for (const msg of msgs) { this.msgs += String(msg); } } NextLine() { this.msgs += '\n'; } GetContent() { return this.msgs; } Clear() { this.msgs = ''; } } class Form { constructor() { this.records = []; } SetCell(col, row, data) { if (this.records[col] == null) { this.records[col] = []; } this.records[col][row] = data; } ToString() { var _a; const logger = new Logger(); for (let col = 0; col != this.records.length; ++col) { for (let row = 0; row != this.records[col].length; ++row) { logger.Info((_a = this.records[col][row]) !== null && _a !== void 0 ? _a : ''); if (row < this.records[col].length - 1) { logger.Info(','); } } if (col < this.records.length - 1) { logger.NextLine(); } } return logger.GetContent(); } } (() => { g_game.bcm_tool = new BcmTool(); })();