csv form format

This commit is contained in:
2026-01-20 16:56:27 +08:00
parent b6331e206b
commit 41cd99fa36
3 changed files with 131 additions and 41 deletions
+1 -1
View File
@@ -1 +1 @@
g_game.bcm_tool.queryPlayerInfo(g_game.bcm_tool.listPlayers());
g_game.bcm_tool.queryPlayerInfo(g_game.bcm_tool.getPlayerIds());
+42 -11
View File
@@ -2,7 +2,6 @@
class BcmTool {
constructor() {
this.mgrTeamInfo = g_game.mgr.mgr_team_player_team_info;
this.logger = new Logger();
}
queryPlayerInfo(playersToQuery) {
const attributes = [
@@ -51,21 +50,24 @@ class BcmTool {
['防守技能', 48],
['身体素质', 50],
];
for (const playerId of playersToQuery) {
var form = new Form();
for (let i = 0; i != attributes.length; ++i) {
form.SetCell(i + 1, 0, attributes[i][0]);
}
for (let i = 0; i != playersToQuery.length; ++i) {
const playerId = playersToQuery[i];
if (!this.checkInfo(playerId)) {
console.log('找不到id', playerId);
continue;
}
this.logger.Info(this.queryName(playerId));
for (const info of attributes) {
const name = info[0];
const id = info[1];
const record = this.queryInfo(playerId, id);
this.logger.Info(name, record);
form.SetCell(0, i + 1, this.queryName(playerId));
for (let j = 0; j != attributes.length; ++j) {
const record = this.queryInfo(playerId, attributes[j][1]);
form.SetCell(j + 1, i + 1, record.toString());
}
g_game.tools.CopyStrToClipboard(this.logger.GetOutput());
this.logger.Clear();
}
console.log(form);
g_game.tools.CopyStrToClipboard(form.ToString());
}
checkInfo(playerId) {
const data = this.mgrTeamInfo.GetPlayerData(playerId);
@@ -97,15 +99,44 @@ class Logger {
for (const msg of msgs) {
this.msgs += String(msg);
}
}
NextLine() {
this.msgs += '\n';
}
GetOutput() {
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;
var 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();
})();
+88 -29
View File
@@ -1,9 +1,10 @@
class BcmTool {
class BcmTool
{
private mgrTeamInfo = g_game.mgr.mgr_team_player_team_info;
private logger = new Logger();
public queryPlayerInfo(playersToQuery:string[]) {
public queryPlayerInfo(playersToQuery: string[])
{
const attributes = [
['速度', 1],
['力量', 2],
@@ -50,71 +51,129 @@ class BcmTool {
['防守技能', 48],
['身体素质', 50],
];
for (const playerId of playersToQuery) {
if (!this.checkInfo(playerId)) {
var form = new Form();
for (let i = 0; i != attributes.length; ++i)
{
form.SetCell(i + 1, 0, attributes[i][0] as string);
}
for (let i = 0; i != playersToQuery.length; ++i)
{
const playerId = playersToQuery[i];
if (!this.checkInfo(playerId))
{
console.log('找不到id', playerId);
continue;
}
this.logger.Info(this.queryName(playerId));
for (const info of attributes) {
const name = info[0];
const id = info[1];
const record = this.queryInfo(playerId, id as number);
this.logger.Info(name, record);
form.SetCell(0, i + 1, this.queryName(playerId));
for (let j = 0; j != attributes.length; ++j)
{
const record = this.queryInfo(playerId, attributes[j][1] as number);
form.SetCell(j + 1, i + 1, record.toString());
}
g_game.tools.CopyStrToClipboard(this.logger.GetOutput());
this.logger.Clear();
}
console.log(form);
g_game.tools.CopyStrToClipboard(form.ToString());
}
public checkInfo(playerId:string) {
public checkInfo(playerId: string)
{
const data = this.mgrTeamInfo.GetPlayerData(playerId);
return data != null;
}
public queryName(playerId:string) {
public queryName(playerId: string)
{
const data = this.mgrTeamInfo.GetPlayerData(playerId);
return data.playerName;
}
public queryInfo(playerId:string, attri:number) {
public queryInfo(playerId: string, attri: number)
{
const data = this.mgrTeamInfo.GetPlayerData(playerId);
return data.GetSingleAttribute(attri).toFixed(2);
}
public getPlayerIds() {
public getPlayerIds()
{
return Object.keys(this.mgrTeamInfo._map_player_detail);
}
public listPlayers() {
public listPlayers()
{
const ids = Object.keys(this.mgrTeamInfo._map_player_detail);
for (const id of ids) {
for (const id of ids)
{
console.log(this.queryName(id), id);
}
}
}
class Logger {
class Logger
{
private msgs = '';
public Info(...msgs:any[]) {
for (const msg of msgs) {
public Info(...msgs: any[])
{
for (const msg of msgs)
{
this.msgs += String(msg);
}
}
public NextLine()
{
this.msgs += '\n';
}
public GetOutput() {
public GetContent()
{
return this.msgs;
}
public Clear() {
public Clear()
{
this.msgs = '';
}
}
(()=>{
class Form
{
private records: string[][] = [];
public SetCell(col: number, row: number, data: string)
{
if (this.records[col] == null)
{
this.records[col] = [];
}
this.records[col][row] = data;
}
public ToString()
{
var logger = new Logger();
for (let col = 0; col != this.records.length; ++col)
{
for (let row = 0; row != this.records[col].length; ++row)
{
logger.Info(this.records[col][row] ?? '');
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();
})();