mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
feat: Add debug scripts to easilly get all pets/mounts/gear
This commit is contained in:
18
README.md
18
README.md
@@ -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.
|
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.
|
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
19
debug-scripts/_helper.js
Normal 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();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
24
debug-scripts/grant-all-equipment.js
Normal file
24
debug-scripts/grant-all-equipment.js
Normal 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);
|
||||||
28
debug-scripts/grant-all-mounts.js
Normal file
28
debug-scripts/grant-all-mounts.js
Normal 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);
|
||||||
28
debug-scripts/grant-all-pets.js
Normal file
28
debug-scripts/grant-all-pets.js
Normal 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);
|
||||||
Reference in New Issue
Block a user