kulmapaikka-ircbot/plugins/character1.js

63 lines
1.2 KiB
JavaScript
Raw Normal View History

var BasePlugin = require('./base.js')
2018-04-29 17:37:07 +03:00
class Character1 extends BasePlugin {
constructor (config) {
super(config)
this.name = 'Character1'
2018-04-29 17:37:07 +03:00
}
2019-11-20 20:28:11 +02:00
help () {
// | Command | Description
return '.luohahmo Luo D&D-hahmon statsit'
}
test (input) {
if (input.match(/^\.luohahmo$/i)) {
return true
2018-04-29 17:37:07 +03:00
}
return false
2018-04-29 17:37:07 +03:00
}
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
2018-04-29 17:37:07 +03:00
}
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
}
2018-04-29 17:37:07 +03:00
}
module.exports = Character1