Skip to content

Commit

Permalink
Build data/text.js from server
Browse files Browse the repository at this point in the history
text.js is no longer maintained in the client repo; it's now built
directly from the server's data/text/ directory.
  • Loading branch information
Zarel committed Oct 27, 2020
1 parent 8e6f370 commit 7fc87ca
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 1,244 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
data/*
!data/text.js
node_modules/
/js/lib/

Expand Down
26 changes: 26 additions & 0 deletions build-tools/build-indexes
Original file line number Diff line number Diff line change
Expand Up @@ -1097,4 +1097,30 @@ process.stdout.write("Building `data/moves,items,abilities,typechart,learnsets.j
fs.writeFileSync('data/learnsets.js', buf);
}

/*********************************************************
* Build text.js
*********************************************************/

{
const textData = Dex.loadTextData();
const Text = textData.Default;

function assignData(id, entry) {
for (const key in entry) {
if (key === 'name' || key.startsWith('desc') || key.startsWith('shortDesc')) {
continue;
}
const textEntry = Text[id] || (Text[id] = {});
textEntry[key] = entry[key];
}
}

for (const id in textData.Moves) assignData(id, textData.Moves[id]);
for (const id in textData.Abilities) assignData(id, textData.Abilities[id]);
for (const id in textData.Items) assignData(id, textData.Items[id]);

const buf = 'exports.BattleText = ' + es3stringify(Text) + ';';
fs.writeFileSync('data/text.js', buf);
}

console.log("DONE");
8 changes: 6 additions & 2 deletions build-tools/update
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,18 @@ if (process.argv[2] === 'full') {

child_process.execSync(`node build-tools/babel-cli/bin/babel.js src --out-dir js --extensions ".ts,.tsx" --incremental${ignoreGraphics}`);

let textData = '';
try {
textData = fs.readFileSync('data/text.js');
} catch (e) {}

fs.writeFileSync(
'js/battledata.js',
fs.readFileSync('js/battle-dex.js') + '\n\n' +
fs.readFileSync('js/battle-dex-data.js') + '\n\n' +
fs.readFileSync('js/battle-log.js') + '\n\n' +
fs.readFileSync('src/battle-log-misc.js') +
fs.readFileSync('data/text.js') + '\n\n' +
fs.readFileSync('data/text-afd.js') + '\n\n' +
textData + '\n\n' +
fs.readFileSync('js/battle-text-parser.js')
);

Expand Down
Loading

0 comments on commit 7fc87ca

Please sign in to comment.