Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*jshint esversion: 6*/
- const commando = require('discord.js-commando');
- const db = require('../config/db');
- module.exports = {
- tradeSkill: (msg, what, type, amount, userData, stats) => {
- // Update userData
- let userSQL = 'SELECT * FROM users_meta WHERE userid = ?';
- db.query(userSQL, userData.id, (err, row) => {
- userData.game = row[0];
- });
- var matgain = null;
- var expgain = null;
- let sql;
- // Start gathering Blocks
- if (what === 'farming' || what === 'food') {
- // exp and yield calculations
- switch (type) {
- case 'wheat':
- matgain = (1 + userData.game.farming_matgain) - 1;
- expgain = (1 + userData.game.farming_expgain) - 1;
- break;
- case 'carrot':
- matgain = (1 + userData.game.farming_matgain) - 1;
- expgain = (4 + userData.game.farming_expgain) - 1;
- break;
- case 'tomato':
- matgain = (1 + userData.game.farming_matgain) - 1;
- expgain = (9 + userData.game.farming_expgain) - 1;
- break;
- case 'cucumber':
- matgain = (1 + userData.game.farming_matgain) - 1;
- expgain = (16 + userData.game.farming_expgain) - 1;
- break;
- case 'potato':
- matgain = (1 + userData.game.farming_matgain) - 1;
- expgain = (25 + userData.game.farming_expgain) - 1;
- break;
- default:
- return msg.reply('You did not produce the correct arguments');
- }
- // Update table
- sql = `UPDATE users_meta SET ${type} = ${type} + ${matgain}, tsexp = tsexp + ${expgain} WHERE userid = ?`;
- db.query(sql, userData.id, (err) => {
- if (err) { return console.log(err); }
- stats.yield += matgain;
- stats.exp += expgain;
- stats.actions--;
- });
- if (stats.actions <= 0) {
- // The report DM
- userData.send({ embed: {
- color: 3447003,
- title: `Farming Report For ${type}`,
- fields: [{
- name: 'Stats',
- value:
- 'Gathered: ' + stats.yield +
- '\nEXP Gained: ' + stats.exp,
- },
- ],
- },
- });
- //Reset stats for Report
- stats = {
- exp: 0,
- actions: amount,
- yield: 0,
- };
- }
- // Start herbolgoy
- } else if (what === 'herbology' || what === 'herbs') {
- switch (type) {
- case 'basil':
- matgain = (1 + userData.game.herbology_matgain) - 1;
- expgain = (1 + userData.game.herbology_expgain) - 1;
- break;
- case 'cilantro':
- matgain = (1 + userData.game.herbology_matgain) - 1;
- expgain = (4 + userData.game.herbology_expgain) - 1;
- break;
- case 'dill':
- matgain = (1 + userData.game.herbology_matgain) - 1;
- expgain = (9 + userData.game.herbology_expgain) - 1;
- break;
- case 'thyme':
- matgain = (1 + userData.game.herbology_matgain) - 1;
- expgain = (16 + userData.game.herbology_expgain) - 1;
- break;
- case 'garlic':
- matgain = (1 + userData.game.herbology_matgain) - 1;
- expgain = (25 + userData.game.herbology_expgain) - 1;
- break;
- default:
- return msg.reply('You did not produce the correct arguments');
- }
- // Update table
- sql = `UPDATE users_meta SET ${type} = ${type} + ${matgain}, tsexp = tsexp + ${expgain} WHERE userid = ?`;
- db.query(sql, userData.id, (err) => {
- if (err) { return console.log(err); }
- stats.yield += matgain;
- stats.exp += expgain;
- stats.actions--;
- });
- if (stats.actions <= 0) {
- // The report DM
- userData.send({ embed: {
- color: 3447003,
- title: `Herbology For ${type}`,
- fields: [{
- name: 'Stats',
- value:
- 'Gathered: ' + stats.yield +
- '\nEXP Gained: ' + stats.exp,
- },
- ],
- },
- });
- //Reset stats for Report
- stats = {
- exp: 0,
- actions: amount,
- yield: 0,
- };
- }
- // Start Hunting Block
- } else if (what === 'hunting' || what === 'hunt') {
- // exp and yield calculations
- var scraps;
- switch (type) {
- case 'rabbit':
- matgain = (1 + userData.game.hunting_matgain) - 1;
- expgain = (1 + userData.game.hunting_expgain) - 1;
- scraps = 'fur_scraps';
- break;
- case 'wolf':
- matgain = (1 + userData.game.hunting_matgain) - 1;
- expgain = (4 + userData.game.hunting_expgain) - 1;
- scraps = 'pelt_scraps';
- break;
- case 'deer':
- matgain = (1 + userData.game.hunting_matgain) - 1;
- expgain = (9 + userData.game.hunting_expgain) - 1;
- scraps = 'leather_scraps';
- break;
- case 'bear':
- matgain = (1 + userData.game.hunting_matgain) - 1;
- expgain = (16 + userData.game.hunting_expgain) - 1;
- scraps = 'hide_scraps';
- break;
- case 'dragon':
- matgain = (1 + userData.game.hunting_matgain) - 1;
- expgain = (25 + userData.game.hunting_expgain) - 1;
- scraps = 'scale_scraps';
- break;
- default:
- return msg.reply('You did not produce the correct arguments');
- }
- // Update table
- sql = `UPDATE users_meta SET ${scraps} = ${scraps} + ${matgain}, tsexp = tsexp + ${expgain} WHERE userid = ?`;
- db.query(sql, userData.id, (err) => {
- if (err) { return console.log(err); }
- stats.yield += matgain;
- stats.exp += expgain;
- stats.actions--;
- });
- if (stats.actions <= 0) {
- // The report DM
- userData.send({ embed: {
- color: 3447003,
- title: `Hunting Report For ${type}`,
- fields: [{
- name: 'Stats',
- value:
- 'Gathered: ' + stats.yield + ' ' + scraps +
- '\nEXP Gained: ' + stats.exp,
- },
- ],
- },
- });
- //Reset stats for Report
- stats = {
- exp: 0,
- actions: amount,
- yield: 0,
- };
- }
- } else if (what === 'lumber' || what === 'wood') {
- // exp and yield calculations
- var logs;
- switch (type) {
- case 'oak':
- matgain = (1 + userData.game.lumber_matgain) - 1;
- expgain = (1 + userData.game.lumber_expgain) - 1;
- logs = 'oak_logs';
- break;
- case 'birch':
- matgain = (1 + userData.game.lumber_matgain) - 1;
- expgain = (4 + userData.game.lumber_expgain) - 1;
- logs = 'birch_logs';
- break;
- case 'cyrpuss':
- matgain = (1 + userData.game.lumber_matgain) - 1;
- expgain = (9 + userData.game.lumber_expgain) - 1;
- logs = 'cypruss_logs';
- break;
- case 'pine':
- matgain = (1 + userData.game.lumber_matgain) - 1;
- expgain = (16 + userData.game.lumber_expgain) - 1;
- logs = 'pine_logs';
- break;
- case 'spruce':
- matgain = (1 + userData.game.lumber_matgain) - 1;
- expgain = (25 + userData.game.lumber_expgain) - 1;
- logs = 'spruce_logs';
- break;
- default:
- return msg.reply('You did not produce the correct arguments');
- }
- // Update table
- sql = `UPDATE users_meta SET ${logs} = ${logs} + ${matgain}, tsexp = tsexp + ${expgain} WHERE userid = ?`;
- db.query(sql, userData.id, (err) => {
- if (err) { return console.log(err); }
- stats.yield += matgain;
- stats.exp += expgain;
- stats.actions--;
- });
- if (stats.actions <= 0) {
- // The report DM
- userData.send({ embed: {
- color: 3447003,
- title: `Lumber Report For ${type}`,
- fields: [{
- name: 'Stats',
- value:
- 'Gathered: ' + stats.yield +
- '\nEXP Gained: ' + stats.exp,
- },
- ],
- },
- });
- //Reset stats for Report
- stats = {
- exp: 0,
- actions: amount,
- yield: 0,
- };
- }
- // Start mining block
- } else if (what === 'mining' || what === 'mine') {
- // exp and yield calculations
- var ore;
- switch (type) {
- case 'copper':
- matgain = (1 + userData.game.mining_matgain) - 1;
- expgain = (1 + userData.game.mining_expgain) - 1;
- ore = 'copper_ore';
- break;
- case 'iron':
- matgain = (1 + userData.game.mining_matgain) - 1;
- expgain = (4 + userData.game.mining_expgain) - 1;
- ore = 'iron_ore';
- break;
- case 'silver':
- matgain = (1 + userData.game.mining_matgain) - 1;
- expgain = (9 + userData.game.mining_expgain) - 1;
- ore = 'silver_ore';
- break;
- case 'malachite':
- matgain = (1 + userData.game.mining_matgain) - 1;
- expgain = (16 + userData.game.mining_expgain) - 1;
- ore = 'malachite_ore';
- break;
- case 'cobalt':
- matgain = (1 + userData.game.mining_matgain) - 1;
- expgain = (25 + userData.game.mining_expgain) - 1;
- ore = 'cobalt_ore';
- break;
- default:
- return msg.reply('You did not produce the correct arguments');
- }
- // Update table
- sql = `UPDATE users_meta SET ${ore} = ${ore} + ${matgain}, tsexp = tsexp + ${expgain} WHERE userid = ?`;
- db.query(sql, userData.id, (err) => {
- if (err) { return console.log(err); }
- stats.yield += matgain;
- stats.exp += expgain;
- stats.actions--;
- });
- if (stats.actions <= 0) {
- // The report DM
- userData.send({ embed: {
- color: 3447003,
- title: `Lumber Report For ${type}`,
- fields: [{
- name: 'Stats',
- value:
- 'Gathered: ' + stats.yield +
- '\nEXP Gained: ' + stats.exp,
- },
- ],
- },
- });
- //Reset stats for Report
- stats = {
- exp: 0,
- actions: amount,
- yield: 0,
- };
- }
- // start stone block
- } else if (what === 'stone') {
- // exp and yield calculations
- var chunks;
- switch (type) {
- case 'basalt':
- matgain = (1 + userData.game.mining_matgain) - 1;
- expgain = (1 + userData.game.mining_expgain) - 1;
- chunks = 'basalt_chunk';
- break;
- case 'granite':
- matgain = (1 + userData.game.mining_matgain) - 1;
- expgain = (4 + userData.game.mining_expgain) - 1;
- chunks = 'granite_chunk';
- break;
- case 'quartz':
- matgain = (1 + userData.game.mining_matgain) - 1;
- expgain = (9 + userData.game.mining_expgain) - 1;
- chunks = 'quartz_chunk';
- break;
- case 'marble':
- matgain = (1 + userData.game.mining_matgain) - 1;
- expgain = (16 + userData.game.mining_expgain) - 1;
- chunks = 'marble_chunk';
- break;
- case 'obsidian':
- matgain = (1 + userData.game.mining_matgain) - 1;
- expgain = (25 + userData.game.mining_expgain) - 1;
- chunks = 'obsidian_chunk';
- break;
- default:
- return msg.reply('You did not produce the correct arguments');
- }
- // Update table
- sql = `UPDATE users_meta SET ${chunks} = ${chunks} + ${matgain}, tsexp = tsexp + ${expgain} WHERE userid = ?`;
- db.query(sql, userData.id, (err) => {
- if (err) { return console.log(err); }
- stats.yield += matgain;
- stats.exp += expgain;
- stats.actions--;
- });
- if (stats.actions <= 0) {
- // The report DM
- userData.send({ embed: {
- color: 3447003,
- title: `Lumber Report For ${type}`,
- fields: [{
- name: 'Stats',
- value:
- 'Gathered: ' + stats.yield +
- '\nEXP Gained: ' + stats.exp,
- },
- ],
- },
- });
- //Reset stats for Report
- stats = {
- exp: 0,
- actions: amount,
- yield: 0,
- };
- }
- }
- },
- };
Advertisement
Add Comment
Please, Sign In to add comment