});
}
-createCities().then(createPaths).then(createLocations).then(() => {
- console.log(`${stats.cityCount} Cities created`);
- console.log(`${stats.paths} paths created`);
- console.log('Complete');
- process.exit(0);
-}).catch(e => {
- console.log(e);
- process.exit(1);
-});
+export async function createAllCitiesAndLocations() {
+ return createCities().then(createPaths).then(createLocations);
+}
+
+if(!module.parent) {
+ createCities().then(createPaths).then(createLocations).then(() => {
+ console.log(`${stats.cityCount} Cities created`);
+ console.log(`${stats.paths} paths created`);
+ console.log('Complete');
+ process.exit(0);
+ }).catch(e => {
+ console.log(e);
+ process.exit(1);
+ });
+}
});
}
-createShopItems().then(() => {
- console.log('Complete');
- process.exit(0);
-}).catch(e => {
- console.log(e);
- process.exit(1);
-})
+if(!module.parent) {
+ createShopItems().then(() => {
+ console.log('Complete');
+ process.exit(0);
+ }).catch(e => {
+ console.log(e);
+ process.exit(1);
+ });
+}
// TEMP!
import { createMonsters } from '../../seeds/monsters';
+import { createAllCitiesAndLocations } from '../../seeds/cities';
+import { createShopItems } from '../../seeds/shop_items';
dotenv();
await createMonsters();
message = broadcastMessage('server', 'Monster refresh!');
}
+ else if(msg === '/server lmnop refresh-cities') {
+ await createAllCitiesAndLocations();
+ message = broadcastMessage('server', 'Cities, Locations, and Paths refreshed!');
+ }
+ else if(msg === '/server lmnop refresh-shops') {
+ await createShopItems();
+ message = broadcastMessage('server', 'Refresh shop items');
+ }
else {
- message = broadcastMessage('server', msg.split('/server lmnop ')[1]);
+ const str = msg.split('/server lmnop ')[1];
+ if(str) {
+ message = broadcastMessage('server', str);
+ }
}
}
else {
message = broadcastMessage(player.username, msg);
}
- chatHistory.push(message);
- chatHistory.slice(-10);
- io.emit('chat', message);
+ if(message) {
+ chatHistory.push(message);
+ chatHistory.slice(-10);
+ io.emit('chat', message);
+ }
}
});