This repository has been archived by the owner on Apr 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsorting.js
46 lines (44 loc) · 2.5 KB
/
sorting.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
const fs = require('fs')
const path = require('path')
module.exports = () => {
var patchDate = require(path.join(__dirname, 'patchDate.json'))['patchDate']
var folder = path.join(__dirname, 'Raw data', patchDate, 'Other')
var count = 0
var announceAtNextCount = 500
fs.readdirSync(folder).forEach(val => {
let rawFile = fs.readFileSync(path.join(folder, val), 'utf8')
if (rawFile.includes('#QNAN')) {
rawFile = rawFile.replace(/#QNAN/gm, '0')
fs.writeFileSync(path.join(folder, val), rawFile)
}
var file = require(path.join(folder, val))
if (file['0 MonoBehaviour Base']) {
var monoBehaviour = file['0 MonoBehaviour Base']
var moveToFolder = ''
if (typeof monoBehaviour['1 string ChallengeTitle'] === 'string') moveToFolder = 'Challenge'
else if (monoBehaviour['0 Array lootTable']) moveToFolder = 'LootTable'
else if (typeof monoBehaviour['1 string NPCName'] === 'string') moveToFolder = 'NPC'
else if (typeof monoBehaviour['1 string MonsterName'] === 'string') moveToFolder = 'Monster'
else if (typeof monoBehaviour['1 string PlayerName'] === 'string') moveToFolder = 'Player'
else if (monoBehaviour['0 PPtr<$ItemDefinition> FusionUpgradeItem']) moveToFolder = 'ItemDefinition'
else if (monoBehaviour['0 Array availableModifiers']) moveToFolder = 'ItemModifier'
else if (monoBehaviour['0 Array LeveledRecipes'] && monoBehaviour['0 Array LeveledRecipes'].length > 0) moveToFolder = 'CraftingRecipe'
else if (typeof monoBehaviour['1 UInt8 shouldContainBloodstone'] === 'number') moveToFolder = 'LootBox'
else if (monoBehaviour['0 Array sets'] && monoBehaviour['0 Array stat']) moveToFolder = 'Ancestral'
else if (monoBehaviour['0 Array spawnList']) moveToFolder = 'SpawnerDef'
else if (monoBehaviour['0 Array quests']) moveToFolder = 'WeeklyChallenge'
else if (typeof monoBehaviour['1 UInt8 IsBuff'] === 'number') moveToFolder = 'StatusEffect'
// else if (monoBehaviour['1 string QuestText']) moveToFolder = 'Quest'
if (moveToFolder.length > 0) {
if (!fs.existsSync(path.join(__dirname, 'Raw data', patchDate, moveToFolder))) fs.mkdirSync(path.join(__dirname, 'Raw data', patchDate, moveToFolder))
fs.renameSync(path.join(folder, val), path.join(__dirname, 'Raw data', patchDate, moveToFolder, val))
count++
if (count === announceAtNextCount) {
announceAtNextCount += 500
console.log('Sorted', count, 'files so far...')
}
}
}
})
return count
}