delta-force-core 0.1.3 → 0.2.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.
package/README.md ADDED
@@ -0,0 +1,797 @@
1
+ <div align="center">
2
+
3
+ <img src="./assets/logo.svg" alt="delta-force-core logo" width="200" />
4
+
5
+ # delta-force-core
6
+
7
+ **三角洲行动核心数据与抽签工具库**
8
+
9
+ [![npm version](https://img.shields.io/npm/v/delta-force-core?color=blue&logo=npm&logoColor=white)](https://www.npmjs.com/package/delta-force-core)
10
+ [![npm downloads](https://img.shields.io/npm/dm/delta-force-core?color=brightgreen)](https://www.npmjs.com/package/delta-force-core)
11
+ [![npm bundle size](https://img.shields.io/bundlephobia/minzip/delta-force-core?label=minzip)](https://bundlephobia.com/package/delta-force-core)
12
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
13
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178c6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
14
+ [![Node.js](https://img.shields.io/badge/Node.js-%E2%89%A518-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
15
+ [![GitHub Stars](https://img.shields.io/github/stars/Zhoyi011/delta-force-core?style=social)](https://github.com/Zhoyi011/delta-force-core/stargazers)
16
+ [![GitHub Issues](https://img.shields.io/github/issues/Zhoyi011/delta-force-core)](https://github.com/Zhoyi011/delta-force-core/issues)
17
+ [![GitHub Last Commit](https://img.shields.io/github/last-commit/Zhoyi011/delta-force-core)](https://github.com/Zhoyi011/delta-force-core/commits/main)
18
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](./CONTRIBUTING.md)
19
+
20
+ [简体中文](./README.md) · [English](./README.en.md) (coming soon)
21
+
22
+ </div>
23
+
24
+ ---
25
+
26
+ > ## 📢 项目状态
27
+ >
28
+ > **v0.2.x** — 稳定版本,覆盖 **干员 / 武器 / 装备 / 子弹** 四大模块。
29
+ >
30
+ > **路线图**:配件系统、子弹细分(1~6 弹)、图片资源、多语言支持。
31
+
32
+ ---
33
+
34
+ ## 📖 目录
35
+
36
+ - [✨ 特性](#-特性)
37
+ - [🎯 使用场景](#-使用场景)
38
+ - [🧠 设计理念](#-设计理念)
39
+ - [📦 安装](#-安装)
40
+ - [🚀 快速开始](#-快速开始)
41
+ - [🧩 核心概念](#-核心概念)
42
+ - [📘 API 参考](#-api-参考)
43
+ - [引擎(Engine)](#引擎engine)
44
+ - [抽签函数](#抽签函数)
45
+ - [查询函数](#查询函数)
46
+ - [列表函数](#列表函数)
47
+ - [用户覆盖层](#用户覆盖层)
48
+ - [📚 数据模块](#-数据模块)
49
+ - [干员(Operators)](#干员operators)
50
+ - [武器(Weapons)](#武器weapons)
51
+ - [装备(Equipment)](#装备equipment)
52
+ - [子弹(Ammo)](#子弹ammo)
53
+ - [📄 index.json](#-indexjson)
54
+ - [🌐 生态与集成](#-生态与集成)
55
+ - [🤝 贡献指南](#-贡献指南)
56
+ - [🛠 开发](#-开发)
57
+ - [📅 路线图](#-路线图)
58
+ - [❓ FAQ](#-faq)
59
+ - [📜 License](#-license)
60
+ - [❤️ 致谢](#️-致谢)
61
+
62
+ ---
63
+
64
+ ## ✨ 特性
65
+
66
+ <table>
67
+ <tr>
68
+ <td align="center" width="25%">
69
+ <h3>📚 完整数据</h3>
70
+ <p>干员 / 武器 / 装备 / 子弹<br/>四大模块官方字段全覆盖</p>
71
+ </td>
72
+ <td align="center" width="25%">
73
+ <h3>🎲 抽签工具</h3>
74
+ <p>随机抽干员、武器、装备<br/>一键生成完整配装</p>
75
+ </td>
76
+ <td align="center" width="25%">
77
+ <h3>🔍 查询工具</h3>
78
+ <p>按 id / 口径 / 别名查询<br/>类型安全,IDE 智能提示</p>
79
+ </td>
80
+ <td align="center" width="25%">
81
+ <h3>🎨 用户覆盖层</h3>
82
+ <p>品质 / 别名 / 标签<br/>运行时注入,不污染官方数据</p>
83
+ </td>
84
+ </tr>
85
+ </table>
86
+
87
+ - ✅ **TypeScript 原生** —— 完整类型定义,IDE 智能提示
88
+ - ✅ **ES Module** —— 现代模块规范,Tree-shaking 友好
89
+ - ✅ **零依赖** —— 核心库不依赖任何第三方包
90
+ - ✅ **向前兼容** —— 所有可选字段 `?:`,新版本不破坏老用户
91
+ - ✅ **Node + 浏览器** —— 同时支持 Node.js ≥ 18 和现代浏览器
92
+
93
+ ---
94
+
95
+ ## 🎯 使用场景
96
+
97
+ <table>
98
+ <tr>
99
+ <th width="20%">场景</th>
100
+ <th>示例</th>
101
+ </tr>
102
+ <tr>
103
+ <td>🎮 <b>抽卡应用</b></td>
104
+ <td>一键生成随机配装,可注入自定义品质评估</td>
105
+ </tr>
106
+ <tr>
107
+ <td>📚 <b>Wiki / 资料站</b></td>
108
+ <td>直接消费结构化数据,渲染装备/武器列表</td>
109
+ </tr>
110
+ <tr>
111
+ <td>🤖 <b>Discord / QQ 机器人</b></td>
112
+ <td><code>getRandomLoadout()</code> 开箱即用</td>
113
+ </tr>
114
+ <tr>
115
+ <td>🧪 <b>游戏数据研究</b></td>
116
+ <td>按口径、等级、模式自由筛选,做统计分析</td>
117
+ </tr>
118
+ <tr>
119
+ <td>🌐 <b>静态网站 / CDN</b></td>
120
+ <td>通过 <code>index.json</code> 直接 fetch,无需构建</td>
121
+ </tr>
122
+ </table>
123
+
124
+ ---
125
+
126
+ ## 🧠 设计理念
127
+
128
+ ### 1. 数据与逻辑分离
129
+
130
+ **官方数据是只读的**,由库维护者持续更新;**用户偏好是运行时注入的**,不污染官方数据。
131
+
132
+ <div align="center">
133
+ ┌──────────────────────────────────────┐
134
+ │ 官方数据(硬编码、只读) │
135
+ │ OPERATORS / WEAPONS / │
136
+ │ EQUIPMENT / AMMO │
137
+ └──────────────────┬───────────────────┘
138
+ │
139
+ ▼
140
+ ┌──────────────────────────────────────┐
141
+ │ 用户覆盖层(可选、运行时) │
142
+ │ qualityOverride / aliasOverride / │
143
+ │ tagOverride │
144
+ └──────────────────┬───────────────────┘
145
+ │
146
+ ▼
147
+ ┌──────────────────────────────────────┐
148
+ │ 引擎(Engine) │
149
+ │ · 抽签 · 查询 │
150
+ └──────────────────────────────────────┘
151
+
152
+ text
153
+
154
+ </div>
155
+
156
+ ### 2. 为什么 quality 不在官方数据里?
157
+
158
+ 三角洲行动里的武器品质(绿色 / 蓝色 / 紫色 / 金色)**不是官方明示的数据**,而是玩家根据实战强度的**主观评估**。因此:
159
+
160
+ - 官方 `Weapon` 类型**不含 `quality` 字段**
161
+ - 用户通过 `createEngine({ qualityOverride })` 注入自己的评估
162
+ - 默认引擎(无覆盖)**按品质抽签会返回空**
163
+
164
+ 这是**刻意的设计**,避免把某一个人的主观判断强加给所有用户。
165
+
166
+ ### 3. 向前兼容
167
+
168
+ 所有可选字段一律 `?:`。以后加新字段(如 `caliber`、`image`、`slots`)不影响老用户。
169
+
170
+ ---
171
+
172
+ ## 📦 安装
173
+
174
+ <details open>
175
+ <summary><b>npm / yarn / pnpm</b></summary>
176
+
177
+ ```bash
178
+ # npm
179
+ npm install delta-force-core
180
+
181
+ # yarn
182
+ yarn add delta-force-core
183
+
184
+ # pnpm
185
+ pnpm add delta-force-core
186
+
187
+ # bun
188
+ bun add delta-force-core
189
+ </details><details> <summary><b>CDN(浏览器直接使用)</b></summary>
190
+ html
191
+ <!-- ES Module -->
192
+ <script type="module">
193
+ import { getRandomLoadout } from 'https://esm.sh/delta-force-core';
194
+ console.log(getRandomLoadout());
195
+ </script>
196
+
197
+ <!-- 或直接拿 JSON 数据 -->
198
+ <script type="module">
199
+ const res = await fetch('https://unpkg.com/delta-force-core/index.json');
200
+ const data = await res.json();
201
+ console.log(data.weapons);
202
+ </script>
203
+ </details>
204
+ 环境要求:Node.js ≥ 18 或任何支持 ES Module 的现代浏览器。
205
+
206
+ 🚀 快速开始
207
+ 场景 1 · 我只是想查数据(Wiki 用户)
208
+ ts
209
+ import { WEAPONS, OPERATORS, EQUIPMENT, AMMO } from 'delta-force-core';
210
+
211
+ console.log(WEAPONS); // 全部武器
212
+ console.log(OPERATORS); // 全部干员
213
+ console.log(EQUIPMENT.armors); // 全部护甲
214
+ console.log(AMMO); // 全部子弹
215
+ 场景 2 · 我想抽签(抽卡应用)
216
+ ts
217
+ import { getRandomWeapon, getRandomLoadout } from 'delta-force-core';
218
+
219
+ console.log(getRandomWeapon()); // 随机一把武器
220
+ console.log(getRandomLoadout()); // 随机一套完整配装
221
+ console.log(getRandomLoadout({ allowNormal: true })); // 只用普通模式
222
+ 场景 3 · 我有自己的品质评估
223
+ ts
224
+ import { createEngine } from 'delta-force-core';
225
+
226
+ const engine = createEngine({
227
+ qualityOverride: {
228
+ m4a1: '金色',
229
+ akm: '紫色',
230
+ k416: '金色',
231
+ },
232
+ });
233
+
234
+ console.log(engine.getRandomWeapon({ quality: '金色' }));
235
+ console.log(engine.getWeaponQuality('m4a1')); // '金色'
236
+ 场景 4 · 我在纯 JS / JSON 环境
237
+ js
238
+ import data from 'delta-force-core/index.json' with { type: 'json' };
239
+
240
+ console.log(data.weapons);
241
+ console.log(data.equipment.helmets);
242
+ 🧩 核心概念
243
+ 引擎(Engine)
244
+ Engine 是访问所有抽签和查询能力的统一入口。它由三层组成:
245
+
246
+ 官方数据(固定) + 用户覆盖层(可选) = 引擎
247
+
248
+ 默认引擎:defaultEngine,官方数据 + 空覆盖层,自动在入口注册
249
+
250
+ 自定义引擎:通过 createEngine(options) 创建,注入你的覆盖层
251
+
252
+ 覆盖层(Override)
253
+ 覆盖类型 用途 影响
254
+ qualityOverride 武器品质评估 影响 getRandomWeapon({ quality })
255
+ aliasOverride 别名(如 M4 → m4a1) 影响 findWeaponByAlias()
256
+ tagOverride 个人标签 纯元数据,不影响抽签
257
+ 普通模式(allowNormal)
258
+ 值 行为
259
+ true 只在普通模式可用的物品中抽
260
+ false 只在禁止普通模式的物品中抽(如 AWM / M82)
261
+ undefined 不筛选,全部进池
262
+ 📘 API 参考
263
+ 💡 提示:所有以 defaultEngine 形式导出的函数,等价于先 createEngine() 再调用。想自定义行为用 createEngine。
264
+
265
+ 引擎(Engine)
266
+ createEngine(options?: EngineOptions): Engine
267
+ 创建一个引擎实例。
268
+
269
+ ts
270
+ import { createEngine } from 'delta-force-core';
271
+
272
+ const engine = createEngine({
273
+ qualityOverride: { m4a1: '金色' },
274
+ aliasOverride: { m4a1: ['M4', 'M4卡宾枪'] },
275
+ tagOverride: { m4a1: ['经典', '入门'] },
276
+ });
277
+ <details> <summary><b>查看 EngineOptions 类型</b></summary>
278
+ ts
279
+ interface EngineOptions {
280
+ /** 武器品质评估:weaponId → '绿色' | '蓝色' | '紫色' | '金色' */
281
+ qualityOverride?: Record<string, WeaponQuality>;
282
+ /** 别名:entityId → string[] */
283
+ aliasOverride?: Record<string, string[]>;
284
+ /** 个人标签:entityId → string[] */
285
+ tagOverride?: Record<string, string[]>;
286
+ }
287
+ </details>
288
+ defaultEngine
289
+ 默认引擎,已自动注册官方数据 + 空覆盖层。
290
+
291
+ ts
292
+ import { defaultEngine } from 'delta-force-core';
293
+
294
+ defaultEngine.getRandomWeapon();
295
+ 所有抽签/查询函数都以默认引擎的形式直接导出:
296
+
297
+ ts
298
+ import { getRandomWeapon } from 'delta-force-core';
299
+ // 等价于
300
+ import { defaultEngine } from 'delta-force-core';
301
+ defaultEngine.getRandomWeapon();
302
+ 抽签函数
303
+ 所有抽签函数使用 Math.random(),均匀分布。空池会抛错。
304
+
305
+ getRandomOperator(category?: string): Operator
306
+ 随机抽取一名干员。
307
+
308
+ 参数 类型 说明
309
+ category string? 兵种分类(突击兵 / 支援兵 / 工程兵 / 侦察兵),不传则从全部干员中抽
310
+ ts
311
+ getRandomOperator(); // 任意干员
312
+ getRandomOperator('突击兵'); // 只从突击兵里抽
313
+ getRandomWeapon(options?: WeaponOptions): Weapon
314
+ 随机抽取一把武器。
315
+
316
+ 选项 类型 说明
317
+ category string? 武器大类
318
+ quality WeaponQuality? 品质,需要引擎有 qualityOverride 才有意义
319
+ allowNormal boolean? 普通模式筛选
320
+ ts
321
+ getRandomWeapon();
322
+ getRandomWeapon({ category: '突击步枪' });
323
+ getRandomWeapon({ allowNormal: true });
324
+ getRandomWeapon({ category: '狙击步枪', allowNormal: false });
325
+ engine.getRandomWeapon({ quality: '金色' });
326
+ getRandomAmmo(options?: AmmoOptions): Ammo
327
+ 随机抽取一种子弹。
328
+
329
+ 选项 类型 说明
330
+ caliber string? 口径筛选,如 5.56x45mm
331
+ ts
332
+ getRandomAmmo();
333
+ getRandomAmmo({ caliber: '5.56x45mm' });
334
+ getRandomArmor / getRandomHelmet / getRandomBackpack / getRandomChestRig
335
+ ts
336
+ getRandomArmor(options?: TierOptions): EquipmentItem
337
+ getRandomHelmet(options?: TierOptions): EquipmentItem
338
+ getRandomBackpack(options?: TierOptions): EquipmentItem
339
+ getRandomChestRig(options?: TierOptions): EquipmentItem
340
+ 选项 类型 说明
341
+ tier number? 指定等级(1~6),不传则全等级
342
+ allowNormal boolean? 普通模式筛选(护甲/头盔支持)
343
+ ts
344
+ getRandomArmor();
345
+ getRandomArmor({ tier: 5 });
346
+ getRandomHelmet({ allowNormal: true });
347
+ getRandomBackpack({ tier: 6 });
348
+ getRandomLoadout(options?: LoadoutOptions): Loadout
349
+ 随机生成一套完整配装。
350
+
351
+ ts
352
+ const loadout = getRandomLoadout({ allowNormal: true });
353
+
354
+ // 返回:
355
+ // {
356
+ // operator: {...}, // 干员
357
+ // weapon: {...}, // 武器
358
+ // armor: {...}, // 护甲
359
+ // helmet: {...}, // 头盔
360
+ // backpack: {...}, // 背包
361
+ // chestRig: {...} // 胸挂
362
+ // }
363
+ 查询函数
364
+ 函数 说明
365
+ findOperatorById(id) 按 id 查干员
366
+ findWeaponById(id) 按 id 查武器
367
+ findAmmoById(id) 按 id 查子弹
368
+ findArmorById(id) 按 id 查护甲
369
+ findHelmetById(id) 按 id 查头盔
370
+ findBackpackById(id) 按 id 查背包
371
+ findChestRigById(id) 按 id 查胸挂
372
+ findWeaponsByCaliber(caliber) 按口径查武器
373
+ findAmmoByCaliber(caliber) 按口径查子弹
374
+ findWeaponByAlias(alias) 按别名查武器(需 aliasOverride)
375
+ ts
376
+ findWeaponById('m4a1');
377
+ // { id: 'm4a1', name: 'M4A1突击步枪', allowNormal: true }
378
+
379
+ findHelmetById('helmet_l4_gt1');
380
+ findWeaponsByCaliber('5.56x45mm');
381
+ 列表函数
382
+ ts
383
+ listOperatorCategories();
384
+ // ['突击兵', '支援兵', '工程兵', '侦察兵']
385
+
386
+ listWeaponCategories();
387
+ // ['突击步枪', '冲锋枪', '精确射手步枪', '狙击步枪', '轻机枪', '霰弹枪', '手枪', '特殊武器']
388
+
389
+ listAllOperators(); // 全部干员,拉平成一维数组
390
+ listAllWeapons(); // 全部武器,拉平成一维数组
391
+ 用户覆盖层
392
+ ts
393
+ const engine = createEngine({
394
+ qualityOverride: { m4a1: '金色' },
395
+ aliasOverride: { m4a1: ['M4', 'M4卡宾枪'] },
396
+ tagOverride: { m4a1: ['经典', '入门'] },
397
+ });
398
+
399
+ engine.getWeaponQuality('m4a1'); // '金色'
400
+ engine.getAliases('m4a1'); // ['M4', 'M4卡宾枪']
401
+ engine.getTags('m4a1'); // ['经典', '入门']
402
+ 📚 数据模块
403
+ 干员(Operators)
404
+ 结构
405
+
406
+ ts
407
+ interface Operator {
408
+ id: string;
409
+ name: string;
410
+ features?: string;
411
+ description?: string;
412
+ image?: string;
413
+ }
414
+
415
+ interface OperatorCategory {
416
+ category: string;
417
+ operators: Operator[];
418
+ }
419
+ 导出
420
+
421
+ ts
422
+ import { OPERATORS } from 'delta-force-core';
423
+ 分类:突击兵 / 支援兵 / 工程兵 / 侦察兵
424
+
425
+ 当前条目:
426
+
427
+ 分类 干员
428
+ 突击兵 红狼 / 威龙 / 疾风 / 无名
429
+ 支援兵 蜂医 / 蛊 / 蝶 / 旅人
430
+ 工程兵 牧羊人 / 乌鲁鲁 / 深蓝 / 液氮 / 比特
431
+ 侦察兵 露娜 / 骇爪 / 回响 / 银翼
432
+ 武器(Weapons)
433
+ 结构
434
+
435
+ ts
436
+ interface Weapon {
437
+ id: string;
438
+ name: string;
439
+ caliber?: string; // 口径
440
+ baseDamage?: number; // 裸枪基础伤害
441
+ description?: string;
442
+ image?: string;
443
+ allowNormal?: boolean; // 缺省视为 true
444
+ }
445
+ ⚠️ 注意:官方 Weapon 不含 quality。品质由用户注入。
446
+
447
+ 导出
448
+
449
+ ts
450
+ import { WEAPONS } from 'delta-force-core';
451
+ 分类与数量:
452
+
453
+ 分类 数量
454
+ 突击步枪 24
455
+ 冲锋枪 12
456
+ 精确射手步枪 10
457
+ 狙击步枪 5
458
+ 轻机枪 4
459
+ 霰弹枪 5
460
+ 手枪 7
461
+ 特殊武器 1
462
+ 合计 68
463
+ 装备(Equipment)
464
+ 结构
465
+
466
+ ts
467
+ interface EquipmentItem {
468
+ id: string;
469
+ name: string;
470
+ features?: string;
471
+ comment?: string;
472
+ description?: string;
473
+ image?: string;
474
+ }
475
+
476
+ interface EquipmentTier {
477
+ tier: number;
478
+ allowNormal?: boolean;
479
+ items: EquipmentItem[];
480
+ }
481
+
482
+ interface Equipment {
483
+ armors: EquipmentTier[];
484
+ helmets: EquipmentTier[];
485
+ backpacks: EquipmentTier[];
486
+ chest_rigs: EquipmentTier[];
487
+ }
488
+ 导出
489
+
490
+ ts
491
+ import { EQUIPMENT } from 'delta-force-core';
492
+
493
+ EQUIPMENT.armors; // 护甲,1~6 级
494
+ EQUIPMENT.helmets; // 头盔,1~6 级
495
+ EQUIPMENT.backpacks; // 背包,1~6 级
496
+ EQUIPMENT.chest_rigs; // 胸挂,1~5 级
497
+ 子弹(Ammo)
498
+ 结构
499
+
500
+ ts
501
+ interface Ammo {
502
+ id: string;
503
+ name: string;
504
+ caliber: string;
505
+ description?: string;
506
+ image?: string;
507
+ }
508
+ ⚠️ 当前粒度:只到"口径",同口径的 1~6 弹(如 M855 / M995)后续再加。
509
+
510
+ 导出
511
+
512
+ ts
513
+ import { AMMO } from 'delta-force-core';
514
+ 当前口径(19 种):
515
+
516
+ 手枪/霰弹 中间威力 全威力 其它
517
+ .357 Magnum 5.45x39mm 7.62x51mm 4.6x30mm
518
+ .45 ACP 5.56x45mm 7.62x54mm .300 Blackout
519
+ .58 AE 5.7x28mm 12.7x55mm 箭矢
520
+ 12 Gauge 5.8x42mm 45-70 Govt
521
+ 9x19mm 6.8x51mm
522
+ 9x39mm 7.62x39mm
523
+ 📄 index.json
524
+ 库在每次构建时生成一份 index.json,包含当前官方数据的完整快照:
525
+
526
+ json
527
+ {
528
+ "$schema": "https://raw.githubusercontent.com/delta-force-core/schema/main/v1.json",
529
+ "version": "0.2.0",
530
+ "generatedAt": "2026-10-14T00:34:01.102Z",
531
+ "operators": [...],
532
+ "weapons": [...],
533
+ "equipment": {...},
534
+ "ammo": [...]
535
+ }
536
+ 用途:
537
+
538
+ 🐍 非 JS 环境(如 Python 脚本)直接消费
539
+
540
+ 🌐 CDN 直接 fetch(https://unpkg.com/delta-force-core/index.json)
541
+
542
+ 📊 数据 diff 检查
543
+
544
+ js
545
+ // ESM
546
+ import data from 'delta-force-core/index.json' with { type: 'json' };
547
+
548
+ // CommonJS
549
+ const data = require('delta-force-core/index.json');
550
+
551
+ // HTTP
552
+ const res = await fetch('https://unpkg.com/delta-force-core/index.json');
553
+ const data = await res.json();
554
+ 🌐 生态与集成
555
+ 平台 用法
556
+ Node.js npm install delta-force-core
557
+ 浏览器 https://esm.sh/delta-force-core
558
+ Deno import ... from 'npm:delta-force-core'
559
+ Bun bun add delta-force-core
560
+ Python 读 index.json
561
+ Discord.js 见下方示例
562
+ Discord.js 示例
563
+ ts
564
+ import { Client, GatewayIntentBits, Events } from 'discord.js';
565
+ import { getRandomLoadout } from 'delta-force-core';
566
+
567
+ const client = new Client({ intents: [GatewayIntentBits.Guilds] });
568
+
569
+ client.on(Events.InteractionCreate, async (interaction) => {
570
+ if (!interaction.isChatInputCommand()) return;
571
+ if (interaction.commandName !== 'random-loadout') return;
572
+
573
+ const l = getRandomLoadout({ allowNormal: true });
574
+ await interaction.reply({
575
+ content: [
576
+ `🧑 **干员**:${l.operator.name}`,
577
+ `🔫 **武器**:${l.weapon.name}`,
578
+ `🛡 **护甲**:${l.armor.name}`,
579
+ `⛑ **头盔**:${l.helmet.name}`,
580
+ `🎒 **背包**:${l.backpack.name}`,
581
+ `🎽 **胸挂**:${l.chestRig.name}`,
582
+ ].join('\n'),
583
+ });
584
+ });
585
+ 🤝 贡献指南
586
+ 更新干员 / 武器 / 装备 / 子弹
587
+ 只需要修改对应的数据文件:
588
+
589
+ text
590
+ src/data/
591
+ ├─ operators.ts ← 干员
592
+ ├─ weapons.ts ← 武器
593
+ ├─ equipment.ts ← 装备(护甲/头盔/背包/胸挂)
594
+ └─ ammo.ts ← 子弹
595
+ 例子:新增一把武器
596
+ ts
597
+ // src/data/weapons.ts
598
+ {
599
+ category: '突击步枪',
600
+ weapons: [
601
+ // ...已有的
602
+ { id: 'new_rifle', name: '新突击步枪', allowNormal: true }, // ← 加一行
603
+ ],
604
+ },
605
+ 例子:新增一件头盔
606
+ ts
607
+ // src/data/equipment.ts → EQUIPMENT.helmets
608
+ {
609
+ tier: 4,
610
+ allowNormal: true,
611
+ items: [
612
+ // ...已有的
613
+ { id: 'helmet_l4_new', name: '新头盔', features: '属性描述' }, // ← 加一行
614
+ ],
615
+ },
616
+ 流程
617
+ bash
618
+ # 1. 改数据文件
619
+ vim src/data/weapons.ts
620
+
621
+ # 2. 编译 + 重新生成 index.json
622
+ npm run build
623
+
624
+ # 3. 提交
625
+ git add .
626
+ git commit -m "data: 新增 XXX 武器"
627
+ git push origin main
628
+ 注意事项
629
+ 项 说明
630
+ id 必须全局唯一 用于查询和去重,重复会静默出 bug
631
+ quality 不要加 官方数据不含品质,由用户层覆盖
632
+ allowNormal 缺省 = true 只在需要禁止时写 false
633
+ 可选字段全部用 ?: 保证向前兼容
634
+ 新增分类 直接在数组里追加 { category, weapons: [...] } 块
635
+ 提交规范
636
+ 采用 Conventional Commits:
637
+
638
+ 前缀 用途
639
+ feat: 新功能
640
+ fix: Bug 修复
641
+ data: 数据更新(新增/修正装备、武器等)
642
+ refactor: 重构
643
+ docs: 文档
644
+ chore: 杂项
645
+ test: 测试
646
+ 例子:
647
+
648
+ text
649
+ feat: 新增 getRandomAmmo() 支持按口径抽签
650
+ data: 新增 5 把突击步枪
651
+ fix: 修正 AKM 的 allowNormal 字段
652
+ docs: 更新 README 安装说明
653
+ 🛠 开发
654
+ 环境要求
655
+ Node.js ≥ 18
656
+
657
+ TypeScript ≥ 5.4
658
+
659
+ 安装
660
+ bash
661
+ git clone https://github.com/Zhoyi011/delta-force-core.git
662
+ cd delta-force-core
663
+ npm install
664
+ 目录结构
665
+ text
666
+ delta-force-core/
667
+ ├─ .gitignore
668
+ ├─ package.json
669
+ ├─ tsconfig.json
670
+ ├─ README.md
671
+ ├─ index.json ← 构建产物
672
+ ├─ scripts/
673
+ │ └─ emit-json.mjs ← 生成 index.json
674
+ ├─ src/
675
+ │ ├─ types.ts ← 所有类型定义
676
+ │ ├─ engine.ts ← 引擎(createEngine + 全部方法)
677
+ │ ├─ index.ts ← 主入口
678
+ │ └─ data/
679
+ │ ├─ index.ts ← 数据统一导出
680
+ │ ├─ operators.ts ← 干员数据
681
+ │ ├─ weapons.ts ← 武器数据
682
+ │ ├─ equipment.ts ← 装备数据
683
+ │ └─ ammo.ts ← 子弹数据
684
+ └─ .github/
685
+ └─ workflows/ ← CI / 自动发布
686
+ 常用命令
687
+ bash
688
+ npm run build # 编译 + 生成 index.json
689
+ npm run dev # 开发模式(watch)
690
+ npm run emit-json # 只生成 index.json
691
+ 发布到 npm
692
+ bash
693
+ # 1. 更新版本号
694
+ npm version patch # 或 minor / major
695
+
696
+ # 2. 发布(会自动跑 prepublishOnly → npm run build)
697
+ npm publish
698
+ 📅 路线图
699
+ <table> <tr> <th>状态</th> <th>功能</th> <th>版本</th> </tr> <tr> <td>✅ 已完成</td> <td>干员 / 武器 / 装备 / 子弹</td> <td>v0.1</td> </tr> <tr> <td>✅ 已完成</td> <td>引擎 + 用户覆盖层(quality / alias / tag)</td> <td>v0.2</td> </tr> <tr> <td>🔄 进行中</td> <td>完整 README + 文档</td> <td>v0.2.x</td> </tr> <tr> <td>📋 计划中</td> <td>配件系统(槽位 / 兼容关系)</td> <td>v0.3</td> </tr> <tr> <td>📋 计划中</td> <td>子弹细分(1~6 弹,伤害/穿透)</td> <td>v0.3</td> </tr> <tr> <td>📋 计划中</td> <td>图片资源(干员 / 武器 / 装备)</td> <td>v0.4</td> </tr> <tr> <td>💭 考虑中</td> <td>多语言(English / 日本語)</td> <td>v1.0</td> </tr> </table>
700
+ ❓ FAQ
701
+ <details> <summary><b>Q1: 为什么官方武器里没有 <code>quality</code> 字段?</b></summary>
702
+ 品质是玩家主观评估,不是官方数据。我们把品质放到用户层 qualityOverride 里,让每个使用者用自己的标准。
703
+
704
+ 如果你的项目需要品质,用 createEngine 注入:
705
+
706
+ ts
707
+ const engine = createEngine({
708
+ qualityOverride: { m4a1: '金色' },
709
+ });
710
+ </details><details> <summary><b>Q2: 默认引擎和自定义引擎有什么区别?</b></summary>
711
+ 默认引擎 defaultEngine = 官方数据 + 空覆盖层。
712
+
713
+ 自定义引擎 = 官方数据 + 你的覆盖层。所有查询和抽签方法行为一致,只是自定义引擎会应用你的 quality/alias/tag。
714
+
715
+ </details><details> <summary><b>Q3: 我能不能只拿数据,不用抽签功能?</b></summary>
716
+ 可以。直接 import 数据常量:
717
+
718
+ ts
719
+ import { WEAPONS, OPERATORS, EQUIPMENT, AMMO } from 'delta-force-core';
720
+ 或者用 index.json(适合非 JS 环境)。
721
+
722
+ </details><details> <summary><b>Q4: 数据多久更新一次?</b></summary>
723
+ 跟随游戏版本更新。新装备 / 武器 / 干员上线后,我们会尽快同步。
724
+
725
+ 你也可以提 PR 直接改数据文件。
726
+
727
+ </details><details> <summary><b>Q5: 支持 TypeScript 吗?</b></summary>
728
+ 原生 TypeScript 编写,完整类型定义。IDE 会有智能提示和类型检查。
729
+
730
+ </details><details> <summary><b>Q6: 支持 CommonJS 吗?</b></summary>
731
+ 主入口是 ES Module。如果是 CommonJS 项目:
732
+
733
+ js
734
+ // 方式 1:动态 import
735
+ const { getRandomLoadout } = await import('delta-force-core');
736
+
737
+ // 方式 2:直接用 JSON
738
+ const data = require('delta-force-core/index.json');
739
+ </details><details> <summary><b>Q7: 怎么自己部署一份 <code>index.json</code>?</b></summary>
740
+ bash
741
+ # fork 仓库 → 改数据 → 构建
742
+ npm run build
743
+ # dist/ 里就是最新数据,index.json 在根目录
744
+ 也可以直接用 npm 包自带的:
745
+
746
+ text
747
+ https://unpkg.com/delta-force-core/index.json
748
+ </details><details> <summary><b>Q8: 怎么贡献数据修正?</b></summary>
749
+ Fork 仓库
750
+
751
+ 改 src/data/*.ts
752
+
753
+ npm run build 确认编译通过
754
+
755
+ 提交 PR,附上数据来源(截图 / 官方公告)
756
+
757
+ 详见 贡献指南。
758
+
759
+ </details>
760
+ 📜 License
761
+ 本项目基于 MIT License 发布。
762
+
763
+ text
764
+ MIT License
765
+
766
+ Copyright (c) 2026 Zhoyi011
767
+
768
+ Permission is hereby granted, free of charge, to any person obtaining a copy
769
+ of this software and associated documentation files (the "Software"), to deal
770
+ in the Software without restriction, including without limitation the rights
771
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
772
+ copies of the Software, and to permit persons to whom the Software is
773
+ furnished to do so, subject to the following conditions:
774
+
775
+ The above copyright notice and this permission notice shall be included in all
776
+ copies or substantial portions of the Software.
777
+
778
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
779
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
780
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
781
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
782
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
783
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
784
+ SOFTWARE.
785
+ ❤️ 致谢
786
+ 感谢所有为三角洲行动数据整理做出贡献的玩家社区
787
+
788
+ 感谢 Shields.io 提供徽章服务
789
+
790
+ 感谢 unpkg / esm.sh 提供 CDN
791
+
792
+ <div align="center">
793
+ 如果这个项目对你有帮助,请给一个 ⭐ Star 支持一下!
794
+
795
+ ⬆ 回到顶部
796
+
797
+ </div> ```