-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencounter.js
6824 lines (6764 loc) · 411 KB
/
encounter.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
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
/*
Encounter Creator for 5e in Roll20
Made by Julexar (https://app.roll20.net/users/9989180/julexar)
API Commands (GM Only):
!enc - Pulls up the Encounter Menu
--create {Insert Name} - Creates an Encounter and pulls up the Edit Menu
--{Insert Name/Number} - Shows the specifics of an Encounter by Name/Number
--edit - Edit a specific Encounter
--name {Insert Name} - Change the name of the Encounter
--party {Insert Party name} - Selects a Party
--add/rem --name/id {Insert Character Name/ID} - Adds/Removes a Character
--cr min/max {Insert min/max CR} - Change the min/max CR of the Monsters in the Encounter
--monster - Edits a Monster
--add/rem {Insert existing Monster Name} --amount {Insert Number} - Adds/Removes a Monster
--{Insert existing Monster Name} - Edits a Monster inside the Encounter
--loot - Edits Loot Table
--add {Insert Item Name} --amount {Insert Amount} - Adds an item to the loot table
--rem {Insert Item Name} --amount {Insert Amount} - Removes an item from the loot table
--money {PP/GP/SP/CP} --add/rem --amount {Insert Amount} - Adds Currency
--{Insert existing Item Name} - Edits an Item inside the Encounter
--genloot {Insert amount} - Generates Loot
--overwrite true/false - Specifies if the old loot table should be replaced (Default: true)
--loot - Shows the Loot table
--monsters - Shows a list of all Monsters
--submit - Finishes the encounter creation and creates Monsters as well as a Handout for loot
--ignorecr - Ignores the minimum and maximum CR when making the Monsters
--delete - Deletes the Encounter
--reset - Resets the encounter to the default
!monster - Pulls up the Monster Menu
--new {Insert Monster name} - Creates a new Monster
--{Insert Monster name} - Selects a specific Monster
--edit - Pulls up the Monster Editor
--name {Insert Name} - Sets the Name of the Monster
--type {Insert Type} - Sets the Monster's type
--ac {Insert Numer} --type {Insert AC Type} - Sets the Monster's AC
--hp {Insert Number} - Sets the Monster's HP
--speed {Insert Speed} - Sets the Monster's Speed
--attr {Insert Attribute} --{Insert value} - Edits the Attribute of a Monster
--save {Insert Attribute} --{Insert value} - Edits the save bonus of a Monster
--saveadd {Insert Attribute} --{Insert value} - Adds a save to the Monster
--saverem {Insert Attribute} - Removes a save from the Monster
--skill {Insert Skill} --{Insert value} - Edits the skill bonus of a Monster
--skilladd {Insert Skill} --{Insert value} - Adds a skill to the Monster
--skillrem {Insert Skill} - Removes a skill from the Monster
--vul {Insert Vulnerabilities} - Sets the Monster's Damage Vulnerabilities
--res {Insert Resistances} - Sets the Monster's Resistances
--dmg_immune {Insert Immunities} - Sets the Monster's Immunities
--cond_immune {Insert Condition Immunities} - Sets the Monster's condition immunities
--sense {Insert Senses} - Sets the Monster's Senses
--lang {Insert Languages} - Sets the Monster's languages
--cr {Insert Number} - Sets the Monster's CR
--pb {Insert Number} - Sets the Monster's prof. bonus
--caster true/false --{Insert Ability} --lvl {Insert number} - Sets whether the Monster can cast Spells and the spellcasting ability and caster lvl
--spellmod {Insert number} - Sets the Monster's spell attack modifier
--spelldc {Insert number} - Sets the Monster's spell save dc
--ba true/false - Sets whether the Monster has Bonus Actions
--react true/false - Sets whether the Monster has Reactions
--legendact {Insert Number} - Sets the Monster's Number of Legendary Actions
--myth true/false --desc {Insert description} - Sets whether the Monster has Mythic Actions and sets the description
--traits - Pulls up the trait editor
--{Insert Trait name} - Selects a specific trait
--setname {Insert Name} - Sets the name of a trait
--setdesc {Insert Desc} - Sets the description of a trait
--add {Insert Trait name} --desc {Insert desc} - Adds a trait
--rem {Insert Trait name} - Removes a trait
--bonusactions - Pulls up the Bonus action editor
--{Insert Bonus action name} - Selects a specific bonus action
--setname {Insert Name} - Sets the name of a bonus action
--setdesc {Insert Desc} - Sets the Description of a bonus action
--toggleatk - Toggles the bonus action to be an attack
--setrange {Insert range} - Sets the range of the attack
--settohit {Insert to hit} - Sets the to hit bonus of the attack
--setdmg {Insert damage dice} --type {Insert damage type} - Sets the damage dice and type of the bonus action
--setatktype Melee/Ranged - Sets the attack to me a Melee or Ranged Attack
--add {Insert Bonus action name} - adds a bonus action
--rem {Insert Bonus action name} - removes a bonus action
--actions - Pulls up the Action Editor
--{Insert Action name} - Selects a specific action
--setname {Insert Name} - Sets the name of an Action
--setdesc {Insert Desc} - Sets the Description of an Action
--toggleatk - Toggles the Action to have an Attack
--setrange {Insert range} - Sets the Range of the Attack
--settohit {Insert to hit} - Sets the to hit bonus of the attack
--setdmg {Insert damage dice} --type {Insert damage type} - Sets the damage and damage type of an Action
--setatktype Melee/Ranged - Sets the attack to me a Melee or Ranged Attack
--add {Insert Action name} - adds an action
--rem {Insert action name} - removes an action
--reactions - Pulls up the reaction editor
--{Insert Reaction name} - Selects a specific reaction
--setname {Insert Name} - Sets the name of a Reaction
--setdesc {Insert Desc} - Sets the Description of a Reaction
--add {Insert Reaction name} - adds a reaction
--desc {Insert Desc} - Sets the description
--rem {Insert Reaction name} - removes a reaction
--legend_actions - pulls up the legendary actions editor
--{Insert Leg. Action name} - Selects a specific legendary action
--setname {Insert Name} - Sets the name of a legendary Action
--setdesc {Insert Desc} - Sets the Description of a legendary Action
--toggleatk - Toggels the legendary Action to have an Attack
--setrange {Insert range} - Sets the Range of the Attack
--settohit {Insert to hit} - Sets the to hit bonus of the attack
--setdmg {Insert damage dice} --type {Insert damage type} - Sets the damage and damage type of a legendary Action
--setatktype Melee/Ranged - Sets the attack to me a Melee or Ranged Attack
--add {Insert Leg. Action name} - Adds a legendary action
--rem {Insert Leg. Action name} - Removes a legendary action
--mythic_actions - pulls up the mythic action editor
--{Insert myth. Action name} - Selects a specific mythic action
--setname {Insert Name} - Sets the name of a mythic Action
--setdesc {Insert Desc} - Sets the Description of a mythic Action
--toggleatk - Toggles the mythic Action to have an Attack
--setrange {Insert range} - Sets the range of the Attack
--settohit {Insert to hit} - Sets the to hit bonus of the attack
--setdmg {Insert damage dice} --type {Insert damage type} - Sets the damage and damage type of a mythic Action
--setatktype Melee/Ranged - Sets the attack to me a Melee or Ranged Attack
--add {Insert Myth. Action name} - Adds a mythic action
--rem {Insert Myth. Action name} - Removes a mythic action
--del - Deletes the Monster
--reset - Resets the monster to the defaults
!party - pulls up the Party Menu
--new {Insert Name} - creates a new Party
--{Insert Party name} - Selects a Party
--add --name/id/sel {Insert Character Name/ID OR select Character Token} - Adds a Character to the Party
--rem --name/id/sel {Insert Character Name/ID OR select Character Token} - Removes a Character from the Party
--del - Deletes the Party
--confirm - Permanently deletes the Party
--cancel - Cancels the Deletion
--setname {Insert Name} - Sets the Name of the Party
!loot - Pulls up the Loot Menu
--new {Insert Item Name} - Creates a new Item on the Loot Table
--value {Insert Number} - Sets the value of the Item
--desc {Insert Text} - Sets the description of the Item
--rarity {Insert Rarity} - Sets the rarity of the Item
--type {Insert Item Type} - Sets the Type of the Item - view the [Wiki](https://github.com/Julexar/encounter-creator/wiki) for Options
--rem {Insert Item Name} - Removes an Item from the Loot Table
--{Insert Item Name} - Views a specific Item
--edit --{Insert Item Name} - Pulls up the Item Editor
--name {Insert Name} - Edits the Name of the Item
--value {Insert Number} - Edits the Value of the Item
--desc {Insert Desc} - Edits the Description of the Item
--rarity {Insert Rarity} - Edits the Rarity of the Item
--type {Insert Item Type} - Edits the Type of the Item - view the [Wiki](https://github.com/Julexar/encounter-creator/wiki) for Options
--attack {true/false} - Toggles the Item to have an attack
--damage {Insert damage} --type {Insert damage type} - Edits the damage of the Item Attack
--secdamage {Insert damage} --type {Insert damage type} - Edits the secondary damage of the Item Attack
--tohit {Insert number} - Edits the To Hit bonus of the Item Attack
--magic {0/1/2/3} - Edits the magic bonus of the Item Attack
--confirm - Confirms the edits and applies them
*/
var EncounterCreator = EncounterCreator || (function() {
'use strict';
var version='0.9.1',
setEncounterDefaults = function() {
state.encounter = [];
},
setLootDefaults = function() {
state.loot = {
item: []
};
},
setTempDefaults = function() {
state.temp = {
item: {
name:"",
val:0,
desc:"",
rarity:"",
type:"",
atk:false,
dmg:"",
dmgtype:"",
secdmg:"",
secdmgtype:"",
tohit:0,
magic:0,
},
monster: {
name: "",
type: "",
ac: 10,
actype: "",
hp: 0,
sense: "",
speed: "",
lang: [],
save: [],
skill: [],
stat: {
str: 0,
dex: 0,
con: 0,
int: 0,
wis: 0,
cha: 0,
},
vuln: "",
res: "",
dmgimm: "",
condimm: "",
cr: 0,
pb: 0,
caster: false,
caster_lvl: 0,
spell_atk_mod: 0,
spell_dc_mod: 0,
cast_ability: "",
bonusact: false,
react: false,
legendary: 0,
mythic: false,
mythic_desc: "",
traits: [],
actions: [],
bonus_actions: [],
reactions: [],
legendary_actions: [],
mythic_actions: []
}
};
},
setPartyDefaults = function() {
state.party = [
{
//Basics
name: "",
members: []
}
];
},
setMonsterDefaults = function() {
state.monster = [];
},
setBasicDefaults = function() {
state.encbasics = {
dmgtype: "Acid|Bludgeoning|Cold|Fire|Force|Lightning|Magical Bludgeoning|Magical Piercing|Magical Slashing|Necrotic|Piercing|Poison|Psychic|Radiant|Slashing|Thunder",
atktype: "Melee|Ranged"
};
},
handleInput = function(msg) {
var args=msg.content.split(/\s+--/);
if (msg.type!=="api") {
return;
}
if (playerIsGM(msg.playerid)) {
switch (args[0]) {
case '!enc':
if (!args[1]) {
encounterMenu(args[1]);
} else if (args[1].includes("create")) {
let name = args[1].replace("create ","");
createEnc(name);
encounterMenu(name);
} else if (args[1]=="reset") {
resetEnc();
encounterMenu(undefined,undefined);
} else if (args[1]!==undefined && !args[1].includes("create") && args[1]!=="reset") {
let enc = args[1];
log(enc);
if (!args[2]) {
encounterMenu(enc);
} else if (args[2]=="edit") {
if (!args[3]) {
encounterMenu(enc);
} else if (args[3]!==undefined) {
let name,party,charident,cr,monster,item,val;
if (args[3].includes("name")) {
name=args[3].replace("name ","");
editEncounter(enc,"name",name);
encounterMenu(name);
} else if (args[3].includes("party")) {
party=args[3].replace("party ","");
if (!args[4]) {
encounterMenu(enc,party);
} else if (args[4]=="add" || args[4]=="rem") {
if (!args[5]) {
sendChat("Encounter Creator","/w gm You must define a Character you wish to add!");
} else if (args[5].includes("name") || args[5].includes("id")) {
charident=args[5];
editEncounter(enc,`party${args[4]}`,party,charident);
encounterMenu(enc,party);
}
}
} else if (args[3].includes("cr")) {
if (args[3].includes("min")) {
cr=Number(args[3].replace("cr min ",""));
editEncounter(enc,"crmin",cr);
} else if (args[3].includes("max")) {
cr=Number(args[3].replace("cr max ",""));
editEncounter(enc,"crmax",cr);
}
encounterMenu(enc,undefined);
} else if (args[3].includes("monster")) {
if (!args[4]) {
viewMonsters(enc);
} else if (args[4].includes("add")) {
monster=args[4].replace("add ","");
if (!args[5]) {
sendChat("Encounter Creator","/w gm You need to define the amount of Monsters you wish to add!");
} else if (args[5].includes("amount")) {
let amount=Number(args[5].replace("amount ",""));
editEncounter(enc,"addmon",monster,amount);
}
} else if (args[4].includes("rem")) {
monster=args[4].replace("rem ","");
if (!args[5]) {
sendChat("Encounter Creator","/w gm You need to define the amount of Monsters you wish to remove!");
} else if (args[5].includes("amount")) {
let amount=Number(args[5].replace("amount ",""));
editEncounter(enc,"remmon",monster,amount);
}
} else if (!args[4].includes("add") && !args[4].includes("rem")) {
monster=args[4];
editEncounter(enc,"monster",monster);
}
} else if (args[3].includes("loot")) {
if (!args[4]) {
viewLoot(enc);
} else if (args[4].includes("add")) {
item=args[4].replace("add ","");
if (!args[5]) {
sendChat("Encounter Creator","/w gm You must define the amount of Items you wish to add!");
} else if (args[5].includes("amount")) {
let amount=Number(args[5].replace("amount ",""));
editEncounter(enc,"addloot",item,amount);
}
} else if (args[4].includes("rem")) {
item=args[4].replace("rem ","");
if (!args[5]) {
sendChat("Encounter Creator","/w gm You must define the amount of Items you wish to remove!");
} else if (args[5].includes("amount")) {
let amount=Number(args[5].replace("amount ",""));
editEncounter(enc,"remloot",item,amount);
}
} else if (args[4].includes("money")) {
let currency=args[4].replace("money ","").toLowerCase();
if (currency!="pp" && currency!="gp" && currency!="sp" && currency!="cp") {
sendChat("Encounter Creator","/w gm Invalid Currency. Please choose PP, GP, SP or CP!");
} else {
if (!agrs[5]) {
sendChat("Encounter Creator","/w gm You must define whether you wish to add or remove Money!");
} else if (args[5]=="add") {
if (!args[6]) {
sendChat("Encounter Creator","/w gm You must define the amount of Money you wish to add!");
} else if (args[6].includes("amount")) {
let amount = args[6].replace("amount ","");
editEncounter(enc,"money",args[3],currency,amount);
}
} else if (args[5]=="rem") {
if (!args[6]) {
sendChat("Encounter Creator","/w gm You must define the amount of Money you wish to remove!");
} else if (args[6].includes("amount")) {
let amount = args[6].replace("amount ","");
editEncounter(enc,"money",args[3],currency,amount);
}
}
}
} else if (!args[4].includes("add") && !args[4].includes("rem") && !args[4].includes("money")) {
item=args[4];
if (!args[5]) {
editEncounter(enc,"item",item);
} else if (args[5].includes("name")) {
let name = args[5].replace("name ","");
editEncounter(enc,"item","name",name);
} else if (args[5].includes("value")) {
let val = Number(args[5].replace("value ",""));
editEncounter(enc,"item","value",val);
} else if (args[5].includes("desc")) {
let desc = args[5].replace("desc ","");
editEncounter(enc,"item","desc",desc);
} else if (args[5].includes("rarity")) {
let rare = args[5].replace("rarity ","");
editEncounter(enc,"item","rarity",rare);
} else if (args[5].includes("type")) {
let type = args[5].replace("type ","");
editEncounter(enc,"item","type",type);
} else if (args[5].includes("attack")) {
let attack = Boolean(args[5].replace("attack ",""));
editEncounter(enc,"item","attack",attack);
} else if (args[5].includes("sec")) {
let secdmg = args[5].replace("secdamage ","");
if (!args[6]) {
sendChat("Encounter Creator","/w gm Missing Damage Type for secondary damage!");
} else if (args[6].includes("type")) {
let secdmgtype = args[5].replace("type ","");
editEncounter(enc,"item","secdamage",secdmg,secdmgtype);
}
} else if (args[5].includes("damage")) {
let dmg = args[5].replace("damage ","");
if (!args[6]) {
sendChat("Encounter Creator","/w gm Missing Damage Type for primary damage!");
} else if (args[6].includes("type")) {
let dmgtype = args[6].replace("type ","");
editEncounter(enc,"item","damage",dmg,dmgtype);
}
} else if (args[5].includes("tohit")) {
let tohit = args[5].replace("tohit ","");
editEncounter(enc,"item","tohit",tohit);
} else if (args[5].includes("magic")) {
let magic = args[5].replace("magic ","");
editEncounter(enc,"item","magic",magic);
} else if (args[5].includes("confirm")) {
editEncounter(enc,"item","confirm");
}
}
}
}
} else if (args[2].includes("genloot")) {
let amount = Number(args[2].replace("genloot ",""));
if (!args[3]) {
genLoot(enc,amount,false,true);
} else if (args[3].includes("hoard")) {
let hoard = Boolean(args[3].replace("hoard ",""));
if (!args[4]) {
genLoot(enc,amount,hoard,true);
} else if (args[4].includes("overwrite")) {
let overwrite = Boolean(args[5].replace("overwrite ",""));
genLoot(enc,amount,hoard,overwrite);
}
}
} else if (args[2]=="loot") {
viewLoot(enc);
} else if (args[2]=="monsters") {
viewMonsters(enc);
} else if (args[2]=="submit") {
if (!args[3]) {
submitEnc(enc);
} else if (args[3].includes("ignorecr")) {
let ignore=args[3].replace("ignorecr ","");
submitEnc(enc,ignore);
}
} else if (args[2]=="reset") {
resetEnc(enc);
} else if (args[2]=="delete") {
deleteEnc(enc);
}
}
return;
case '!monster':
if (!args[1]) {
monsterMenu(args[1]);
} else if (!args[1].includes("new")) {
let monster = args[1];
if (!args[2]) {
monsterMenu(monster);
} else if (args[2]=="edit") {
let name,type,ac,actype,hp,speed,attr,attrval,saveattr,saveval,skill,skillval,vul,res,dmg_immune,cond_immune,sense,lang,cr,pb,caster,castattr,castlvl,spellmod,spelldc,ba,react,legendact,myth,mythdesc;
if (!args[3]) {
monsterMenu(monster);
} else if (args[3].includes("name")) {
name=args[3].replace("name ","");
editMonster(monster,"name",name);
monsterMenu(name);
} else if (args[3].includes("type")) {
type=args[3].repalce("type ","");
editMonster(monster,"type",type);
monsterMenu(monster);
} else if (args[3].includes("ac")) {
ac=Number(args[3].replace("ac ",""))
if (!args[4]) {
actpye="";
} else if (args[4].includes("type")) {
actype=args[4].replace("type ","");
}
editMonster(monster,"ac",ac,actype);
monsterMenu(monster);
} else if (args[3].includes("hp")) {
hp=Number(args[3].replace("hp ",""));
editMonster(monster,"hp",hp);
monsterMenu(monster);
} else if (args[3].includes("speed")) {
speed=args[3].replace("speed ","");
editMonster(monster,"speed",speed);
monsterMenu(monster);
} else if (args[3].includes("attr")) {
attr=args[3].replace("attr ","");
if (!args[4]) {
sendChat("Encounter Creator","/w gm You need to define a value for the Attribute!");
} else if (args[4]) {
attrval=Number(args[4]);
editMonster(monster,"attr",attr,attrval);
monsterMenu(monster);
}
} else if (args[3].includes("save")) {
if (!args[3].includes("add") || !args[3].includes("rem")) {
saveattr=args[3].replace("save ","");
if (!args[4]) {
sendChat("Encounter Creator","/w gm You need to define a value for the Save bonus!");
} else if (args[4]) {
saveval=Number(args[4]);
editMonster(monster,"save",saveattr,saveval);
monsterMenu(monster);
}
} else if (args[3].includes("add")) {
saveattr=args[3].replace("saveadd ","");
if (!args[4]) {
sendChat("Encounter Creator","/w gm You need to define a value for the Save bonus!");
} else if (args[4]) {
saveval=Number(args[4]);
editMonster(monster,"saveadd",saveattr,saveval);
monsterMenu(monster);
}
} else if (args[3].includes("rem")) {
saveattr=args[3].replace("saverem ","");
editMonster(monster,"saverem",saveattr);
monsterMenu(monster);
}
} else if (args[3].includes("skill")) {
if (!args[3].includes("add") && !args[3].includes("rem")) {
skill=args[3].replace("skill ","");
if (!args[4]) {
sendChat("Encounter Creator","/w gm You need to define a value for the Skill bonus!");
} else if (args[4]) {
saveval=Number(args[4]);
editMonster(monster,"skill",skill,skillval);
monsterMenu(monster);
}
} else if (args[3].includes("add")) {
skill=args[3].replace("skilladd ","");
if (!args[4]) {
sendChat("Encounter Creator","/w gm You need to define a value for the Skill bonus!");
} else if (args[4]) {
saveval=Number(args[4]);
editMonster(monster,"skilladd",skill,skillval);
monsterMenu(monster);
}
} else if (args[3].includes("rem")) {
skill=args[3].replace("skillrem ","");
editMonster(monster,"skillrem",skill);
monsterMenu(monster);
}
} else if (args[3].includes("vul")) {
vul=args[3].replace("vul ","");
editMonster(monster,"vul",vul);
monsterMenu(monster);
} else if (args[3].includes("res")) {
res=args[3].replace("res ","");
editMonster(monster,"res",res);
monsterMenu(monster);
} else if (args[3].includes("dmg_immune")) {
dmg_immune=args[3].replace("dmg_immune ","");
editMonster(monster,"dmg_immune",dmg_immune);
monsterMenu(monster);
} else if (args[3].includes("cond_immune")) {
cond_immune=args[3].replace("cond_immune ","");
editMonster(monster,"dmg_immune",dmg_immune);
monsterMenu(monster);
} else if (args[3].includes("sense")) {
sense=args[3].replace("sense ","");
editMonster(monster,"sense",sense);
monsterMenu(monster);
} else if (args[3].includes("lang")) {
lang=args[3].replace("lang ","");
editMonster(monster,"lang",lang);
monsterMenu(monster);
} else if (args[3].includes("cr")) {
cr=Number(args[3].replace("cr ",""));
editMonster(monster,"cr",cr);
monsterMenu(monster);
} else if (args[3].includes("pb")) {
pb=Number(args[3].replace("pb ",""));
editMonster(monster,"pb",cr);
monsterMenu(monster);
} else if (args[3].includes("caster")) {
caster=Boolean(args[3].replace("caster ",""));
if (caster==true) {
if (!args[4]) {
sendChat("Encounter Creator","/w gm You need to define a spellcasting ability!");
} else if (args[4]) {
castattr=args[4];
if (!args[5]) {
sendChat("Encounter Creator","/w gm You need to define the caster level!");
} else if (args[5].includes("lvl")) {
castlvl=Number(args[5].replace("lvl ",""));
editMonster(monster,"caster",caster,castattr,castlvl);
monsterMenu(monster);
}
}
} else if (caster==false) {
editMonster(monster,"caster",caster);
monsterMenu(monster);
}
} else if (args[3].includes("spellmod")) {
spellmod=Number(args[3].repalce("spellmod ",""));
editMonster(monster,"spellmod",spellmod);
monsterMenu(monster);
} else if (args[3].includes("spelldc")) {
spelldc=Number(args[3].replace("spelldc ",""));
editMonster(monster,"spelldc",spelldc);
monsterMenu(monster);
} else if (args[3].includes("ba")) {
ba=Boolean(args[3].replace("ba ",""));
editMonster(monster,"ba",ba);
monsterMenu(monster);
} else if (args[3].includes("react")) {
react=Boolean(args[3].replace("react ",""));
editMonster(monster,"react",react);
monsterMenu(monster);
} else if (args[3].includes("legendact")) {
legendact=Number(args[3].replace("legendact ",""));
editMonster(monster,"legendact",legendact);
monsterMenu(monster);
} else if (args[3].includes("myth")) {
myth=Boolean(args[3].replace("myth ",""));
if (myth==true) {
if (!args[4]) {
sendChat("Encounter Creator","/w gm You must define a description for Mythic Actions!");
} else if (args[4].includes("desc")) {
mythdesc=args[4].replace("desc ","");
editMonster(monster,"myth",myth,mythdesc);
monsterMenu(monster);
}
} else if (myth==false) {
editMonster(monster,"myth",myth);
monsterMenu(monster);
}
} else if (args[3]=="traits") {
if (!args[4].includes("add") && !args[4].includes("rem")) {
let trait=args[4];
if (!args[5]) {
traitEditor(monster,trait);
} else if (args[5].includes("setname")) {
let name=args[5].replace("setname ","");
editTrait(monster,trait,"name",name);
traitEditor(name);
} else if (args[5].includes("setdesc")) {
let desc=args[5].replace("setdesc ","");
editTrait(monster,trait,"desc",desc);
traitEditor(monster,trait);
}
} else if (args[4].includes("add")) {
let name=args[4].replace("add ","");
createTrait(monster,name);
traitEditor(monster,name);
} else if (args[4].includes("rem")) {
let name=args[4].replace("rem ","");
removeTrait(monster,name);
traitEditor(monster,undefined);
}
} else if (args[3]=="bonusactions") {
if (!args[4].includes("add") && !args[4].includes("rem")) {
let ba=args[4];
if (!args[5]) {
baEditor(monster,ba);
} else if (args[5].includes("setname")) {
let name=args[5].replace("setname ","");
editBA(monster,ba,"name",name);
baEditor(monster,name);
} else if (args[5].includes("setdesc")) {
let desc=args[5].replace("setdesc ","");
editBA(monster,ba,"desc",desc);
baEditor(monster,ba);
} else if (args[5].includes("toggleatk")) {
let mon=state.monster.find(m => m.name==monster);
let bonus_act=mon.bonus_actions.find(b => b.name==ba);
let atk=bonus_act.attack;
if (atk==true) {
atk=false;
editBA(monster,ba,"atk",atk);
baEditor(monster,ba);
} else if (atk==false) {
atk=true;
editBA(monster,ba,"atk",atk);
baEditor(monster,ba);
}
} else if (args[5].includes("setdmg")) {
let dice=args[5].replace("setdmg ","");
if (!args[6]) {
sendChat("Encounter Creator","/w gm You need to define a damage type!");
} else if (args[6].includes("dmgtype")) {
let dmgtype=args[6].replace("dmgtype ","");
if (!state.encbasics.dmgtype.includes(dmgtype)) {
sendChat("Encounter Creator","/w gm Invalid Damage Type!");
} else if (state.encbasics.dmgtype.includes(dmgtype)) {
editBA(monster,ba,"dmg",dice,dmgtype);
baEditor(monster,ba);
}
}
} else if (args[5].includes("settohit")) {
let tohit=Number(args[5].replace("settohit ",""));
editBA(monster,ba,"tohit",tohit);
baEditor(monster,ba);
} else if (args[5].includes("setatktype")) {
let atktype=args[5].replace("setatktype ","");
if (!state.encbasics.atktype.includes(atktype)) {
sendChat("Encounter Creator","/w gm Invalid Attack Type!");
} else if (state.encbasics.atktype.includes(atktype)) {
editBA(monster,ba,"atktype",atktype);
baEditor(monster,ba);
}
} else if (args[5].includes("setrange")) {
let range=args[5].replace("setrange ","")+" ft.";
editBA(monster,ba,"range",range);
baEditor(monster,ba);
}
} else if (args[4].includes("add")) {
let ba=args[4].replace("add ","");
createBA(monster,ba);
baEditor(monster,ba);
} else if (args[4].includes("rem")) {
let ba=args[4].replace("rem ","");
removeBA(monster,ba);
baEditor(monster,undefined);
}
} else if (args[3]=="actions") {
if (!args[4].includes("add") && !args[4].includes("rem")) {
let act=args[4];
if (!args[5]) {
actEditor(monster,act);
} else if (args[5].includes("setname")) {
let name=args[5].replace("setname ","");
editAct(monster,act,"name",name);
actEditor(monster,name);
} else if (args[5].includes("setdesc")) {
let desc=args[5].replace("setdesc ","");
editAct(monster,act,"desc",desc);
actEditor(monster,act);
} else if (args[5].includes("toggleatk")) {
let mon=state.monster.find(m => m.name==monster);
let action=mon.actions.find(a => a.name==act);
let atk=action.attack;
if (atk==true) {
atk=false;
editAct(monster,act,"atk",atk);
actEditor(monster,act);
} else if (atk==false) {
atk=true;
editAct(monster,act,"atk",atk);
actEditor(monster,act);
}
} else if (args[5].includes("setdmg")) {
let dice=args[5].replace("setdmg ","");
if (!args[6]) {
sendChat("Encounter Creator","/w gm You need to define a damage type!");
} else if (args[6].includes("dmgtype")) {
let dmgtype=args[6].replace("dmgtype ","");
if (!state.encbasics.dmgtype.includes(dmgtype)) {
sendChat("Encounter Creator","/w gm Invalid Damage Type!");
} else if (state.encbasics.dmgtype.includes(dmgtype)) {
editAct(monster,act,"dmg",dice,dmgtype);
actEditor(monster,act);
}
}
} else if (args[5].includes("settohit")) {
let tohit=Number(args[5].replace("settohit ",""));
editAct(monster,act,"tohit",tohit);
actEditor(monster,act);
} else if (args[5].includes("setatktype")) {
let atktype=args[5].replace("setatktype ","");
if (!state.encbasics.atktype.includes(atktype)) {
sendChat("Encounter Creator","/w gm Invalid Attack Type");
} else if (state.encbasics.atktype.includes(atktype)) {
editAct(monster,act,"atktype",atktype);
actEditor(monster,act);
}
} else if (args[5].includes("setrange")) {
let range=args[5].replace("setrange ","")+" ft.";
editAct(monster,act,"range",range);
actEditor(monster,act);
}
} else if (args[4].includes("add")) {
let act=args[4].replace("add ","");
createAct(monster,act);
actEditor(monster,act);
} else if (args[4].includes("rem")) {
let act=args[4].replace("rem ","");
removeAct(monster,act);
actEditor(monster,undefined);
}
} else if (args[3]=="reactions") {
if (!args[4].includes("add") && !args[4].includes("rem")) {
let reaction=args[4];
if (!args[5]) {
reactEditor(monster,reaction);
} else if (args[5].includes("setname")) {
let name=args[5].replace("setname ","");
editReact(monster,reaction,"name",name);
reactEditor(monster,name);
} else if (args[5].includes("setdesc")) {
let desc=args[5].replace("setdesc ","");
editReact(monster,reaction,"desc",desc);
reactEditor(monster,reaction);
}
} else if (args[4].includes("add")) {
let reaction=args[4].replace("add ","");
createReact(monster,reaction);
reactEditor(monster,reaction);
} else if (args[4].includes("rem")) {
let reaction=args[4].replace("rem ","");
removeReact(monster,reaction);
reactEditor(monster,undefined);
}
} else if (args[3]=="legend_actions") {
if (!args[4].includes("add") && !args[4].includes("rem")) {
let leg=args[4];
if (!args[5]) {
legEditor(monster,leg);
} else if (args[5].includes("setname")) {
let name=args[5].replace("setname ","");
editLeg(monster,leg,"name",name);
legEditor(monster,name);
} else if (args[5].includes("setdesc")) {
let desc=args[5].replace("setdesc ","");
editLeg(monster,leg,"desc",desc);
legEditor(monster,leg);
} else if (args[5].includes("toggleatk")) {
let mon=state.monster.find(m => m.name==monster);
let leg_act=mon.legend_actions.find(l => l.name==leg);
let atk=leg_act.attack;
if (atk==true) {
atk=false;
editLeg(monster,leg,"atk",atk);
legEditor(monster,leg);
} else if (atk==false) {
atk=true;
editLeg(monster,leg,"atk",atk);
legEditor(monster,leg);
}
} else if (args[5].includes("setdmg")) {
let dice=args[5].replace("setdmg ","");
if (!args[6]) {
sendChat("Encounter Creator","/w gm You need to define a damage type!");
} else if (args[6].includes("dmgtype")) {
let dmgtype=args[6].replace("dmgtype ","");
if (!state.encbasics.dmgtype.includes(dmgtype)) {
sendChat("Encounter Creator","/w gm Invalid Damage Type!");
} else if (state.encbasics.dmgtype.includes(dmgtype)) {
editLeg(monster,leg,"dmg",dice,dmgtype);
legEditor(monster,leg);
}
}
} else if (args[5].includes("settohit")) {
let tohit=Number(args[5].replace("settohit ",""));
editLeg(monster,leg,"tohit",tohit);
legEditor(monster,leg);
} else if (args[5].includes("setatktype")) {
let atktype=args[5].replace("setatktype ","");
if (!state.encbasics.atktype.includes(atktype)) {
sendChat("Encounter Creator","/w gm Invalid Attack Type!");
} else if (state.encbasics.atktype.includes(atktype)) {
editLeg(monster,leg,"atktype",atktype);
legEditor(monster,leg);
}
} else if (args[5].includes("setrange")) {
let range=args[5].replace("setrange ","")+" ft.";
editLeg(monster,leg,"range",range);
legEditor(monster,leg);
}
} else if (args[4].includes("add")) {
let leg=args[4].replace("add ","");
createLeg(monster,leg);
legEditor(monster,leg);
} else if (args[4].includes("rem")) {
let leg=args[4].replace("rem ","");
removeLeg(monster,leg);
legEditor(monster,undefined);
}
} else if (args[3]=="mythic_actions") {
if (!args[4].includes("add") && !args[4].includes("rem")) {
let myth=args[4];
if (!args[5]) {
mythEditor(monster,myth);
} else if (args[5].includes("setname")) {
let name=args[5].replace("setname ","");
editMyth(monster,myth,"name",name);
mythEditor(monster,name);
} else if (args[5].includes("setdesc")) {
let desc=args[5].replace("setdesc ","");
editMyth(monster,myth,"desc",desc);
mythEditor(monster,myth);
} else if (args[5].includes("toggleatk")) {
let mon=state.monster.find(m => m.name==monster);
let myth_act=mon.mythic_actions.find(m => m.name==myth);
let atk=myth_act.attack;
if (atk==true) {
atk=false;
editMyth(monster,myth,"atk",atk);
mythEditor(monster,myth);
} else if (atk==false) {
atk=true;
editMyth(monster,myth,"atk",atk);
mythEditor(monster,myth);
}
} else if (args[5].includes("setdmg")) {
let dice=args[5].replace("setdmg ","");
if (!args[6]) {
sendChat("Encounter Creator","/w gm You need to define a damage type!");
} else if (args[6].includes("dmgtype")) {
let dmgtype=args[6].replace("dmgtype ","");
if (!state.encbasics.dmgtype.includes(dmgtype)) {
sendChat("Encounter Creator","/w gm Invalid Damage Type!");
} else if (state.encbasics.dmgtype.includes(dmgtype)) {
editMyth(monster,myth,"dmg",dice,dmgtype);
mythEditor(monster,myth);
}
}
} else if (args[5].includes("settohit")) {
let tohit=Number(args[5].replace("settohit ",""));
editMyth(monster,myth,"tohit",tohit);
mythEditor(monster,myth);
} else if (args[5].includes("setatktype")) {
let atktype=args[5].replace("setatktype ","");
if (!state.encbasics.atktype.includes(atktype)) {
sendChat("Encounter Creator","/w gm Invalid Attack Type!");
} else if (state.encbasics.atktype.includes(atktype)) {
editMyth(monster,myth,"atktype",atktype);
mythEditor(monster,myth);
}
} else if (args[5].includes("setrange")) {
let range=args[5].replace("setrange ","")+" ft.";
editMyth(monster,myth,"range",range);
mythEditor(monster,myth);
}
} else if (args[4].includes("add")) {
let myth=args[4].replace("add ","");
createMyth(monster,myth);
mythEditor(monster,myth);
} else if (args[4].includes("rem")) {
let myth=args[4].replace("rem ","");
removeMyth(monster,myth);
mythEditor(monster,undefined);
}
} else if (args[3]=="confirm") {
editMonster(monster,"confirm");
checkMonUpdate(monster);
}
} else if (args[2]=="reset") {
resetMonster(monster);
checkMonUpdate(monster);
monsterMenu(monster);
} else if (args[2]=="del") {
deleteMon(monster);
monsterMenu(undefined);
}
} else if (args[1].includes("new")) {
let monster=args[1].replace("new ","");
createMon(monster);
monsterMenu(monster);
}
return;
case '!party':
if (!args[1]) {
partyMenu(args[1]);
} else if (args[1] && !args[1].includes("new")) {
let party = args[1];
if (!args[2]) {
partyMenu(party);
} else if (args[2]=="add") {
if (!args[3]) {
sendChat("Encounter Creator","/w gm You must submit a Character name or ID!");
} else if (args[3].includes("name")) {
let name = args[3].replace("name ","");
let char = findObjs({
_type: 'character',
name: name
}, {caseInsensitive: true})[0];
if (!char) {
sendChat("Encounter Creator","/w gm Could not find a Character with that name!");
} else if (char) {
let charid = char.get('_id');
partyAdd(party,charid);
partyMenu(party);
}
} else if (args[3].includes("id")) {
let id = args[3].replace("id ","");
let char = findObjs({
_type: 'character',
_id: id
})[0];
if (!char) {
sendChat("Encounter Creator","/w gm Could not find a Character with that ID!");
} else if (char) {
let charid = char.get('_id');
partyAdd(party,charid);
partyMenu(party);
}
} else if (args[3]=="sel") {
let selected = msg.selected;
if (!selected) {
sendChat("Encounter Creator","/w gm You need to select a Token!");
} else if (selected) {
let id = getIDsFromTokens(selected);
let char = findObjs({
_type: 'character',
_id: id
})[0];
if (!char) {
sendChat("Encounter Creator","/w gm An Error occurred while trying to fetch the ID of the selected Character. Maybe try using the Name instead.");
} else if (char) {
let charid = char.get('_id');
partyAdd(party,charid);
partyMenu(party);
}
}