-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate.js
108 lines (85 loc) · 3.01 KB
/
generate.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
* Tool to automatically generate documentation for the Frackin' Universe (Starbound mod)
* directly from the sources of the mod (things like "what is material A extracted to/from").
*
* @author Edward Chernenko
*
* Usage: node generate.js
*/
'use strict';
const { ItemDatabase, RecipeDatabase, ResearchTreeDatabase, ArmorSetDatabase, PlanetDatabase,
BiomeDatabase, MonsterDatabase, RegionDatabase, WeatherPoolDatabase, StatusEffectDatabase,
ResultsWriter, TreasurePoolDatabase, SaplingDatabase, TenantDatabase,
BotUpdatedPages, util } = require( './lib' );
/* -------------------------------------------------------------------------------------------- */
// Generate the wikitext for each item that has at least 1 Recipe.
// Then send the results to ResultsWriter.write().
for ( var itemCode of RecipeDatabase.listMentionedItemCodes() ) {
var item = ItemDatabase.find( itemCode );
if ( !item ) {
// Must be tolerant to bad input (ignore unknown items, continue with known items),
// because a typo somewhere in the mod shouldn't stop the script.
util.warnAboutUnknownItem( itemCode );
continue;
}
if ( item.isCodex() ) {
// Codexes will be handled below.
continue;
}
ResultsWriter.writeItem( item );
}
// Write all non-vanilla codexes (regardless of whether they have a recipe or not). Skip vanilla codexes.
ItemDatabase.forEach( ( itemCode2, item2 ) => {
if ( item2.isNonVanillaCodex() ) {
ResultsWriter.writeItem( item2 );
}
} );
// Generate Cargo database of all known recipes.
RecipeDatabase.forEach( ( recipe ) => {
ResultsWriter.writeRecipe( recipe );
} );
// Generate Cargo database of all research nodes.
ResearchTreeDatabase.forEach( ( node ) => {
ResultsWriter.writeResearchNode( node );
} );
// Generate Cargo database of all known armor sets.
ArmorSetDatabase.forEach( ( armorSet ) => {
ResultsWriter.writeArmorSet( armorSet );
} );
// Generate Cargo database of all known monsters.
MonsterDatabase.forEach( ( monster ) => {
ResultsWriter.writeMonster( monster );
} );
for ( var poolName of RecipeDatabase.listMentionedTreasurePools() ) {
var pool = TreasurePoolDatabase.find( poolName );
if ( !pool ) {
util.log( '[error] Unknown TreasurePool in the recipe: ' + poolName );
continue;
}
ResultsWriter.writeTreasurePool( pool );
}
PlanetDatabase.forEach( ( planet ) => {
ResultsWriter.writePlanet( planet );
} );
RegionDatabase.forEach( ( region ) => {
ResultsWriter.writeRegion( region );
} );
BiomeDatabase.forEach( ( biome ) => {
ResultsWriter.writeBiome( biome );
} );
WeatherPoolDatabase.forEach( ( weatherPool ) => {
ResultsWriter.writeWeatherPool( weatherPool );
} );
StatusEffectDatabase.forEach( ( statusEffect ) => {
ResultsWriter.writeStatusEffect( statusEffect );
} );
SaplingDatabase.forEach( ( saplingPart ) => {
ResultsWriter.writeSaplingPart( saplingPart );
} );
TenantDatabase.forEach( ( tenant ) => {
ResultsWriter.writeTenant( tenant );
} );
BotUpdatedPages.forEach( ( page ) => {
ResultsWriter.overwritePage( page.getTitle(), page.getText() );
} );
ResultsWriter.finalize();