Skip to content

Commit

Permalink
Revert "Revert "Revert "Add .sim-dist with warning"""
Browse files Browse the repository at this point in the history
This reverts commit 8e715fd.
  • Loading branch information
scheibo committed Feb 26, 2019
1 parent 9bafb4a commit 278704a
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ server/tournaments/lib/
logs/
dev-tools/globals.js
node_modules/
.sim-dist/
sim/*.js
3 changes: 0 additions & 3 deletions .sim-dist/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ try {
execSync('npm install', {stdio: 'inherit'});
}

execSync('npx sucrase ./sim -d ./.sim-dist --transforms typescript,imports');
execSync('npx sucrase ./sim -d ./sim --transforms typescript,imports');
2 changes: 1 addition & 1 deletion data/mods/ssb/moves.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Used for bumbadadabum and Snaquaza's move
const RandomStaffBrosTeams = require('./random-teams');
const Pokemon = require('../../../.sim-dist/pokemon');
const Pokemon = require('../../../sim/pokemon');

/** @type {{[k: string]: ModdedMoveData}} */
let BattleMovedex = {
Expand Down
4 changes: 2 additions & 2 deletions data/random-teams.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const Dex = require('./../.sim-dist/dex');
const PRNG = require('./../.sim-dist/prng').PRNG;
const Dex = require('./../sim/dex');
const PRNG = require('./../sim/prng').PRNG;

/**@type {AnyObject} */
// @ts-ignore
Expand Down
16 changes: 8 additions & 8 deletions pokemon-showdown
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ try {
// # Make sure the Typescript sources have been compiled into Javascript.

try {
require.resolve('./.sim-dist/dex');
require.resolve('./sim/dex');
} catch(err) {
if (err.code !== 'MODULE_NOT_FOUND') throw err; // should never happen

Expand Down Expand Up @@ -100,7 +100,7 @@ if (!process.argv[2] || /^[0-9]+$/.test(process.argv[2])) {
console.log('pokemon-showdown simulate-battle');
console.log('');
console.log(' Simulates a battle, taking input to stdin and writing output to stdout');
console.log(' Protocol is documented in ./.sim-dist/README.md');
console.log(' Protocol is documented in ./sim/README.md');
console.log('');
console.log('pokemon-showdown unpack-team');
console.log('');
Expand All @@ -125,16 +125,16 @@ if (!process.argv[2] || /^[0-9]+$/.test(process.argv[2])) {
}
case 'generate-team':
{
var Dex = require('./.sim-dist/dex');
var Dex = require('./sim/dex');
global.toId = Dex.getId;
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':
{
var Dex = require('./.sim-dist/dex');
var TeamValidator = require('./.sim-dist/team-validator');
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);
Expand All @@ -157,7 +157,7 @@ if (!process.argv[2] || /^[0-9]+$/.test(process.argv[2])) {
break;
case 'simulate-battle':
{
var BattleTextStream = require('./.sim-dist/battle-stream').BattleTextStream;
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);
Expand All @@ -171,7 +171,7 @@ if (!process.argv[2] || /^[0-9]+$/.test(process.argv[2])) {
break;
case 'unpack-team':
{
var Dex = require('./.sim-dist/dex');
var Dex = require('./sim/dex');
var Streams = require('./lib/streams');
var stdin = new Streams.ReadStream(process.stdin);

Expand All @@ -189,7 +189,7 @@ if (!process.argv[2] || /^[0-9]+$/.test(process.argv[2])) {
break;
case 'pack-team':
{
var Dex = require('./.sim-dist/dex');
var Dex = require('./sim/dex');
var Streams = require('./lib/streams');
var stdin = new Streams.ReadStream(process.stdin);

Expand Down
8 changes: 4 additions & 4 deletions server/chat-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -3035,12 +3035,12 @@ const commands = {
if (lock['battles']) return this.errorReply(`Hot-patching battles has been disabled by ${lock['battles'].by} (${lock['battles'].reason})`);
if (lock['validator']) return this.errorReply(`Hot-patching the validator has been disabled by ${lock['validator'].by} (${lock['validator'].reason})`);

// uncache the .sim-dist/dex.js dependency tree
// uncache the sim/dex.js dependency tree
Chat.uncacheDir('./sim');
Chat.uncacheDir('./data');
Chat.uncache('./config/formats');
// reload .sim-dist/dex.js
global.Dex = require('../.sim-dist/dex');
// reload sim/dex.js
global.Dex = require('../sim/dex');
// rebuild the formats list
delete Rooms.global.formatList;
// respawn validator processes
Expand Down Expand Up @@ -3089,7 +3089,7 @@ const commands = {
`You can disable various hot-patches with /nohotpatch. For more information on this, see /help nohotpatch`,
`/hotpatch chat - reload chat-commands.js and the chat-plugins`,
`/hotpatch validator - spawn new team validator processes`,
`/hotpatch formats - reload the .sim-dist/dex.js tree, rebuild and rebroad the formats list, and spawn new simulator and team validator processes`,
`/hotpatch formats - reload the sim/dex.js tree, rebuild and rebroad the formats list, and spawn new simulator and team validator processes`,
`/hotpatch dnsbl - reloads Dnsbl datacenters`,
`/hotpatch punishments - reloads new punishments code`,
`/hotpatch tournaments - reloads new tournaments code`,
Expand Down
4 changes: 2 additions & 2 deletions server/chat-plugins/datasearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1614,10 +1614,10 @@ if (!PM.isParentProcess) {
});
}

global.Dex = require('../../.sim-dist/dex');
global.Dex = require('../../sim/dex');
global.toId = Dex.getId;
Dex.includeData();
global.TeamValidator = require('../../.sim-dist/team-validator');
global.TeamValidator = require('../../sim/team-validator');

require('../../lib/repl').start('dexsearch', cmd => eval(cmd));
} else {
Expand Down
2 changes: 1 addition & 1 deletion server/chat-plugins/modlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ if (!PM.isParentProcess) {
require('../../lib/crashlogger')(err, 'A modlog child process');
}
});
global.Dex = require('../../.sim-dist/dex');
global.Dex = require('../../sim/dex');
global.toId = Dex.getId;

require('../../lib/repl').start('modlog', cmd => eval(cmd));
Expand Down
4 changes: 2 additions & 2 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* rooms.js. There's also a global room which every user is in, and
* handles miscellaneous things like welcoming the user.
*
* Dex - from .sim-dist/dex.js
* Dex - from sim/dex.js
*
* Handles getting data about Pokemon, items, etc.
*
Expand Down Expand Up @@ -96,7 +96,7 @@ if (Config.watchconfig) {
* Set up most of our globals
*********************************************************/

global.Dex = require('../.sim-dist/dex');
global.Dex = require('../sim/dex');
global.toId = Dex.getId;

global.LoginServer = require('./loginserver');
Expand Down
2 changes: 1 addition & 1 deletion server/room-battle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ exports.RoomBattle = Battle;
const StreamProcessManager = require('../lib/process-manager').StreamProcessManager;

const PM = new StreamProcessManager(module, () => {
const BattleStream = require('../.sim-dist/battle-stream').BattleStream;
const BattleStream = require('../sim/battle-stream').BattleStream;
return new BattleStream({keepAlive: true});
});

Expand Down
4 changes: 2 additions & 2 deletions server/team-validator-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if (!PM.isParentProcess) {
// This is a child process!
// @ts-ignore This file doesn't exist on the repository, so Travis checks fail if this isn't ignored
global.Config = require('../config/config');
global.TeamValidator = require('../.sim-dist/team-validator');
global.TeamValidator = require('../sim/team-validator');
// @ts-ignore ???
global.Monitor = {
/**
Expand All @@ -88,7 +88,7 @@ if (!PM.isParentProcess) {
});
}

global.Dex = require('../.sim-dist/dex').includeData();
global.Dex = require('../sim/dex').includeData();
global.toId = Dex.getId;
global.Chat = require('./chat');

Expand Down
2 changes: 1 addition & 1 deletion test/application/team-validator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const assert = require('assert');
const TeamValidator = require('../../.sim-dist/team-validator');
const TeamValidator = require('../../sim/team-validator');

describe('Team Validator', function () {
it('should have valid formats to work with', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/common.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const assert = require('assert');
const Dex = require('./../.sim-dist/dex');
const Dex = require('./../sim/dex');
const Sim = require('./../sim');

const cache = new Map();
Expand Down
8 changes: 4 additions & 4 deletions test/simulator/misc/dex.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ const assert = require('./../../assert');
describe('Mod loader', function () {
it.skip('should work fine in any order', function () {
{
Chat.uncacheTree('./.sim-dist/dex');
let Dex = require('./../../../.sim-dist/dex');
Chat.uncacheTree('./sim/dex');
let Dex = require('./../../../sim/dex');
assert.strictEqual(Dex.mod('gen2').getTemplate('nidoking').learnset.bubblebeam.join(','), '1M');
assert.strictEqual(Dex.mod('gen2').getMove('crunch').secondaries[0].boosts.def, undefined);
}
{
Chat.uncacheTree('./.sim-dist/dex');
let Dex = require('./../../../.sim-dist/dex');
Chat.uncacheTree('./sim/dex');
let Dex = require('./../../../sim/dex');
Dex.mod('gen2').getTemplate('nidoking');
Dex.mod('gen4').getMove('crunch');
assert.strictEqual(Dex.mod('gen2').getTemplate('nidoking').learnset.bubblebeam.join(','), '1M');
Expand Down
2 changes: 1 addition & 1 deletion test/simulator/misc/prng.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const PRNG = require('../../../.sim-dist/prng').PRNG;
const PRNG = require('../../../sim/prng').PRNG;
const assert = require('../../assert');

const testSeed = [1, 2, 3, 4];
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"./server/chat-commands.js"
],
"include": [
"./.sim-dist/*",
"./config/formats.js",
"./data/*",
"./data/mods/*/*",
Expand Down

0 comments on commit 278704a

Please sign in to comment.