test
This commit is contained in:
Vendored
+60
-54
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
class BcmTool {
|
class BcmTool {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.attributes = new Map([
|
this.attributes = new Map([
|
||||||
['年龄', -100],
|
|
||||||
['速度', 1],
|
['速度', 1],
|
||||||
['力量', 2],
|
['力量', 2],
|
||||||
['内攻', 3],
|
['内攻', 3],
|
||||||
@@ -81,52 +80,52 @@ class BcmTool {
|
|||||||
console.log(form);
|
console.log(form);
|
||||||
g_game.tools.CopyStrToClipboard(form.ToString());
|
g_game.tools.CopyStrToClipboard(form.ToString());
|
||||||
}
|
}
|
||||||
BulkSearchMarket(searchStr, maxIterate = 100) {
|
BulkSearchMarket(searchStr_1) {
|
||||||
searchStr = searchStr.replace(/ /g, '');
|
return __awaiter(this, arguments, void 0, function* (searchStr, maxIterate = 100) {
|
||||||
const strs = searchStr.split('&&');
|
searchStr = searchStr.replace(/ /g, '');
|
||||||
const operators = ['>', '<', '=='];
|
const strs = searchStr.split('&&');
|
||||||
const handlers = [
|
const operators = ['>', '<', '=='];
|
||||||
(id, attri, value) => {
|
const handlers = [
|
||||||
return this.QueryInfo(id, attri) > value;
|
(id, attri, value) => {
|
||||||
},
|
return this.QueryInfo(id, attri) > value;
|
||||||
(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 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;
|
||||||
(id, attri, value) => {
|
},
|
||||||
return this.QueryInfo(id, attri) <= value;
|
(id, attri, value) => {
|
||||||
},
|
return this.QueryInfo(id, attri) <= value;
|
||||||
];
|
},
|
||||||
const conditions = [];
|
];
|
||||||
const requireAttributes = [];
|
const conditions = [];
|
||||||
const requireSearch = [];
|
const requireAttributes = [];
|
||||||
const requireValues = [];
|
const requireSearch = [];
|
||||||
for (let i = 0; i != strs.length; ++i) {
|
const requireValues = [];
|
||||||
const str = strs[i];
|
for (let i = 0; i != strs.length; ++i) {
|
||||||
const operator = operators.find(e => str.search(e) != -1);
|
const str = strs[i];
|
||||||
if (operator == null) {
|
const operator = operators.find(e => str.search(e) != -1);
|
||||||
console.log('条件解析失败', str);
|
if (operator == null) {
|
||||||
continue;
|
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 = [];
|
var results = [];
|
||||||
const ids = Object.keys(this.mgrMarket._map_player_infos);
|
const ids = Object.keys(this.mgrMarket._map_player_infos);
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
@@ -134,23 +133,26 @@ class BcmTool {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const info = this.mgrMarket._map_player_infos[id];
|
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]))) {
|
if (conditions.every((e, i) => e(info.playerId, requireAttributes[i], requireValues[i]))) {
|
||||||
results.push(info);
|
results.push(info);
|
||||||
}
|
}
|
||||||
maxIterate -= 1;
|
|
||||||
}
|
}
|
||||||
const displays = new Set(requireAttributes);
|
const displays = new Set(requireAttributes);
|
||||||
for (const result of results) {
|
for (const result of results) {
|
||||||
const displayStr = [...displays].map(e => {
|
const displayStr = [...displays].map(e => {
|
||||||
const idx = requireAttributes.indexOf(e);
|
const idx = requireAttributes.indexOf(e);
|
||||||
const search = requireSearch[idx];
|
const search = requireSearch[idx];
|
||||||
const value = result.GetSingleAttribute(e, true);
|
const value = this.QueryInfo(result.playerId, requireAttributes[idx]);
|
||||||
return `${search}:${value}`;
|
return `${search}:${value}`;
|
||||||
});
|
});
|
||||||
console.log(result.playerName, ...displayStr);
|
console.log(`${result.playerName}(${result.playerAge})`, ...displayStr);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
RefreshPlayerInTransaction(teamId, playerId) {
|
RefreshPlayerInTransaction(teamId, playerId) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@@ -172,9 +174,6 @@ class BcmTool {
|
|||||||
}
|
}
|
||||||
QueryInfo(playerId, attri) {
|
QueryInfo(playerId, attri) {
|
||||||
const data = this.mgrTeamInfo.GetPlayerData(playerId);
|
const data = this.mgrTeamInfo.GetPlayerData(playerId);
|
||||||
if (attri == -100) {
|
|
||||||
return data.playerAge;
|
|
||||||
}
|
|
||||||
return data.GetSingleAttribute(attri);
|
return data.GetSingleAttribute(attri);
|
||||||
}
|
}
|
||||||
GetPlayerIds() {
|
GetPlayerIds() {
|
||||||
@@ -191,6 +190,13 @@ class BcmTool {
|
|||||||
console.log(this.mgrMarket._map_player_infos);
|
console.log(this.mgrMarket._map_player_infos);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Wait(time) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve();
|
||||||
|
}, time);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
class Logger {
|
class Logger {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
+41
-30
@@ -2,7 +2,6 @@
|
|||||||
class BcmTool
|
class BcmTool
|
||||||
{
|
{
|
||||||
private attributes = new Map<string, number>([
|
private attributes = new Map<string, number>([
|
||||||
['年龄', -100],
|
|
||||||
['速度', 1],
|
['速度', 1],
|
||||||
['力量', 2],
|
['力量', 2],
|
||||||
['内攻', 3],
|
['内攻', 3],
|
||||||
@@ -78,7 +77,7 @@ class BcmTool
|
|||||||
g_game.tools.CopyStrToClipboard(form.ToString());
|
g_game.tools.CopyStrToClipboard(form.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BulkSearchMarket(searchStr: string, maxIterate = 100)
|
public async BulkSearchMarket(searchStr: string, maxIterate = 100)
|
||||||
{
|
{
|
||||||
searchStr = searchStr.replace(/ /g, '');
|
searchStr = searchStr.replace(/ /g, '');
|
||||||
const strs = searchStr.split('&&');
|
const strs = searchStr.split('&&');
|
||||||
@@ -134,37 +133,43 @@ class BcmTool
|
|||||||
requireSearch.push(requires[0]);
|
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[] = [];
|
if (maxIterate < 0)
|
||||||
const ids = Object.keys(this.mgrMarket._map_player_infos);
|
{
|
||||||
for (const id of ids)
|
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);
|
await this.RefreshPlayerInTransaction(info.teamId, info.playerId);
|
||||||
if (conditions.every((e, i) => e(info.playerId, requireAttributes[i], requireValues[i])))
|
await this.Wait(100);
|
||||||
{
|
|
||||||
results.push(info);
|
|
||||||
}
|
|
||||||
maxIterate -= 1;
|
maxIterate -= 1;
|
||||||
}
|
}
|
||||||
const displays = new Set<number>(requireAttributes);
|
if (conditions.every((e, i) => e(info.playerId, requireAttributes[i], requireValues[i])))
|
||||||
for (const result of results)
|
|
||||||
{
|
{
|
||||||
const displayStr = [...displays].map(e =>
|
results.push(info);
|
||||||
{
|
|
||||||
const idx = requireAttributes.indexOf(e);
|
|
||||||
const search = requireSearch[idx];
|
|
||||||
const value = result.GetSingleAttribute(e, true);
|
|
||||||
return `${search}:${value}`;
|
|
||||||
});
|
|
||||||
console.log(result.playerName, ...displayStr);
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
const displays = new Set<number>(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)
|
private RefreshPlayerInTransaction(teamId: string, playerId: string)
|
||||||
@@ -198,10 +203,6 @@ class BcmTool
|
|||||||
public QueryInfo(playerId: string, attri: number)
|
public QueryInfo(playerId: string, attri: number)
|
||||||
{
|
{
|
||||||
const data = this.mgrTeamInfo.GetPlayerData(playerId);
|
const data = this.mgrTeamInfo.GetPlayerData(playerId);
|
||||||
if (attri == -100)
|
|
||||||
{
|
|
||||||
return data.playerAge;
|
|
||||||
}
|
|
||||||
return data.GetSingleAttribute(attri);
|
return data.GetSingleAttribute(attri);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,6 +228,16 @@ class BcmTool
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Wait(time: number)
|
||||||
|
{
|
||||||
|
return new Promise<void>(resolve =>
|
||||||
|
{
|
||||||
|
setTimeout(() =>
|
||||||
|
{
|
||||||
|
resolve();
|
||||||
|
}, time)
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Logger
|
class Logger
|
||||||
|
|||||||
Reference in New Issue
Block a user