-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbundle.js
12629 lines (10458 loc) · 346 KB
/
bundle.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
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
const dnd = require('dnd-combat-simulator');
const $ = require('jquery');
$("#character_form").on("submit", function(event) {
event.preventDefault();
var ckd = checkfulldata();
if(ckd.type){
// create new combatant
let id = $(this).find('[name=char_id]').val();
let hp = Number($(this).find('[name=hp]').val()); // PS
let ac = Number($(this).find('[name=ac]').val()); // PA
let initiative = Number($(this).find('[name=initiative]').val()); // Base Init
let atk = Number($(this).find('[name=atk]').val()); // Base ATQ
let def = Number($(this).find('[name=def]').val()); // Base DEF
let dmg = Number($(this).find('[name=dmg]').val()); // Y XdY+Z
let dmg_dice = Number($(this).find('[name=dmg_dice]').val()); // X XdY+Z
let dmg_bonus = Number($(this).find('[name=dmg_bonus]').val()); // Z XdY+Z
let FR = $('#FR').is(':checked');
let FP = $('#FP').is(':checked');
let Monster = $('#Monster').is(':checked');
let RoF = Number($('#RoF').val());
let loc = Number($('#Loc').val());
if(loc==3){loc={viser:-6,dmg:3};}else if(loc==1){loc={viser:-1,dmg:1};}else if(loc==0.5){loc={viser:-3,dmg:0.5};}else{loc={viser:null,dmg:null};}
let position = Number($('#Position').val());if(position==NaN||position<=1){position=1;}
let Strat = ($('#Strat').val());
let regen = Number($('#Regen').val()); if(regen==NaN){regen=0;}
let party_id = $(this).find('[name=party_id]').val();
// check if party exists
if (!combat.parties.hasOwnProperty(party_id)) {
// create and add party
let p = new dnd.Party();
combat.addParty(p, party_id);
}
// vérifier si l'id n'est pas double
var doublon = combat.parties[party_id].members.find(f => f.id === id);
while(doublon){
id += "1";
doublon = combat.parties[party_id].members.find(f => f.id === id);
}
let new_combatant = new dnd.Combatant(id, hp, ac, initiative, atk, dmg, dmg_dice, dmg_bonus, def, FR, FP, Monster, RoF, Strat, loc, position, regen);
console.log(new_combatant);
// add new combatant to party
combat.parties[party_id].addMember(new_combatant);
afficher_gens(combat);
}else{
$('#Alert1').append('<div class="alert alert-danger alert-dismissible fade show" role="alert"> <strong>Erreur:</strong> fiche mal rempli.<br><b>'+ckd.err+'</b> <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> </div>');
}
});
$("#run_simulation").on("click", function(event) {
let winners = [];
NombreDeTour = [];
$('#moche').html('');
for (let i = 0; i < 100; i++){
$('#moche').append('<div id="Combat '+Number(Number(i)+1)+'"><u>Combat '+Number(Number(i)+1)+'</u></div>');
winners.push(combat.runFight(console.log));
$('#moche').append('<hr>');
combat.reset();
}
let parties = {};
let party = [];
for (let party_id in combat.parties){
parties[party_id] = 0;
party.push(party_id);
}
let count = 1;
var Survivant = '';
let iconVic = '<svg style="color:forestgreen;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-shield-fill" viewBox="0 0 16 16"> <path d="M5.072.56C6.157.265 7.31 0 8 0s1.843.265 2.928.56c1.11.3 2.229.655 2.887.87a1.54 1.54 0 0 1 1.044 1.262c.596 4.477-.787 7.795-2.465 9.99a11.775 11.775 0 0 1-2.517 2.453 7.159 7.159 0 0 1-1.048.625c-.28.132-.581.24-.829.24s-.548-.108-.829-.24a7.158 7.158 0 0 1-1.048-.625 11.777 11.777 0 0 1-2.517-2.453C1.928 10.487.545 7.169 1.141 2.692A1.54 1.54 0 0 1 2.185 1.43 62.456 62.456 0 0 1 5.072.56z"/> </svg>';
let iconDef = '<svg style="color:darkred;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-shield-slash-fill" viewBox="0 0 16 16"> <path fill-rule="evenodd" d="M1.093 3.093c-.465 4.275.885 7.46 2.513 9.589a11.777 11.777 0 0 0 2.517 2.453c.386.273.744.482 1.048.625.28.132.581.24.829.24s.548-.108.829-.24a7.159 7.159 0 0 0 1.048-.625 11.32 11.32 0 0 0 1.733-1.525L1.093 3.093zm12.215 8.215L3.128 1.128A61.369 61.369 0 0 1 5.073.56C6.157.265 7.31 0 8 0s1.843.265 2.928.56c1.11.3 2.229.655 2.887.87a1.54 1.54 0 0 1 1.044 1.262c.483 3.626-.332 6.491-1.551 8.616zm.338 3.046-13-13 .708-.708 13 13-.707.707z"/> </svg>';
winners.forEach(function(winner_party){
Survivant +=('<div style="cursor: pointer;" onclick="scroller(\'Combat '+count+'\')">Combat ' + count + ': ' + winner_party[0].party_id);
if(winner_party[0].party_id == party[0]){Survivant += " "+iconVic;}else{Survivant += " "+iconDef;}
winner_party.forEach(function(e){
Survivant +=(' '+e.combatant.id);
});
Survivant +=('</div>');
count++;
parties[winner_party[0].party_id] += 1;
});
$('#aff_survivant').html(Survivant);
var Ratio = 'Ratios:';
for (let p in parties){
Ratio += '<br><b>'+p + '</b>: ' + parties[p] + '%';
}
$('#aff_ratio').html(Ratio+'<p>Nombre tour en moyenne: '+Math.round(NombreDeTour.reduce(reducer)/100)+'</p>');
});
var myModal = new bootstrap.Modal(document.getElementById('myModal'), {keyboard: false});
function afficher_gens(combat){
$('#aff_char').html('');
var Gr = Object.keys(combat.parties);
DataGr(Gr);
Gr.forEach(function(e){
var aff = ' • '+e+':';
combat.parties[e].members.forEach(function(f){
var content = "PS: "+f.hp+"<br>PA: "+f.ac+"<br>Initiative: "+f.initiative+"<br>Attaque: "+f.atk+"<br>Défense: "+f.def+"<br>Dommages: "+f.dmg_dice+"d"+f.dmg+"+"+f.dmg_bonus;
if(f.Monster){
content += "<br> Monstre, Att/tour: "+f.RoF;
if(f.FP){content += "<br>Frappe Puissante";}
}else{
if(f.FR){content += "<br>Frappe Rapide";}
if(f.FP){content += "<br>Frappe Puissante";}
}
if(f.loc.dmg==3){content += "<br>Localisation: Tête"}else if(f.loc.dmg==1){content += "<br>Localisation: Torse"}else if(f.loc.dmg==0.5){content += "<br>Localisation: Membre"}else{content += "<br>Localisation: Aléatoire"}
content += "<br>Position: "+f.position+"<br>Stratégie: "+f.Strat;
if(f.regen!=0){content+="<br>Régénération:"+f.regen;}
var button1 = '<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-trigger="focus" title="'+f.id+'" data-bs-placement="left" data-bs-content="'+content+'" data-bs-html="true">'+f.id+'</button>';
var del = '<span Groupe="'+e+'" Nom="'+f.id+'" class="Dlt"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash-fill" viewBox="0 0 16 16"> <path d="M2.5 1a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1H3v9a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V4h.5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1H2.5zm3 4a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5zM8 5a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7A.5.5 0 0 1 8 5zm3 .5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 1 0z"/> </svg></span>';
var edit = '<span class="trig" Groupe="'+e+'" Nom="'+f.id+'"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-square" viewBox="0 0 16 16"> <path d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"/> <path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"/> </svg></span>';
aff += '<div>'+button1+edit+del+'</div>';
});
$('#aff_char').append('<div>'+aff+'</div>');
});
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'));
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {return new bootstrap.Popover(popoverTriggerEl)});
$('.Dlt').on('click',function(e){
var Gr = e.currentTarget.attributes.Groupe.value;
var ID = e.currentTarget.attributes.Nom.value;
var index = combat.parties[Gr].members.findIndex(f => f.id === ID);
combat.parties[Gr].members.splice(index,1);
if(combat.parties[Gr].members.length == 0){
delete combat.parties[Gr];
}
afficher_gens(combat);
});
var Gr,ID,index,found = "";
$('.trig').on('click',function(e){
Gr = e.currentTarget.attributes.Groupe.value;
ID = e.currentTarget.attributes.Nom.value;
index = combat.parties[Gr].members.findIndex(f => f.id === ID);
found = combat.parties[Gr].members[index];
$('#modalGroupe').val(Gr);
$('#modalNom').val(ID);
$('#modalPS').val(found.hp);
$('#modalPA').val(found.ac);
$('#modalINI').val(found.initiative);
$('#modalATQ').val(found.atk);
$('#modalDEF').val(found.def);
$('#Modald1').val(found.dmg_dice);
$('#Modald2').val(found.dmg);
$('#Modald3').val(found.dmg_bonus);
$('#modalRoF').val(found.RoF);
$('#ModalStrat').val(found.Strat);
$('#ModPosition').val(found.position);
$('#ModalLoc').val(found.loc.dmg);
$('#ModalRegen').val(found.regen);
if(found.FR){
$('#ModalFR').prop('checked', true);
}else{$('#ModalFR').prop('checked', false);}
if(found.FP){
$('#ModalFP').prop('checked', true);
}else{$('#ModalFP').prop('checked', false);}
if(found.Monster){
$('#ModalMo').prop('checked', true);
}else{$('#ModalMo').prop('checked', false);}
myModal.toggle();
$('#SaveModal').on('click', function(event){
let loc = Number($('#ModLoc').val());
if(loc==3){loc={viser:-6,dmg:3};}else if(loc==1){loc={viser:-1,dmg:1};}else if(loc==0.5){loc={viser:-3,dmg:0.5};}else{loc={viser:null,dmg:null}}
combat.parties[Gr].members[index].id = $('#modalNom').val();
combat.parties[Gr].members[index].hp = $('#modalPS').val();
combat.parties[Gr].members[index].ac = $('#modalPA').val();
combat.parties[Gr].members[index].initiative = $('#modalINI').val();
combat.parties[Gr].members[index].atk = $('#modalATQ').val();
combat.parties[Gr].members[index].def = $('#modalDEF').val();
combat.parties[Gr].members[index].dmg_dice = $('#Modald1').val();
combat.parties[Gr].members[index].dmg = $('#Modald2').val();
combat.parties[Gr].members[index].dmg_bonus = $('#Modald3').val();
combat.parties[Gr].members[index].RoF = $('#modalRoF').val();
combat.parties[Gr].members[index].Strat = $('#ModalStrat').val();
combat.parties[Gr].members[index].position = $('#ModPosition').val();
combat.parties[Gr].members[index].loc = loc;
combat.parties[Gr].members[index].regen = $('#ModalRegen').val();
combat.parties[Gr].members[index].FR = $('#ModalFR').is(':checked');
combat.parties[Gr].members[index].FP = $('#ModalFP').is(':checked');
combat.parties[Gr].members[index].Monster = $('#ModalMo').is(':checked');
afficher_gens(combat);
$(this).off(event);
});
});
}
$('#reini').on('click',function(){
combat = new dnd.Combat();
afficher_gens(combat);
});
$('#link').on('click',function(){
var Gr = Object.keys(combat.parties);
var url = "";
Gr.forEach(function(e){
combat.parties[e].members.forEach(function(f){
url += "?!?"+e+"?&?"+f.id+'?&?'+f.max_hp+'?&?'+f.ac+'?&?'+f.initiative+'?&?'+f.atk+'?&?'+f.def+'?&?'+f.dmg_dice+'?&?'+f.dmg+'?&?'+f.dmg_bonus+'?&?'+f.FR+'?&?'+f.FP+'?&?'+f.Monster+'?&?'+f.RoF+'?&?'+f.Strat+'?&?'+f.loc.dmg+'?&?'+f.position+'?&?'+f.regen;
});
});
copyToClipboard(url);
});
let combat = new dnd.Combat();
},{"dnd-combat-simulator":5,"jquery":7}],2:[function(require,module,exports){
const _ = require('underscore');
module.exports = function(){
this.parties = {};
this.addParty = function(party, id){
this.parties[id] = party;
};
this.turnList = [];
this.initiateCombat = function(logger){
let self = this;
for(let party in self.parties){
self.parties[party].members.forEach(function(combatant){
self.turnList.push({
party_id: party,
combatant: combatant,
roll: combatant.rollInitiative().total
});
});
}
self.turnList.sort(function(a, b) {
return (a.roll < b.roll) ? 1 : ((b.roll < a.roll) ? -1 : 0);
});
$('#moche').append('<div>Ordre du tour:');
let n = 1;
self.turnList.forEach(function(member){
$('#moche').append(n + '. ' + member.combatant.id+' ; ');
n += 1;
});
$('#moche').append('</div><br><br>');
};
this.runRound = function(logger){
let self = this;
self.turnList.forEach(function(current_combatant){
let combatant = current_combatant.combatant;
let party_id = current_combatant.party_id;
if (!combatant.isDead()){
let opponentParties = [];
for (let p_id in self.parties){
if (party_id != p_id){
opponentParties.push(self.parties[p_id]);
}
}
let opponents = [];
opponentParties.forEach(function(party){
party.members.forEach(function(member){
if (!member.isDead()){
opponents.push(member);
}
});
});
if(combatant.Strat=='PS'){
var target = self.parties[party_id].selectTarget(opponents);
}else if(combatant.Strat=='PA'){
var target = self.parties[party_id].selectTargetPA(opponents);
}else if(combatant.Strat=='P1'){
var target = self.parties[party_id].selectTargetP1(opponents);
}else if(combatant.Strat=='P2'){
var target = self.parties[party_id].selectTargetP2(opponents);
}else{
var target = self.parties[party_id].selectTargetAlea(opponents);
}
if (typeof target == 'undefined'){
return;
}
for(let i=0; i < combatant.RoF; i++){
let atk = combatant.attackRoll();
let atkRoll = atk.total;
let def = target.defRoll();
let defRoll = def.total;
if(combatant.toucher[target.id]){
combatant.toucher[target.id].try ++
}else{
combatant.toucher[target.id] = {};
combatant.toucher[target.id].try=1;
combatant.toucher[target.id].suc = 0;
}
var lavisée = combatant.loc.viser;if(lavisée==null){lavisée=0;}
if (target.isHit(Number(atkRoll)-Number(combatant.loc.viser),defRoll)){
let damage = combatant.damageRoll(atkRoll,defRoll,target.ac,combatant.loc.dmg);
target.takeDamage(damage.total);
target.ac -= 1; if(target.ac <= 0){target.ac=0;}
combatant.toucher[target.id].suc ++;
$('#moche').append('<div>'+combatant.id + ' touche ' + target.id + ' et inflige ' + damage.total + ' points de dégâts ('+damage.roll+') à '+damage.loc+'. Jet: '+atkRoll+' ('+atk.roll+','+combatant.atk+','+lavisée+') VS '+defRoll+' ('+def.roll+','+target.def+')</div>');
} else {
$('#moche').append('<div>'+combatant.id + ' rate ' + target.id + '. Jet: '+atkRoll+' ('+atk.roll+','+combatant.atk+','+lavisée+') VS '+defRoll+' ('+def.roll+','+target.def+')</div>');
}
}
if(combatant.regen!=0){combatant.regenHP(combatant.regen);}
}
});
};
this.runFight = function(logger){
this.initiateCombat(logger);
var compteur = 0;
while(this.isFightOnGoing()){
this.runRound(logger);
compteur++;
}
NombreDeTour.push(compteur);
$('#moche').append('<div>Nombre de tour durant ce combat: <b>'+compteur+'</b></div>');
return this.survivors();
};
this.isFightOnGoing = function(){
let alive = {};
for ( c in this.turnList ) {
if (!this.turnList[c].combatant.isDead()){
alive[this.turnList[c].party_id] = 1;
if (Object.keys(alive).length > 1){
return true;
}
}
}
return false;
};
this.survivors = function(){
function statuch(e){
let obj = Object.keys(e.combatant.toucher);
let affi = "";
obj.forEach(function(f){
affi += f+', '+Math.round(Number(e.combatant.toucher[f].suc)/Number(e.combatant.toucher[f].try)*100)+"% ("+e.combatant.toucher[f].suc+'/'+e.combatant.toucher[f].try+") ; ";
});
return affi;
}
let alive = [];
let party = [];for(let party_id in this.parties){party.push(party_id);}
var aff = "";let grSur=1;var eff = "<br><div><u>Morts:</u></div>";
for ( c in this.turnList ) {
if (!this.turnList[c].combatant.isDead()){
aff += ('<div><b>'+this.turnList[c].combatant.id+':</b> '+this.turnList[c].combatant.hp+'/'+this.turnList[c].combatant.max_hp+' PS, '+this.turnList[c].combatant.ac+' PA</div>');
aff += '<div>Satistiques de toucher: '+statuch(this.turnList[c])+'</div>';
alive.push(this.turnList[c]);
var found = this.parties[party[0]].members.find(element => element.id == this.turnList[c].combatant.id);
if(found){grSur=0;}
}else{
eff += ('<div><b>'+this.turnList[c].combatant.id+':</b> '+this.turnList[c].combatant.hp+'/'+this.turnList[c].combatant.max_hp+' PS, '+this.turnList[c].combatant.ac+' PA</div>');
eff += '<div>Satistiques de toucher: '+statuch(this.turnList[c])+'</div>';
}
}
if(grSur==0){
$('#moche').append('<br><div><u>Survivants:</u> <svg style="color:forestgreen;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-shield-fill" viewBox="0 0 16 16"> <path d="M5.072.56C6.157.265 7.31 0 8 0s1.843.265 2.928.56c1.11.3 2.229.655 2.887.87a1.54 1.54 0 0 1 1.044 1.262c.596 4.477-.787 7.795-2.465 9.99a11.775 11.775 0 0 1-2.517 2.453 7.159 7.159 0 0 1-1.048.625c-.28.132-.581.24-.829.24s-.548-.108-.829-.24a7.158 7.158 0 0 1-1.048-.625 11.777 11.777 0 0 1-2.517-2.453C1.928 10.487.545 7.169 1.141 2.692A1.54 1.54 0 0 1 2.185 1.43 62.456 62.456 0 0 1 5.072.56z"/> </svg></div>')
}else{
$('#moche').append('<br><div><u>Survivants:</u> <svg style="color:darkred;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-shield-slash-fill" viewBox="0 0 16 16"> <path fill-rule="evenodd" d="M1.093 3.093c-.465 4.275.885 7.46 2.513 9.589a11.777 11.777 0 0 0 2.517 2.453c.386.273.744.482 1.048.625.28.132.581.24.829.24s.548-.108.829-.24a7.159 7.159 0 0 0 1.048-.625 11.32 11.32 0 0 0 1.733-1.525L1.093 3.093zm12.215 8.215L3.128 1.128A61.369 61.369 0 0 1 5.073.56C6.157.265 7.31 0 8 0s1.843.265 2.928.56c1.11.3 2.229.655 2.887.87a1.54 1.54 0 0 1 1.044 1.262c.483 3.626-.332 6.491-1.551 8.616zm.338 3.046-13-13 .708-.708 13 13-.707.707z"/> </svg></div>')
}
$('#moche').append(aff+eff);
return alive;
};
this.reset = function(){
this.turnList = [];
let self = this;
for (let party in self.parties){
self.parties[party].members.forEach(function(combatant){
combatant.hp = combatant.max_hp;
combatant.ac = combatant.max_ac;
combatant.toucher = {};
});
}
};
}
},{"underscore":8}],3:[function(require,module,exports){
const dice = require('./dice_roller')
/**
* Constructs a combatant object.
*
* @constructor
*
* @param {string} id
* Identifier for log prints.
* @param {number} hp
* Starting hit points for the combatant.
* @param {number} ac
* Armour class of the combatant.
* @param {number} initiative
* Initiative bonus for the combatant.
* @param {number} atk
* Attack bonus for the combatants attack rolls.
* @param {number} dmg
* Type of dice used for damage roll.
* @param {number} dmg_dice
* Number of dice used for damage roll.
* @param {number} dmg_bonus
* Damage bonus from ability modifier.
*/
module.exports = function(id, hp, ac, initiative, atk, dmg, dmg_dice, dmg_bonus, def, FR, FP, Monster, RoF, Strat, loc, position, regen){
this.id = id;
this.hp = hp;
this.max_hp = hp;
this.ac = ac;this.max_ac = ac;
this.initiative = initiative;
this.atk = atk;
this.dmg = dmg;
this.dmg_dice = dmg_dice;
this.dmg_bonus = dmg_bonus;
this.def = def;
this.FP = FP;
this.FR = FR;
this.Monster = Monster;
this.RoF = RoF;
this.Strat = Strat; if(Strat==null){this.Strat='Aléatoire';}
this.loc = loc; // viser & dmg
this.toucher = {}; // [nom du perso] try: nombre d'essaie, suc: nombre success
this.position = position;
this.regen = regen;
if(!Monster){
if(FR){this.RoF=2;}else{this.RoF=1;}
}
this.rollInitiative = function(){
return dice(10, this.initiative, 'Expl');
};
this.attackRoll = function(){
return dice(10, atk, 'Expl');
};
this.defRoll = function(){
return dice(10, def, 'Expl');
};
this.damageRoll = function(attackRoll,defRoll,PA,loc){
let sum = 0;let roll = "[";
for(let i = 0; i < this.dmg_dice; i++){
let rand = dice(this.dmg, 0);
sum += Number(rand.total);
roll+= rand.roll+","
}
sum += Number(this.dmg_bonus) - Number(PA);
roll+=this.dmg_bonus+",-"+PA+"]";
if(sum<=0){
sum=0;
loc="|Armure > DMG|"
}else{
if(this.FP){sum *= 2;}
if(!loc){
loc = dice(10,0).total;
if(loc==1){loc=3;}else if(loc<=4){loc=1;}else{loc=0.5;}
}
sum *= loc;
}
if(loc==3){var loca="Tête";}else if(loc==1){var loca="Torse";}else{var loca="Membre";}
roll+="*"+loc;
let cc = 0;
let diff = Number(attackRoll)-Number(defRoll);
if(diff < 7){}else if(diff<10){cc=3;}else if(diff<13){cc=5;}else if(diff<15){cc=8;}else{cc=10;}
if(cc!=0){roll += ", crit:"+cc;}
return {total:Number(Number(sum)+Number(cc)),loc:loca,roll:roll};
};
this.isHit = function(attackRoll,defRoll){
if(attackRoll > defRoll){
return true;
}
};
this.takeDamage = function(damageRoll){
this.hp -= damageRoll;
if (this.hp < 0){
this.hp = 0;
}
};
this.isDead = function(){
if (this.hp <= 0) {
return true;
} else {
return false;
}
};
this.regenHP = function(e){
if(this.hp<=this.max_hp){
this.hp+=e;
}
if(this.hp>this.max_hp){
this.hp = this.max_hp;
}
}
};
},{"./dice_roller":4}],4:[function(require,module,exports){
module.exports = function(e, modifier, type){
function RandomInt(max) {
return Math.floor(Math.random() * max)+1;
}
function Expl(){
var r = RandomInt(e);
var s = r;
while (r==1||r==e){
r = RandomInt(e);
s += RandomInt(e);
}
return s;
}
var rand = RandomInt(e);
if(type == 'Expl'){
if(rand == 1){rand = -Expl(e);}else if(rand == 10){rand += Expl(e);}else{}
}
return {roll:rand,total:rand+modifier};
};
},{}],5:[function(require,module,exports){
const Combatant = require('./combatant');
const Dice = require('./dice_roller');
const Party = require('./party');
const Combat = require('./combat');
module.exports = {
Combatant: Combatant,
Dice: Dice,
Party: Party,
Combat: Combat
}
},{"./combat":2,"./combatant":3,"./dice_roller":4,"./party":6}],6:[function(require,module,exports){
module.exports = function(){
this.members = [];
this.combatStrategies = {
lowest_hp: function(combatantA, combatantB){
return combatantA.hp - combatantB.hp;
},
highest_hp: function(combatantA, combatantB){
return combatantB.hp - combatantA.hp;
},
lowest_ac: function(combatantA, combatantB){
return combatantA.ac - combatantB.ac;
},
lowest_position: function(combatantA, combatantB){
return combatantA.position - combatantB.position;
},
highest_position: function(combatantA, combatantB){
return combatantB.position - combatantA.position;
}
};
this.combatStrategy = this.combatStrategies.lowest_hp;
this.addMember = function(combatant){
this.members.push(combatant);
};
this.selectTarget = function(opponents){
opponents.sort(this.combatStrategy);
return opponents[0];
};
this.selectTargetPA = function(opponents){
opponents.sort(this.combatStrategies.lowest_ac);
return opponents[0];
};
this.selectTargetP1 = function(opponents){
opponents.sort(this.combatStrategies.lowest_position);
return opponents[0];
};
this.selectTargetP2 = function(opponents){
opponents.sort(this.combatStrategies.highest_position);
return opponents[0];
};
this.selectTargetAlea = function(opponents){
var rand = Math.floor(Math.random() * opponents.length);
return opponents[rand];
}
}
},{}],7:[function(require,module,exports){
/*!
* jQuery JavaScript Library v3.3.1
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2018-01-20T17:24Z
*/
( function( global, factory ) {
"use strict";
if ( typeof module === "object" && typeof module.exports === "object" ) {
// For CommonJS and CommonJS-like environments where a proper `window`
// is present, execute the factory and get jQuery.
// For environments that do not have a `window` with a `document`
// (such as Node.js), expose a factory as module.exports.
// This accentuates the need for the creation of a real `window`.
// e.g. var jQuery = require("jquery")(window);
// See ticket #14549 for more info.
module.exports = global.document ?
factory( global, true ) :
function( w ) {
if ( !w.document ) {
throw new Error( "jQuery requires a window with a document" );
}
return factory( w );
};
} else {
factory( global );
}
// Pass this if window is not defined yet
} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
// enough that all such attempts are guarded in a try block.
"use strict";
var arr = [];
var document = window.document;
var getProto = Object.getPrototypeOf;
var slice = arr.slice;
var concat = arr.concat;
var push = arr.push;
var indexOf = arr.indexOf;
var class2type = {};
var toString = class2type.toString;
var hasOwn = class2type.hasOwnProperty;
var fnToString = hasOwn.toString;
var ObjectFunctionString = fnToString.call( Object );
var support = {};
var isFunction = function isFunction( obj ) {
// Support: Chrome <=57, Firefox <=52
// In some browsers, typeof returns "function" for HTML <object> elements
// (i.e., `typeof document.createElement( "object" ) === "function"`).
// We don't want to classify *any* DOM node as a function.
return typeof obj === "function" && typeof obj.nodeType !== "number";
};
var isWindow = function isWindow( obj ) {
return obj != null && obj === obj.window;
};
var preservedScriptAttributes = {
type: true,
src: true,
noModule: true
};
function DOMEval( code, doc, node ) {
doc = doc || document;
var i,
script = doc.createElement( "script" );
script.text = code;
if ( node ) {
for ( i in preservedScriptAttributes ) {
if ( node[ i ] ) {
script[ i ] = node[ i ];
}
}
}
doc.head.appendChild( script ).parentNode.removeChild( script );
}
function toType( obj ) {
if ( obj == null ) {
return obj + "";
}
// Support: Android <=2.3 only (functionish RegExp)
return typeof obj === "object" || typeof obj === "function" ?
class2type[ toString.call( obj ) ] || "object" :
typeof obj;
}
/* global Symbol */
// Defining this global in .eslintrc.json would create a danger of using the global
// unguarded in another place, it seems safer to define global only for this module
var
version = "3.3.1",
// Define a local copy of jQuery
jQuery = function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
// Need init if jQuery is called (just allow error to be thrown if not included)
return new jQuery.fn.init( selector, context );
},
// Support: Android <=4.0 only
// Make sure we trim BOM and NBSP
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
jQuery.fn = jQuery.prototype = {
// The current version of jQuery being used
jquery: version,
constructor: jQuery,
// The default length of a jQuery object is 0
length: 0,
toArray: function() {
return slice.call( this );
},
// Get the Nth element in the matched element set OR
// Get the whole matched element set as a clean array
get: function( num ) {
// Return all the elements in a clean array
if ( num == null ) {
return slice.call( this );
}
// Return just the one element from the set
return num < 0 ? this[ num + this.length ] : this[ num ];
},
// Take an array of elements and push it onto the stack
// (returning the new matched element set)
pushStack: function( elems ) {
// Build a new jQuery matched element set
var ret = jQuery.merge( this.constructor(), elems );
// Add the old object onto the stack (as a reference)
ret.prevObject = this;
// Return the newly-formed element set
return ret;
},
// Execute a callback for every element in the matched set.
each: function( callback ) {
return jQuery.each( this, callback );
},
map: function( callback ) {
return this.pushStack( jQuery.map( this, function( elem, i ) {
return callback.call( elem, i, elem );
} ) );
},
slice: function() {
return this.pushStack( slice.apply( this, arguments ) );
},
first: function() {
return this.eq( 0 );
},
last: function() {
return this.eq( -1 );
},
eq: function( i ) {
var len = this.length,
j = +i + ( i < 0 ? len : 0 );
return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
},
end: function() {
return this.prevObject || this.constructor();
},
// For internal use only.
// Behaves like an Array's method, not like a jQuery method.
push: push,
sort: arr.sort,
splice: arr.splice
};
jQuery.extend = jQuery.fn.extend = function() {
var options, name, src, copy, copyIsArray, clone,
target = arguments[ 0 ] || {},
i = 1,
length = arguments.length,
deep = false;
// Handle a deep copy situation
if ( typeof target === "boolean" ) {
deep = target;
// Skip the boolean and the target
target = arguments[ i ] || {};
i++;
}
// Handle case when target is a string or something (possible in deep copy)
if ( typeof target !== "object" && !isFunction( target ) ) {
target = {};
}
// Extend jQuery itself if only one argument is passed
if ( i === length ) {
target = this;
i--;
}
for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values
if ( ( options = arguments[ i ] ) != null ) {
// Extend the base object
for ( name in options ) {
src = target[ name ];
copy = options[ name ];
// Prevent never-ending loop
if ( target === copy ) {
continue;
}
// Recurse if we're merging plain objects or arrays
if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
( copyIsArray = Array.isArray( copy ) ) ) ) {
if ( copyIsArray ) {
copyIsArray = false;
clone = src && Array.isArray( src ) ? src : [];
} else {
clone = src && jQuery.isPlainObject( src ) ? src : {};
}
// Never move original objects, clone them
target[ name ] = jQuery.extend( deep, clone, copy );
// Don't bring in undefined values
} else if ( copy !== undefined ) {
target[ name ] = copy;
}
}
}
}
// Return the modified object
return target;
};
jQuery.extend( {
// Unique for each copy of jQuery on the page
expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
// Assume jQuery is ready without the ready module
isReady: true,
error: function( msg ) {
throw new Error( msg );
},
noop: function() {},
isPlainObject: function( obj ) {
var proto, Ctor;
// Detect obvious negatives
// Use toString instead of jQuery.type to catch host objects
if ( !obj || toString.call( obj ) !== "[object Object]" ) {
return false;
}
proto = getProto( obj );
// Objects with no prototype (e.g., `Object.create( null )`) are plain
if ( !proto ) {
return true;
}
// Objects with prototype are plain iff they were constructed by a global Object function
Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
},
isEmptyObject: function( obj ) {
/* eslint-disable no-unused-vars */
// See https://github.com/eslint/eslint/issues/6125
var name;
for ( name in obj ) {
return false;
}
return true;
},
// Evaluates a script in a global context
globalEval: function( code ) {
DOMEval( code );
},
each: function( obj, callback ) {
var length, i = 0;
if ( isArrayLike( obj ) ) {
length = obj.length;
for ( ; i < length; i++ ) {
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
break;
}
}
} else {
for ( i in obj ) {
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
break;
}
}
}
return obj;
},
// Support: Android <=4.0 only
trim: function( text ) {
return text == null ?
"" :
( text + "" ).replace( rtrim, "" );
},
// results is for internal usage only
makeArray: function( arr, results ) {
var ret = results || [];
if ( arr != null ) {
if ( isArrayLike( Object( arr ) ) ) {
jQuery.merge( ret,
typeof arr === "string" ?
[ arr ] : arr
);
} else {
push.call( ret, arr );
}
}
return ret;
},
inArray: function( elem, arr, i ) {
return arr == null ? -1 : indexOf.call( arr, elem, i );
},
// Support: Android <=4.0 only, PhantomJS 1 only
// push.apply(_, arraylike) throws on ancient WebKit
merge: function( first, second ) {
var len = +second.length,
j = 0,
i = first.length;
for ( ; j < len; j++ ) {
first[ i++ ] = second[ j ];
}
first.length = i;
return first;
},
grep: function( elems, callback, invert ) {
var callbackInverse,
matches = [],
i = 0,
length = elems.length,
callbackExpect = !invert;
// Go through the array, only saving the items
// that pass the validator function
for ( ; i < length; i++ ) {
callbackInverse = !callback( elems[ i ], i );
if ( callbackInverse !== callbackExpect ) {
matches.push( elems[ i ] );
}
}
return matches;
},
// arg is for internal usage only