2019-08-13 19:37:22 +03:00
|
|
|
var BasePlugin = require('./base.js')
|
2018-04-29 17:37:07 +03:00
|
|
|
|
|
|
|
class Character1 extends BasePlugin {
|
2019-08-13 19:37:22 +03:00
|
|
|
constructor (config) {
|
|
|
|
super(config)
|
|
|
|
this.name = 'Character1'
|
2018-04-29 17:37:07 +03:00
|
|
|
}
|
|
|
|
|
2019-08-13 19:37:22 +03:00
|
|
|
test (input) {
|
|
|
|
if (input.match(/^\.luohahmo$/i)) {
|
|
|
|
return true
|
2018-04-29 17:37:07 +03:00
|
|
|
}
|
2019-08-13 19:37:22 +03:00
|
|
|
return false
|
2018-04-29 17:37:07 +03:00
|
|
|
}
|
|
|
|
|
2019-08-13 19:37:22 +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
|
|
|
}
|
|
|
|
|
2019-08-13 19:37:22 +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
|
|
|
}
|
|
|
|
|
2019-08-13 19:37:22 +03:00
|
|
|
module.exports = Character1
|