Merge pull request #1 from TobenderZephyr/development
Merge current development branch to master.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
node_modules
|
||||
.env
|
||||
.eslintrc.js
|
||||
|
||||
.eslintrc.json
|
||||
dsabot.db
|
||||
|
||||
|
15
Dockerfile
Normal file
15
Dockerfile
Normal file
@ -0,0 +1,15 @@
|
||||
FROM node:alpine
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
ARG NODE_ENV
|
||||
ENV NODE_ENV $NODE_ENV
|
||||
|
||||
COPY package.json /usr/src/app/
|
||||
RUN npm install
|
||||
|
||||
COPY . /usr/src/app
|
||||
|
||||
# replace this with your application's default port
|
||||
EXPOSE 3000
|
||||
CMD [ "npm", "start" ]
|
0
data/dsabot.db
Normal file
0
data/dsabot.db
Normal file
1815
package-lock.json
generated
1815
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,12 +10,12 @@
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"discord.js": "^12.0.2",
|
||||
"discord.js": "^12.5.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"mysql": "^2.18.1",
|
||||
"nodemon": "^2.0.2"
|
||||
"nedb": "^1.8.0",
|
||||
"node-fetch": "^2.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^6.8.0"
|
||||
"jest": "^26.6.3"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,50 @@
|
||||
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) {
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
module.exports = async (message, args, db) => {
|
||||
var n;
|
||||
|
||||
@ -21,7 +68,7 @@ module.exports = async (message, args, db) => {
|
||||
} else if(args[1] === 'LP') {
|
||||
n = parseInt(row[0].EK, 10) + parseInt(args[0], 10);
|
||||
}
|
||||
// eslint-disable-next-line no-undef
|
||||
// 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
|
||||
@ -30,4 +77,5 @@ module.exports = async (message, args, db) => {
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
*/
|
@ -1,12 +1,22 @@
|
||||
module.exports = async (message, args, db) => {
|
||||
// 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.length < 1) {
|
||||
// eslint-disable-next-line no-undef
|
||||
db.query('INSERT INTO `dsageld` (`userName`, `GD`,`ST`, `BH`, `EK`, `LP`) VALUES (' + '"' + message.author.tag + '"' + ', 0, 0, 0, 0, 0)');
|
||||
message.reply('Dein Eintrag wurde registriert.');
|
||||
} else if(row.length >= 1) {
|
||||
message.reply('Dein Eintrag existiert bereits.');
|
||||
}
|
||||
});
|
||||
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;
|
||||
}
|
||||
};
|
26
src/commands/createFromFile.js
Normal file
26
src/commands/createFromFile.js
Normal file
@ -0,0 +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;
|
||||
}
|
||||
};
|
@ -1,44 +1,65 @@
|
||||
const fs = require('fs');
|
||||
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 mysql = require('mysql');
|
||||
const tp = require('./tp');
|
||||
const talent = require('./talent');
|
||||
const skill = require('./skill');
|
||||
const createFromFile = require('./createFromFile');
|
||||
require('dotenv').config();
|
||||
const prefix = '!';
|
||||
|
||||
const cmdprefix = process.env.CMDPREFIX || '!';
|
||||
|
||||
const commands = {
|
||||
roll,
|
||||
create,
|
||||
add,
|
||||
remove,
|
||||
show
|
||||
roll,
|
||||
create,
|
||||
add,
|
||||
remove,
|
||||
show,
|
||||
skill,
|
||||
tp,
|
||||
talent,
|
||||
};
|
||||
const Datastore = require('nedb'),
|
||||
db = new Datastore({
|
||||
filename: 'data/dsabot.db',
|
||||
autoload: true,
|
||||
});
|
||||
|
||||
module.exports = async (message) => {
|
||||
console.log(`${new Date().toUTCString()} ${message.author.tag} (size: ${message.attachments.size})`)
|
||||
if ((message.attachments.size > 0) && message.channel.type == 'dm' && !message.author.bot) {
|
||||
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(cmdprefix) || message.author.bot) return;
|
||||
const args = message.content.slice(cmdprefix.length).split(' ');
|
||||
const command = args.shift().toLowerCase();
|
||||
if (Object.keys(commands).includes(command)) {
|
||||
commands[command](message, args, db);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var db = mysql.createConnection({
|
||||
host : 'localhost',
|
||||
port : '3306',
|
||||
user : 'root',
|
||||
password : process.env.DB_PASSWORD,
|
||||
database : 'DSA'
|
||||
});
|
||||
|
||||
db.connect((err) => {
|
||||
if(err){
|
||||
throw err;
|
||||
}
|
||||
console.log('MySql connected...');
|
||||
});
|
||||
|
||||
module.exports = async (message) =>{
|
||||
//command manager
|
||||
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 {
|
||||
const data = body.json();
|
||||
// if came to here, then valid
|
||||
return data;
|
||||
}
|
||||
catch (e) {
|
||||
// failed to parse
|
||||
return null;
|
||||
}
|
||||
}
|
0
src/commands/read.js
Normal file
0
src/commands/read.js
Normal file
@ -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,7 +1,28 @@
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
module.exports = async (message, args, db) => {
|
||||
// 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
|
||||
// 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
|
||||
if(row && err) {
|
||||
message.reply('Es gab einen Fehler.');
|
||||
}
|
||||
@ -11,5 +32,5 @@ module.exports = async (message, args, db) => {
|
||||
message.reply('du hast: ' + row[0].GD + ' GD, ' + row[0].ST + ' ST, ' + row[0].BH + ' BH, ' + row[0].EK + ' EK.' + row[0].LP + ' LeP.');
|
||||
}
|
||||
}
|
||||
);
|
||||
);*/
|
||||
};
|
19
src/commands/skill.js
Normal file
19
src/commands/skill.js
Normal file
@ -0,0 +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;
|
||||
}
|
||||
};
|
84
src/commands/talent.js
Normal file
84
src/commands/talent.js
Normal file
@ -0,0 +1,84 @@
|
||||
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;
|
||||
}
|
||||
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) {
|
||||
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++) {
|
||||
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;
|
||||
}
|
||||
};
|
59
src/commands/tp.js
Normal file
59
src/commands/tp.js
Normal file
@ -0,0 +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 {
|
||||
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] + '.',
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
88
src/globals.js
Normal file
88
src/globals.js
Normal file
@ -0,0 +1,88 @@
|
||||
const money = [{
|
||||
'GD': 'Golddukaten',
|
||||
'ST': 'Silbertaler',
|
||||
|
||||
|
||||
}];
|
||||
|
||||
const Werte = [
|
||||
{ id: 'mut', kuerzel: 'MU', name: 'Mut' },
|
||||
{ id: 'klugheit', kuerzel: 'KL', name: 'Klugheit' },
|
||||
{ id: 'intuition', kuerzel: 'IN', name: 'Intuition' },
|
||||
{ id: 'charisma', kuerzel: 'CH', name: 'Charisma' },
|
||||
{ id: 'fingerfertigkeit', kuerzel: 'FF', name: 'Fingerfertigkeit' },
|
||||
{ id: 'gewandtheit', kuerzel: 'GE', name: 'Gewandheit' },
|
||||
{ id: 'konstitution', kuerzel: 'KO', name: 'Konstitution' },
|
||||
{ id: 'koerperkraft', kuerzel: 'KK', name: 'Körperkraft' },
|
||||
];
|
||||
|
||||
const Talente = [
|
||||
// Körpertalente
|
||||
{ id: 'fliegen', name: 'Fliegen', values: ['MU', 'IN', 'GE'] },
|
||||
{ id: 'gaukeleien', name: 'Gaugekleien', values: ['MU', 'CH', 'FF'] },
|
||||
{ id: 'klettern', name:'Klettern', values: ['MU', 'GE', 'KK'] },
|
||||
{ id: 'koerperbeherrschung', name: 'Körperbeherrschung', values: ['GE', 'GE', 'KO'] },
|
||||
{ id: 'kraftakt', name: 'Kraftakt', values: ['KO', 'KK', 'KK'] },
|
||||
{ id: 'reiten', name: 'Reiten', values: ['CH', 'GE', 'KK'] },
|
||||
{ id: 'schwimmen', name: 'Schwimmen', values: ['GE', 'KO', 'KK'] },
|
||||
{ id: 'selbstbeherrschung', name: 'Selbstbeherrschung', values: ['MU', 'MU', 'KO'] },
|
||||
{ id: 'singen', name: 'Singen', values: ['KL', 'CH', 'KO'] },
|
||||
{ id: 'sinnesschaerfe', name: 'Sinnesschärfe', values: ['KL', 'IN', 'IN'] },
|
||||
{ id: 'tanzen', name: 'Tanzen', values: ['KL', 'CH', 'GE'] },
|
||||
{ id: 'taschendiebstahl', name: 'Taschendiebstahl', values: ['MU', 'FF', 'GE'] },
|
||||
{ id: 'verbergen', name: 'Verbergen', values: ['MU', 'IN', 'GE'] },
|
||||
{ id: 'zechen', name: 'Zechen', values: ['KL', 'KO', 'KK'] },
|
||||
|
||||
// Gesellschaftstalente
|
||||
{ id: 'bekehrenueberzeugen', name: 'Bekehren & Überzeugen', values: ['MU', 'KL', 'CH'] },
|
||||
{ id: 'betoeren', name: 'Betören', values: ['MU', 'CH', 'CH'] },
|
||||
{ id: 'einschuechtern', name: 'Einschüchtern', values: ['MU', 'IN', 'CH'] },
|
||||
{ id: 'etikette', name: 'Etikette', values: ['KL', 'IN', 'CH'] },
|
||||
{ id: 'gassenwissen', name: 'Gassenwissen', values: ['KL', 'IN', 'CH'] },
|
||||
{ id: 'menschenkenntnis', name: 'Menschenkenntnis', values: ['KL', 'IN', 'CH'] },
|
||||
{ id: 'ueberreden', name: 'Überreden', values: ['MU', 'IN', 'CH'] },
|
||||
{ id: 'willenskraft', name: 'Willenskraft', values: ['MU', 'IN', 'CH'] },
|
||||
|
||||
// Naturtalente
|
||||
{ id: 'faehrtensuchen', name: 'Fährtensuchen', values: ['MU', 'IN', 'GE'] },
|
||||
{ id: 'fesseln', name: 'Fesseln', values: ['KL', 'FF', 'KK'] },
|
||||
{ id: 'fischenangeln', name: 'Fischen & Angeln', values: ['FF', 'GE', 'KO'] },
|
||||
{ id: 'orientierung', name: 'Orientierung', values: ['KL', 'IN', 'IN'] },
|
||||
{ id: 'pflanzenkunde', name: 'Pflanzenkunde', values: ['KL', 'FF', 'KO'] },
|
||||
{ id: 'tierkunde', name: 'Tierkunde', values: ['MU', 'MU', 'CH'] },
|
||||
{ id: 'wildnisleben', name: 'Wildnisleben', values: ['MU', 'GE', 'KO'] },
|
||||
|
||||
// Wissenstalente
|
||||
{ id: 'brettspiel', name: 'Brett- & Glücksspiel', values: ['KL', 'KL', 'IN'] },
|
||||
{ id: 'geographie', name: 'Geographie', values: ['KL', 'KL', 'IN'] },
|
||||
{ id: 'geschichtswissen', name: 'Geschichtswissen', values: ['KL', 'KL', 'IN'] },
|
||||
{ id: 'goetterkulte', name: 'Götter & Kulte', values: ['KL', 'KL', 'IN'] },
|
||||
{ id: 'kriegkunst', name: 'Kriegskunst', values: ['MU', 'KL', 'IN'] },
|
||||
{ id: 'magiekunde', name: 'Magiekunde', values: ['KL', 'KL', 'IN'] },
|
||||
{ id: 'mechanik', name: 'Mechanik', values: ['KL', 'KL', 'FF'] },
|
||||
{ id: 'rechnen', name: 'Rechnen', values: ['KL', 'KL', 'IN'] },
|
||||
{ id: 'rechtskunde', name: 'Rechtskunde', values: ['KL', 'KL', 'IN'] },
|
||||
{ id: 'sagenlegenden', name: 'Sagen & Legenden', values: ['KL', 'KL', 'IN'] },
|
||||
{ id: 'sphaerenkunde', name: 'Sphärenkunde', values: ['KL', 'KL', 'IN'] },
|
||||
{ id: 'sternkunde', name: 'Sternkunde', values: ['KL', 'KL', 'IN'] },
|
||||
|
||||
// Handwerkstalente
|
||||
{ id: 'alchimie', name: 'Alchimie', values: ['MU', 'KL', 'FF'] },
|
||||
{ id: 'boote', name: 'Boote & Schiffe', values: ['FF', 'GE', 'KK'] },
|
||||
{ id: 'fahrzeuge', name: 'Fahrzeuge', values: ['CH', 'FF', 'KO'] },
|
||||
{ id: 'handel', name: 'Handel', values: ['KL', 'IN', 'CH'] },
|
||||
{ id: 'heilkundegift', name: 'Heilkunde: Gift', values: ['MU', 'KL', 'IN'] },
|
||||
{ id: 'heilkundekrankheiten', name: 'Heilkunde: Krankheiten', values: ['MU', 'IN', 'KO'] },
|
||||
{ id: 'heilkundeseele', name: 'Heilkunde: Seele', values: ['IN', 'CH', 'KO'] },
|
||||
{ id: 'heilkundewunden', name: 'Heilkunde: Wunden', values: ['KL', 'FF', 'FF'] },
|
||||
{ id: 'holzbearbeitung', name: 'Holzbearbeitung', values: ['FF', 'GE', 'KK'] },
|
||||
{ id: 'lebensmittel', name: 'Lebensmittelbearbeitung', values: ['IN', 'FF', 'FF'] },
|
||||
{ id: 'lederbearbeitung', name: 'Lederbearbeitung', values: ['FF', 'GE', 'KO'] },
|
||||
{ id: 'malenzeichnen', name: 'Malen & Zeichnen', values: ['IN', 'FF', 'FF'] },
|
||||
{ id: 'musizieren', name: 'Musizieren', values: ['CH', 'FF', 'KO'] },
|
||||
{ id: 'schloesserknacken', name: 'Schlösserknacken', values: ['IN', 'FF', 'FF'] },
|
||||
{ id: 'steinbearbeitung', name: 'Steinbearbeitung', values: ['FF', 'FF', 'KK'] },
|
||||
{ id: 'stoffbearbeitung', name: 'Stoffbearbeitung', values: ['KL', 'FF', 'FF'] },
|
||||
|
||||
];
|
||||
module.exports = { Werte, Talente };
|
23
src/index.js
23
src/index.js
@ -1,9 +1,26 @@
|
||||
require('dotenv').config();
|
||||
const Discord = require('discord.js');
|
||||
const bot = new Discord.Client();
|
||||
const client = new Discord.Client();
|
||||
const SERVERID = process.env.SERVERID;
|
||||
const commandHandler = require('./commands');
|
||||
|
||||
bot.on('message', commandHandler);
|
||||
client.on('message', commandHandler);
|
||||
|
||||
bot.login(process.env.BOT_TOKEN);
|
||||
client.login(process.env.BOT_TOKEN);
|
||||
client.once('ready', () => {
|
||||
console.log('Ready!');
|
||||
});
|
||||
|
||||
|
||||
client.on('error', err => {
|
||||
console.error('Error\n' + err);
|
||||
process.exit(1);
|
||||
});
|
||||
client.on('disconnect', message => {
|
||||
console.error('User Disconnected');
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
client.on('reconnecting', message => {
|
||||
console.log('User Reconnecting');
|
||||
});
|
Reference in New Issue
Block a user