Skip to content

Commit

Permalink
增加怀旧服玩家技能名称反查 ID 与等级
Browse files Browse the repository at this point in the history
  • Loading branch information
whc2001 committed Jan 12, 2023
1 parent 1c9554c commit fe04945
Show file tree
Hide file tree
Showing 9 changed files with 3,059 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ todo
node_modules
package-lock.json
.npmrc
temp
Binary file added build/lua51.dll
Binary file not shown.
Binary file added build/lua51.exe
Binary file not shown.
34 changes: 34 additions & 0 deletions build/origin_talent.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function WorkDir()
return debug.getinfo(2, "S").source:sub(2):match("(.*\\)")
end

function ExecuteFileGetExport(file)
local code = loadfile(file)
local env = {}
setfenv(code, env)
code()
return env
end

function TraverseNestedTable(table, delegate)
for k, v in pairs(table) do
if type(v) == "table" then
TraverseNestedTable(v, delegate)
else
delegate(v)
end
end
end

local workDir = WorkDir()
local talent = ExecuteFileGetExport(workDir .. "..\\raw\\origin\\TalentTab.lua")["TALENT_TAB"]
local hashTable = {}
TraverseNestedTable(talent, function(i)
hashTable[i] = true
end)
os.execute("mkdir " .. workDir .. "..\\temp\\ >nul 2>nul")
local output = io.open(workDir .. "..\\temp\\talent.txt", "w")
for i, _ in pairs(hashTable) do
output:write(tostring(i) .. "\n")
end
output:close()
63 changes: 36 additions & 27 deletions build/skill_name_to_id_level.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ async function readAllSkillReplace(client) {
useDefaultRow: TABLE_DEFAULT_ROW_MODE.IGNORE
});

for(let line of skillReplaceTable) {
if(line['dst_skill_id1'])
for (let line of skillReplaceTable) {
if (line['dst_skill_id1'])
ret[line['dst_skill_id1']] = line['src_skill_id'];
if(line['dst_skill_id2'])
if (line['dst_skill_id2'])
ret[line['dst_skill_id2']] = line['src_skill_id'];
}

Expand All @@ -96,33 +96,40 @@ async function buildSkillNameToIDAndLevel(client, maxSkillLevel, skillIDLevelAnd
const kungFuSkillTable = await parseTable(await readFile(kungfuSkillPath), {
keepColumns: ['Skill'],
});
const allKungfuSkills = kungFuSkillTable.reduce((acc, cur) => {
const kungfuSkills = kungFuSkillTable.reduce((acc, cur) => {
const skills = (cur['Skill'] || '').trim().replace('|', ';').split(';');
for (let skill of skills)
if (skill)
acc.push(skill);
return acc;
}, []);
logger.info(`共读取 ${allKungfuSkills.length} 条数据`);
logger.info(`共读取 ${kungfuSkills.length} 条数据`);

// 面板奇穴表
// 面板奇穴表,怀旧服使用上一步 Lua 输出的所有镇派技能 ID
logger.info('读取所有奇穴');
const tenextraPointPath = path.join(__dirname, `../raw/${client}/tenextrapoint.tab`);
const tenExtraPointsTable = await parseTable(await readFile(tenextraPointPath));
const allTenExtraPointSkills = tenExtraPointsTable.reduce((acc, cur) => {
for (let i = 1; i <= 5; ++i) {
const skillID = cur[`SkillID${i}`];
const skillLevel = cur[`SkillLevel${i}`];
if (skillID && skillLevel)
acc.push(skillID);
}
return acc;
}, []);
logger.info(`共读取 ${allTenExtraPointSkills.length} 条数据`);
let extraPointSkills;
if (client === 'std') {
const tenExtraPointPath = path.join(__dirname, `../raw/${client}/tenextrapoint.tab`);
const tenExtraPointsTable = await parseTable(await readFile(tenExtraPointPath));
extraPointSkills = tenExtraPointsTable.reduce((acc, cur) => {
for (let i = 1; i <= 5; ++i) {
const skillID = cur[`SkillID${i}`];
const skillLevel = cur[`SkillLevel${i}`];
if (skillID && skillLevel)
acc.push(skillID);
}
return acc;
}, []);
}
else if (client === 'origin') {
const talentOutputPath = path.join(__dirname, `../temp/talent.txt`);
extraPointSkills = (await readFile(talentOutputPath)).split('\n').map(i => ~~i);
}
logger.info(`共读取 ${extraPointSkills.length} 条数据`);

// 开始构建
logger.info('构建技能名称到 ID 与等级反查映射');
for (let skillID of [...allKungfuSkills, ...allTenExtraPointSkills]) {
for (let skillID of [...kungfuSkills, ...extraPointSkills]) {

// 直接查询
if (skillIDLevelAndName[skillID]) {
Expand All @@ -137,15 +144,17 @@ async function buildSkillNameToIDAndLevel(client, maxSkillLevel, skillIDLevelAnd
}

// 替换查询
if(skillReplace[skillID]) {
if (skillReplace[skillID]) {
let replaceSkillID = skillReplace[skillID];
let maxLevel = maxSkillLevel[replaceSkillID];
if (!maxLevel || !skillIDLevelAndName[replaceSkillID][maxLevel])
maxLevel = GetMaxKey(skillIDLevelAndName[replaceSkillID]);
ret[skillIDLevelAndName[replaceSkillID][maxLevel]] = {
id: skillID,
level: maxLevel
};
if (skillIDLevelAndName[replaceSkillID]) {
let maxLevel = maxSkillLevel[replaceSkillID];
if (!maxLevel || !skillIDLevelAndName[replaceSkillID][maxLevel])
maxLevel = GetMaxKey(skillIDLevelAndName[replaceSkillID]);
ret[skillIDLevelAndName[replaceSkillID][maxLevel]] = {
id: skillID,
level: maxLevel
};
}
}
}
logger.info(`共构建 ${Object.keys(ret).length} 条数据`);
Expand Down
Loading

0 comments on commit fe04945

Please sign in to comment.