-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass.js
More file actions
95 lines (94 loc) · 2.58 KB
/
Copy pathClass.js
File metadata and controls
95 lines (94 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
const fs = require("fs");
const fuel = require("aigis-fuel");
const getAssets = require("./getAssets");
const skillMeta = require("./skillMeta.json");
const fileName = "PlayerUnitTable.aar";
const file = fs.readFileSync(`old/${fileName}`);
const oldAL = fuel.parseAL(file).Files[1].Content;
var util = require("util");
function getAbility(value, config) {
const startIndex = config.Contents.findIndex(v => v._ConfigID === value);
if (startIndex === -1) {
throw "No such ConfigID";
}
return sliceToNext(config.Contents, "_ConfigID", startIndex).map(v => {
v._InfluenceTypeName = (
skillMeta.find(meta => meta.ID === v._InfluenceType) || {
Description: ""
}
).Description;
return v;
});
}
function sliceToNext(a, key, startIndex) {
let index = startIndex;
while (true) {
index++;
if (index === a.length) {
return a.slice(startIndex, index);
}
if (a[index][key] !== 0) {
return a.slice(startIndex, index);
}
}
}
function compare(a, b) {
if (a.length !== b.length) {
return true;
}
a.forEach((v, i) => {
const bv = b[i];
Object.keys(v).forEach(key => {
if (v[key] !== bv[key]) {
return true;
}
});
});
return false;
}
// Skill
try {
(async function() {
const newAL = fuel.parseAL(await getAssets(fileName)).Files[1].Content;
const newConfigAL = fuel.parseAL(await getAssets("AbilityConfig.atb"));
const oldConfigAL = fuel.parseAL(fs.readFileSync(`old/AbilityConfig.atb`));
// 分析old和new
diffs = [];
oldAL.Contents.forEach((oldContent, index) => {
const newContent = newAL.Contents.find(
v => v.ClassID === oldContent.ClassID
);
if (!newContent) {
throw "wired";
}
// 比较每一项
const diff = {
name: oldContent.Name,
id: oldContent.ClassID
};
let dirty = false;
Object.keys(oldContent).forEach(key => {
if (key === "ClassAbility1") {
oldContent[key] = getAbility(oldContent[key], oldConfigAL);
newContent[key] = getAbility(newContent[key], newConfigAL);
if (compare(oldContent[key], newContent[key])) {
diff[key] = [oldContent[key], newContent[key]];
dirty = true;
}
} else {
if (oldContent[key] !== newContent[key]) {
diff[key] = [oldContent[key], newContent[key]];
dirty = true;
}
}
});
if (dirty) {
diffs.push(diff);
// console.log(newContent);
}
});
console.log(diffs);
})();
} catch (err) {
console.log(err);
}