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
+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();
})();