forked from PrismarineJS/minecraft-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
audit_items.js
54 lines (51 loc) · 1.64 KB
/
audit_items.js
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
/* eslint-env mocha */
const fs = require('fs')
const path = require('path')
// checks for duplicates names and jumps in ids
require('./version_iterator')(function (p, versionString) {
describe('audit items ' + versionString, function () {
it('audit items', function () {
let items
const pFile = path.join(p, 'items.json')
if (fs.existsSync(pFile)) {
items = require(pFile)
} else {
// console.log('No items for version ' + versionString)
}
if (items) {
const displayNames = {}
const names = {}
let lastItemId = 0
items.forEach(item => {
if (item.displayName == null) {
console.log('Missing displayName:', item.id)
} else {
const otherBlock = displayNames[item.displayName]
if (otherBlock) {
// console.log('Duplicate displayName:', otherBlock.id, 'and', item.id,
// 'both share', item.displayName)
} else {
displayNames[item.displayName] = item
}
}
if (item.name == null) {
console.log('Missing name:', item.id)
} else {
const otherBlock = names[item.name]
if (otherBlock) {
// console.log('Duplicate name:', otherBlock.id, 'and', item.id,
// 'both share', item.name)
} else {
names[item.name] = item
}
}
const delta = item.id - lastItemId
if (delta !== 1) {
// console.log('jump from', lastItemId, 'to', item.id)
}
lastItemId = item.id
})
}
})
})
})