eslint
This commit is contained in:
@ -1,47 +1,48 @@
|
||||
module.exports = async (message, args, db) => {
|
||||
try {
|
||||
console.log(message.author.tag + ': ' + args)
|
||||
if (!isNaN(args[0])) {
|
||||
message.reply(args[1])
|
||||
console.log('1: ' + args[1] + ', 2: ' + args[2])
|
||||
const money = ["gold", "silver", "bronce", "iron", "hp"]
|
||||
if (money.indexOf(args[1].toLowerCase()) < 0) {
|
||||
message.reply(
|
||||
'Sorry, Aber du musst eins der folgenden Wörter angeben: ' + money.join(",")
|
||||
)
|
||||
return;
|
||||
}
|
||||
db.find({
|
||||
user: message.author.tag
|
||||
}, function (err, docs) {
|
||||
try {
|
||||
console.log(message.author.tag + ': ' + args);
|
||||
if (!isNaN(args[0])) {
|
||||
message.reply(args[1]);
|
||||
console.log('1: ' + args[1] + ', 2: ' + args[2]);
|
||||
const money = ['gold', 'silver', 'bronce', 'iron', 'hp'];
|
||||
if (money.indexOf(args[1].toLowerCase()) < 0) {
|
||||
message.reply(
|
||||
'Sorry, Aber du musst eins der folgenden Wörter angeben: ' + money.join(','),
|
||||
);
|
||||
return;
|
||||
}
|
||||
db.find({
|
||||
user: message.author.tag,
|
||||
}, function(err, docs) {
|
||||
|
||||
gold = docs[0].gold
|
||||
silver = docs[0].silver
|
||||
bronce = docs[0].bronce
|
||||
iron = docs[0].iron
|
||||
hp = docs[0].hp
|
||||
gold = docs[0].gold;
|
||||
silver = docs[0].silver;
|
||||
bronce = docs[0].bronce;
|
||||
iron = docs[0].iron;
|
||||
hp = docs[0].hp;
|
||||
|
||||
})
|
||||
db.update({
|
||||
user: message.author.tag
|
||||
}, {
|
||||
gold: gold,
|
||||
silver: silver,
|
||||
bronce: bronce,
|
||||
iron: iron,
|
||||
hp: hp
|
||||
}, function (err, docs) {
|
||||
if (!docs.length > 0) {
|
||||
message.reply('Sorry, Für dich habe ich keinen Eintrag 😥')
|
||||
return;
|
||||
}
|
||||
message.reply(`ich habe ${args[2]} zu ${args[1]} hinzugefügt.`)
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
});
|
||||
db.update({
|
||||
user: message.author.tag,
|
||||
}, {
|
||||
gold: gold,
|
||||
silver: silver,
|
||||
bronce: bronce,
|
||||
iron: iron,
|
||||
hp: hp,
|
||||
}, function(err, docs) {
|
||||
if (!docs.length > 0) {
|
||||
message.reply('Sorry, Für dich habe ich keinen Eintrag 😥');
|
||||
return;
|
||||
}
|
||||
message.reply(`ich habe ${args[2]} zu ${args[1]} hinzugefügt.`);
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
module.exports = async (message, args, db) => {
|
||||
|
@ -1,20 +1,22 @@
|
||||
module.exports = async (message, args, db) => {
|
||||
try {
|
||||
console.log(message)
|
||||
db.find({
|
||||
user: message.author.tag
|
||||
}, function (err, docs) {
|
||||
if(!docs.length>0)
|
||||
db.insert({user: message.author.tag,
|
||||
gold: 0,
|
||||
silver: 0,
|
||||
bronce: 0,
|
||||
iron: 0,
|
||||
hp: 0
|
||||
})
|
||||
console.log(docs)
|
||||
});
|
||||
} catch (e) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
try {
|
||||
console.log(message);
|
||||
db.find({
|
||||
user: message.author.tag,
|
||||
}, function(err, docs) {
|
||||
if(!docs.length > 0) {
|
||||
db.insert({ user: message.author.tag,
|
||||
gold: 0,
|
||||
silver: 0,
|
||||
bronce: 0,
|
||||
iron: 0,
|
||||
hp: 0,
|
||||
});
|
||||
}
|
||||
console.log(docs);
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
throw e;
|
||||
}
|
||||
};
|
@ -1,24 +1,26 @@
|
||||
module.exports = async (message, data, db) => {
|
||||
try {
|
||||
console.log(message.channel)
|
||||
db.find({
|
||||
user: message.author.tag
|
||||
}, function (err, docs) {
|
||||
if (!docs.length > 0)
|
||||
db.insert({
|
||||
user: message.author.tag,
|
||||
gold: 0,
|
||||
silver: 0,
|
||||
bronce: 0,
|
||||
iron: 0,
|
||||
hp: 0,
|
||||
character: data
|
||||
}, function (err, docs) {
|
||||
message.reply('Ich habe deine Daten abgespeichert.')
|
||||
//console.log(docs[0].character.name)
|
||||
})
|
||||
});
|
||||
} catch (e) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
try {
|
||||
console.log(message.channel);
|
||||
db.find({
|
||||
user: message.author.tag,
|
||||
}, function(err, docs) {
|
||||
if (!docs.length > 0) {
|
||||
db.insert({
|
||||
user: message.author.tag,
|
||||
gold: 0,
|
||||
silver: 0,
|
||||
bronce: 0,
|
||||
iron: 0,
|
||||
hp: 0,
|
||||
character: data,
|
||||
}, function(err, docs) {
|
||||
message.reply('Ich habe deine Daten abgespeichert.');
|
||||
// console.log(docs[0].character.name)
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
throw e;
|
||||
}
|
||||
};
|
@ -1,61 +1,65 @@
|
||||
const fs = require('fs');
|
||||
const fetch = require('node-fetch')
|
||||
const fetch = require('node-fetch');
|
||||
const roll = require('./roll');
|
||||
const create = require('./create');
|
||||
const add = require('./add');
|
||||
const remove = require('./remove');
|
||||
const show = require('./show');
|
||||
const tp = require('./tp')
|
||||
const talent = require('./talent')
|
||||
const skill = require('./skill')
|
||||
const createFromFile = require('./createFromFile')
|
||||
const tp = require('./tp');
|
||||
const talent = require('./talent');
|
||||
const skill = require('./skill');
|
||||
const createFromFile = require('./createFromFile');
|
||||
require('dotenv').config();
|
||||
|
||||
const prefix = process.env.PREFIX || '!';
|
||||
|
||||
const commands = {
|
||||
roll,
|
||||
create,
|
||||
add,
|
||||
remove,
|
||||
show,
|
||||
skill,
|
||||
tp,
|
||||
talent,
|
||||
roll,
|
||||
create,
|
||||
add,
|
||||
remove,
|
||||
show,
|
||||
skill,
|
||||
tp,
|
||||
talent,
|
||||
};
|
||||
var Datastore = require('nedb'),
|
||||
db = new Datastore({
|
||||
filename: 'dsabot.db',
|
||||
autoload: true
|
||||
});
|
||||
const Datastore = require('nedb'),
|
||||
db = new Datastore({
|
||||
filename: 'dsabot.db',
|
||||
autoload: true,
|
||||
});
|
||||
|
||||
module.exports = async (message) => {
|
||||
if ((message.attachments.size > 0) && message.channel.type == 'dm') {
|
||||
try {
|
||||
let response = await fetch(message.attachments.first().url)
|
||||
let data = await validateJSON(response);
|
||||
if (data) createFromFile(message, data, db);
|
||||
} catch (e) {
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
|
||||
if (!message.content.startsWith(prefix) || message.author.bot) return;
|
||||
const args = message.content.slice(prefix.length).split(' ');
|
||||
const command = args.shift().toLowerCase();
|
||||
if (Object.keys(commands).includes(command)) {
|
||||
commands[command](message, args, db);
|
||||
}
|
||||
}
|
||||
console.log(`${new Date().toUTCString} ${message.author.tag}`)
|
||||
if ((message.attachments.size > 0) && message.channel.type == 'dm') {
|
||||
try {
|
||||
const response = await fetch(message.attachments.first().url);
|
||||
const data = await validateJSON(response);
|
||||
if (data) createFromFile(message, data, db);
|
||||
}
|
||||
catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if (!message.content.startsWith(prefix) || message.author.bot) return;
|
||||
const args = message.content.slice(prefix.length).split(' ');
|
||||
const command = args.shift().toLowerCase();
|
||||
if (Object.keys(commands).includes(command)) {
|
||||
commands[command](message, args, db);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function validateJSON(body) {
|
||||
try {
|
||||
var data = body.json();
|
||||
// if came to here, then valid
|
||||
return data;
|
||||
} catch (e) {
|
||||
// failed to parse
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const data = body.json();
|
||||
// if came to here, then valid
|
||||
return data;
|
||||
}
|
||||
catch (e) {
|
||||
// failed to parse
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,46 +1,53 @@
|
||||
module.exports = async (message, args, db) => {
|
||||
var n;
|
||||
let n;
|
||||
|
||||
if(!isNaN(args[0]) && (args[1] === 'GD' || args[1] === 'ST' || args[1] === 'BH' || args[1] === 'EK')) {
|
||||
// eslint-disable-next-line no-undef
|
||||
db.query('SELECT * FROM dsageld WHERE userName = ' + '"' + message.author.tag + '"', function(err, row) { //the row is the user's data
|
||||
if(row && err) {
|
||||
message.reply('Es gab einen Fehler.');
|
||||
}
|
||||
if(typeof(row) == 'undefined') { //if the user is not in the database
|
||||
message.reply('Es existiert kein Eintrag für dich füge ihn mit !create hinzu.');
|
||||
} else { //if the user is in the database
|
||||
|
||||
if(args[1] === 'GD') {
|
||||
n = parseInt(row[0].GD, 10) - parseInt(args[0], 10);
|
||||
} else if(args[1] === 'ST') {
|
||||
n = parseInt(row[0].ST, 10) - parseInt(args[0], 10);
|
||||
} else if(args[1] === 'BH') {
|
||||
n = parseInt(row[0].BH, 10) - parseInt(args[0], 10);
|
||||
} else if(args[1] === 'EK') {
|
||||
n = parseInt(row[0].EK, 10) - parseInt(args[0], 10);
|
||||
} else if(args[1] === 'LP') {
|
||||
n = parseInt(row[0].EK, 10) - parseInt(args[0], 10);
|
||||
}
|
||||
|
||||
if(n >= 0) {
|
||||
// eslint-disable-next-line no-undef
|
||||
db.query('UPDATE dsageld SET' + '`' + args[1] + '`' + ' = (' + n + ') WHERE userName = ' + '"' + message.author.tag + '"');
|
||||
// eslint-disable-next-line no-undef
|
||||
db.query('SELECT * FROM dsageld WHERE userName = ' + '"' + message.author.tag + '"', function(err, row) { //the row is the user's data
|
||||
message.reply(args[0] + args[1] + ' abgezogen, du hast: ' + row[0].GD + 'GD, ' + row[0].ST + 'ST, ' + row[0].BH + 'BH, ' + row[0].EK + 'EK,' + row[0].LP + 'LeP.');
|
||||
});
|
||||
} else if(n < 0 && !(args[1] === 'LP')) {
|
||||
message.reply('du hast nicht genügend ' + args[1] );
|
||||
} else if(n < 0 && args[1] === 'LP') {
|
||||
// eslint-disable-next-line no-undef
|
||||
db.query('UPDATE dsageld SET' + '`' + args[1] + '`' + ' = (' + n + ') WHERE userName = ' + '"' + message.author.tag + '"');
|
||||
// eslint-disable-next-line no-undef
|
||||
db.query('SELECT * FROM dsageld WHERE userName = ' + '"' + message.author.tag + '"', function(err, row) { //the row is the user's data
|
||||
message.reply('Deine LeP sind unter Null: ' + n + ' LeP.');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if(!isNaN(args[0]) && (args[1] === 'GD' || args[1] === 'ST' || args[1] === 'BH' || args[1] === 'EK')) {
|
||||
// eslint-disable-next-line no-undef
|
||||
db.query('SELECT * FROM dsageld WHERE userName = ' + '"' + message.author.tag + '"', function(err, row) { // the row is the user's data
|
||||
if(row && err) {
|
||||
message.reply('Es gab einen Fehler.');
|
||||
}
|
||||
if(typeof (row) == 'undefined') { // if the user is not in the database
|
||||
message.reply('Es existiert kein Eintrag für dich füge ihn mit !create hinzu.');
|
||||
}
|
||||
else { // if the user is in the database
|
||||
|
||||
if(args[1] === 'GD') {
|
||||
n = parseInt(row[0].GD, 10) - parseInt(args[0], 10);
|
||||
}
|
||||
else if(args[1] === 'ST') {
|
||||
n = parseInt(row[0].ST, 10) - parseInt(args[0], 10);
|
||||
}
|
||||
else if(args[1] === 'BH') {
|
||||
n = parseInt(row[0].BH, 10) - parseInt(args[0], 10);
|
||||
}
|
||||
else if(args[1] === 'EK') {
|
||||
n = parseInt(row[0].EK, 10) - parseInt(args[0], 10);
|
||||
}
|
||||
else if(args[1] === 'LP') {
|
||||
n = parseInt(row[0].EK, 10) - parseInt(args[0], 10);
|
||||
}
|
||||
|
||||
if(n >= 0) {
|
||||
// eslint-disable-next-line no-undef
|
||||
db.query('UPDATE dsageld SET' + '`' + args[1] + '`' + ' = (' + n + ') WHERE userName = ' + '"' + message.author.tag + '"');
|
||||
// eslint-disable-next-line no-undef
|
||||
db.query('SELECT * FROM dsageld WHERE userName = ' + '"' + message.author.tag + '"', function(err, row) { // the row is the user's data
|
||||
message.reply(args[0] + args[1] + ' abgezogen, du hast: ' + row[0].GD + 'GD, ' + row[0].ST + 'ST, ' + row[0].BH + 'BH, ' + row[0].EK + 'EK,' + row[0].LP + 'LeP.');
|
||||
});
|
||||
}
|
||||
else if(n < 0 && !(args[1] === 'LP')) {
|
||||
message.reply('du hast nicht genügend ' + args[1]);
|
||||
}
|
||||
else if(n < 0 && args[1] === 'LP') {
|
||||
// eslint-disable-next-line no-undef
|
||||
db.query('UPDATE dsageld SET' + '`' + args[1] + '`' + ' = (' + n + ') WHERE userName = ' + '"' + message.author.tag + '"');
|
||||
// eslint-disable-next-line no-undef
|
||||
db.query('SELECT * FROM dsageld WHERE userName = ' + '"' + message.author.tag + '"', function(err, row) { // the row is the user's data
|
||||
message.reply('Deine LeP sind unter Null: ' + n + ' LeP.');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
@ -1,17 +1,18 @@
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
module.exports = async (message, args, db) => {
|
||||
if (!args.length == 3) {
|
||||
message.reply('Du hast die Würfel nicht korrekt angegeben.');
|
||||
}
|
||||
if (!args.length == 3) {
|
||||
message.reply('Du hast die Würfel nicht korrekt angegeben.');
|
||||
}
|
||||
|
||||
else if(!isNaN(args[0]) && !isNaN(args[2]) && args[0] > 0 && args[2] > 0) {
|
||||
var roll = [];
|
||||
for (let i = 0; i < args[0]; i++) {
|
||||
var a = Math.floor(Math.random() * args[2]) + 1;
|
||||
roll.push(a);
|
||||
}
|
||||
message.reply('Deine Würfe(' + args[0] + 'W' + args[2] + '): ' + roll.join(', ') + '.');
|
||||
} else {
|
||||
message.reply('Du hast die Würfel nicht korrekt angegeben.');
|
||||
}
|
||||
else if(!isNaN(args[0]) && !isNaN(args[2]) && args[0] > 0 && args[2] > 0) {
|
||||
const roll = [];
|
||||
for (let i = 0; i < args[0]; i++) {
|
||||
const a = Math.floor(Math.random() * args[2]) + 1;
|
||||
roll.push(a);
|
||||
}
|
||||
message.reply('Deine Würfe(' + args[0] + 'W' + args[2] + '): ' + roll.join(', ') + '.');
|
||||
}
|
||||
else {
|
||||
message.reply('Du hast die Würfel nicht korrekt angegeben.');
|
||||
}
|
||||
};
|
@ -1,27 +1,28 @@
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
module.exports = async (message, args, db) => {
|
||||
// eslint-disable-next-line no-undef
|
||||
try {
|
||||
console.log(message)
|
||||
db.find({
|
||||
user: message.author.tag
|
||||
}, function (err, docs) {
|
||||
// docs is an array containing documents Mars, Earth, Jupiter If no document is
|
||||
// found, docs is equal to []
|
||||
if (!docs.length > 0)
|
||||
message.reply('Sorry, Für dich habe ich keinen Eintrag 😥')
|
||||
else
|
||||
message.reply(
|
||||
`Du besitzt folgendes:
|
||||
${docs[0].silver} Silberstücke.`
|
||||
)
|
||||
});
|
||||
} catch (e) {
|
||||
throw e
|
||||
}
|
||||
// eslint-disable-next-line no-undef
|
||||
try {
|
||||
console.log(message);
|
||||
db.find({
|
||||
user: message.author.tag,
|
||||
}, function(err, docs) {
|
||||
// docs is an array containing documents Mars, Earth, Jupiter If no document is
|
||||
// found, docs is equal to []
|
||||
if (!docs.length > 0) {message.reply('Sorry, Für dich habe ich keinen Eintrag 😥');}
|
||||
else {
|
||||
message.reply(
|
||||
`Du besitzt folgendes:
|
||||
${docs[0].silver} Silberstücke.`,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
/* db.query('SELECT * FROM dsageld WHERE userName = ' + '"' + message.author.tag + '"', function(err, row) { //the row is the user's data
|
||||
/* db.query('SELECT * FROM dsageld WHERE userName = ' + '"' + message.author.tag + '"', function(err, row) { //the row is the user's data
|
||||
if(row && err) {
|
||||
message.reply('Es gab einen Fehler.');
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
module.exports = async (message, args, db) => {
|
||||
try {
|
||||
db.find({
|
||||
user: message.author.tag
|
||||
}, function (err, docs) {
|
||||
if (!docs.length > 0)
|
||||
message.reply('Sorry, Für dich habe ich keinen Eintrag 😥')
|
||||
else {
|
||||
let level = 0
|
||||
for(i in docs[0].character.skills) {
|
||||
if(docs[0].character.skills[i].id == args[0]) level = docs[0].character.skills[i].level
|
||||
}
|
||||
message.reply('Du hast Folgenden Skill in ' + args[0] + ': ' + level)
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
throw e
|
||||
}
|
||||
try {
|
||||
db.find({
|
||||
user: message.author.tag,
|
||||
}, function(err, docs) {
|
||||
if (!docs.length > 0) {message.reply('Sorry, Für dich habe ich keinen Eintrag 😥');}
|
||||
else {
|
||||
let level = 0;
|
||||
for(i in docs[0].character.skills) {
|
||||
if(docs[0].character.skills[i].id == args[0]) level = docs[0].character.skills[i].level;
|
||||
}
|
||||
message.reply('Du hast Folgenden Skill in ' + args[0] + ': ' + level);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
throw e;
|
||||
}
|
||||
};
|
@ -1,81 +1,84 @@
|
||||
const globals = require('../globals')
|
||||
const globals = require('../globals');
|
||||
module.exports = async (message, args, db) => {
|
||||
try {
|
||||
db.find({
|
||||
user: message.author.tag
|
||||
}, function (err, docs) {
|
||||
if (!docs.length > 0)
|
||||
message.reply('Sorry, Für dich habe ich keinen Eintrag 😥')
|
||||
else {
|
||||
if (!args) message.reply('Sorry, du musst mir schon etwas zum prüfen geben.')
|
||||
if (args[1]) {
|
||||
var erschwernis = parseInt(args[1]);
|
||||
} else {
|
||||
erschwernis = 0;
|
||||
}
|
||||
let values = []
|
||||
var roll = [];
|
||||
let bonus = 0;
|
||||
var ok = 0;
|
||||
var patzer = 0;
|
||||
var crit = 0;
|
||||
for (i in docs[0].character.skills) {
|
||||
if (docs[0].character.skills[i].id == args[0]) bonus = docs[0].character.skills[i].level
|
||||
}
|
||||
let bonus_orig = bonus
|
||||
const result = globals.Talente.find(talent => talent.id === args[0]);
|
||||
try {
|
||||
db.find({
|
||||
user: message.author.tag,
|
||||
}, function(err, docs) {
|
||||
if (!docs.length > 0) {message.reply('Sorry, Für dich habe ich keinen Eintrag 😥');}
|
||||
else {
|
||||
if (!args) message.reply('Sorry, du musst mir schon etwas zum prüfen geben.');
|
||||
if (args[1]) {
|
||||
var erschwernis = parseInt(args[1]);
|
||||
}
|
||||
else {
|
||||
erschwernis = 0;
|
||||
}
|
||||
const values = [];
|
||||
const roll = [];
|
||||
let bonus = 0;
|
||||
let ok = 0;
|
||||
let patzer = 0;
|
||||
let crit = 0;
|
||||
for (i in docs[0].character.skills) {
|
||||
if (docs[0].character.skills[i].id == args[0]) bonus = docs[0].character.skills[i].level;
|
||||
}
|
||||
const bonus_orig = bonus;
|
||||
const result = globals.Talente.find(talent => talent.id === args[0]);
|
||||
|
||||
for (i in result.values) {
|
||||
let kuerzel = globals.Werte.find(wert => wert.kuerzel === result.values[i])
|
||||
for (val in docs[0].character.attributes) {
|
||||
if (docs[0].character.attributes[val].id == kuerzel.id) values.push(docs[0].character.attributes[val].level)
|
||||
}
|
||||
}
|
||||
//message.reply(`Du musst mit ${result.values.join(", ")} würfeln. Die werte sind: ${values.join(", ")}. Dein Bonus auf ${result.name}: ${bonus}`)
|
||||
for (i in result.values) {
|
||||
const kuerzel = globals.Werte.find(wert => wert.kuerzel === result.values[i]);
|
||||
for (val in docs[0].character.attributes) {
|
||||
if (docs[0].character.attributes[val].id == kuerzel.id) values.push(docs[0].character.attributes[val].level);
|
||||
}
|
||||
}
|
||||
// message.reply(`Du musst mit ${result.values.join(", ")} würfeln. Die werte sind: ${values.join(", ")}. Dein Bonus auf ${result.name}: ${bonus}`)
|
||||
|
||||
|
||||
// roll dice.
|
||||
for (i = 1; i <= 3; i++) {
|
||||
var a = Math.floor(Math.random() * 20 + 1);
|
||||
roll.push(a);
|
||||
}
|
||||
// compare results
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (Math.floor(values[i] + parseInt(erschwernis)) >= roll[i])
|
||||
ok++;
|
||||
else if ((Math.floor(values[i]) + parseInt(bonus) + parseInt(erschwernis)) >= roll[i]) {
|
||||
ok++;
|
||||
bonus = bonus - (roll[i] - parseInt(erschwernis) - values[i]);
|
||||
}
|
||||
if (roll[i] == 1) crit++;
|
||||
if (roll[i] == 20) patzer++;
|
||||
}
|
||||
if (patzer >= 2) {
|
||||
message.reply("Du würfelst auf das Talent " + result.name + ".\n"+
|
||||
"Deine Werte für " + result.values.join(", ") + " sind " + values.join(", ") + ".\n" +
|
||||
"Deine 🎲: " + roll.join(", ") + ". Patzer! Du hast aber auch Pech 😥"
|
||||
);
|
||||
} else if (crit >= 2) {
|
||||
message.reply("Du würfelst auf das Talent " + result.name + ".\n"+
|
||||
"Deine Werte für " + result.values.join(", ") + " sind " + values.join(", ") + ".\n" +
|
||||
"Deine 🎲: " + roll.join(", ") + ". Damit hast du einen kritischen Erfolg erzielt 🎈✨🥳"
|
||||
);
|
||||
} else if (ok < 3) {
|
||||
message.reply("Du würfelst auf das Talent " + result.name + ".\n"+
|
||||
"Deine Werte für " + result.values.join(", ") + " sind " + values.join(", ") + ". (Bonus: " + bonus_orig + ")\n" +
|
||||
"Deine 🎲: " + roll.join(", ") + ". Damit hast du nur " + ok + "/3 Proben bestanden. 😪"
|
||||
);
|
||||
} else {
|
||||
message.reply("Du würfelst auf das Talent " + result.name + ".\n"+
|
||||
"Deine Werte für " + result.values.join(", ") + " sind " + values.join(", ") + ". (Bonus: " + bonus_orig + ")\n" +
|
||||
"Das waren deine 🎲: " + roll.join(", ") + ". Damit hast du " + ok + "/3 Proben bestanden. Dein Bonus: " + bonus + "/" + bonus_orig + "."
|
||||
);
|
||||
}
|
||||
// roll dice.
|
||||
for (i = 1; i <= 3; i++) {
|
||||
const a = Math.floor(Math.random() * 20 + 1);
|
||||
roll.push(a);
|
||||
}
|
||||
// compare results
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (Math.floor(values[i] + parseInt(erschwernis)) >= roll[i]) {ok++;}
|
||||
else if ((Math.floor(values[i]) + parseInt(bonus) + parseInt(erschwernis)) >= roll[i]) {
|
||||
ok++;
|
||||
bonus = bonus - (roll[i] - parseInt(erschwernis) - values[i]);
|
||||
}
|
||||
if (roll[i] == 1) crit++;
|
||||
if (roll[i] == 20) patzer++;
|
||||
}
|
||||
if (patzer >= 2) {
|
||||
message.reply('Du würfelst auf das Talent ' + result.name + '.\n' +
|
||||
'Deine Werte für ' + result.values.join(', ') + ' sind ' + values.join(', ') + '.\n' +
|
||||
'Deine 🎲: ' + roll.join(', ') + '. Patzer! Du hast aber auch Pech 😥',
|
||||
);
|
||||
}
|
||||
else if (crit >= 2) {
|
||||
message.reply('Du würfelst auf das Talent ' + result.name + '.\n' +
|
||||
'Deine Werte für ' + result.values.join(', ') + ' sind ' + values.join(', ') + '.\n' +
|
||||
'Deine 🎲: ' + roll.join(', ') + '. Damit hast du einen kritischen Erfolg erzielt 🎈✨🥳',
|
||||
);
|
||||
}
|
||||
else if (ok < 3) {
|
||||
message.reply('Du würfelst auf das Talent ' + result.name + '.\n' +
|
||||
'Deine Werte für ' + result.values.join(', ') + ' sind ' + values.join(', ') + '. (Bonus: ' + bonus_orig + ')\n' +
|
||||
'Deine 🎲: ' + roll.join(', ') + '. Damit hast du nur ' + ok + '/3 Proben bestanden. 😪',
|
||||
);
|
||||
}
|
||||
else {
|
||||
message.reply('Du würfelst auf das Talent ' + result.name + '.\n' +
|
||||
'Deine Werte für ' + result.values.join(', ') + ' sind ' + values.join(', ') + '. (Bonus: ' + bonus_orig + ')\n' +
|
||||
'Das waren deine 🎲: ' + roll.join(', ') + '. Damit hast du ' + ok + '/3 Proben bestanden. Dein Bonus: ' + bonus + '/' + bonus_orig + '.',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
throw e;
|
||||
}
|
||||
};
|
@ -1,54 +1,59 @@
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
module.exports = async (message, args, db) => {
|
||||
if (args.length < 3) {
|
||||
message.reply("Der Talentwurf funktioniert so:\n"+
|
||||
"!tp Eigenschaftswert1 Eigenschaftswert2 Eigenschaftswert3 [Bonus] [Erschwernis]");
|
||||
} else {
|
||||
var roll = [];
|
||||
if (args[3]) {
|
||||
var bonus = parseInt(args[3]);
|
||||
} else {
|
||||
bonus = 0;
|
||||
}
|
||||
if (args[4]) {
|
||||
var erschwernis = parseInt(args[4]);
|
||||
} else {
|
||||
erschwernis = 0;
|
||||
}
|
||||
for (i = 1; i <= 3; i++) {
|
||||
var a = Math.floor(Math.random() * 20 + 1);
|
||||
roll.push(a);
|
||||
}
|
||||
var ok = 0;
|
||||
var patzer = 0;
|
||||
var crit = 0;
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (Math.floor(parseInt(args[i]) + parseInt(erschwernis)) >= roll[i])
|
||||
ok++;
|
||||
else if (
|
||||
Math.floor(parseInt(args[i]) + parseInt(bonus) + parseInt(erschwernis)) >= roll[i]) {
|
||||
ok++;
|
||||
bonus = bonus - (roll[i] - parseInt(erschwernis) - parseInt(args[i]));
|
||||
}
|
||||
if (roll[i] == 1) crit++;
|
||||
if (roll[i] == 20) patzer++;
|
||||
}
|
||||
if (patzer >= 2) {
|
||||
message.reply(
|
||||
"Deine 🎲: " + roll.join(", ") + ". Patzer! Du hast aber auch Pech 😥"
|
||||
);
|
||||
} else if (crit >= 2) {
|
||||
message.reply(
|
||||
"Deine 🎲: " + roll.join(", ") + ". Damit hast du einen kritischen Erfolg erzielt 🎈✨🥳"
|
||||
);
|
||||
} else if (ok < 3) {
|
||||
message.reply(
|
||||
"Deine 🎲: " + roll.join(", ") + ". Damit hast du nur " + ok + "/3 Proben bestanden. 😪"
|
||||
);
|
||||
} else {
|
||||
message.reply(
|
||||
"Das waren deine 🎲: " + roll.join(", ") + ". Damit hast du " + ok + "/3 Proben bestanden. Dein Bonus: " + bonus + "/" + args[3] + "."
|
||||
);
|
||||
}
|
||||
}
|
||||
if (args.length < 3) {
|
||||
message.reply('Der Talentwurf funktioniert so:\n' +
|
||||
'!tp Eigenschaftswert1 Eigenschaftswert2 Eigenschaftswert3 [Bonus] [Erschwernis]');
|
||||
}
|
||||
else {
|
||||
const roll = [];
|
||||
if (args[3]) {
|
||||
var bonus = parseInt(args[3]);
|
||||
}
|
||||
else {
|
||||
bonus = 0;
|
||||
}
|
||||
if (args[4]) {
|
||||
var erschwernis = parseInt(args[4]);
|
||||
}
|
||||
else {
|
||||
erschwernis = 0;
|
||||
}
|
||||
for (i = 1; i <= 3; i++) {
|
||||
const a = Math.floor(Math.random() * 20 + 1);
|
||||
roll.push(a);
|
||||
}
|
||||
let ok = 0;
|
||||
let patzer = 0;
|
||||
let crit = 0;
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (Math.floor(parseInt(args[i]) + parseInt(erschwernis)) >= roll[i]) {ok++;}
|
||||
else if (
|
||||
Math.floor(parseInt(args[i]) + parseInt(bonus) + parseInt(erschwernis)) >= roll[i]) {
|
||||
ok++;
|
||||
bonus = bonus - (roll[i] - parseInt(erschwernis) - parseInt(args[i]));
|
||||
}
|
||||
if (roll[i] == 1) crit++;
|
||||
if (roll[i] == 20) patzer++;
|
||||
}
|
||||
if (patzer >= 2) {
|
||||
message.reply(
|
||||
'Deine 🎲: ' + roll.join(', ') + '. Patzer! Du hast aber auch Pech 😥',
|
||||
);
|
||||
}
|
||||
else if (crit >= 2) {
|
||||
message.reply(
|
||||
'Deine 🎲: ' + roll.join(', ') + '. Damit hast du einen kritischen Erfolg erzielt 🎈✨🥳',
|
||||
);
|
||||
}
|
||||
else if (ok < 3) {
|
||||
message.reply(
|
||||
'Deine 🎲: ' + roll.join(', ') + '. Damit hast du nur ' + ok + '/3 Proben bestanden. 😪',
|
||||
);
|
||||
}
|
||||
else {
|
||||
message.reply(
|
||||
'Das waren deine 🎲: ' + roll.join(', ') + '. Damit hast du ' + ok + '/3 Proben bestanden. Dein Bonus: ' + bonus + '/' + args[3] + '.',
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user