-
Notifications
You must be signed in to change notification settings - Fork 0
/
CRSuggestor.html
1712 lines (1526 loc) · 76.4 KB
/
CRSuggestor.html
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
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body onload="setupPage()" style="background-color:rgb(59, 56, 56);">
<div style="font: small-caps 700 2em Libre Baskerville; color:rgb(255, 255, 255); text-align:center; margin:auto;">Encounter Adjustment Calculator</div>
<br>
<div id="leftCol" style="float:left; background-color: rgb(239, 184, 103); padding:10px;">
<div style="box-shadow: 0px 4px 5px black; background-color: rgb(248, 225, 190); display: block; padding:2px;">
<div style="font: small-caps 700 1.2em Libre Baskerville; color:rgb(88, 24, 13); text-align:center; margin:auto;">Base Challenge Rating (optional)</div>
<table style="width:420px; margin:auto;">
<tr style="height:30px;">
<td><button class="crButton" onclick="setBaseCR(0)">0</button></td>
<td><button class="crButton" onclick="setBaseCR(1/8)">1/8</button></td>
<td><button class="crButton" onclick="setBaseCR(1/4)">1/4</button></td>
<td><button class="crButton" onclick="setBaseCR(1/2)">1/2</button></td>
</tr>
<tr style="height:30px;">
<td><button class="crButton" onclick="setBaseCR(1)">1</button></td>
<td><button class="crButton" onclick="setBaseCR(2)">2</button></td>
<td><button class="crButton" onclick="setBaseCR(3)">3</button></td>
<td><button class="crButton" onclick="setBaseCR(4)">4</button></td>
<td><button class="crButton" onclick="setBaseCR(5)">5</button></td>
<td><button class="crButton" onclick="setBaseCR(6)">6</button></td>
<td><button class="crButton" onclick="setBaseCR(7)">7</button></td>
<td><button class="crButton" onclick="setBaseCR(8)">8</button></td>
<td><button class="crButton" onclick="setBaseCR(9)">9</button></td>
<td><button class="crButton" onclick="setBaseCR(10)">10</button></td>
</tr>
<tr style="height:30px;">
<td><button class="crButton" onclick="setBaseCR(11)">11</button></td>
<td><button class="crButton" onclick="setBaseCR(12)">12</button></td>
<td><button class="crButton" onclick="setBaseCR(13)">13</button></td>
<td><button class="crButton" onclick="setBaseCR(14)">14</button></td>
<td><button class="crButton" onclick="setBaseCR(15)">15</button></td>
<td><button class="crButton" onclick="setBaseCR(16)">16</button></td>
<td><button class="crButton" onclick="setBaseCR(17)">17</button></td>
<td><button class="crButton" onclick="setBaseCR(18)">18</button></td>
<td><button class="crButton" onclick="setBaseCR(19)">19</button></td>
<td><button class="crButton" onclick="setBaseCR(20)">20</button></td>
</tr>
<tr style="height:30px;">
<td><button class="crButton" onclick="setBaseCR(21)">21</button></td>
<td><button class="crButton" onclick="setBaseCR(22)">22</button></td>
<td><button class="crButton" onclick="setBaseCR(23)">23</button></td>
<td><button class="crButton" onclick="setBaseCR(24)">24</button></td>
<td><button class="crButton" onclick="setBaseCR(25)">25</button></td>
<td><button class="crButton" onclick="setBaseCR(26)">26</button></td>
<td><button class="crButton" onclick="setBaseCR(27)">27</button></td>
<td><button class="crButton" onclick="setBaseCR(28)">28</button></td>
<td><button class="crButton" onclick="setBaseCR(29)">29</button></td>
<td><button class="crButton" onclick="setBaseCR(30)">30</button></td>
</tr>
</table>
</div>
<br>
<!--Defensive CR: <span id="defensiveCRDisplay">Unknown</span> <br>
Offensive CR: <span id="offensiveCRDisplay">Unknown</span> <br>
<b>Total CR: <span id="totalCRDisplay">Unknown</span></b> -->
<div style="box-shadow: 0px 4px 5px black; background-color: rgb(248, 225, 190); display: block; padding:5px;">
<input type="text" id="monsterName" placeholder="Monster Name" class="monsterNameInput">
<button class="saveButton" onclick="saveMonster()">Add to ➨<br>Encounter</button>
<table>
<tr>
<td rowspan="2"><img src="Skull.png" alt="UpArrow" width="40" height="40" style="vertical-align:middle;"></td>
<td style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13);">Challenge Rating (CR)</td>
</tr>
<tr>
<td>
<div style="margin: auto">
<input style="float:left; box-shadow:0px 3px 5px 1px rgb(124, 104, 74) inset; border:none; background-color: rgb(243, 203, 145); font: bold 1em Noto Sans; text-align:center;" type="text" size=4 id="challengeRating" onchange="totalCR = eval(this.value); recalcTotalCR();">
<button class="plusButton" onclick="var element = document.getElementById('challengeRating'); element.value = nextCR(eval(element.value), 1); element.onchange();">+</button>
<button class="plusButton" onclick="var element = document.getElementById('challengeRating'); element.value = nextCR(eval(element.value), -1); element.onchange();">-</button>
</div>
</td>
</tr>
<tr>
<td rowspan="2"><img src="Breastplate.png" alt="UpArrow" width="40" height="40" style="vertical-align:middle"></td>
<td style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13);">Armor Class (AC)</td>
<td style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13);">Hit Points (HP)</td>
</tr>
<tr>
<td>
<input style="float:left; box-shadow:0px 3px 5px 1px rgb(124, 104, 74) inset; border:none; background-color: rgb(243, 203, 145); font: bold 1em Noto Sans; text-align:center;" type="text" size=4 id="armorClass" onchange="AC = parseInt(this.value); recalcTotalCR();">
<button class="plusButton" onclick="addValue(document.getElementById('armorClass'), 1)">+</button>
<button class="plusButton" onclick="addValue(document.getElementById('armorClass'), -1)">-</button>
</td>
<td>
<input style="float:left; box-shadow:0px 3px 5px 1px rgb(124, 104, 74) inset; border:none; background-color: rgb(243, 203, 145); font: bold 1em Noto Sans; text-align:center;" type="text" size=4 id="hitPoints" onchange="HP = parseInt(this.value); recalcTotalCR();">
<button class="plusButton" onclick="addValue(document.getElementById('hitPoints'), 1)">+</button>
<button class="plusButton" onclick="addValue(document.getElementById('hitPoints'), -1)">-</button>
</td>
</tr>
<tr>
<td rowspan="2"><img src="Sword.png" alt="UpArrow" width="40" height="40" style="vertical-align:middle"></td>
<td style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13); padding: 0px;">Attack Bonus</td>
<td style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13); padding: 0px;">Damage Per Round</td>
</tr>
<tr>
<td style="font: bold 1em Noto Sans; text-align:center; padding: 0px;"><span id="attackBonus"></span></td>
<td style="font: bold 1em Noto Sans; text-align:center; padding: 0px;"><span id="damagePerRound"></span></td>
</tr>
</table>
</div>
<br>
<div style="box-shadow: 0px 4px 5px black; background-color: rgb(248, 225, 190); display: block; padding:5px;">
<div style="font: small-caps 700 1.2em Libre Baskerville; color:rgb(88, 24, 13); text-align:center; margin:auto;">Optional Monster Features</div>
<table id="monsterFeatTable" style="font-size:x-small; width:420px; margin:auto;">
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Aggressive" >Aggressive</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Ambusher" >Ambusher</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Amorphous" >Amorphous</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Amphibious" >Amphibious</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Angelic Weapons" >Angelic Weapons</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="AntimagicSusceptibility" >Antimagic Susceptibility</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Avoidance" >Avoidance</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="BlindSenses" >Blind Senses</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="BloodFrenzy" >Blood Frenzy</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="BreathWeapon" >Breath Weapon</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Brute" >Brute</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Avoidance" >Chameleon Skin</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="ChameleonSkin" >Change Shape</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Charge" >Charge</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Charm" >Charm</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Constrict" >Constrict</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="DamageAbsorption" >Damage Absorption</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="DamageTransfer" >Damage Transfer</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="DeathBurst" >Death Burst</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="DevilSight" >Devil Sight</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Dive" >Dive</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Echolocation" >Echolocation</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="ElementalBody" >Elemental Body</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Enlarge" >Enlarge</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Etherealness" >Etherealness</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="False Appearance" >False Appearance</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="FeyAncestry" >Fey Ancestry</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="FiendishBlessing" >Fiendish Blessing</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Flyby" >Flyby</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="FrightfulPresence" >Frightful Presence</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Grappler" >Grappler</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="HoldBreath" >Hold Breath</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="HorrifyingVisage" >Horrifying Visage</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Illumination" >Illumination</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="IllusoryAppearance" >Illusory Appearance</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="ImmutableForm" >Immutable Form</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="IncorporealMovement" >Incorporeal Movement</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="InnateSpellcasting" >Innate Spellcasting</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Inscrutable" >Inscrutable</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Invisibility" >Invisibility</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="KeenSenses" >Keen Senses</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="LabrynthineRecall" >Labrynthine Recall</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Leadership" >Leadership</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="LegendaryResistance" >Legendary Resistance</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="LifeDrain" >Life Drain</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="LightSensitivity" >Light Sensitivity</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="MagicResistance" >Magic Resistance</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="MagicWeapons" >Magic Weapons</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="MartialAdvantage" >Martial Advantage</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Mimicry" >Mimicry</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="NimbleEscape" >Nimble Escape</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="OtherworldlyPerception" >Otherworldly Perception</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="PackTactics" >Pack Tactics</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Parry" >Parry</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Possession" >Possession</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Pounce" >Pounce</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="PsychicDefense" >Psychic Defense</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Rampage" >Rampage</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Reactive" >Reactive</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="ReadThoughts" >Read Thoughts</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Reckless" >Reckless</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="RedirectAttack" >Redirect Attack</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Reel" >Reel</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Regeneration" >Regeneration</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Rejuvenation" >Rejuvenation</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Relentless" >Relentless</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="ShadowStealth" >Shadow Stealth</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="ShapeChanger" >Shape Changer</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="SiegeMonster" >Siege Monster</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Slippery" >Slippery</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Spellcasting" >Spellcasting</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="SpiderClimb" >Spider Climb</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="StandingLeap" >Standing Leap</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Steadfast" >Steadfast</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Stench" >Stench</button></td>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="SunlightSensitivity" >Sunlight Sensitivity</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="SuperiorInvisibility" >Superior Invisibility</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="SureFooted" >Sure-Footed</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="SurpriseAttack" >Surprise Attack</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Swallow" >Swallow</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Teleport" >Teleport</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="TerrainCamoflage" >Terrain Camoflage</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Tunneler" >Tunneler</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="TurnImmunity" >Turn Immunity</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="TurnResistance" >Turn Resistance</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="TwoHeads" >Two Heads</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="UndeadFortitude" >Undead Fortitude</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="Web" >Web</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="WebSense" >Web Sense</button></td>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="WebWalker" >Web Walker</button></td>
</tr>
<tr>
<td><button class="featDisabled" onclick="setFeatureNEW(this);" value="WoundedFury" >Wounded Fury</button></td>
</tr>
</table>
</div>
</div>
</div>
<div style="float:left; width:15px; color:rgb(59, 56, 56);">
x
</div>
<div id="rightCol" style="float:left;">
<div style="background-color: rgb(239, 184, 103); padding:10px;">
<div style="box-shadow: 0px 4px 5px black; background-color: rgb(248, 225, 190); display: block; padding:2px;">
<div style="font: small-caps 700 1.2em Libre Baskerville; color:rgb(88, 24, 13); text-align:center; margin:auto;">Party Members</div>
<table id="partyList" style="width:100%;">
<tr>
<td style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13);">Number of Players</td>
<td style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13);">Player Level</td>
<td><button class="partyButton" onclick="addPartyRow();">Add row</button></td>
</tr>
<tr>
<td><input style="float:left; box-shadow:0px 3px 5px 1px rgb(124, 104, 74) inset; border:none; background-color: rgb(243, 203, 145); font: bold 1em Noto Sans; text-align:center;" type='text' id="partySize" size=10 onchange='calculatePartyThresholds();'></input></td>
<td><input style="float:left; box-shadow:0px 3px 5px 1px rgb(124, 104, 74) inset; border:none; background-color: rgb(243, 203, 145); font: bold 1em Noto Sans; text-align:center;" type='text' id="partyLevel" size=10 onchange='calculatePartyThresholds();'></input></td>
</tr>
</table>
</div>
<br>
<div style="box-shadow: 0px 4px 5px black; background-color: rgb(248, 225, 190); display: block; padding:5px;">
<div style="font: small-caps 700 1.2em Libre Baskerville; color:rgb(88, 24, 13); text-align:center; margin:auto;">XP Difficulty Thresholds</div>
<table width="300px" style="text-align:center; margin:auto;">
<tr>
<td style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13);" width="25%"><b><u>Easy</u></b></td>
<td style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13);" width="25%"><b><u>Medium</u></b></td>
<td style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13);" width="25%"><b><u>Hard</u></b></td>
<td style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13);" width="25%"><b><u>Deadly</u></b></td>
</tr>
<tr>
<td><span id="easyThreshold"></span></td>
<td><span id="mediumThreshold"></span></td>
<td><span id="hardThreshold"></span></td>
<td><span id="deadlyThreshold"></span></td>
</tr>
</table>
<div style="font: small-caps 700 1.2em Libre Baskerville; color:rgb(88, 24, 13); text-align:center; margin:auto;">Adjust to Desired Difficulty</div>
<div style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13);">Add at least one monster to the encounter</div>
<div style="margin:auto; display:block; text-align:center;">
<button id="easyButton" onclick="adjustEncounter('Easy');">Easy</button>
<button id="mediumButton" onclick="adjustEncounter('Medium');">Medium</button>
<button id="hardButton" onclick="adjustEncounter('Hard');">Hard</button>
<button id="deadlyButton" onclick="adjustEncounter('Deadly');">Deadly</button>
</div>
<table width="300px" style="text-align:center; margin:auto;">
<tr><td style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13);"><u>Original:</u></td>
<td style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13);"><u>Adjusted:</u></td>
<td style="font: bold 0.8em Noto Sans; text-align:center; color:rgb(88, 24, 13);"><u>Reward:</u></td>
</tr>
<tr><td><span id="encounterDifficulty">0</span> XP</td>
<td><span id="adjustedDifficulty">0</span> XP</td>
<td><span id="rewardDifficulty">0</span> XP</td>
</tr>
</table>
</div>
</div>
<br>
<div style="background-color: rgb(239, 184, 103); padding:10px;">
<div style="box-shadow: 0px 4px 5px black; background-color: rgb(248, 225, 190); display: block; padding:2px;">
<div style="font: small-caps 700 1.2em Libre Baskerville; color:rgb(88, 24, 13); text-align:center; margin:auto;">Encounter List</div>
</div>
<table id="monsterList">
</table>
</div>
</div>
<script>
var defensiveCR;
var offensiveCR;
var totalCR;
var HP;
var AC;
var AB;
var DPR;
var monsterFeats = {};
var encounterSize = 0;
//Party Info
var partySize = 0;
var editing = false;
var editingMonster = 0;
function displayDPRDice(panel) {
if(panel.style.display == "block")
panel.style.display = "none";
else
panel.style.display = "block";
}
function getDPRDiceText(DPR, modifier) {
var output = "<span style='font: small-caps 700 1.2em Libre Baskerville; color: rgb(100, 0, 0); text-align: center;'>Damage Dice</span><br>"
output +="<span style='font: bold 1em Noto Sans;'>Single Attack</span><br>";
output += getDPRDiceCodes(DPR, modifier) + "<br><br>";
output += "<span style='font: bold 1em Noto Sans;'>Multiattack x2</span><br>";
output += getDPRDiceCodes(DPR * 0.6, modifier) + "<br>";
output += getDPRDiceCodes(DPR * 0.4, modifier) + "<br><br>";
output += "<span style='font: bold 1em Noto Sans;'>Multiattack x3</span><br>";
output += getDPRDiceCodes(DPR * 0.45, modifier) + "<br>";
output += getDPRDiceCodes(DPR * 0.3, modifier) + "<br>";
output += getDPRDiceCodes(DPR * 0.25, modifier);
return output;
}
function getDPRDiceCodes(DPR, modifier) {
DPR = Math.round(DPR);
var diceAvg = DPR - modifier;
var numDice = 0;
var onlyDice = 0;
var output = "<span style='font: .8em Noto Sans;'>" + DPR + " (";
if(DPR <= 1)
{
output += DPR;
onlyDice = 1;
}
else if(diceAvg <= 2 && DPR >= 2) {
output += "1d4";
onlyDice = 2;
}
else if(diceAvg <= 10) { //Use d4's
numDice = Math.round(diceAvg / 2.5);
output += numDice + "d4";
onlyDice = Math.floor(numDice * 2.5);
}
else if(diceAvg <= 21) { //Use d6's
numDice = Math.round(diceAvg / 3.5);
output += numDice + "d6";
onlyDice = Math.floor(numDice * 3.5);
}
else if(diceAvg <= 36) { //Use d8's
numDice = Math.round(diceAvg / 4.5);
output += numDice + "d8";
onlyDice = Math.floor(numDice * 4.5);
}
else if(diceAvg <= 55) { //Use d10's
numDice = Math.round(diceAvg / 5.5);
output += numDice + "d10";
onlyDice = Math.floor(numDice * 5.5);
}
else if(diceAvg <= 320) { //Use d12's
numDice = Math.round(diceAvg / 6.5);
output += numDice + "d12";
onlyDice = Math.floor(numDice * 6.5);
}
if(DPR - onlyDice > 0)
{
output += "+" + (DPR - onlyDice);
}
output += ")</span>";
return output;
}
function adjustEncounter(difficulty) {
var minXPThreshold;
var maxXPThreshold
if(difficulty == "Easy") {
minXPThreshold = document.getElementById("easyThreshold").innerHTML;
maxXPThreshold = document.getElementById("mediumThreshold").innerHTML; }
if(difficulty == "Medium") {
minXPThreshold = document.getElementById("mediumThreshold").innerHTML;
maxXPThreshold = document.getElementById("hardThreshold").innerHTML; }
if(difficulty == "Hard") {
minXPThreshold = document.getElementById("hardThreshold").innerHTML;
maxXPThreshold = document.getElementById("deadlyThreshold").innerHTML; }
if(difficulty == "Deadly") {
minXPThreshold = document.getElementById("deadlyThreshold").innerHTML;
//maxXPThreshold = Number.POSITIVE_INFINITY; }
maxXPThreshold = Math.max(document.getElementById("deadlyThreshold").innerHTML * 1.4, parseInt(document.getElementById("deadlyThreshold").innerHTML) + 200);} //Let a Deadly encounter be only 50% above deadly. Still deadly but not impossibly high.
var monsterArray = JSON.parse(localStorage.getItem('monsterArray'));
var encounterSize = getEncounterSize(monsterArray);
var onlyGroups = true; //false if there are some single monsters, true if every monster has at least 2
for(var i = 0; i < monsterArray.length; i++)
{
if(monsterArray[i]["count"] == 1)
{
onlyGroups = false;
break;
}
}
var mob = false;
//FIRST STEP: ADD OR REMOVE MONSTERS TO BETTER BALANCE WITH THE NUMBER OF PLAYERS
if(calculateEncounterDifficulty(monsterArray) <= minXPThreshold)
{
do
{
for(var i = 0; i < monsterArray.length; i++)
{ //If already 2 or more of the same monster, add some more. Probably meant as a mob or group battle.
//If one of each monster, this is probably meant to be some individually strong monsters, so don't change numbers.
if(monsterArray[i]["count"] >= 2 && encounterSize < (partySize))
{
mob = true;
monsterArray[i]["count"] += 1;
console.log("ADDING A " + monsterArray[i]["monsterName"]);
}
encounterSize = getEncounterSize(monsterArray);
if(calculateEncounterDifficulty(monsterArray) > minXPThreshold || encounterSize >= (partySize - 1))
break;
}
} while(encounterSize < partySize - 1 && mob == true) //If we added any monsters, and there are still more players than monsters, keep adding more.
}
else if(calculateEncounterDifficulty(monsterArray) > maxXPThreshold)
{
do
{
mob = false;
for(var i = 0; i < monsterArray.length; i++)
{ //If 2 or more of the same monster, try to lower until one of each monster or equal to number of players
if(monsterArray[i]["count"] >= 2 && encounterSize > partySize)
{
mob = true;
monsterArray[i]["count"] -= 1;
console.log("REMOVING A " + monsterArray[i]["monsterName"]);
}
encounterSize = getEncounterSize(monsterArray);
if(calculateEncounterDifficulty(monsterArray) <= maxXPThreshold || encounterSize <= partySize)
break;
}
} while(encounterSize > partySize && mob == true)
}
console.log("encounter diff " + calculateEncounterDifficulty(monsterArray));
console.log("maxXPThreshold " + maxXPThreshold);
var k = 0;
var change = false;
var currentXP;
var heavyMode = false;
//SECOND STEP: RAISE OR LOWER CR OF EACH MONSTER TYPE ONE BY ONE
while(calculateEncounterDifficulty(monsterArray) <= minXPThreshold || calculateEncounterDifficulty(monsterArray) > maxXPThreshold)
{
currentXP = calculateEncounterDifficulty(monsterArray);
if(calculateEncounterDifficulty(monsterArray) > maxXPThreshold) //Lower CR
{
for( ; k < monsterArray.length; k++)
{
console.log("lowering difficulty of " + monsterArray[k]["monsterName"] + "...");
monsterArray[k] = lowerCR(monsterArray[k]);
console.log("Total XP set to " + calculateEncounterDifficulty(monsterArray));
if(calculateEncounterDifficulty(monsterArray) <= maxXPThreshold)
break;
}
}
else if(calculateEncounterDifficulty(monsterArray) <= minXPThreshold) //Raise CR
{
for( ; k < monsterArray.length; k++)
{
console.log("raising difficulty of " + monsterArray[k]["monsterName"] + "...");
var tempMonster = JSON.stringify(monsterArray[k]);
monsterArray[k] = raiseCR(monsterArray[k]);
//If this change was made to a group of monsters, thus pushing difficulty too high now, AND the whole encounter is only groups of monsters,
// keep the weaker version of the monsters but just make the group larger. This could help increase difficulty by a smaller amount.
if(calculateEncounterDifficulty(monsterArray) > maxXPThreshold)
{
console.log("uh oh. Raised too high!");
monsterArray[k] = JSON.parse(tempMonster); //Return to previous weaker stats
//if(monsterArray[k]["count"] >= 2 && onlyGroups)
if(onlyGroups || heavyMode || monsterArray.length == 1) //If just increasing CR raises it too much, try adding monsters (only if all monsters are in sets, or only one set of monsters)
monsterArray[k]["count"] += 1;
}
else
{
console.log("raised a good amount"); // Good. Keep the changes (delete this branch later)
}
console.log("Total XP set to " + calculateEncounterDifficulty(monsterArray));
if(calculateEncounterDifficulty(monsterArray) > minXPThreshold)
break;
}
}
if(currentXP == calculateEncounterDifficulty(monsterArray)) //If no changes could be made, allow more severe changes.
{
heavyMode = true;
}
k += 1;
if(k >= monsterArray.length) k = 0; //We are doing this so if we break out of the loop we don't get stuck editing the same monster.
}
var originalMonsterArray = JSON.parse(localStorage.getItem('monsterArray'));
var table = document.getElementById("monsterList");
for(var i = 0; i < monsterArray.length; i++)
{
console.log(monsterArray[i]);
var countCell = table.rows[i * 4 + 2].cells[1];
countCell.innerHTML = printArrows(originalMonsterArray[i], monsterArray[i], "count") + "Count: " + monsterArray[i]["count"];
var row = table.rows[i * 4 + 3];
var adjustedStatsCell = row.cells[1];
var DPRDiceDiv = document.createElement('div');
//Fill list with details
adjustedStatsCell.innerHTML = "";
adjustedStatsCell.innerHTML += printArrows(originalMonsterArray[i], monsterArray[i], "totalCR") + "<span class='subTitle'>Challenge:</span> " + monsterArray[i]["totalCR"] + "<br>"
+ '<svg height="5" width="160" style="fill: #922610; stroke: #922610; padding: 0px; margin: 0px;"><polyline points="3,1 160,2.5 3,4"></polyline></svg>'
+ "<table style='width: 100%; font-family: Noto Sans; border-collapse:separate; margin: 0px;'><tr>"
+ "<td style='padding: 0px;'>" + printArrows(originalMonsterArray[i], monsterArray[i], "armorClass") + "<span class='subTitle'>AC</span> " + monsterArray[i]["armorClass"] + "</td>"
+ "<td style='padding: 0px;'>" + printArrows(originalMonsterArray[i], monsterArray[i], "hitPoints") + "<span class='subTitle'>HP</span> " + monsterArray[i]["hitPoints"] + "</td></tr><tr>"
+ "<td style='padding: 0px;'>" + printArrows(originalMonsterArray[i], monsterArray[i], "attackBonus") + "<span class='subTitle'>AB</span> " + monsterArray[i]["attackBonus"] + "</td>"
+ "<td style='padding: 0px;'>" + printArrows(originalMonsterArray[i], monsterArray[i], "damagePerRound") + "<span class='subTitle'>DPR</span> " + monsterArray[i]["damagePerRound"] + "</td>"
+ "<td style='padding: 0px;'>"
+ '<button onclick="displayDPRDice(this.nextSibling);" class="diceButton"><img src="Dice.png" alt="Dice" width="18" height="18" style="padding: 4px; vertical-align:middle;"></button>'
+ '<div class="diceDPRPanel">'
+ getDPRDiceText(monsterArray[i]["damagePerRound"], (monsterArray[i]["attackBonus"] - PBLevels[monsterArray[i]["totalCR"]]))
+ '</div>'
+ "</td></tr>"
+ "</table>";
var atLeastOneFeat = false;
for(var j = 0; j < Object.keys(originalMonsterArray[i]["monsterFeats"]).length; j++)
{
var feat = Object.keys(originalMonsterArray[i]["monsterFeats"])[j];
if(originalMonsterArray[i]["monsterFeats"][feat])
{
if(atLeastOneFeat == false)
{
atLeastOneFeat = true;
adjustedStatsCell.innerHTML += '<svg height="5" width="160" style="fill: #922610; stroke: #922610;"><polyline points="3,1 160,2.5 3,4"></polyline></svg>';
}
if(monsterArray[i]["monsterFeats"][feat])
{
adjustedStatsCell.innerHTML += '<img src="Transparent.png" alt="Blank" width="16" height="16" style="vertical-align:middle">';
adjustedStatsCell.innerHTML += "<span style='font: bold italic 0.8em Noto Sans;'>" + feat + "</span><br>";
}
else
{
adjustedStatsCell.innerHTML += '<img src="RedX.png" alt="RedX" width="16" height="16" style="vertical-align:middle">';
adjustedStatsCell.innerHTML += "<span style='font: bold italic 0.8em Noto Sans; text-decoration: line-through; color: red;'>" + feat + "</span><br>";
}
}
}
}
document.getElementById("adjustedDifficulty").innerHTML = calculateEncounterDifficulty(monsterArray);
document.getElementById("rewardDifficulty").innerHTML = calculateEncounterXPReward(monsterArray);
}
function printArrows(originalMonster, newMonster, index) {
if(newMonster[index] > originalMonster[index])
return '<img src="UpArrow.png" alt="UpArrow" width="16" height="16" style="vertical-align:middle">';
else if (newMonster[index] < originalMonster[index])
return '<img src="DownArrow.png" alt="DownArrow" width="16" height="16" style="vertical-align:middle">';
else
return '<img src="Transparent.png" alt="Equals" width="16" height="16" style="vertical-align:middle">';
}
function setBaseCR(val) {
AC = ACLevels[val];
HP = HPLevels[val];
totalCR = val;
document.getElementById("armorClass").value = AC;
document.getElementById("hitPoints").value = HP;
document.getElementById("challengeRating").value = totalCR;
recalcTotalCR();
}
function addPartyRow() {
var table = document.getElementById("partyList");
var row = table.insertRow(-1);
var numberCell = row.insertCell(-1);
numberCell.innerHTML = "<input style='float:left; box-shadow:0px 3px 5px 1px rgb(124, 104, 74) inset; border:none; background-color: rgb(243, 203, 145); font: bold 1em Noto Sans; text-align:center;' type='text' size=10 onchange='calculatePartyThresholds();'></input>";
var levelCell = row.insertCell(-1);
levelCell.innerHTML = "<input style='float:left; box-shadow:0px 3px 5px 1px rgb(124, 104, 74) inset; border:none; background-color: rgb(243, 203, 145); font: bold 1em Noto Sans; text-align:center;' type='text' size=10 onchange='calculatePartyThresholds();'></input>";
var deleteButtonCell = row.insertCell(-1);
deleteButtonCell.innerHTML = "<button class='partyButton' onclick='deletePlayer(this.parentNode.parentNode.rowIndex)'>Delete</button>";
}
function deletePlayer(playerIndex) {
var table = document.getElementById("partyList");
table.deleteRow(playerIndex);
}
function calculatePartyThresholds() {
var table = document.getElementById("partyList");
partySize = 0; //Clear this count to start over
var totalXPEasy = 0;
var totalXPMedium = 0;
var totalXPHard = 0;
var totalXPDeadly = 0;
for(var i = 1; i < table.rows.length; i++)
{
if(table.rows[i].cells[0].firstElementChild.value != "" && table.rows[i].cells[1].firstElementChild.value != "") //Skip rows with blanks
{
var playerCount = parseInt(table.rows[i].cells[0].firstElementChild.value);
partySize += playerCount;
var playerLevel = parseInt(table.rows[i].cells[1].firstElementChild.value)
totalXPEasy += playerCount * XPThresholdEasy[playerLevel];
totalXPMedium += playerCount * XPThresholdMedium[playerLevel];
totalXPHard += playerCount * XPThresholdHard[playerLevel];
totalXPDeadly += playerCount * XPThresholdDeadly[playerLevel];
}
}
document.getElementById("easyThreshold").innerHTML = totalXPEasy;
document.getElementById("mediumThreshold").innerHTML = totalXPMedium;
document.getElementById("hardThreshold").innerHTML = totalXPHard;
document.getElementById("deadlyThreshold").innerHTML = totalXPDeadly;
calculateEncounterDifficulty(JSON.parse(localStorage.getItem('monsterArray')));
}
function getEncounterSize(monsterArray) {
var encounterSize = 0;
for(var i = 0; i < monsterArray.length; i++)
{
encounterSize += monsterArray[i]["count"];
}
return encounterSize;
}
function calculateEncounterDifficulty(monsterArray) {
var encounterSize = 0;
var totalXP = 0;
for(var i = 0; i < monsterArray.length; i++)
{
var monsterData = monsterArray[i];
var monsterCount = monsterData["count"];
encounterSize += monsterCount;
var monsterCR = monsterData["totalCR"];
totalXP += monsterCount * XPLevels[monsterCR];
}
//Add modifiers for encounter size
var multiplierIndex = 1;
if(encounterSize == 1)
multiplierIndex = 1;
else if(encounterSize == 2)
multiplierIndex = 2;
else if(encounterSize >= 3 && encounterSize <= 6)
multiplierIndex = 3;
else if(encounterSize >= 7 && encounterSize <= 10)
multiplierIndex = 4;
else if(encounterSize >= 11 && encounterSize <= 14)
multiplierIndex = 5;
else if(encounterSize >= 15)
multiplierIndex = 6;
//Adjust modifier based on party size
if(partySize <= 2)
multiplierIndex += 1;
else if(partySize >= 6)
multiplierIndex -= 1;
console.log("ENCOUNSIZE " + encounterSize);
console.log("MULTINDEX " + multiplierIndex);
console.log("MULTIPLIER " + encounterSizeMultipliers[multiplierIndex]);
totalXP *= encounterSizeMultipliers[multiplierIndex];
return totalXP;
}
function calculateEncounterXPReward(monsterArray) {
var totalXP = 0;
for(var i = 0; i < monsterArray.length; i++)
{
var monsterData = monsterArray[i];
var monsterCount = monsterData["count"];
var monsterCR = monsterData["totalCR"];
totalXP += monsterCount * XPLevels[monsterCR];
}
return totalXP;
}
function setFeature(value, isSet) {
monsterFeats[value] = isSet;
recalcTotalCR();
}
function setFeatureNEW(element) {
var isEnabled = element.className == "featEnabled";
if(isEnabled)
element.className = "featDisabled";
else
element.className = "featEnabled";
monsterFeats[element.value] = !isEnabled;
recalcTotalCR();
}
function addValue(element, value) {
element.value = parseInt(element.value) + value;
element.onchange();
}
function raiseCR(monsterData) {
var baseHP = monsterData["hitPoints"];
var baseAC = monsterData["armorClass"];
var baseAB = monsterData["attackBonus"];
var baseDPR = monsterData["damagePerRound"];
var baseFeats = monsterData["monsterFeats"];
var targetCR = nextHigherCR(monsterData["totalCR"]);
var effectiveTotalCR = monsterData["totalCR"];
var effectiveOffensiveCR = recalcOffensiveCR(baseAB, baseDPR, baseHP, baseFeats);
var effectiveDefensiveCR = recalcDefensiveCR(baseAC, baseHP, targetCR, baseFeats);
//Repeat this until CR is raised by 1
while(effectiveTotalCR < targetCR)
{
if(effectiveDefensiveCR < effectiveOffensiveCR) //========----- RAISE DEFENSIVE CR
{
//STEP 1: Raise base AC up to average level
if(baseAC < ACLevels[targetCR])
{
baseAC += 1;
console.log("RAISED BASE AC to " + baseAC);
}
//STEP 2: Raise base HP
else if(baseHP < HPLevels[targetCR])
{
var baseHPCR = getHPCR(baseHP);
baseHP = Math.round((HPLevels[baseHPCR] + HPLevels[nextHigherCR(baseHPCR)]) / 2);
console.log("RAISED BASE HP to " + baseHP);
}
//STEP 3: Raise base AC up further
else if(baseAC < ACLevels[targetCR] + 2)
{
baseAC += 1;
console.log("RAISED BASE AC to " + baseAC);
}
effectiveDefensiveCR = recalcDefensiveCR(baseAC, baseHP, targetCR, baseFeats);
console.log("effectiveDefensiveCR " + effectiveDefensiveCR);
}
else //========----- RAISE OFFENSIVE CR
{
//STEP 1: Raise base AB up to average level
if(baseAB < ABLevels[targetCR])
{
baseAB += 1;
console.log("RAISED BASE AB to " + baseAB);
}
//STEP 2: Raise base DPR
else if(baseDPR < DPRLevels[targetCR])
{
var baseDPRCR = getDPRCR(baseDPR);
baseDPR = Math.round((DPRLevels[baseDPRCR] + DPRLevels[nextHigherCR(baseDPRCR)]) / 2);
console.log("RAISED BASE DPR to " + baseDPR);
}
//STEP 3: Raise base AB up further
else if(baseAB < ABLevels[targetCR] + 2)
{
baseAB += 1;
console.log("RAISED BASE AB to " + baseAB);
}
effectiveOffensiveCR = recalcOffensiveCR(baseAB, baseDPR, baseHP, baseFeats);
console.log("effectiveOffensiveCR " + effectiveOffensiveCR);
}
//Recalc total CR. If total CR is target, end
effectiveTotalCR = (effectiveDefensiveCR + effectiveOffensiveCR)/2;
}
//Handle cases when totalCR is around the fractional CRs
if (0 <= effectiveTotalCR && effectiveTotalCR < 1/16) effectiveTotalCR = 0;
else if(1/16 <= effectiveTotalCR && effectiveTotalCR < 3/16) effectiveTotalCR = 1/8;
else if(3/16 <= effectiveTotalCR && effectiveTotalCR < 6/16) effectiveTotalCR = 1/4;
else if(6/16 <= effectiveTotalCR && effectiveTotalCR < 12/16) effectiveTotalCR = 1/2;
else effectiveTotalCR = Math.round(effectiveTotalCR);
console.log("effectiveTotalCR" + effectiveTotalCR);
monsterData["hitPoints"] = baseHP;
monsterData["armorClass"] = baseAC;
monsterData["attackBonus"] = baseAB;
monsterData["damagePerRound"] = baseDPR;
monsterData["monsterFeats"] = baseFeats;
monsterData["totalCR"] = effectiveTotalCR;
return monsterData;
}
function lowerCR(monsterData) { //Given a monsterData array, return a modified one with CR one step lower
//Capture initial monster stats
var baseHP = monsterData["hitPoints"];
var baseAC = monsterData["armorClass"];
var baseAB = monsterData["attackBonus"];
var baseDPR = monsterData["damagePerRound"];
var baseFeats = monsterData["monsterFeats"];
var targetCR = nextLowerCR(monsterData["totalCR"]);
var effectiveTotalCR = monsterData["totalCR"];
var effectiveOffensiveCR = recalcOffensiveCR(baseAB, baseDPR, baseHP, baseFeats);
console.log("OFFENSIVE??? : " + effectiveOffensiveCR);
var effectiveDefensiveCR = recalcDefensiveCR(baseAC, baseHP, targetCR, baseFeats);
console.log("DEFENSIVE??? : " + effectiveDefensiveCR);
//Sort monster features by strength and store in a list
//Offensive Features
console.log(baseFeats);
var monsterFeatsOffensive = [];
if(baseFeats["DamageTransfer"]) monsterFeatsOffensive.push("DamageTransfer");
if(baseFeats["Enlarge"]) monsterFeatsOffensive.push("Enlarge");
if(baseFeats["MartialAdvantage"]) monsterFeatsOffensive.push("MartialAdvantage");
if(baseFeats["Swallow"]) monsterFeatsOffensive.push("Swallow");
if(baseFeats["Charge"]) monsterFeatsOffensive.push("Charge");
if(baseFeats["Dive"]) monsterFeatsOffensive.push("Dive");
if(baseFeats["Pounce"]) monsterFeatsOffensive.push("Pounce");
if(baseFeats["SurpriseAttack"]) monsterFeatsOffensive.push("SurpriseAttack");
if(baseFeats["WoundedFury"]) monsterFeatsOffensive.push("WoundedFury");
if(baseFeats["BloodFrenzy"]) monsterFeatsOffensive.push("BloodFrenzy");
if(baseFeats["NimbleEscape"]) monsterFeatsOffensive.push("NimbleEscape");
if(baseFeats["Ambusher"]) monsterFeatsOffensive.push("Ambusher");
if(baseFeats["PackTactics"]) monsterFeatsOffensive.push("PackTactics");
if(baseFeats["ElementalBody"]) monsterFeatsOffensive.push("ElementalBody");
if(baseFeats["Aggressive"]) monsterFeatsOffensive.push("Aggressive");
if(baseFeats["Rampage"]) monsterFeatsOffensive.push("Rampage");
console.log(monsterFeatsOffensive);
//Defensive Features
var monsterFeatsDefensive = [];
if(baseFeats["NimbleEscape"]) monsterFeatsDefensive.push("NimbleEscape");
if(baseFeats["ShadowStealth"]) monsterFeatsDefensive.push("ShadowStealth");
if(baseFeats["Possession"]) monsterFeatsDefensive.push("Possession");
if(baseFeats["DamageTransfer"]) monsterFeatsDefensive.push("DamageTransfer");
if(baseFeats["SuperiorInvisibility"]) monsterFeatsDefensive.push("SuperiorInvisibility");
if(baseFeats["MagicResistance"]) monsterFeatsDefensive.push("MagicResistance");
if(baseFeats["FrightfulPresence"]) monsterFeatsDefensive.push("FrightfulPresence");
if(baseFeats["HorrifyingVisage"]) monsterFeatsDefensive.push("HorrifyingVisage");
if(baseFeats["Avoidance"]) monsterFeatsDefensive.push("Avoidance");
if(baseFeats["Constrict"]) monsterFeatsDefensive.push("Constrict");
if(baseFeats["Parry"]) monsterFeatsDefensive.push("Parry");
if(baseFeats["Stench"]) monsterFeatsDefensive.push("Stench");
if(baseFeats["Web"]) monsterFeatsDefensive.push("Web");
if(baseFeats["LegendaryResistance"]) monsterFeatsDefensive.push("LegendaryResistance");
if(baseFeats["UndeadFortitude"]) monsterFeatsDefensive.push("UndeadFortitude");
if(baseFeats["Relentless"]) monsterFeatsDefensive.push("Relentless");
//Repeat this until CR is lowered by 1
while(effectiveTotalCR > targetCR)
{
if(effectiveDefensiveCR > effectiveOffensiveCR) //========----- LOWER DEFENSIVE CR
{
//STEP 1: Remove monster features until only one defensive feature is left
if(monsterFeatsDefensive.length > 1)
{
var featToCut = monsterFeatsDefensive[0];
delete baseFeats[featToCut];
monsterFeatsOffensive.splice(monsterFeatsOffensive.indexOf(featToCut), 1);
monsterFeatsDefensive = monsterFeatsDefensive.slice(1); //Take first item out of the FEAT list
console.log(monsterFeatsDefensive);
console.log("CUT OFF A DEFENSIVE MONSTER FEAT");
}
//STEP 2: Lower base AC up to a point
else if(baseAC > ACLevels[targetCR] + 2)
{
baseAC -= 1;
console.log("LOWERED BASE AC to " + baseAC);
}
//STEP 3: Lower base HP
else if(baseHP > HPLevels[targetCR])
{
var baseHPCR = getHPCR(baseHP);
baseHP = Math.round((HPLevels[nextLowerCR(baseHPCR)] + HPLevels[nextLowerCR(nextLowerCR(baseHPCR))]) / 2);
console.log("LOWERED BASE HP to " + baseHP);
}
//STEP 4: Lower base AC even more
else if(baseAC > ACLevels[targetCR])
{
baseAC -= 1;
console.log("LOWERED BASE AC to " + baseAC);
}
//STEP 5: Remove all defensive features
else if(monsterFeatsDefensive.length > 0)
{
var featToCut = monsterFeatsDefensive[0];
delete baseFeats[featToCut];
monsterFeatsOffensive.splice(monsterFeatsOffensive.indexOf(featToCut), 1);
monsterFeatsDefensive = monsterFeatsDefensive.slice(1); //Take first item out of the FEAT list
console.log(monsterFeatsDefensive);
console.log("CUT OFF A DEFENSIVE MONSTER FEAT");
}
effectiveDefensiveCR = recalcDefensiveCR(baseAC, baseHP, targetCR, baseFeats);
console.log("effectiveDefensiveCR " + effectiveDefensiveCR);
}
else //========----- LOWER OFFENSIVE CR
{
//STEP 1: Remove monster features until only one offensive feature is left
console.log("offensive feats: " + monsterFeatsOffensive.length);
if(monsterFeatsOffensive.length > 1)
{
var featToCut = monsterFeatsOffensive[0];
console.log("feattocut " + featToCut);
delete baseFeats[featToCut];
console.log("baseFeats " + baseFeats);
monsterFeatsDefensive.splice(monsterFeatsDefensive.indexOf(featToCut), 1);
monsterFeatsOffensive = monsterFeatsOffensive.slice(1); //Take first item out of the FEAT list
console.log(monsterFeatsOffensive);
console.log("CUT OFF AN OFFENSIVE MONSTER FEAT");
}
//STEP 2: Lower base AB up to a point
else if(baseAB > ABLevels[targetCR] + 2)
{
baseAB -= 1;
console.log("LOWERED BASE AB to " + baseAB);
}
//STEP 3: Lower base DPR
else if(baseDPR > DPRLevels[targetCR])
{
var baseDPRCR = getDPRCR(baseDPR);
baseDPR = Math.round((DPRLevels[nextLowerCR(baseDPRCR)] + DPRLevels[nextLowerCR(nextLowerCR(baseDPRCR))]) / 2);
console.log("LOWERED BASE DPR to " + baseDPR);
}