-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdicePool.js
78 lines (66 loc) · 1.71 KB
/
dicePool.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
class DicePool
{
// Constructor
constructor( rl = 0, kp = 0 )
{
this.bonus = 0;
this.explodeOn = 10;
this.emphasis = false;
this.keepHigh = true;
this.kept = 0;
this.keptDice = kp;
this.oopsed = false;
this.owner = 'Hugh Mann';
this.pool = [];
this.raises = 0;
this.rolledDice = rl;
this.TN = 0;
}
// DiePool.printPool()
printPool( wordy = true )
{
let msg = `${this.owner} rolled **`;
let rolledTotal = this.kept + this.bonus
msg += this.bonus != 0 ?
`${rolledTotal}** (${this.kept} ${this.bonus > 0? "+": ""}${this.bonus})` : `${this.kept}**`;
if ( wordy )
{
msg += this.explodeOn > 10 ? ` Unskilled` : '';
msg += this.explodeOn < 10 ? ` with Mastery` : '';
msg += this.emphasis ? ` with Emphasis` : ``;
msg += this.keepHigh ? `` : ` keeping low`;
if ( this.TN != 0 )
{
msg += ` against TN ${this.TN + this.raises * 5}`;
if ( this.raises != 0)
{
msg += ` (${this.TN} + ${this.raises} raises)`;
}
if ( rolledTotal >= this.TN + this.raises * 5 )
{
msg += `\n**Success!** you passed by ${ (this. kept + this.bonus) - ( this.TN + this.raises * 5 ) }`
}
else
{
msg += `\n**Failure!** you missed by ${ ( this.TN + this.raises * 5 ) - (this. kept + this.bonus) }`;
}
}
msg += '\n[ **';
for ( let k = 0; k < this.keptDice; k++ )
{
msg += `${this.pool[k]}`;
msg += k + 1 < this.pool.length ? ',' : '';
}
msg += `**`;
for ( let r = this.keptDice; r < this.pool.length; r++ )
{
msg += `${this.pool[r]}`;
msg += r + 1 < this.pool.length ? ',' : '';
}
msg += ` ]`;
msg += this.oopsed ? '\n__this roll has been modified__' : '';
};
return msg;
}
}
module.exports = DicePool