feat: Add debug scripts to easilly get all pets/mounts/gear

This commit is contained in:
Blade Barringer
2016-03-15 12:47:24 -05:00
parent ed013ee34d
commit d62807f760
5 changed files with 117 additions and 0 deletions

View File

@@ -10,3 +10,21 @@ For an introduction to the technologies used and how the software is organized,
To set up a local install of Habitica for development and testing, see [Setting up Habitica Locally](http://habitica.wikia.com/wiki/Setting_up_Habitica_Locally), which contains instructions for Windows, *nix / Mac OS, and Vagrant.
Then read [Guidance for Blacksmiths](http://habitica.wikia.com/wiki/Guidance_for_Blacksmiths) for additional instructions and useful tips.
## Debug Scripts
In the `./debug-scripts/` folder, there are a few files. Here's a sample:
```bash
grant-all-equipment.js
grant-all-mounts.js
grant-all-pets.js
```
You can run them by doing:
```bash
node debug-scripts/name-of-script.js
```
If there are more arguments required to make the script work, it will print out the usage and an explanation of what the script does.

19
debug-scripts/_helper.js Normal file
View File

@@ -0,0 +1,19 @@
import { MongoClient as mongo } from 'mongodb';
import config from '../config';
module.exports.updateUser = (_id, path, value) => {
mongo.connect(config.NODE_DB_URI, (err, db) => {
if (err) throw err;
let collection = db.collection('users');
collection.updateOne(
{ _id },
{ $set: { [`${path}`]: value } },
(updateErr, result) => {
if (updateErr) throw updateErr;
console.log('done updating', _id);
db.close();
}
);
});
}

View File

@@ -0,0 +1,24 @@
'use strict';
require('babel-register');
let _ = require('lodash');
let updateUser = require('./_helper').updateUser;
let userId = process.argv[2];
if (!userId) {
console.error('USAGE: node debug-scripts/grant-all-equipment.js <user_id>');
console.error('EFFECT: Adds all gear to specified user');
return;
}
let gearFlat = require('../common').content.gear.flat;
let userGear = {};
_.each(gearFlat, (piece, key) => {
userGear[key] = true;
});
updateUser(userId, 'items.gear.owned', userGear);

View File

@@ -0,0 +1,28 @@
'use strict';
require('babel-register');
let _ = require('lodash');
let updateUser = require('./_helper').updateUser;
let userId = process.argv[2];
if (!userId) {
console.error('USAGE: node debug-scripts/grant-all-mounts.js <user_id>');
console.error('EFFECT: Adds all mounts to specified user');
return;
}
let dropMounts = require('../common').content.mounts;
let questMounts = require('../common').content.questMounts;
let specialMounts = require('../common').content.specialMounts;
let premiumMounts = require('../common').content.premiumPets; // premium mounts isn't exposed on the content object
let userMounts = {};
_.each([ dropMounts, questMounts, specialMounts, premiumMounts ], (set) => {
_.each(set, (pet, key) => {
userMounts[key] = true;
});
})
updateUser(userId, 'items.mounts', userMounts);

View File

@@ -0,0 +1,28 @@
'use strict';
require('babel-register');
let _ = require('lodash');
let updateUser = require('./_helper').updateUser;
let userId = process.argv[2];
if (!userId) {
console.error('USAGE: node debug-scripts/grant-all-pets.js <user_id>');
console.error('EFFECT: Adds all pets to specified user');
return;
}
let dropPets = require('../common').content.pets;
let questPets = require('../common').content.questPets;
let specialPets = require('../common').content.specialPets;
let premiumPets = require('../common').content.premiumPets;
let userPets = {};
_.each([ dropPets, questPets, specialPets, premiumPets ], (set) => {
_.each(set, (pet, key) => {
userPets[key] = 95;
});
})
updateUser(userId, 'items.pets', userPets);