Cash me outsyde howabout dat!
This commit is contained in:
38
cash.js
Normal file
38
cash.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import fs from 'fs';
|
||||
import request from 'request';
|
||||
|
||||
const config = JSON.parse(fs.readFileSync('config.json'));
|
||||
const players = JSON.parse(fs.readFileSync('accounts.json')).accounts;
|
||||
|
||||
let totalcash = 0.00;
|
||||
|
||||
|
||||
const lookup = player => {
|
||||
const postbody = {"_method":"GET","_ApplicationId":"TINAGTG_PARSE","_ClientVersion":"js1.11.1","_InstallationId":"","_SessionToken":""};
|
||||
postbody._InstallationId = player._InstallationId;
|
||||
postbody._SessionToken = player.sessionToken;
|
||||
request({
|
||||
method: 'POST',
|
||||
uri: `${config.PROD_SERVER_URL}/parse/classes/_User/${player.objectId}`,
|
||||
body: postbody,
|
||||
json: true // Automatically stringifies the body to JSON
|
||||
},(err, response, body)=>{
|
||||
totalcash = totalcash + body.points;
|
||||
const cash_display = body.points.toFixed(2).toString();
|
||||
console.log(`${player.username} has $${cash_display}`);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
let time = 700;
|
||||
let interval = 0;
|
||||
|
||||
players.forEach(player=>{
|
||||
setTimeout(()=>{
|
||||
lookup(player);
|
||||
if(player.objectId === players[players.length-1].objectId){
|
||||
setTimeout(()=>{console.log(`You have $${totalcash.toFixed(2).toString()}`);},2000);
|
||||
}
|
||||
},time*interval);
|
||||
interval++;
|
||||
});
|
||||
38
cashout.js
Normal file
38
cashout.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import fs from 'fs';
|
||||
import request from 'request';
|
||||
|
||||
const config = JSON.parse(fs.readFileSync('config.json'));
|
||||
const players = JSON.parse(fs.readFileSync('accounts.json')).accounts;
|
||||
|
||||
const cashout = player => {
|
||||
const postbody = {"email":"","_ApplicationId":"TINAGTG_PARSE","_ClientVersion":"js1.11.1","_InstallationId":"","_SessionToken":""};
|
||||
postbody._InstallationId = player._InstallationId;
|
||||
postbody._SessionToken = player.sessionToken;
|
||||
postbody.email = player.email;
|
||||
request({
|
||||
method: 'POST',
|
||||
uri: `${config.PROD_SERVER_URL}/parse/functions/cashoutWithPaypal`,
|
||||
body: postbody,
|
||||
json: true // Automatically stringifies the body to JSON
|
||||
},(err, response, body)=>{
|
||||
if(body.result === "ok"){
|
||||
console.log(`${player.username} has cashed out to ${player.email}!`);
|
||||
} else{
|
||||
console.warn(`${player.username} failed to cash out to ${player.email}!`);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
let time = 700;
|
||||
let interval = 0;
|
||||
|
||||
players.forEach(player=>{
|
||||
setTimeout(()=>{
|
||||
cashout(player);
|
||||
if(player.objectId === players[players.length-1].objectId){
|
||||
setTimeout(()=>{console.log(`Done, enjoy!`);},2000);
|
||||
}
|
||||
},time*interval);
|
||||
interval++;
|
||||
});
|
||||
@@ -23,7 +23,9 @@
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "babel-node quiz.js --presets env,es2016,stage-2",
|
||||
"register": "babel-node registration.js --presets env,es2016,stage-2"
|
||||
"register": "babel-node registration.js --presets env,es2016,stage-2",
|
||||
"balance": "babel-node cash.js --presets env,es2016,stage-2",
|
||||
"cashout": "babel-node cashout.js --presets env,es2016,stage-2"
|
||||
},
|
||||
"author": "MrARM",
|
||||
"license": "ISC"
|
||||
|
||||
Reference in New Issue
Block a user