kulmapaikka-ircbot/plugins/character1.js
2018-04-29 17:37:07 +03:00

63 lines
1.2 KiB
JavaScript

var Promise = require('promise');
var requestPromise = require('./helpers/requestPromise.js');
var BasePlugin = require('./base.js');
var logger = require('winston');
class Character1 extends BasePlugin {
constructor(config) {
super(config);
this.name = 'Character1';
}
test(input) {
var res = null;
if (res = 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();
var sum = 0;
for(var 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;