@cs2dak/core 0.2.1 → 1.0.0
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/package.json +2 -2
- package/src/economy.test.ts +1 -15
- package/src/economy.ts +0 -19
- package/src/index.test.ts +39 -52
- package/src/index.ts +19 -4
- package/src/normalize.ts +1 -150
- package/src/side-win-rate.test.ts +33 -0
- package/src/side-win-rate.ts +49 -0
- package/src/signals.ts +1 -1
- package/src/weapon-highlights.ts +55 -0
- package/src/weapons.test.ts +0 -32
- package/src/weapons.ts +0 -93
- package/src/workspace.ts +0 -726
package/src/weapons.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { normalizeWeapon } from "./utils.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Single source of truth for weapon display names.
|
|
5
|
-
*
|
|
6
|
-
* Keyed by the *normalized* raw code (lowercase, `weapon_` prefix stripped — see
|
|
7
|
-
* {@link normalizeWeapon}). This consolidates what RivalHub previously kept in
|
|
8
|
-
* three drifting tables (`weapon-names.ts` `WEAPON_LABELS` / `WEAPON_FULL_NAMES`
|
|
9
|
-
* and `DemoKillFeed.WEAPON_DISPLAY`). Consumers — replay tokens, the current-frame
|
|
10
|
-
* panel, and a future kill feed — should all route through {@link displayWeaponName}.
|
|
11
|
-
*/
|
|
12
|
-
const WEAPON_DISPLAY_NAMES: Record<string, string> = {
|
|
13
|
-
// Rifles
|
|
14
|
-
ak47: "AK-47",
|
|
15
|
-
m4a4: "M4A4",
|
|
16
|
-
m4a1: "M4A4",
|
|
17
|
-
m4a1_silencer: "M4A1-S",
|
|
18
|
-
aug: "AUG",
|
|
19
|
-
sg556: "SG 553",
|
|
20
|
-
sg553: "SG 553",
|
|
21
|
-
famas: "FAMAS",
|
|
22
|
-
galilar: "Galil AR",
|
|
23
|
-
galil: "Galil AR",
|
|
24
|
-
// Snipers
|
|
25
|
-
awp: "AWP",
|
|
26
|
-
ssg08: "SSG 08",
|
|
27
|
-
scar20: "SCAR-20",
|
|
28
|
-
g3sg1: "G3SG1",
|
|
29
|
-
// Pistols
|
|
30
|
-
deagle: "Desert Eagle",
|
|
31
|
-
deserteagle: "Desert Eagle",
|
|
32
|
-
revolver: "R8 Revolver",
|
|
33
|
-
glock: "Glock-18",
|
|
34
|
-
usp_silencer: "USP-S",
|
|
35
|
-
usp: "USP-S",
|
|
36
|
-
hkp2000: "P2000",
|
|
37
|
-
p2000: "P2000",
|
|
38
|
-
p250: "P250",
|
|
39
|
-
fiveseven: "Five-SeveN",
|
|
40
|
-
tec9: "Tec-9",
|
|
41
|
-
cz75a: "CZ75-Auto",
|
|
42
|
-
cz75: "CZ75-Auto",
|
|
43
|
-
elite: "Dual Berettas",
|
|
44
|
-
// SMGs
|
|
45
|
-
mp9: "MP9",
|
|
46
|
-
mp7: "MP7",
|
|
47
|
-
mp5sd: "MP5-SD",
|
|
48
|
-
ump45: "UMP-45",
|
|
49
|
-
p90: "P90",
|
|
50
|
-
bizon: "PP-Bizon",
|
|
51
|
-
mac10: "MAC-10",
|
|
52
|
-
// Heavy
|
|
53
|
-
nova: "Nova",
|
|
54
|
-
xm1014: "XM1014",
|
|
55
|
-
mag7: "MAG-7",
|
|
56
|
-
sawedoff: "Sawed-Off",
|
|
57
|
-
m249: "M249",
|
|
58
|
-
negev: "Negev",
|
|
59
|
-
// Equipment / utility
|
|
60
|
-
taser: "Zeus x27",
|
|
61
|
-
zeus: "Zeus x27",
|
|
62
|
-
hegrenade: "HE 手雷",
|
|
63
|
-
flashbang: "闪光弹",
|
|
64
|
-
smokegrenade: "烟雾弹",
|
|
65
|
-
molotov: "燃烧弹",
|
|
66
|
-
incgrenade: "燃烧弹",
|
|
67
|
-
decoy: "诱饵弹",
|
|
68
|
-
c4: "C4"
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Map a raw weapon code to a stable display name.
|
|
73
|
-
*
|
|
74
|
-
* Always returns a non-empty string: a mapped name when known, the generic "刀"
|
|
75
|
-
* for any knife/bayonet variant, otherwise the normalized raw code (never the
|
|
76
|
-
* literal "unknown"-style placeholder). Never returns a purely numeric string,
|
|
77
|
-
* so replay frames stay free of numeric weapon ids.
|
|
78
|
-
*/
|
|
79
|
-
export function displayWeaponName(raw: string): string {
|
|
80
|
-
const normalized = normalizeWeapon(raw);
|
|
81
|
-
if (!normalized) {
|
|
82
|
-
return raw;
|
|
83
|
-
}
|
|
84
|
-
// Catch all knife/blade variants: knife_*, *knife*, bayonet, karambit, etc.
|
|
85
|
-
if (
|
|
86
|
-
normalized.includes("knife") ||
|
|
87
|
-
normalized.includes("bayonet") ||
|
|
88
|
-
normalized === "karambit"
|
|
89
|
-
) {
|
|
90
|
-
return "knife";
|
|
91
|
-
}
|
|
92
|
-
return WEAPON_DISPLAY_NAMES[normalized] ?? normalized;
|
|
93
|
-
}
|