fortnite-replay-analysis 1.1.0 → 1.1.2

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.
Files changed (4) hide show
  1. package/LICENSE +30 -0
  2. package/README.ja.md +144 -0
  3. package/README.md +105 -80
  4. package/package.json +15 -3
package/LICENSE ADDED
@@ -0,0 +1,30 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 yuyutti
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ This project includes code from the following MIT-licensed project:
26
+
27
+ FortniteReplayDecompressor
28
+ https://github.com/Shiqan/FortniteReplayDecompressor
29
+ Copyright (c) 2021 Ferron
30
+ Licensed under the MIT License.
package/README.ja.md ADDED
@@ -0,0 +1,144 @@
1
+ ## 🌐 Language
2
+
3
+ - [English](./README.md)
4
+ - [日本語](./README.ja.md)
5
+
6
+ # Fortnite Replay Analysis
7
+
8
+ FortniteのリプレイファイルをNode.jsで解析し、プレイヤーデータを取得・集計・ソートできるモジュールです。
9
+
10
+ ## 特徴
11
+
12
+ * OS判定でビルド済みの自己完結バイナリを呼び出し、高速に解析できます。
13
+ * botプレイヤーの除外や順位ソートのオプションに対応しています。
14
+ * 複数マッチのスコアをパーティ単位でマージして集計できます。
15
+ * 公式準拠のルールでスコアをソートできます。
16
+
17
+ ## インストール
18
+
19
+ ```bash
20
+ npm install fortnite-replay-analysis@latest
21
+ ```
22
+
23
+ ## 使い方
24
+
25
+ 以下は、1試合のリプレイ解析からスコア計算、複数マッチのマージまでを実行する例です。
26
+
27
+ ```js
28
+ const {
29
+ ReplayAnalysis,
30
+ calculateScore,
31
+ sortScores,
32
+ mergeScores
33
+ } = require('fortnite-replay-analysis');
34
+
35
+ (async () => {
36
+ // リプレイ解析(ディレクトリ指定時は最初に見つけた .replay を処理、ファイル指定時はそのファイルを使用)
37
+ const {
38
+ rawReplayData,
39
+ rawPlayerData,
40
+ processedPlayerInfo
41
+ } = await ReplayAnalysis(
42
+ './path/to/replayDirOrFile',
43
+ { bot: false, sort: true }
44
+ );
45
+
46
+ console.log('Raw Data:', rawPlayerData);
47
+ console.log('Processed Player Info:', processedPlayerInfo);
48
+
49
+ // 公式ルールでソート
50
+ const sortedScores = sortScores(processedPlayerInfo);
51
+
52
+ // ポイント&キル計算
53
+ const score = await calculateScore({
54
+ matchData: processedPlayerInfo,
55
+ points: { 1: 11, 2: 6, 3: 5, 4: 4, 5: 3, 6: 2 },
56
+ killCountUpperLimit: 10, // 省略可能、デフォルト null(無制限)
57
+ killPointMultiplier: 1 // 1撃破あたりの倍率(1の場合1撃破1pt, 2の場合1撃破2ポイント)、省略可能、デフォルト 1
58
+ });
59
+
60
+ console.log('Score:', score);
61
+
62
+ // 複数マッチのマージと再ソート
63
+ const merged = mergeScores([ sortedScores, sortedScores2 ]);
64
+ const finalSorted = sortScores(merged);
65
+
66
+ console.log('Merged & Sorted:', finalSorted);
67
+ })();
68
+ ```
69
+
70
+ ## API
71
+
72
+ ### `ReplayAnalysis(inputPath, options)`
73
+
74
+ * `inputPath`: .replayファイルがあるディレクトリまたはファイルのパス
75
+ * `options`(省略可):
76
+
77
+ * `bot`(boolean): botプレイヤーを含めるか(デフォルト: `false`)
78
+ * `sort`(boolean): 順位でソートするか(デフォルト: `true`)
79
+ * 戻り値: Promise<{
80
+ rawReplayData: Object,
81
+ rawPlayerData: Array,
82
+ processedPlayerInfo: Array
83
+ }>
84
+
85
+ ### `calculateScore({ matchData, points, killCountUpperLimit, killPointMultiplier })`
86
+
87
+ * `matchData`: `ReplayAnalysis`の`processedPlayerInfo`配列、またはそのJSONファイルへのパス
88
+ * `points`: 順位ごとのポイント設定オブジェクト(例: `{1:11,2:6,...}`)
89
+ * `killCountUpperLimit`: キル数の上限(省略可能、デフォルト: `null` で無制限)
90
+ * `killPointMultiplier`: 1撃破あたりの倍率(1の場合1撃破1pt, 2の場合1撃破2ポイント)、省略可能、デフォルト: `1`
91
+ * 戻り値: Promise(パーティごとの集計結果)
92
+
93
+ ### `sortScores(scoreArray)`
94
+
95
+ * 公式準拠のルールでスコアをソートして返します。
96
+ * 引数: `calculateScore`や`mergeScores`の戻り値として得られる配列
97
+ * ソート順:
98
+
99
+ 1. 累計ポイント降順
100
+ 2. Victory Royale 回数降順
101
+ 3. 平均撃破数降順
102
+ 4. 平均順位昇順
103
+ 5. 合計生存時間降順
104
+ 6. 最初のパーティ番号昇順
105
+
106
+ ### `mergeScores(scoreArrays)`
107
+
108
+ * 複数マッチ分のスコア配列をパーティ単位でマージします。
109
+ * 引数: ソート済みスコア配列の配列(例: `[sorted1, sorted2, ...]`)
110
+ * 戻り値: マージ後のスコア配列
111
+ * `mergeScores` を使用する際は、各スコアデータに `matchName` プロパティを含めてください。これがないと、一部の処理で正しく動作しない可能性があります。
112
+
113
+ ```javascript
114
+ function loadScores(matchNames) {
115
+ return matchNames.map(name => {
116
+ const raw = fs.readFileSync(
117
+ path.join(outputDir, name, `${name}.json`),
118
+ 'utf8'
119
+ );
120
+ const arr = JSON.parse(raw);
121
+ return arr.map(p => ({ ...p, matchName: name })); // 各マッチデータに対してマッチ名を追加
122
+ });
123
+ }
124
+
125
+ (async () => {
126
+ const scores = loadScores(['match4','match5']);
127
+ let merged = mergeScores(scores);
128
+ merged = sortScores(merged);
129
+ })();
130
+ ```
131
+
132
+ ## 注意事項
133
+
134
+ * ディレクトリ指定時は最初に見つけた `.replay` を処理します。
135
+ * 直接ファイルを指定した場合はそのファイルを処理し、`.replay` が存在しない場合でも最初に見つけたものを使用します。
136
+ * 本ツールの利用により発生した問題について、開発者は一切の責任を負いません。
137
+ * フォークする場合は、GitHub の「Fork」機能を利用してください(clone → 新規リポジトリ作成は非推奨です)。
138
+
139
+ ## 🔗 使用ライブラリ
140
+
141
+ このプロジェクトは以下のオープンソースライブラリを使用しています:
142
+
143
+ - [FortniteReplayDecompressor](https://github.com/Shiqan/FortniteReplayDecompressor)
144
+ © Shiqan — 本プロジェクトは MIT ライセンスのもとで利用しています。
package/README.md CHANGED
@@ -1,112 +1,137 @@
1
+ ## 🌐 Language
2
+
3
+ - [English](./README.md)
4
+ - [日本語](./README.ja.md)
5
+
1
6
  # Fortnite Replay Analysis
2
7
 
3
- FortniteのリプレイファイルをNode.jsで解析し、プレイヤーデータを取得・集計・ソートできるモジュールです。
8
+ Fortnite Replay Analysis is a Node.js module for reading Fortnite replay files, extracting player data, and ranking results.
4
9
 
5
- ## 特徴
10
+ ## Features
6
11
 
7
- * OS判定でビルド済みの自己完結バイナリを呼び出し、高速に解析できます。
8
- * botプレイヤーの除外や順位ソートのオプションに対応しています。
9
- * 複数マッチのスコアをパーティ単位でマージして集計できます。
10
- * 公式準拠のルールでスコアをソートできます。
12
+ * Detects the operating system and invokes a prebuilt, self-contained binary for fast parsing.
13
+ * Supports excluding bot players and optional placement sorting.
14
+ * Merges scores across multiple matches by party.
15
+ * Sorts scores following the official Fortnite scoring rules.
11
16
 
12
- ## インストール
17
+ ## Installation
13
18
 
14
19
  ```bash
15
20
  npm install fortnite-replay-analysis@latest
16
21
  ```
17
22
 
18
- ## 使い方
19
-
20
- 以下は、1試合のリプレイ解析からスコア計算、複数マッチのマージまでを実行する例です。
23
+ ## Usage
21
24
 
22
25
  ```js
23
- const {
24
- ReplayAnalysis,
25
- calculateScore,
26
- sortScores,
27
- mergeScores
28
- } = require('fortnite-replay-analysis');
29
-
30
- (async () => {
31
- // リプレイ解析(ディレクトリ指定時は最初に見つけた .replay を処理、ファイル指定時はそのファイルを使用)
32
26
  const {
33
- rawReplayData,
34
- rawPlayerData,
35
- processedPlayerInfo
36
- } = await ReplayAnalysis(
37
- './path/to/replayDirOrFile',
38
- { bot: false, sort: true }
39
- );
40
-
41
- console.log('Raw Data:', rawPlayerData);
42
- console.log('Processed Player Info:', processedPlayerInfo);
43
-
44
- // 公式ルールでソート
45
- const sortedScores = sortScores(processedPlayerInfo);
46
-
47
- // ポイント&キル計算
48
- const score = await calculateScore({
49
- matchData: processedPlayerInfo,
50
- points: { 1: 11, 2: 6, 3: 5, 4: 4, 5: 3, 6: 2 },
51
- killCountUpperLimit: 10, // 省略可能、デフォルト null(無制限)
52
- killPointMultiplier: 1 // 1撃破あたりの倍率(1の場合1撃破1pt, 2の場合1撃破2ポイント)、省略可能、デフォルト 1
53
- });
54
-
55
- console.log('Score:', score);
56
-
57
- // 複数マッチのマージと再ソート
58
- const merged = mergeScores([ sortedScores, sortedScores2 ]);
59
- const finalSorted = sortScores(merged);
60
-
61
- console.log('Merged & Sorted:', finalSorted);
62
- })();
27
+ ReplayAnalysis,
28
+ calculateScore,
29
+ sortScores,
30
+ mergeScores
31
+ } = require('fortnite-replay-analysis');
32
+
33
+ (async () => {
34
+ // Parse a single match (directory: first .replay file; file: specific .replay)
35
+ const {
36
+ rawReplayData,
37
+ rawPlayerData,
38
+ processedPlayerInfo
39
+ } = await ReplayAnalysis(
40
+ './path/to/replayDirOrFile',
41
+ { bot: false, sort: true }
42
+ );
43
+
44
+ console.log('Raw Data:', rawPlayerData);
45
+ console.log('Processed Player Info:', processedPlayerInfo);
46
+
47
+ // Sort by official rules
48
+ const sortedScores = sortScores(processedPlayerInfo);
49
+
50
+ // Calculate points & kills
51
+ const score = await calculateScore({
52
+ matchData: processedPlayerInfo,
53
+ points: { 1: 11, 2: 6, 3: 5, 4: 4, 5: 3, 6: 2 },
54
+ killCountUpperLimit: 10, // optional, default null (no limit)
55
+ killPointMultiplier: 1 // points per kill multiplier, optional, default 1
56
+ });
57
+
58
+ console.log('Score:', score);
59
+
60
+ // Merge and re-sort multiple matches
61
+ const merged = mergeScores([sortedScores, sortedScores2]);
62
+ const finalSorted = sortScores(merged);
63
+
64
+ console.log('Merged & Sorted:', finalSorted);
65
+ })();
63
66
  ```
64
67
 
65
68
  ## API
66
69
 
67
70
  ### `ReplayAnalysis(inputPath, options)`
68
71
 
69
- * `inputPath`: .replayファイルがあるディレクトリまたはファイルのパス
70
- * `options`(省略可):
72
+ * `inputPath`: Path to a directory or a `.replay` file.
73
+ * `options` (optional):
71
74
 
72
- * `bot`(boolean): botプレイヤーを含めるか(デフォルト: `false`)
73
- * `sort`(boolean): 順位でソートするか(デフォルト: `true`)
74
- * 戻り値: Promise<{
75
- rawReplayData: Object,
76
- rawPlayerData: Array,
77
- processedPlayerInfo: Array
78
- }>
75
+ * `bot` (boolean): Include bot players (default: `false`).
76
+ * `sort` (boolean): Sort by placement (default: `true`).
77
+ * Returns: `Promise<{ rawReplayData: Object, rawPlayerData: Array, processedPlayerInfo: Array }>`
79
78
 
80
79
  ### `calculateScore({ matchData, points, killCountUpperLimit, killPointMultiplier })`
81
80
 
82
- * `matchData`: `ReplayAnalysis`の`processedPlayerInfo`配列、またはそのJSONファイルへのパス
83
- * `points`: 順位ごとのポイント設定オブジェクト(例: `{1:11,2:6,...}`)
84
- * `killCountUpperLimit`: キル数の上限(省略可能、デフォルト: `null` で無制限)
85
- * `killPointMultiplier`: 1撃破あたりの倍率(1の場合1撃破1pt, 2の場合1撃破2ポイント)、省略可能、デフォルト: `1`
86
- * 戻り値: Promise(パーティごとの集計結果)
81
+ * `matchData`: The `processedPlayerInfo` array from `ReplayAnalysis`, or a path to its JSON file.
82
+ * `points`: Object mapping placement to points (e.g., `{1:11,2:6,...}`).
83
+ * `killCountUpperLimit`: Upper limit for kills (optional, default `null` for unlimited).
84
+ * `killPointMultiplier`: Points multiplier per kill (optional, default `1`).
85
+ * Returns: `Promise<Array>` of aggregated results per party.
87
86
 
88
87
  ### `sortScores(scoreArray)`
89
88
 
90
- * 公式準拠のルールでスコアをソートして返します。
91
- * 引数: `calculateScore`や`mergeScores`の戻り値として得られる配列
92
- * ソート順:
89
+ Sorts scores according to official Fortnite rules:
93
90
 
94
- 1. 累計ポイント降順
95
- 2. Victory Royale 回数降順
96
- 3. 平均撃破数降順
97
- 4. 平均順位昇順
98
- 5. 合計生存時間降順
99
- 6. 最初のパーティ番号昇順
91
+ 1. Total points (descending)
92
+ 2. Victory Royale count (descending)
93
+ 3. Average kills (descending)
94
+ 4. Average placement (ascending)
95
+ 5. Total survival time (descending)
96
+ 6. First party number (ascending)
100
97
 
101
98
  ### `mergeScores(scoreArrays)`
102
99
 
103
- * 複数マッチ分のスコア配列をパーティ単位でマージします。
104
- * 引数: ソート済みスコア配列の配列(例: `[sorted1, sorted2, ...]`)
105
- * 戻り値: マージ後のスコア配列
100
+ * Merges multiple sorted score arrays by party.
101
+ * `scoreArrays`: Array of sorted score arrays (e.g., `[sorted1, sorted2, ...]`).
102
+ * Returns: Merged score array.
103
+ * ※When using `mergeScores`, ensure each entry includes a `matchName` property. Omitting this field may lead to unexpected behavior.
104
+
105
+ ```javascript
106
+ function loadScores(matchNames) {
107
+ return matchNames.map(name => {
108
+ const raw = fs.readFileSync(
109
+ path.join(outputDir, name, `${name}.json`),
110
+ 'utf8'
111
+ );
112
+ const arr = JSON.parse(raw);
113
+ return arr.map(p => ({ ...p, matchName: name })); // 各マッチデータに対してマッチ名を追加
114
+ });
115
+ }
116
+
117
+ (async () => {
118
+ const scores = loadScores(['match1','match2']);
119
+ let merged = mergeScores(scores);
120
+ merged = sortScores(merged);
121
+ })();
122
+ ```
123
+
124
+ ## Notes
125
+
126
+ * When a directory is provided, the first `.replay` file found will be processed.
127
+ * When a file is specified, that file will be processed; if no `.replay` is found, the first one in the directory is used.
128
+ * This software is provided without any warranty. Use it at your own risk.
129
+ * When forking this repository, please use GitHub’s "Fork" feature to retain commit history.
130
+ * I’m not very good at English, so the translation might be incorrect.
131
+
132
+ ## 🔗 Acknowledgements
106
133
 
107
- ## 注意事項
134
+ This project uses the following open-source library:
108
135
 
109
- * ディレクトリ指定時は最初に見つけた `.replay` を処理します。
110
- * 直接ファイルを指定した場合はそのファイルを処理し、`.replay` が存在しない場合でも最初に見つけたものを使用します。
111
- * 問題が発生しても責任は負いかねます。
112
- * フォークする場合はGitHubのFork機能を利用し、履歴を追いやすくしてください。
136
+ - [FortniteReplayDecompressor](https://github.com/Shiqan/FortniteReplayDecompressor)
137
+ © Shiqan — Licensed under the MIT License.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fortnite-replay-analysis",
3
- "version": "1.1.0",
4
- "description": "Fortniteのリプレイ解析をNode.jsから呼べる自己完結型C#バイナリラッパー",
3
+ "version": "1.1.2",
4
+ "description": "Fortnite replay analysis tool (Node.js用Fortniteリプレイ解析バイナリラッパー)",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/yuyutti/Fortnite_Replay_Analysis"
@@ -16,13 +16,25 @@
16
16
  "analysis",
17
17
  "decimal",
18
18
  "csharp",
19
- "nodejs"
19
+ "nodejs",
20
+ "C#",
21
+ "fortnite-replay",
22
+ "fortnite解析",
23
+ "リプレイ解析",
24
+ "自動スコア計算",
25
+ "tournament",
26
+ "game-analysis",
27
+ "epicgames",
28
+ "fortnite-scoring",
29
+ "match-result",
30
+ "yuyutti"
20
31
  ],
21
32
  "author": "yuyutti",
22
33
  "license": "MIT",
23
34
  "files": [
24
35
  "index.js",
25
36
  "README.md",
37
+ "README.ja.md",
26
38
  "CSproj/bin/Release/net8.0/"
27
39
  ],
28
40
  "dependencies": {