-
Notifications
You must be signed in to change notification settings - Fork 2
/
Cleave-ORE.js
1456 lines (1308 loc) · 33.7 KB
/
Cleave-ORE.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
String.prototype.format = function(a)
{
var reg = /(\{([^}]+)\})/im;
var matches = this.match(reg);
var result = this;
for(var i in a)
result = result.replace("{"+i+"}", a[i]);
return result;
};
String.prototype.contains = function(a)
{
if(this.indexOf(a) > -1) return !0;
else return !1;
};
String.prototype.replaceArray = function(a)
{
var r = this;
for(var i in a)
while(r.contains(a[i].target))
r = r.replace(a[i].target, a[i].replacement);
return r;
};
Number.prototype.nanFix = function()
{
return parseFloat(isNaN(this)?0:this);
};
Number.prototype.numFormat = new function()
{
var str = "";
var data = 0;
try
{
if (data != Infinity && data != 0 && data != NaN)
{
var reg = /(^[+-]?\d+)(\d{3})/;
var n = (this + "");
while (reg.test(n)) n = n.replace(reg, "$1,$2");
return n;
}
else
return "0";
}
catch (ex)
{
return "0";
}
};
var Lib = new function()
{
this.getJobUrl = function(filename, dir)
{
if (dir == undefined)
dir = "Glow";
if (filename == undefined)
dir = "PLD";
return "https://github.com/laiglinne-ff/FFXIV_Chamsucript/blob/master/images/job/" + dir + "/" + filename + ".png?raw=true";
};
this.jobs = {
"ADV": { "code": 0 },
"GLA": { "code": 1 },
"GLD": { "code": 1 },
"PGL": { "code": 2 },
"MRD": { "code": 3 },
"LNC": { "code": 4 },
"ARC": { "code": 5 },
"CNJ": { "code": 6 },
"THM": { "code": 7 },
/* CRAFTER */
"CRP": { "code": 8 },
"BSM": { "code": 9 },
"ARM": { "code": 10 },
"GSM": { "code": 11 },
"LTW": { "code": 12 },
"WVR": { "code": 13 },
"ALC": { "code": 14 },
"CUL": { "code": 15 },
/* GATHERER */
"MIN": { "code": 16 },
"BTN": { "code": 17 },
"FSH": { "code": 18 },
/* JOBS */
"PLD": { "code": 19 },
"MNK": { "code": 20 },
"WAR": { "code": 21 },
"DRG": { "code": 22 },
"BRD": { "code": 23 },
"WHM": { "code": 24 },
"BLM": { "code": 25 },
/* ARR CLASS */
"ACN": { "code": 26 },
/* ARR JOBS */
"SMN": { "code": 27 },
"PLD": { "code": 28 },
/* WA! SHIVA! T13! NINJA-DA! */
"ROG": { "code": 29 },
"NIN": { "code": 30 },
/* HW JOBS */
"MCH": { "code": 31 },
"DRK": { "code": 32 },
"AST": { "code": 33 },
/* SB JOBS */
"SAM": { "code": 34 },
"RDM": { "code": 35 },
};
},
QueryString = function()
{
var query_string = {};
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++)
{
var pair = vars[i].split("=");
if (typeof query_string[pair[0]] === "undefined")
{
query_string[pair[0]] = decodeURIComponent(pair[1]);
}
else if (typeof query_string[pair[0]] === "string")
{
var arr = [query_string[pair[0]], decodeURIComponent(pair[1])];
query_string[pair[0]] = arr;
}
else
{
query_string[pair[0]].push(decodeURIComponent(pair[1]))
}
}
return query_string;
}(),
Language = function(l)
{
this.get = function(v)
{
var returnvalue = this.getPriv(v);
if(returnvalue != undefined)
return returnvalue;
else
return v;
};
this.getPriv = function(v)
{
// 값은 매번 불러오므로 Save 프로세스를 잘 진행해주세요.
this.userdic = JSON.parse(localStorage.getItem("claveore-dic"));
try
{
if(this.dictionary.dots[v] != undefined && this.lang == "ko")
return this.dictionary.dots[v];
else if(this.userdic != null)
{
// 유저 사전 먼저 찾습니다.
if(this.userdic.skills[v] != undefined && shorter) // optional
return this.userdic.skills[v];
}
// 그 후에 기본값
else if(this.dictionary.skills[v] != undefined && shorter) // optional
return this.dictionary.skills[v];
else if(this.dictionary.display[v] != undefined)
{
if(this.dictionary.display[v][this.lang] != undefined) // JOBS
return this.dictionary.display[v][this.lang];
}
else
return v;
}
catch(ex)
{
console.log(ex);
return v;
}
};
this.setLangDefine = function(ln)
{
if(ln != undefined)
{
this.languageDefine = true;
this.lang = b;
}
};
this.getUserDic = function()
{
try
{
this.userdic = JSON.parse(localStorage.getItem("claveore-dic"));
if(this.userdic == null || this.userdic == undefined)
{
this.userdic = this.dictionary;
this.setUserDic();
}
}
catch(ex)
{
}
};
this.setUserDic = function()
{
localStorage.setItem("claveore-dic", JSON.stringify(this.userdic));
};
this.deleteUserSkillItem = function(key)
{
if(this.userdic.skills[key] != undefined)
delete this.userdic.skills[key];
};
this.setUserSkillItem = function(key, val)
{
this.userdic.skills[key] = val;
};
this.languageDefine = false;
this.lang = (l == undefined ? "ko" : l);
this.userdic = null;
this.dictionary = {
// Default = en
"display":{
"PLD":{"ko":"나", "jp":"ナイト"},
"GLD":{"ko":"검술사", "jp":"剣術士"},
"WAR":{"ko":"전", "jp":"戦"},
"MRD":{"ko":"도끼술사", "jp":"斧術士"},
"DRK":{"ko":"암", "jp":"暗"},
"MNK":{"ko":"몽", "jp":"モンク"},
"PGL":{"ko":"격투사", "jp":"格闘士"},
"DRG":{"ko":"용", "jp":"竜"},
"LNC":{"ko":"창술사", "jp":"槍術士"},
"NIN":{"ko":"닌", "jp":"忍"},
"ROG":{"ko":"쌍검사", "jp":"双剣士"},
"BRD":{"ko":"음", "jp":"吟"},
"ARC":{"ko":"궁술사", "jp":"弓術士"},
"MCH":{"ko":"기", "jp":"機"},
"SMN":{"ko":"솬", "jp":"召"},
"BLM":{"ko":"흑", "jp":"黒"},
"THM":{"ko":"주술사", "jp":"呪術士"},
"WHM":{"ko":"백", "jp":"白"},
"CNJ":{"ko":"환술사", "jp":"幻術士"},
"SCH":{"ko":"학", "jp":"学"},
"ACN":{"ko":"비술사", "jp":"巴術士"},
"AST":{"ko":"점", "jp":"占"},
"LMB":{"ko":"리밋", "jp":"リミット"},
"FAIRY":{"ko":"요정", "jp":"FAIRY"},
"AUTOTURRET":{"ko":"포탑", "jp":"オートタレット"},
"EGI":{"ko":"에기", "jp":"エギ"},
"CARBUNCLE":{"ko":"카벙클", "jp":"カーバンクル"},
"CHOCOBO":{"ko":"초코보", "jp":"チョコ"}
},
"skills":
{
// ko
"재빠른 검격":"재빠른",
"야성의 검격":"야성",
"방패 던지기":"방던",
"폭도의 검격":"폭도",
"방패 후려치기":"방.후",
"할로네의 분노":"할로네",
"내면의 기개":"내면",
"꿰뚫는 검격":"꿰뚫",
"제왕의 권위":"제왕",
"육중한 일격":"육중",
"두개골 절단":"절단",
"잔혹한 일격":"잔혹",
"도끼 던지기":"도.던",
"최후의 일격":"최후",
"휘도는 도끼":"휘도",
"강철 회오리":"강철",
"강렬한 참격":"강렬",
"비열한 기습":"비열",
"흡수의 일격":"흡수",
"심연의 갈증":"심.갈",
"어둠의 여행자":"여행자",
"정권 지르기":"정권",
"혈도 찌르기":"혈도",
"직선 찌르기":"직선",
"눈속임 공격":"눈속임",
"사선 찌르기":"사선",
"다리 쳐내기":"다리",
"꿰뚫는 발톱":"창던지기",
"올려 찌르기":"올.찌",
"이단 찌르기":"이단",
"몸통 가르기":"몸.가",
"악몽의 쇄기":"악몽",
"가시 소용돌이":"소용돌이",
"게이르스코굴":"코굴",
"쌍검 회전베기":"회전",
"마무리 일격":"마.격",
"춤추는 칼날":"춤.칼",
"풍마의 수리검":"풍마",
"그림자 송곳니":"그.송",
"육중한 사격":"육중",
"재빠른 활시위":"재빠른",
"침묵의 화살":"침묵",
"죽음의 화살비":"죽.비",
"천상의 화살":"천상",
"강렬한 사격":"강렬",
"생명력 흡수":"생.흡",
"미아즈마 버스트":"버스트"
// en
// jp
// fr
// de
},
"dots":
{
"Goring Blade (*)":"*꿰뚫",
"Circle of Scorn (*)":"*파멸의 진",
"Fracture (*)":"*골절",
"Scourge (*)":"*재앙",
"Aero (*)":"*에어로",
"Aero II (*)":"*에어로라",
"Aero Iii (*)":"*에어로가",
"Medica II (*)":"*메디카라",
"Regen (*)":"*리제네",
"Combust (*)":"*컴버스",
"Combust II (*)":"*컴버라",
"Touch Of Death (*)":"*혈도",
"Phlebotomize (*)":"*이단",
"Chaos Thrust (*)":"*꽃잎",
"Shadow Fang (*)":"*그.송",
"Mutilation (*)":"*무쌍",
"Venomous Bite (*)":"*독화살",
"Windbite (*)":"*바람",
"Lead Shot (*)":"*산탄",
"Bio (*)":"*바이오",
"Bio II (*)":"*바이오라",
"Miasma (*)":"*미아즈마",
"Miasma II (*)":"*미아즈라",
"Thunder (*)":"*선더"
}
};
this.getUserDic();
},
Person = function(e, p)
{
this.recalculate = function()
{
var dur = this.DURATION;
if (dur == 0) dur = 1;
this.dps = pFloat(this.mergedDamage / dur);
this.encdps = pFloat(this.mergedDamage / this.parent.DURATION);
this.hps = pFloat(this.mergedHealed / dur);
this.enchps = pFloat(this.mergedHealed / this.parent.DURATION);
this["DAMAGE-k"] = Math.floor(this.mergedDamage / 1000);
this["DAMAGE-m"] = Math.floor(this.mergedDamage / 1000000);
this.DPS = Math.floor(this.dps);
this["DPS-k"] = Math.floor(this.dps / 1000);
this.ENCDPS = Math.floor(this.encdps);
this.ENCHPS = Math.floor(this.enchps);
this["ENCDPS-k"] = Math.floor(this.encdps / 1000);
this["ENCHPS-k"] = Math.floor(this.enchps / 1000);
this["damage%"] = pFloat(this.mergedDamage / this.parent.Encounter.damage * 100);
this["healed%"] = pFloat(this.mergedHealed / this.parent.Encounter.healed * 100);
this["crithit%"] = pFloat(this.mergedCrithits / this.mergedHits * 100);
this["critheal%"] = pFloat(this.mergedCritheals / this.mergedHeals * 100);
this["DirectHit%"] = pFloat(this.mergedDirectHitCount / this.mergedHits * 100);
this["CritDirectHit%"] = pFloat(this.mergedCritDirectHitCount / this.mergedHeals * 100);
this.tohit = pFloat(this.mergedHits / this.mergedSwings * 100);
this.effectiveHeal = pFloat(this.mergedHealed - this.mergedOverHeal);
this["overHeal%"] = pFloat(this.mergedOverHeal / this.mergedHealed * 100);
};
this.returnOrigin = function()
{
for(var i in this.original)
{
if (i.indexOf("Last") > -1)
this["merged"+i] = this[i];
else if (i == "CritDirectHitCount" || i == "DirectHitCount")
this["merged"+i] = this[i];
else
this["merged"+i] = this[i.substr(0,1).toLowerCase()+i.substr(1)];
}
};
this.merge = function(person)
{
this.returnOrigin();
if(person.petType != "Chocobo_Persons")
{
this.pets[person.name] = person;
for(var k in this.pets)
{
for(var i in this.original)
{
if (i.indexOf("Last") > -1)
this["merged"+i] += this.pets[k].original[i];
else
this["merged"+i] += this.pets[k].original[i];
}
}
}
this.recalculate();
};
this.recalc = function()
{
this.recalculate();
};
this.get = function(key)
{
if (this.parent.summonerMerge && managedKeys[key] != undefined)
return this[managedKeys[key]];
else
return this[key];
};
if(e == undefined) return;
/* REWORK TAKEN VALUES */
for(var i in e)
{
if (i.indexOf("NAME") > -1) continue;
if (i == "t" || i == "n") continue;
var onlyDec = e[i].replace(/[0-9.,%]+/ig, "");
if (onlyDec != "")
{
if (onlyDec == "---" || onlyDec == "--")
this[i] = 0;
else
this[i] = e[i];
}
else
{
var tmp = parseFloat(e[i].replace(/[,%]+/ig, "")).nanFix().toFixed(underDot);
if (e[i].indexOf("%") > 0)
this[i] = parseFloat(tmp);
else if (Math.floor(tmp) != tmp || e[i].indexOf(".") > 0)
this[i] = parseFloat(tmp);
else
this[i] = parseInt(tmp).nanFix();
}
}
/* VARIABLES */
this.pets = {};
this.parent = p;
this.Class = "Unknown";
this.PetType = "Unknown";
this.role = "DPS";
this.isPet = !1;
this.isLower = !1;
this.visible = !0;
this.rank = 0;
this.maxdamage = 0;
this.displayName = this.name;
this.displayNameWithInitial = {
"original":this.name,
"firstinit":this.name,
"lastinit":this.name,
"fullinit":this.name
};
this.effectiveHeal = this.healed - this.overHeal;
this["overHeal%"] = Math.floor(this.overHeal / this.healed * 10000) / 100;
this.original = {
Damage: this.damage,
Hits: this.hits,
Misses: this.misses,
Swings: this.swings,
Crithits: this.crithits,
DirectHitCount: this.DirectHitCount,
CritDirectHitCount: this.CritDirectHitCount,
Damagetaken: this.damagetaken,
Heals: this.heals,
Healed: this.healed,
Critheals: this.critheals,
Healstaken: this.healstaken,
DamageShield: this.damageShield,
OverHeal: this.overHeal,
AbsorbHeal: this.absorbHeal,
Last10DPS: this.Last10DPS,
Last30DPS: this.Last30DPS,
Last60DPS: this.Last60DPS,
Last180DPS: this.Last180DPS,
effectiveheal: this.effectiveHeal
};
this.maxhitstr = "";
this.maxhitval = 0;
this.maxhealstr = "";
this.maxhealval = 0;
/* FIX MAXHIT */
try
{
this.maxhitstr = parent.langpack.get(this.maxhit.substring(0, this.maxhit.indexOf("-")));
this.maxhitval = parseInt(this.maxhit.substring(this.maxhit.indexOf("-") + 1).replace(/[,.]/, "")).nanFix();
}
catch (ex)
{
this.maxhit = "?-0";
}
/* FIX MAXHEAL */
try
{
this.maxhealstr = parent.langpack.get(this.maxheal.substring(0, this.maxheal.indexOf("-")));
this.maxhealval = parseInt(this.maxheal.substring(this.maxheal.indexOf("-") + 1).replace(/[,.]/, "")).nanFix();
}
catch (ex)
{
this.maxheal = "?-0";
}
/* IF NAME HAVE SPACE, TO MAKE INITIAL NAME */
if(this.name.indexOf(" ") > -1)
{
try
{
var d = this.name.split(" ");
this.displayNameWithInitial.firstinit = d[0].substring(0, 1)+". "+d[1];
this.displayNameWithInitial.lastinit = d[0]+" "+d[1].substring(0, 1)+".";
this.displayNameWithInitial.fullinit = d[0].substring(0, 1)+". "+d[1].substring(0, 1)+".";
}
catch (ex)
{
}
}
/* FIX INFINITY */
if (this.DURATION <= 0)
{
this.dps = parseFloat((this.damage / this.parent.DURATION).nanFix().toFixed(underDot));
this.hps = parseFloat((this.healed / this.parent.DURATION).nanFix().toFixed(underDot));
this.DPS = Math.floor(this.dps);
this.HPS = Math.floor(this.hps);
this["DPS-k"] = Math.floor(this.dps / 1000);
this["HPS-k"] = Math.floor(this.hps / 1000);
for(var i in this)
{
if (this[i] == "∞" || this[i] == "infinity")
this[i] = 0;
}
}
/* GIVE CLASS UPPER JOB AND CHECK PET TYPE */
if(this.Job != "" && this.Job != null && this.Job != undefined)
{
this.Class = this.Job.toUpperCase();
if(advclass.indexOf(this.Class) > -1)
{
this.Class = advjob[advclass.indexOf(this.Class)];
this.isLower = !0;
}
if(tanker.indexOf(this.Class) > -1)
this.role = "Tanker";
else if(healer.indexOf(this.Class) > -1)
this.role = "Healer";
}
if(this.Job == "")
{
for(var i in specialist)
{
for(var j in specialist[i])
{
if(this.name.toUpperCase().indexOf(specialist[i][j]) > -1)
{
this.Class = i;
if(i == "SMN")
this.petType = "Egi";
else if(i == "SCH")
this.petType = "Fairy";
else if(i == "MCH")
this.petType = "AutoTurret";
if(i != "LMB")
{
this.isPet = !0;
this.Job = "AVA";
}
else
{
this.Job = i;
}
}
}
}
}
if (this.petOwner != "" && this.Class == "")
{
this.isPet = !1;
this.Job = "CBO";
this.Class = "CBO";
this.petType = "Chocobo_Persons";
}
/* IF USING CHOCOBO SKILL, THIS PERSON IS CHOCOBO */
if(chocoboskill.indexOf(this.maxhitstr) > -1 || chocoboskill.indexOf(this.maxhealstr) > -1)
{
this.isPet = !1;
this.petType = "Chocobo_Persons";
this.Class = "CBO";
this.Job = "CBO";
}
if(this.isPet)
{
var regex = /(?:.*?)\((.*?)\)/im;
var matches = this.name.match(regex);
if(regex.test(this.name)) // do not use Array.length
{
this.petOwner = matches[1];
}
}
if (this.isPet && this.Class != "" && this.parent.users[this.petOwner] == undefined)
{
this.petOwner = "YOU";
}
for (var i in this.original)
{
if (i.indexOf("Last") > -1)
this["merged" + i] = this[i];
else if (i == "CritDirectHitCount" || i == "DirectHitCount")
this["merged" + i] = this[i];
else
this["merged" + i] = this[i.substr(0, 1).toLowerCase() + i.substr(1)];
}
},
Combatant = function(e, sortkey, lang)
{
this.indexOf = function(person)
{
var v = -1;
for(var i in this.Combatant)
{
v++;
if ( i == person)
return v;
}
return v;
};
this.sort = function(vector)
{
if (vector != undefined)
this.sortvector = vector;
if (this.summonerMerge && managedKeys[this.sortkey] != undefined)
this.sortkey = managedKeys[this.sortkey];
for (var i in this.Combatant)
{
if (this.Combatant[i].isPet && this.summonerMerge)
{
this.Combatant[this.Combatant[i].petOwner].pets[i] = this.Combatant[i];
this.Combatant[this.Combatant[i].petOwner].merge(this.Combatant[i]);
this.Combatant[i].visible = !1;
}
else
{
this.Combatant[i].visible = !0;
}
}
var tmp = new Array();
var r = 0;
for (var i in this.Combatant) tmp.push({ key: this.Combatant[i][this.sortkey], val: this.Combatant[i] });
this.Combatant = {};
if (this.sortvector)
tmp.sort(function(a, b) { return b.key - a.key });
else
tmp.sort(function(a, b) { return a.key - b.key });
this.maxValue = tmp[0].key;
this.maxdamage = tmp[0].key;
for (var i in tmp)
{
this.Combatant[tmp[i].val.name] = tmp[i].val;
}
for (var i in this.Combatant)
{
if (!this.Combatant[i].visible) continue;
this.Combatant[i].rank = r++;
this.Combatant[i].maxdamage = this.maxdamage;
}
this.persons = this.Combatant;
};
this.rerank = function(vector)
{
this.sort(vector);
};
this.AttachPets = function()
{
this.summonerMerge = !0;
for(var i in this.Combatant)
{
this.Combatant[i].returnOrigin();
this.Combatant[i].recalculate();
this.Combatant[i].parent = this;
}
this.rerank();
};
this.DetachPets = function()
{
this.summonerMerge = !1;
for(var i in this.Combatant)
{
this.Combatant[i].returnOrigin();
this.Combatant[i].recalculate();
this.Combatant[i].parent = this;
}
this.rerank();
};
this.resort = function(key, vector)
{
if (key == undefined)
this.sortkey = activeSort(this.sortkey);
else
this.sortkey = activeSort(key);
if (vector == undefined)
vector = this.sortvector;
this.sort(vector);
};
this.sortkeyChange = function(key)
{
this.resort(key, !0);
};
this.sortkeyChangeDesc = function(key)
{
this.resort(key, !1);
};
if (sortkey == undefined) var sortkey = "encdps";
if (e == undefined) return;
if (!langpack.languageDefine)
{
if (lang == undefined)
{
var lang = "ko";
langpack = new Language(lang);
}
else
{
langpack = new Language(lang);
langpack.setLangDefine(lang);
}
}
this.Encounter = {};
this.Combatant = {};
this.users = {};
this.raw = {"detail":e.detail};
for (var i in e.detail.Combatant)
{
this.users[i] = !0;
}
// 모든 Encounter 값을 가지고 있게끔
for(var i in e.detail.Encounter)
{
if (i == "t" || i == "n") continue;
var onlyDec = e.detail.Encounter[i].replace(/[0-9.,%]+/ig, "");
if (onlyDec != "")
{
if (onlyDec == "---" || onlyDec == "--")
this.Encounter[i] = 0;
else
this.Encounter[i] = e.detail.Encounter[i];
}
else
{
var tmp = parseFloat(e.detail.Encounter[i].replace(/[,%]+/ig, "")).nanFix().toFixed(underDot);
if (e.detail.Encounter[i].indexOf("%") > 0)
this.Encounter[i] = parseFloat(tmp);
else if (Math.floor(tmp) != tmp || e.detail.Encounter[i].indexOf(".") > 0)
this.Encounter[i] = parseFloat(tmp);
else
this.Encounter[i] = parseInt(tmp).nanFix();
}
}
for(var i in e.detail.Combatant)
{
this.Combatant[i] = new Person(e.detail.Combatant[i], this);
}
/* Refresh parent */
for(var i in e.detail.Combatant)
{
this.Combatant[i].parent = this;
}
/* Remove Enemy */
var tmp = {};
for(var i in this.Combatant)
{
if (this.Combatant[i].Class != "")
{
tmp[i] = this.Combatant[i];
}
}
this.Combatant = tmp;
/* Extra Value settings */
this.maxdamage = 0; // for old versions
this.maxValue = 0; // please use this value
this.zone = this.Encounter.CurrentZoneName;
this.title = this.Encounter.title;
this.sortvector = !0;
this.duration = this.Encounter.duration;
this.DURATION = this.Encounter.DURATION;
this.summonerMerge = !0;
this.sortkey = sortkey;
this.isActive = e.detail.isActive;
this.combatKey = this.Encounter.title.concat(this.Encounter.damage).concat(this.Encounter.healed);
this.persons = this.Combatant;
this.resort();
},
ActWebsocketInterface = function(uri, path)
{
this.connect = function()
{
if(typeof this.websocket != "undefined" && this.websocket != null)
this.close();
this.activate = true;
var This = this;
this.websocket = new WebSocket(this.uri);
this.websocket.onopen = function(evt) {This.onopen(evt);};
this.websocket.onmessage = function(evt) {This.onmessage(evt);};
this.websocket.onclose = function(evt) {This.onclose(evt);};
this.websocket.onerror = function(evt) {This.onerror(evt);};
};
this.close = function()
{
this.activate = false;
if(this.websocket != null && typeof this.websocket != "undefined")
{
this.websocket.close();
}
};
this.onopen = function(evt)
{
// get id from useragent
if(this.id != null && typeof this.id != "undefined")
{
this.set_id(this.id);
}
else
{
if(typeof overlayWindowId != "undefined")
{
this.set_id(overlayWindowId);
}
else
{
var r = new RegExp('[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}');
var id = r.exec(navigator.userAgent);
if(id != null && id.length == 1)
{
this.set_id(id[0]);
}
}
}
};
this.onclose = function()
{
this.websocket = null;
if(this.activate)
{
var This = this;
setTimeout(function() {This.connect();}, 5000);
}
};
this.onmessage = function(evt)
{
if (evt.data == ".")
{
// ping pong
this.websocket.send(".");
}
else
{
try{
var obj = JSON.parse(evt.data);
var type = obj["type"];
if(type == "broadcast")
{
var from = obj["from"];
var type = obj["msgtype"];
var msg = obj["msg"];
document.dispatchEvent(new CustomEvent('onBroadcastMessage', { detail: obj }));
}
if(type == "send")
{
var from = obj["from"];
var type = obj["msgtype"];
var msg = obj["msg"];
document.dispatchEvent(new CustomEvent('onRecvMessage', { detail: obj }));
}
if(type == "set_id")
{
//document.dispatchEvent(new CustomEvent('onIdChanged', { detail: obj }));
}
}
catch(e)
{
}
}
};
this.onerror = function(evt)
{
this.websocket.close();
console.log(evt);
};
this.getQuerySet = function()
{
var querySet = {};
// get query
var query = window.location.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
try{
var pair = vars[i].split('=');
querieSet[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
catch(e)
{
}
}
return querySet;
};
this.broadcast = function(type, msg)
{
if(typeof overlayWindowId != 'undefined' && this.id != overlayWindowId)
{
this.set_id(overlayWindowId);
}
var obj = {};
obj["type"] = "broadcast";
obj["msgtype"] = type;
obj["msg"] = msg;
this.websocket.send(JSON.stringify(obj));
};
this.send = function(to, type, msg)
{
if(typeof overlayWindowId != 'undefined' && this.id != overlayWindowId)