-
Notifications
You must be signed in to change notification settings - Fork 1
/
zombie-stats.ts
65 lines (58 loc) · 1.58 KB
/
zombie-stats.ts
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
import { readJsonSync, writeFileSync } from "fs-extra"
import { array } from "./util"
const zombies = readJsonSync("json/entityclasses.json")
.entity_classes.entity_class.filter(
(zombie) => !zombie._name.includes("Admin"),
)
.filter((zombie) =>
array(zombie.effect_group).find(
(group) => group._name === "Base Effects" || !group._name,
),
)
function table(prop, decimals, filteredZombies) {
const entries = filteredZombies
.map((zombie) => {
const name = zombie._name
const baseEffects = array(zombie.effect_group).find(
(group) => group._name === "Base Effects" || !group._name,
)
const valueNode = array(baseEffects.passive_effect).find(
(effect) => effect._name === prop,
)
if (valueNode) {
const str = valueNode._value
const value = Number.isNaN(+str) ? str : +str
return { name, value }
}
})
.filter(Boolean)
.sort((a, b) => {
if (a.value !== b.value) {
return b.value - a.value
}
return a.name.localeCompare(b.name)
})
.map((pair) => {
const value =
typeof pair.value === "string"
? pair.value
: pair.value.toFixed(decimals)
return `| ${pair.name.padEnd(30)} | ${value.padStart(10)} |`
})
.join("\n")
return `
### ${prop}
| | |
| :-- | --: |
${entries}`
}
writeFileSync(
"stats/zombies.md",
`## Base Effects
- [HealthMax](#HealthMax)
- [PhysicalDamageResist](#PhysicalDamageResist)
${table("HealthMax", 0, zombies)}
${table("PhysicalDamageResist", 0, zombies)}
`,
"utf8",
)