fortnite-replay-analysis 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +15 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -25,11 +25,14 @@ function ReplayAnalysis(inputPath, { bot = false, sort = true } = {}) { // Fortn
|
|
|
25
25
|
try {
|
|
26
26
|
const stat = fs.statSync(inputPath);
|
|
27
27
|
if (stat.isDirectory()) {
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const files = fs.readdirSync(inputPath)
|
|
29
|
+
.filter(f => f.endsWith('.replay'))
|
|
30
|
+
.map(f => ({ f, t: fs.statSync(path.join(inputPath, f)).mtimeMs }))
|
|
31
|
+
.sort((a, b) => b.t - a.t); // 新しい順
|
|
32
|
+
if (files.length === 0) {
|
|
30
33
|
return reject(new Error(`No .replay files found in directory: ${inputPath}`));
|
|
31
34
|
}
|
|
32
|
-
replayFilePath = path.join(inputPath,
|
|
35
|
+
replayFilePath = path.join(inputPath, files[0].f);
|
|
33
36
|
} else if (stat.isFile()) {
|
|
34
37
|
replayFilePath = inputPath;
|
|
35
38
|
} else {
|
|
@@ -145,6 +148,7 @@ async function calculateScore({ matchData, points, killCountUpperLimit = null, k
|
|
|
145
148
|
partyNumber: player.partyNumber,
|
|
146
149
|
partyKills: limitedKills,
|
|
147
150
|
partyKillsNoLimit: player.TeamKills || 0,
|
|
151
|
+
partyKillPoints: (limitedKills) * killPointMultiplier,
|
|
148
152
|
partyScore: (points[player.Placement] ?? 0) + ((limitedKills) * killPointMultiplier),
|
|
149
153
|
partyPoint: points[player.Placement] ?? 0,
|
|
150
154
|
partyVictoryRoyale: player.Placement === 1,
|
|
@@ -181,13 +185,16 @@ function mergeScores(scoreArrays) { // 複数マッチの結果をマージし
|
|
|
181
185
|
partyPoint: p.partyPoint,
|
|
182
186
|
partyKills: p.partyKills,
|
|
183
187
|
partyKillsNoLimit: p.partyKillsNoLimit,
|
|
188
|
+
partyKillPoints: p.partyKillPoints,
|
|
184
189
|
partyVictoryRoyaleCount: p.partyVictoryRoyale ? 1 : 0,
|
|
185
190
|
matchList: [p.matchName],
|
|
186
191
|
partyMemberList: [...p.partyMemberList],
|
|
192
|
+
partyDiscordInfo: p.partyDiscordInfo ? { ...p.partyDiscordInfo } : undefined,
|
|
187
193
|
partyAliveTimeByMatch: [
|
|
188
194
|
{ match: p.matchName, times: [...(p.partyAliveTimeList || [])] }
|
|
189
195
|
],
|
|
190
196
|
partyPlacementList: [p.partyPlacement],
|
|
197
|
+
blockNames: p.blockName ? [p.blockName] : [],
|
|
191
198
|
matchs: { [p.matchName]: { ...p } }
|
|
192
199
|
});
|
|
193
200
|
} else {
|
|
@@ -196,6 +203,7 @@ function mergeScores(scoreArrays) { // 複数マッチの結果をマージし
|
|
|
196
203
|
ex.partyPoint += p.partyPoint;
|
|
197
204
|
ex.partyKills += p.partyKills;
|
|
198
205
|
ex.partyKillsNoLimit += p.partyKillsNoLimit;
|
|
206
|
+
ex.partyKillPoints += p.partyKillPoints;
|
|
199
207
|
ex.partyVictoryRoyaleCount += p.partyVictoryRoyale ? 1 : 0;
|
|
200
208
|
ex.matchList.push(p.matchName);
|
|
201
209
|
ex.partyAliveTimeByMatch.push({
|
|
@@ -204,6 +212,9 @@ function mergeScores(scoreArrays) { // 複数マッチの結果をマージし
|
|
|
204
212
|
});
|
|
205
213
|
ex.partyPlacementList.push(p.partyPlacement);
|
|
206
214
|
ex.matchs[p.matchName] = { ...p };
|
|
215
|
+
if (p.blockName && !ex.blockNames.includes(p.blockName)) {
|
|
216
|
+
ex.blockNames.push(p.blockName);
|
|
217
|
+
}
|
|
207
218
|
}
|
|
208
219
|
})
|
|
209
220
|
);
|
|
@@ -212,7 +223,6 @@ function mergeScores(scoreArrays) { // 複数マッチの結果をマージし
|
|
|
212
223
|
}
|
|
213
224
|
|
|
214
225
|
function sortScores(arr) { // 公式準拠のスコアソート関数
|
|
215
|
-
// リザルトとしてpoint, ビクロイ数, マッチ数, 平均撃破数, 平均順位, 合計生存時間を追加したい
|
|
216
226
|
if (!Array.isArray(arr) || arr.length === 0) return arr;
|
|
217
227
|
|
|
218
228
|
arr.forEach(p => {
|
|
@@ -249,7 +259,7 @@ function sortScores(arr) { // 公式準拠のスコアソート関数
|
|
|
249
259
|
}
|
|
250
260
|
|
|
251
261
|
// 4. 平均順位(小さいほうが上位)
|
|
252
|
-
const cmpAvgPlacement =
|
|
262
|
+
const cmpAvgPlacement = a.summary.avgPlacement.comparedTo(b.summary.avgPlacement);
|
|
253
263
|
if (cmpAvgPlacement !== 0) {
|
|
254
264
|
return cmpAvgPlacement;
|
|
255
265
|
}
|