diff --git a/dist/bcm_tool.js b/dist/bcm_tool.js index 06211b8..afd80c5 100644 --- a/dist/bcm_tool.js +++ b/dist/bcm_tool.js @@ -132,11 +132,14 @@ class BcmTool { if (maxIterate < 0) { break; } - const info = this.mgrMarket._map_player_infos[id]; + const info = this.mgrMarket.GetSellPlayer(id); if (!this.CheckInfo(info.playerId)) { yield this.RefreshPlayerInTransaction(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); @@ -150,10 +153,12 @@ class BcmTool { const value = this.QueryInfo(result.playerId, requireAttributes[idx]); return `${search}:${value}`; }); - console.log(`${result.playerName}(${result.playerAge})`, ...displayStr); + console.log(`${result.playerName}(${this.QueryPlayerOwner(result.playerId)})`, ...displayStr); } }); } + QuickOpenPlayer(name) { + } RefreshPlayerInTransaction(teamId, playerId) { return new Promise(resolve => { this.mgrTeamInfo.OpenPlayerDetailInTransaction(teamId, playerId, e => { @@ -170,11 +175,15 @@ class BcmTool { } QueryName(playerId) { const data = this.mgrTeamInfo.GetPlayerData(playerId); - return data.playerName; + return data === null || data === void 0 ? void 0 : data.playerName; } QueryInfo(playerId, attri) { const data = this.mgrTeamInfo.GetPlayerData(playerId); - return data.GetSingleAttribute(attri); + return data === null || data === void 0 ? void 0 : data.GetSingleAttribute(attri); + } + QueryPlayerOwner(playerId) { + const data = this.mgrTeamInfo.GetPlayerData(playerId); + return data === null || data === void 0 ? void 0 : data.teamName; } GetPlayerIds() { return Object.keys(this.mgrTeamInfo._map_player_detail); diff --git a/src/bcm_tool.ts b/src/bcm_tool.ts index 5f5b3e4..a83247e 100644 --- a/src/bcm_tool.ts +++ b/src/bcm_tool.ts @@ -47,7 +47,7 @@ class BcmTool ['防守技能', 48], ['身体素质', 50], ]); - private mgrTeamInfo = g_game.mgr.mgr_team_player_team_info; + private mgrPlayers = g_game.mgr.mgr_team_player_team_info; private mgrMarket = g_game.mgr.mgr_market; public ExportPlayerInfo(playersToQuery: string[]) @@ -141,12 +141,16 @@ class BcmTool { break; } - const info = this.mgrMarket._map_player_infos[id]; + const info = this.mgrMarket.GetSellPlayer(id); if (!this.CheckInfo(info.playerId)) { - await this.RefreshPlayerInTransaction(info.teamId, info.playerId); + await this.OpenPlayerInTransaction(info.teamId, info.playerId); await this.Wait(100); maxIterate -= 1; + if (!this.CheckInfo(info.playerId)) + { + continue; + } } if (conditions.every((e, i) => e(info.playerId, requireAttributes[i], requireValues[i]))) { @@ -163,20 +167,15 @@ class BcmTool const value = this.QueryInfo(result.playerId, requireAttributes[idx]); return `${search}:${value}`; }); - // TODO TeamName - console.log(`${result.playerName}(${result.playerAge})`, ...displayStr); + console.log(`${result.playerName}(${this.QueryOwner(result.playerId)})`, ...displayStr); } } - public QuickOpenPlayer(name:string) { - - } - - private RefreshPlayerInTransaction(teamId: string, playerId: string) + private OpenPlayerInTransaction(teamId: string, playerId: string) { return new Promise(resolve => { - this.mgrTeamInfo.OpenPlayerDetailInTransaction(teamId, playerId, e => + this.mgrPlayers.OpenPlayerDetailInTransaction(teamId, playerId, e => { resolve() return true; @@ -190,30 +189,36 @@ class BcmTool public CheckInfo(playerId: string) { - const data = this.mgrTeamInfo.GetPlayerData(playerId); + const data = this.mgrPlayers.GetPlayerData(playerId); return data != null; } public QueryName(playerId: string) { - const data = this.mgrTeamInfo.GetPlayerData(playerId); - return data.playerName; + const data = this.mgrPlayers.GetPlayerData(playerId); + return data?.playerName; } public QueryInfo(playerId: string, attri: number) { - const data = this.mgrTeamInfo.GetPlayerData(playerId); - return data.GetSingleAttribute(attri); + const data = this.mgrPlayers.GetPlayerData(playerId); + return data?.GetSingleAttribute(attri); + } + + public QueryOwner(playerId: string) + { + const data = this.mgrPlayers.GetPlayerData(playerId); + return data?.teamName; } public GetPlayerIds() { - return Object.keys(this.mgrTeamInfo._map_player_detail); + return Object.keys(this.mgrPlayers._map_player_detail); } public ListPlayers() { - const ids = Object.keys(this.mgrTeamInfo._map_player_detail); + const ids = Object.keys(this.mgrPlayers._map_player_detail); for (const id of ids) { console.log(this.QueryName(id), id); diff --git a/src/global.d.ts b/src/global.d.ts index 3fdb228..19e5ae2 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -6,6 +6,7 @@ declare global { public mgr_team_player_team_info: MgrTeamPlayerInfo; public mgr_market: MgrMarket; + public mgr_team_info: MgrTeamInfo; } interface BGameTools @@ -24,6 +25,7 @@ declare global interface MgrMarket { public _map_player_infos: { [key: string]: CMarketPlayerInfo }; + public GetSellPlayer(id: string): CMarketPlayerInfo; public SendSynOpenMarketInfoByFilter(callback?: () => void); } @@ -47,6 +49,24 @@ declare global } + interface MgrTeamInfo + { + public _map_team_info: { [key: string]: CTeam }; + + public GetTeamInfoById(id: string): CTeam; + public OpenTeamDetails(player_id: string, turnState?: boolean); + public SendGetTeamInfo(arr_team_id: string[], callback: () => void); + } + + interface CTeam + { + public name: string; + public unionName: string; + public webChat: string; + public qq: string; + public stadium: string; + } + var g_game: { bcm_tool: BcmTool; mgr: BGameMgr;