-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.js
72 lines (67 loc) · 1.7 KB
/
process.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import * as util from "./util.js";
function processrecipe(recipe){
let newrecipe={"type":"recipe"};
for(let x of ["normal","expensive"]){
if(!(x in recipe)){
continue;
}
newrecipe[x]={"ingredients":[],"results":[]};
for(let ingredient of recipe[x].ingredients){
newrecipe[x].ingredients.push([
ingredient.name,
ingredient.amount
]);
}
for(let result of recipe[x].results){
newrecipe[x].results.push([
result.name,
result.amount
]);
}
newrecipe[x].time=recipe[x].energy_required;
}
newrecipe.name=recipe.name;
newrecipe.category=recipe.category||"crafting";
return newrecipe;
}
function processtech(tech){
let newtech={"type":"tech"};
newtech.name=tech.name;
for(let x of util.util.difficulty){
if(!(x in tech)){
continue;
}
newtech[x]={"packs":[]};
for(let pack of tech[x].unit.ingredients){
newtech[x].packs.push([
pack.name,
pack.amount
]);
}
if("count" in tech[x].unit){
newtech[x].count=tech[x].unit.count;
}else{
newtech[x].count=tech[x].unit.count_formula;
}
newtech[x].time=tech[x].unit.time;
newtech[x].prerequisites=tech[x].prerequisites??[];
if(!Array.isArray(newtech[x].prerequisites)){
newtech[x].prerequisites=Object.values(newtech[x].prerequisites);
}
let effects=tech[x].effects??{};
if(!Array.isArray(effects)){
effects=Object.values(effects);
}
newtech[x].effects=effects.filter(e=>e.type=="unlock-recipe").map(e=>e.recipe);
}
return newtech;
}
/*
function processitem(item){
return item;
}
function processentity(entity){
return entity;
}
*/
export {processrecipe,processtech};