-
Notifications
You must be signed in to change notification settings - Fork 5
/
custom.js
524 lines (491 loc) · 17.2 KB
/
custom.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
function rolld4() {
var randomNumber = Math.floor(Math.random() * 4) + 1;
return randomNumber;
}
function rolld6() {
var randomNumber = Math.floor(Math.random() * 6) + 1;
return randomNumber;
}
function generalDice(n,d,m){
var result = 0
for (let i = 0; i < n; i++ ) {
result += (Math.floor(Math.random() * d) + 1)
}
return (result + m)
}
let tuTable = {
1: {
"min": 13,
"skeleton / 1 HD":[13,14,15,16],
"zombie / 2 HD" : [17,18],
"Ghoul / 3 HD" : [19,20]
}
}
function turnUndead (level, roll) {
switch (level){
case 1:
if (roll >=13 && roll < 17) {
return "1 HD / Skeleton"
} else if (roll >=17 && roll < 19) {
return "2 HD / Zombie"
} else if (roll >=17 && roll < 21) {
return "3 HD / Ghoul"
} else { return "Nothing"}
case 2:
if (roll >=11 && roll < 15) {
return "1 HD / Skeleton"
} else if (roll >=15 && roll < 18) {
return "2 HD / Zombie"
} else if (roll >=18 && roll < 20) {
return "3 HD / Ghoul"
} else if (roll >= 20 ) {
return "4 HD / Wight"
} else { return "Nothing"}
case 3:
if (roll >=9 && roll < 13) {
return "1 HD / Skeleton"
} else if (roll >=13 && roll < 17) {
return "2 HD / Zombie"
} else if (roll >=17 && roll < 19) {
return "3 HD / Ghoul"
} else if (roll >= 19 ) {
return "4 HD / Wight"
} else { return "Nothing"}
case 4:
if (roll >=7 && roll < 11) {
return "1 HD / Skeleton"
} else if (roll >=11 && roll < 15) {
return "2 HD / Zombie"
} else if (roll >=15 && roll < 18) {
return "3 HD / Ghoul"
} else if (roll >= 18 && roll < 20) {
return "4 HD / Wight"
} else if (roll >= 20 && roll < 21) {
return "5 HD / Wraith"
} else { return "Nothing"}
case 5:
if (roll >=5 && roll < 9) {
return "1 HD / Skeleton"
} else if (roll >=9 && roll < 13) {
return "2 HD / Zombie"
} else if (roll >=13 && roll < 17) {
return "3 HD / Ghoul"
} else if (roll >= 17 && roll < 19) {
return "4 HD / Wight"
} else if (roll >= 19 && roll < 21) {
return "5 HD / Wraith"
} else { return "Nothing"}
case 6:
if (roll >=3 && roll < 7) {
return "1 HD / Skeleton"
} else if (roll >=7 && roll < 11) {
return "2 HD / Zombie"
} else if (roll >=11 && roll < 15) {
return "3 HD / Ghoul"
} else if (roll >= 15 && roll < 18) {
return "4 HD / Wight"
} else if (roll >= 18 && roll < 20) {
return "5 HD / Wraith"
} else if (roll >= 20 && roll < 21) {
return "6 HD / Mummy"
} else { return "Nothing"}
case 7:
if (roll >=2 && roll < 5) {
return "1 HD / Skeleton"
} else if (roll >=5 && roll < 9) {
return "2 HD / Zombie"
} else if (roll >=9 && roll < 13) {
return "3 HD / Ghoul"
} else if (roll >= 13 && roll < 17) {
return "4 HD / Wight"
} else if (roll >= 17 && roll < 19) {
return "5 HD / Wraith"
} else if (roll >= 19 && roll < 21) {
return "6 HD / Mummy"
} else { return "Nothing"}
case 8:
if (roll >=3 && roll < 7) {
return "Skeleton T + 2 HD / Zombie"
} else if (roll >=7 && roll < 11) {
return "Skeleton T + 3 HD / Ghoul"
} else if (roll >= 11 && roll < 15) {
return "Skeleton T + 4 HD / Wight"
} else if (roll >= 15 && roll < 18) {
return "Skeleton T + 5 HD / Wraith"
} else if (roll >= 18 && roll < 20) {
return "Skeleton T + 6 HD / Mummy"
} else if (roll >= 20 && roll < 21) {
return "Skeleton T + 7 HD / Spectre"
} else { return "Skeleton T, Automatically"}
case 9:
if (roll >=2 && roll < 5) {
return "Skeleton T + 2 HD / Zombie"
} else if (roll >=5 && roll < 9) {
return "Skeleton T + 3 HD / Ghoul"
} else if (roll >= 9 && roll < 13) {
return "Skeleton T + 4 HD / Wight"
} else if (roll >= 13 && roll < 17) {
return "Skeleton T + 5 HD / Wraith"
} else if (roll >= 17 && roll < 19) {
return "Skeleton T + 6 HD / Mummy"
} else if (roll >= 19 && roll < 21) {
return "Skeleton T + 7 HD / Spectre"
} else { return "Skeleton T, Automatically"}
case 10:
if (roll >=3 && roll < 7) {
return "Skeleton,Zombie T + 3 HD / Ghoul"
} else if (roll >= 7 && roll < 11) {
return "Skeleton,Zombie T + 4 HD / Wight"
} else if (roll >= 11 && roll < 15) {
return "Skeleton,Zombie T + 5 HD / Wraith"
} else if (roll >= 15 && roll < 18) {
return "Skeleton,Zombie T + 6 HD / Mummy"
} else if (roll >= 18 && roll < 20) {
return "Skeleton,Zombie T + 7 HD / Spectre"
} else if (roll >= 20 && roll < 21) {
return "Skeleton,Zombie T + 8 HD / VAmpire"
} else { return "Skeleton,Zombie T, Automatically"}
case 11:
if (roll >=2 && roll < 5) {
return "Skeleton D + Zombie T + 3 HD / Ghoul"
} else if (roll >= 5 && roll < 9) {
return "Skeleton D + Zombie T + 4 HD / Wight"
} else if (roll >= 9 && roll < 13) {
return "Skeleton D + Zombie T + 5 HD / Wraith"
} else if (roll >= 13 && roll < 17) {
return "Skeleton D + Zombie T + 6 HD / Mummy"
} else if (roll >= 17 && roll < 19) {
return "Skeleton D + Zombie T + 7 HD / Spectre"
} else if (roll >= 19 && roll < 21) {
return "Skeleton D + Zombie T + 8 HD / Vampire"
} else { return "Skeleton D + Zombie T, Automatically"}
case 12:
if (roll >=3 && roll < 7) {
return "Skeleton D + Zombie, Ghoul T + 4 HD / Wight"
} else if (roll >= 7 && roll < 11) {
return "Skeleton D + Zombie, Ghoul T + 5 HD / Wraith"
} else if (roll >= 11 && roll < 15) {
return "Skeleton D + Zombie, Ghoul T + 6 HD / Mummy"
} else if (roll >= 15 && roll < 18) {
return "Skeleton D + Zombie, Ghoul T + 7 HD / Spectre"
} else if (roll >= 18 && roll < 20) {
return "Skeleton D + Zombie, Ghoul T + 8 HD / Vampire"
} else if (roll >= 20 && roll < 21) {
return "Skeleton D + Zombie, Ghoul T + 9 HD / Ghost"
} else { return "Skeleton D + Zombie, Ghoul T, Automatically"}
case 13:
if (roll >=2 && roll < 5) {
return "Skeleton,Zombie D + Ghoul T + 4 HD / Wight"
} else if (roll >= 5 && roll < 9) {
return "Skeleton,Zombie D + Ghoul T + 5 HD / Wraith"
} else if (roll >= 9 && roll < 13) {
return "Skeleton,Zombie D + Ghoul T + 6 HD / Mummy"
} else if (roll >= 13 && roll < 17) {
return "Skeleton,Zombie D + Ghoul T + 7 HD / Spectre"
} else if (roll >= 17 && roll < 19) {
return "Skeleton,Zombie D + Ghoul T + 8 HD / Vampire"
} else if (roll >= 19 && roll < 21) {
return "Skeleton,Zombie D + Ghoul T + 9 HD / Ghost"
} else { return "Skeleton,Zombie D + Ghoul T, Automatically"}
case 14:
if (roll >=3 && roll < 7) {
return "Skeleton,Zombie D + Ghoul, Wight T + 5 HD / Wraith"
} else if (roll >= 7 && roll < 11) {
return "Skeleton,Zombie D + Ghoul, Wight T + 6 HD / Mummy"
} else if (roll >= 11 && roll < 15) {
return "Skeleton,Zombie D + Ghoul, Wight T + 7 HD / Spectre"
} else if (roll >= 15 && roll < 18) {
return "Skeleton,Zombie D + Ghoul, Wight T + 8 HD / Vampire"
} else if (roll >= 18 && roll < 21) {
return "Skeleton,Zombie D + Ghoul, Wight T + 9 HD / Ghost"
} else { return "Skeleton,Zombie D + Ghoul, Wight T, Automatically"}
case 15:
if (roll >=2 && roll < 5) {
return "Skeleton,Zombie,Ghoul D + Wight T + 5 HD / Wraith"
} else if (roll >= 5 && roll < 9) {
return "Skeleton,Zombie,Ghoul D + Wight T + 6 HD / Mummy"
} else if (roll >= 9 && roll < 13) {
return "Skeleton,Zombie,Ghoul D + Wight T + 7 HD / Spectre"
} else if (roll >= 13 && roll < 17) {
return "Skeleton,Zombie,Ghoul D + Wight T + 8 HD / Vampire"
} else if (roll >= 17 && roll < 21) {
return "Skeleton,Zombie,Ghoul D + Wight T + 9 HD / Ghost"
} else { return "Skeleton,Zombie,Ghoul D + Wight T, Automatically"}
case 16:
if (roll >=3 && roll < 7) {
return "Skeleton,Zombie,Ghoul D + Wight,Wraith T + 6 HD / Mummy"
} else if (roll >= 7 && roll < 11) {
return "Skeleton,Zombie,Ghoul D + Wight,Wraith T + 7 HD / Spectre"
} else if (roll >= 11 && roll < 15) {
return "Skeleton,Zombie,Ghoul D + Wight,Wraith T + 8 HD / Vampire"
} else if (roll >= 15 && roll < 21) {
return "Skeleton,Zombie,Ghoul D + Wight,Wraith T + 9 HD / Ghost"
} else { return "Skeleton,Zombie,Ghoul D + Wight,Wraith T, Automatically"}
case 17:
if (roll >=2 && roll < 5) {
return "Skeleton,Zombie,Ghoul,Wight D + Wraith T + 6 HD / Mummy"
} else if (roll >= 5 && roll < 9) {
return "Skeleton,Zombie,Ghoul,Wight D + Wraith T + 7 HD / Spectre"
} else if (roll >= 9 && roll < 13) {
return "Skeleton,Zombie,Ghoul,Wight D + Wraith T + 8 HD / Vampire"
} else if (roll >= 13 && roll < 21) {
return "Skeleton,Zombie,Ghoul,Wight D + Wraith T + 9 HD / Ghost"
} else { return "Skeleton,Zombie,Ghoul,Wight D + Wraith T, Automatically"}
case 18:
if (roll >=3 && roll < 7) {
return "Skeleton,Zombie,Ghoul,Wight D + Wraith,Mummy T + 7 HD / Spectre"
} else if (roll >= 7 && roll < 11) {
return "Skeleton,Zombie,Ghoul,Wight D + Wraith,Mummy T + 8 HD / Vampire"
} else if (roll >= 11 && roll < 21) {
return "Skeleton,Zombie,Ghoul,Wight D + Wraith,Mummy T + 9 HD / Ghost"
} else { return "Skeleton,Zombie,Ghoul,Wight D + Wraith,Mummy T, Automatically"}
case 19:
if (roll >=2 && roll < 5) {
return "Skeleton,Zombie,Ghoul,Wight,Wraith D + Mummy T + 7 HD / Spectre"
} else if (roll >= 5 && roll < 9) {
return "Skeleton,Zombie,Ghoul,Wight,Wraith D + Mummy T + 8 HD / Vampire"
} else if (roll >= 9 && roll < 21) {
return "Skeleton,Zombie,Ghoul,Wight,Wraith D + Mummy T + 9 HD / Ghost"
} else { return "Skeleton,Zombie,Ghoul,Wight,Wraith D + Mummy T, Automatically"}
case 20:
if (roll >=3 && roll < 7) {
return "Skeleton,Zombie,Ghoul,Wight,Wraith D + Mummy,Spectre T + 8 HD / Vampire"
} else if (roll >= 7 && roll < 21) {
return "Skeleton,Zombie,Ghoul,Wight,Wraith D + Mummy,Spectre T + 9 HD / Ghost"
} else { return "Skeleton,Zombie,Ghoul,Wight,Wraith D + Mummy,Spectre T, Automatically"}
default:
return "Nothing"
}
}
function treasureGeMTable() {
const roll = generalDice(1,100,0)
if (roll >= 1 && roll <=20 ){
return 1
} else if (roll >= 21 && roll <= 45 ){
return 2
} else if (roll >= 46 && roll <= 75 ){
return 3
} else if (roll >= 76 && roll <= 95 ){
return 4
} else {return 5}
}
export function treasureGeMTable2() {
const roll = generalDice(2,6,0)
if (roll === 2 ){
return 1
} else if (roll === 3 ){
return 2
} else if (roll === 4 ){
return 3
} else if (roll >= 5 && roll <= 9 ){
return 4
} else if (roll === 10 ){
return 5
} else if (roll === 11 ){
return 6
} else if (roll === 12 ){
return 7
}
}
export function confusionTable() {
const roll = generalDice(1,10,0)
if (roll === 1 ){
return 1
} else if (roll === 2 ){
return 2
} else if (roll >=3 && roll <=5 ){
return 3
} else if (roll >= 6 && roll <= 7 ){
return 4
} else if (roll >= 8 && roll <= 10 ){
return 5 }
}
export function generalTableSelect(dice, values) {
const roll = generalDice(dice[0], dice[1], dice[2])
var counter = 0
for (let i =0; i < values.length; i++) {
if (roll >= values[i][0] && roll <= values[i][1]) { return i + 1}
}
}
export function generalTableSelect2(dice, values) {
const roll = generalDice(dice[0], dice[1], dice[2])
var counter = 0
for (let i =0; i < values.length; i++) {
if (roll >= values[i][0] && roll <= values[i][1]) { return [i + 1,roll]}
}
}
export function treasureGeMTable3() {
const roll = generalDice(1,100,0)
if (roll >= 1 && roll <=10 ){
return 1
} else if (roll >= 11 && roll <= 20 ){
return 2
} else if (roll >= 21 && roll <= 28 ){
return 3
} else if (roll >= 29 && roll <= 38 ){
return 4
} else if (roll >= 39 && roll <= 45 ){
return 5
} else if (roll >= 46 && roll <= 54 ){
return 6
} else if (roll >= 55 && roll <= 60 ){
return 7
} else if (roll >= 61 && roll <= 65 ){
return 8
} else if (roll >= 66 && roll <= 70 ){
return 9
} else if (roll >= 71 && roll <= 75 ){
return 10
} else if (roll >= 76 && roll <= 79 ){
return 11
} else if (roll >= 80 && roll <= 89 ){
return 12
} else if (roll >= 90 && roll <= 94 ){
return 13
} else if (roll >= 95 && roll <= 97 ){
return 14
} else if (roll >= 98 && roll <= 100 ){
return 15
}
}
export function treasureGeMTable4() {
const roll = generalDice(1,100,0)
if (roll >= 1 && roll <=6 ){
return [1,1]
} else if (roll >= 7 && roll <= 12 ){
return [2,1]
} else if (roll >= 13 && roll <= 14 ){
return [3,1]
} else if (roll >= 15 && roll <= 21 ){
return [4,1]
} else if (roll >= 22 && roll <= 27 ){
return [5,1]
} else if (roll >= 28 && roll <= 32 ){
return [6,1]
} else if (roll >= 32 && roll <= 37 ){
return [7,1]
} else if (roll >= 38 && roll <= 40 ){
return [8,1]
} else if (roll >= 41 && roll <= 42 ){
return [9,1]
} else if (roll >= 42 && roll <= 47 ){
return [10,1]
} else if (roll >= 48 && roll <= 51 ){
return [11,1]
} else if (roll === 52 ){
return [12,1]
} else if (roll >= 53 && roll <= 55 ){
return [13,1]
} else if (roll >= 56 && roll <= 62 ){
return [1,3]
} else if (roll >= 63 && roll <= 65 ){
return [2,3]
} else if (roll >= 66 && roll <= 68 ){
return [3,3]
} else if (roll >= 69 && roll <= 73 ){
return [4,3]
} else if (roll >= 74 && roll <= 77 ){
return [5,3]
} else if (roll >= 78 && roll <= 80 ){
return [6,3]
} else if (roll >= 81 && roll <= 82 ){
return [7,3]
} else if (roll >= 83 && roll <= 89 ){
return [8,3]
} else if (roll === 90 ){
return [9,3]
} else if (roll >= 91 && roll <= 95 ){
return [10,3]
} else if (roll === 96 ){
return [11,3]
} else if (roll >= 97 && roll <= 99){
return [12,3]
} else if (roll === 100 ){
return [13,3]
}
}
function highlightTableRow(table, num) {
// Get a reference to the table element
var table = document.querySelector(table + " " + "table");
// clear table of any highlights
for (var i = 0; i < table.rows.length; i++) {
table.rows[i].classList.remove('myHighlighted');
}
// Get a reference to the specific row that matches the random number
var row = table.rows[num];
// Add a class to highlight the row
row.classList.add("myHighlighted");
}
export function highlightTableRowRet(table, num) {
// Get a reference to the table element
var table = document.querySelector(table + " " + "table");
// clear table of any highlights
for (var i = 0; i < table.rows.length; i++) {
table.rows[i].classList.remove('myHighlighted');
}
// Get a reference to the specific row that matches the random number
var row = table.rows[num[0]];
// Add a class to highlight the row
row.classList.add("myHighlighted");
return num[1]
}
export function highlightTableCell(table, r, c) {
// Get a reference to the table element
var table = document.querySelector(table + " " + "table");
var highlightedCells = table.querySelectorAll(".myHighlightedCell");
for (var i = 0; i < highlightedCells.length; i++) {
highlightedCells[i].classList.remove("myHighlightedCell");
}
// Get a reference to the specific cell that matches the number
var rows = table.getElementsByTagName("tr");
var cells = rows[r].getElementsByTagName("td")
//console.log(cells)
// rows[num].classList.add("myHighlighted");
cells[c].classList.add("myHighlightedCell")
//console.log(cells[c])
}
export function calculateModifier (stat) {
switch (stat) {
case 3:
return "-3"
case 4:
case 5:
return "-2"
case 6:
case 7:
case 8:
return "-1"
case 9:
case 10:
case 11:
case 12:
return "0"
case 13:
case 14:
case 15:
return "+1"
case 16:
case 17:
return "+2"
case 18:
return "+3"
default:
return "+3"
}
}
export function convertToGold(value, coin) {
switch(coin){
case "gp":
return value
case "pp":
return value*5
case "sp":
return value*0.1
case "cp":
return value*0.1*0.2
}
}
export {
rolld4, rolld6,
generalDice, turnUndead, treasureGeMTable, highlightTableRow
}