Navigation Menu

Skip to content

Commit

Permalink
Make pokemon-showdown ES3-compatible
Browse files Browse the repository at this point in the history
Old versions of Node might consider some uses of `const` a syntax
error, which would prevent PS from displaying the "Node version too
old" error message.
  • Loading branch information
Zarel committed Jul 17, 2018
1 parent 56b4ad3 commit bfb6075
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions pokemon-showdown
Expand Up @@ -15,9 +15,9 @@ echo "We require Node.js version 8 or later; Node.js not found"
exit 1
*/;

const child_process = require('child_process');
const fs = require('fs');
const path = require('path');
var child_process = require('child_process');
var fs = require('fs');
var path = require('path');

// # Make sure we're Node 8+

Expand Down Expand Up @@ -112,24 +112,24 @@ if (!process.argv[2] || /^[0-9]+$/.test(process.argv[2])) {
break;
case 'generate-team':
{
const Dex = require('./sim/dex');
var Dex = require('./sim/dex');
global.toId = Dex.getId;
const seed = process.argv[4] ? process.argv[4].split(',').map(Number) : undefined;
var seed = process.argv[4] ? process.argv[4].split(',').map(Number) : undefined;
console.log(Dex.packTeam(Dex.generateTeam(process.argv[3], seed)));
}
break;
case 'validate-team':
{
const Dex = require('./sim/dex');
const TeamValidator = require('./sim/team-validator');
const validator = TeamValidator(process.argv[3]);
const Streams = require('./lib/streams');
const stdin = new Streams.ReadStream(process.stdin);
var Dex = require('./sim/dex');
var TeamValidator = require('./sim/team-validator');
var validator = TeamValidator(process.argv[3]);
var Streams = require('./lib/streams');
var stdin = new Streams.ReadStream(process.stdin);

stdin.readLine().then(function (textTeam) {
try {
const team = Dex.fastUnpackTeam(textTeam);
const result = validator.validateTeam(team);
var team = Dex.fastUnpackTeam(textTeam);
var result = validator.validateTeam(team);
if (result) {
console.error(result.join('\n'));
process.exit(1);
Expand All @@ -144,25 +144,25 @@ if (!process.argv[2] || /^[0-9]+$/.test(process.argv[2])) {
break;
case 'simulate-battle':
{
const BattleTextStream = require('./sim/battle-stream').BattleTextStream;
const Streams = require('./lib/streams');
const stdin = new Streams.ReadStream(process.stdin);
const stdout = new Streams.WriteStream(process.stdout);
var BattleTextStream = require('./sim/battle-stream').BattleTextStream;
var Streams = require('./lib/streams');
var stdin = new Streams.ReadStream(process.stdin);
var stdout = new Streams.WriteStream(process.stdout);

const battleStream = new BattleTextStream();
var battleStream = new BattleTextStream();
stdin.pipeTo(battleStream);
battleStream.pipeTo(stdout);
}
break;
case 'unpack-team':
{
const Dex = require('./sim/dex');
const Streams = require('./lib/streams');
const stdin = new Streams.ReadStream(process.stdin);
var Dex = require('./sim/dex');
var Streams = require('./lib/streams');
var stdin = new Streams.ReadStream(process.stdin);

stdin.readLine().then(function (packedTeam) {
try {
const unpackedTeam = Dex.fastUnpackTeam(packedTeam);
var unpackedTeam = Dex.fastUnpackTeam(packedTeam);
console.log(JSON.stringify(unpackedTeam));
process.exit(0);
} catch (e) {
Expand All @@ -174,13 +174,13 @@ if (!process.argv[2] || /^[0-9]+$/.test(process.argv[2])) {
break;
case 'pack-team':
{
const Dex = require('./sim/dex');
const Streams = require('./lib/streams');
const stdin = new Streams.ReadStream(process.stdin);
var Dex = require('./sim/dex');
var Streams = require('./lib/streams');
var stdin = new Streams.ReadStream(process.stdin);

stdin.readLine().then(function (unpackedTeam) {
try {
const packedTeam = Dex.packTeam(JSON.parse(unpackedTeam));
var packedTeam = Dex.packTeam(JSON.parse(unpackedTeam));
console.log(packedTeam);
process.exit(0);
} catch (e) {
Expand Down

0 comments on commit bfb6075

Please sign in to comment.