var BasePlugin = require('./base.js') class Character1 extends BasePlugin { constructor (config) { super(config) this.name = 'Character1' } help () { // | Command | Description return '.luohahmo Luo D&D-hahmon statsit' } test (input) { if (input.match(/^\.luohahmo$/i)) { return true } return false } throwStat () { // Heittää 4 kertaa d6:n, tiputtaa heikoimman tuloksen ja laskee // loput yhteen var throws = [] var sum = 0 for (var i = 0; i < 4; i++) { var t = Math.floor(Math.random() * 6) + 1 throws.push(t) } throws.sort() throws.reverse() sum = 0 for (i = 0; i < 3; i++) { sum += throws[i] } return sum } getDnDCharacter () { var statPoints = 'DnD-statsit:' var total = 0 for (var i = 0; i < 6; i++) { var newStat = this.throwStat() statPoints += ' ' // erotetaan sanat toisistaan statPoints += newStat total += Number(newStat) } statPoints += ' (' + total + ')' return statPoints }; result (input) { // Different cases let info = this.getDnDCharacter() return info } } module.exports = Character1