forked from brewk/wowspreadsheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wow_legion.js
1269 lines (1098 loc) · 41.7 KB
/
wow_legion.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
/* ***********************************
*** Copyright (c) 2018 bruk
*** This script is free software; you can redistribute it and/or modify
*** it under the terms of the GNU General Public License as published by
*** the Free Software Foundation; either version 3 of the License, or
*** (at your option) any later version.
***
*** Want to keep up to date or suggest modifications to this script?
*** then hop on over to http://twitter.com/bruk
** SHOUT OUTS / THANKS TO CONTRIBUTORS:
** /u/InABohx for massive overhauls to the gem system, help with the final part of the legendary quest, tons of other stuff
** /u/jethryn for the awesome job getting the new legendary quest milestone IDs
** /u/Kiingzy for enchant id numbers which helped greatly with the audit
** all the folks on twitter and reddit who have suggested such great features
************************************* */
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ IMPORTANT!!! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// You need to put your api key here, inside the quotes
// Request one here: https://dev.battle.net/apps/register
// Step by step instructions: http://bruk.org/api
var apikey = "";
// Change this to the threshold you want to start checking for epic gems (ie: if it's 709 anything 710 or above will be checked for epic gems)
var CONST_EPICGEM_ILVL = 160;
// You shouldn't need to change this, but this is threshold item level where gear is checked for enchants and gems
var CONST_AUDIT_ILVL = 160;
// Set this to be the minimum iLvl of the current raid's tier gear (helps weed out the tier column noise)
var CONST_TIER_GEAR_ILVL =160;
//If you want total AP gathered displayed next to highest weapon rank, change this to true
var showTotalArtifactPower = false;
//If you want Legendary items to be marked with a + next to item level (use conditional formatting to change their color) change this to true
var markLegendary = false;
//If you want Pantheon Trinkets to be marked with a 'p' next to item level (use conditional formatting to change their color) change this to true
var markPantheon = false;
// Everything below this, you shouldn't have to edit
//***************************************************************
/* globals Utilities, UrlFetchApp, Logger */
/* exported wow, vercheck */
var current_version = 3.41;
function relic(equippedRelic)
{
var id = equippedRelic.itemId;
if (id == 140070)
{
return "Frost +45 ilvls";
}
var bonusLists = "";
equippedRelic.bonusLists.forEach(function(bonusListNumber)
{
bonusLists = bonusLists + bonusListNumber + ",";
});
Utilities.sleep(500);
var relicDat = "";
var relicJSON ="";
{
try
{
relicJSON = UrlFetchApp.fetch("https://us.api.battle.net/wow/item/"+id+"?bl="+bonusLists+"&locale=en_US&apikey="+apikey+"");
relicDat = JSON.parse(relicJSON.toString());
}
catch (e)
{
Logger.log("Error Fetching: "+ e.message);
}
Logger.log(relicDat);
}
var elementType = relicDat.gemInfo.type.type;
if (elementType === "WIND") //Fixing a bug on Blizzard's end for the storm relic
{
elementType = "STORM";
}
var ilvl = relicDat.itemLevel;
//@Corazu: ilvl is wonky for lower level where they aren't necessarily on increments of 5. 3 rounds down, 8 rounds up
//the data is collected via item links in game to get the right +ilvl bonus for each ilvl of relic. The data may be incomplete
//for certain increments that aren't 5, even with the rounding, as there are gaps in between the 5 increments where the +ilvl
//bonus jumps by more than 1, leaving room for say, a xx8 to be in the middle.
//At some point for posterity I'll probably come back and fix those cases, but it's a lot of manual work to hand-check all the values
/*if (ilvl%5!=0)
{
var spare = ilvl%10;
if (spare<=3)
{
ilvl-=spare;
}
else
{
ilvl+=(5-spare);
}
}*/
var relicIlvl = 0;
if (ilvl<=141)
{
relicIlvl = 2; //anything less than this adds 2
}
else if (ilvl == 870)
{
relicIlvl="22";
}
else if (ilvl > 500)
{
relicIlvl = "??? item: " + id + " (" + ilvl + ")";
}
else if (ilvl > 255)
{
relicIlvl = ">35";
}
else
{
switch (ilvl)
{
case (142): relicIlvl="3"; break;
case (144): relicIlvl="3"; break;
case (145): relicIlvl="3"; break;
case (147): relicIlvl="4"; break;
case (148): relicIlvl="4"; break;
case (149): relicIlvl="5"; break;
case (156): relicIlvl="7"; break;
case (158): relicIlvl="7"; break;
case (160): relicIlvl="8"; break;
case (161): relicIlvl="8"; break;
case (162): relicIlvl="8"; break;
case (164): relicIlvl="9"; break;
case (166): relicIlvl="9"; break;
case (168): relicIlvl="10"; break;
case (167): relicIlvl="10?"; break;
case (169): relicIlvl="10??"; break;
case (171): relicIlvl="10???"; break;
case (170): relicIlvl="11"; break;
case (172): relicIlvl="11"; break;
case (176): relicIlvl="12"; break;
case (173): relicIlvl="12"; break;
case (174): relicIlvl="12"; break;
case (175): relicIlvl="12"; break;
case (178): relicIlvl="13"; break;
case (180): relicIlvl="13"; break;
case (182): relicIlvl="14"; break;
case (183): relicIlvl="15?"; break;
case (184): relicIlvl="15"; break;
case (185): relicIlvl="15"; break;
case (186): relicIlvl="15"; break;
case (187): relicIlvl="16??"; break;
case (188): relicIlvl="16"; break;
case (189): relicIlvl="16??"; break;
case (190): relicIlvl="16"; break;
case (191): relicIlvl="16???"; break;
case (192): relicIlvl="17"; break;
case (193): relicIlvl="17?"; break;
case (194): relicIlvl="17"; break;
case (195): relicIlvl="18"; break;
case (198): relicIlvl="19"; break;
case (199): relicIlvl="19?"; break;
case (200): relicIlvl="20"; break;
case (201): relicIlvl="20?"; break;
case (202): relicIlvl="20??"; break;
case (203): relicIlvl="20"; break;
case (204): relicIlvl="20"; break;
case (205): relicIlvl="20"; break;
case (208): relicIlvl="21"; break;
case (210): relicIlvl="22"; break;
case (213): relicIlvl="23"; break;
case (215): relicIlvl="23"; break;
case (220): relicIlvl="25"; break;
case (223): relicIlvl="26"; break;
case (225): relicIlvl="26"; break;
case (228): relicIlvl="27"; break;
case (230): relicIlvl="27"; break;
case (235): relicIlvl="29"; break;
case (240): relicIlvl="30"; break;
case (243): relicIlvl="31"; break;
case (245): relicIlvl="32"; break;
case (250): relicIlvl="33"; break;
case (255): relicIlvl="35"; break;
default: relicIlvl="???";
}
}
return elementType+" +"+relicIlvl+" ilvls";
}
function rep(standing)
{
switch (standing)
{
case 0:
return "Hated";
case 1:
return "Hostile";
case 2:
return "Unfriendly";
case 3:
return "Neutral";
case 4:
return "Friendly";
case 5:
return "Honored";
case 6:
return "Revered";
case 7:
return "Exalted";
default:
return "ERROR";
}
}
//thanks to github user bloodrash for this function
function numberWithCommas(x)
{
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
function wow(region,toonName,realmName)
{
if (!toonName || !realmName)
{
return " "; // If there's nothing in the column, don't even bother calling the API
}
if (!apikey)
{
return "Error: No API key entered. Please visit http://dev.battle.net/ to obtain one. Instructions availible at http://bruk.org/wow";
}
Utilities.sleep(Math.floor((Math.random() * 10000) + 1000)); // This is a random sleepy time so that we dont spam the api and get bonked with an error
//Getting rid of any sort of pesky no width white spaces we may run into
toonName = toonName.replace(/[\u200B-\u200D\uFEFF]/g, "");
region = region.replace(/[\u200B-\u200D\uFEFF]/g, "");
realmName = realmName.replace(/[\u200B-\u200D\uFEFF]/g, "");
region = region.toLowerCase(); // if we don't do this, it screws up the avatar display 9_9
var options={ muteHttpExceptions:true };
var toon = "";
while (!toon.name) //try again because of these frequent timeouts
{
try
{
var toonJSON = UrlFetchApp.fetch("https://"+region+".api.battle.net/wow/character/"+realmName+"/"+toonName+"?fields=reputation,statistics,items,quests,achievements,audit,progression,feed,professions,talents&?locale=en_US&apikey="+apikey+"", options);
toon = JSON.parse(toonJSON.toString());
}
catch (e)
{
Logger.log("Error Fetching: "+ e.message);
}
Logger.log(toonJSON);
}
var mainspec = "none";
for (var i = 0; i < 4; i++)
{
if (toon.talents[i].selected === true)
{
mainspec=toon.talents[i].spec.name;
}
}
// figuring out what the class is
var toon_class = 0;
switch (toon.class)
{
case 1:
toon_class = "Warrior";
break;
case 2:
toon_class = "Paladin";
break;
case 3:
toon_class = "Hunter";
break;
case 4:
toon_class = "Rogue";
break;
case 5:
toon_class = "Priest";
break;
case 6:
toon_class = "DeathKnight";
break;
case 7:
toon_class = "Shaman";
break;
case 8:
toon_class = "Mage";
break;
case 9:
toon_class = "Warlock";
break;
case 10:
toon_class = "Monk";
break;
case 11:
toon_class = "Druid";
break;
case 12:
toon_class = "Demon Hunter";
break;
default:
toon_class = "?";
}
// Time to do some gear audits
var auditInfo ="";
var totalGems = [0, 0, 0, 0];
var gemAudit = [
{ bool: 0, issue: " Old:" },
{ bool: 0, issue: " Cheap:" },
{ bool: 0, issue: " No Prime Stat Epic" }, // this was a list of non-epic gems, when they weren't unique
{ bool: 0, issue: " Mixed Gems" }
];
var gemStats = [
{ value: 0, stat: "Crit" },
{ value: 0, stat: "Haste" },
{ value: 0, stat: "Vers" },
{ value: 0, stat: "Mast" },
{ value: 0, stat: "Str" },
{ value: 0, stat: "Agi" },
{ value: 0, stat: "Int" },
{ value: 0, stat: "Crit" }, //look, this is gonna be weird.. but it's for the new epic gems which are weirdly numbered and different from previous order
{ value: 0, stat: "-" },
{ value: 0, stat: "-" },
{ value: 0, stat: "Haste" },
{ value: 0, stat: "Mast" },
{ value: 0, stat: "Vers" },
];
// I love me some look up tables! These are to check if you have a crappy enchant or gem
var audit_lookup = {};
//cheap enchants and gems
//ring
audit_lookup["5423"] = "Word +7Crit";
audit_lookup["5424"] = "Word +7Hst";
audit_lookup["5425"] = "Word +7Mast";
audit_lookup["5426"] = "Word +7Vers";
//cloak
audit_lookup["5431"] = "Word +7Str";
audit_lookup["5432"] = "Word +7Agi";
audit_lookup["5433"] = "Word +7Int";
//gems
audit_lookup["130218"] =
audit_lookup["130217"] =
audit_lookup["130216"] =
audit_lookup["130215"] = 0;
//better enchants and gems
//ring
audit_lookup["5427"] = "Binding +9Crit";
audit_lookup["5428"] = "Binding +9Hst";
audit_lookup["5429"] = "Binding +9Mast";
audit_lookup["5430"] = "Binding +7Vers";
//cloak
audit_lookup["5434"] = "Binding +9Str";
audit_lookup["5435"] = "Binding +9Agi";
audit_lookup["5436"] = "Binding +9Int";
//gems
audit_lookup["130219"] =
audit_lookup["130220"] =
audit_lookup["130221"] =
audit_lookup["130222"] =1;
//epic gems
audit_lookup["130246"] = //strengh
audit_lookup["130247"] = //agility
audit_lookup["130248"] = 2; //Int
// NEW epic gems
audit_lookup["151580"] =
audit_lookup["151583"] =
audit_lookup["151584"] =
audit_lookup["151585"] = 3;
//neck
audit_lookup["5437"] = "Claw";
audit_lookup["5438"] = "Army";
audit_lookup["5439"] = "Satyr";
audit_lookup["5889"] = "Hide";
audit_lookup["5890"] = "Soldier";
audit_lookup["5891"] = "Priestess";
audit_lookup["5895"] = "Master";
audit_lookup["5896"] = "Versatile";
audit_lookup["5897"] = "Quick";
audit_lookup["5898"] = "Deadly";
//shoulder
audit_lookup["5440"] = "Scavenger (cloth)";
audit_lookup["5441"] = "Gemfinder";
audit_lookup["5442"] = "Harvester (herbs/fish)";
audit_lookup["5443"] = "Butcher (leather/meat)";
audit_lookup["5882"] = "Manaseeker (enchant)";
audit_lookup["5881"] = "Salvager (ore/armor)";
audit_lookup["5883"] = "Bloodhunter (Blood)";
audit_lookup["5900"] = "Zookeeper (Pet)";
audit_lookup["5888"] = "Netherdrift";
audit_lookup["5899"] = "Builder (Engineer)";
//gloves
audit_lookup["5444"] = "Herb";
audit_lookup["5445"] = "Mine";
audit_lookup["5446"] = "Skin";
audit_lookup["5447"] = "Survey";
var thumbnail = "http://render-"+region+".worldofwarcraft.com/character/"+ toon.thumbnail;
var armory = "http://"+region+".battle.net/wow/en/character/"+realmName+"/"+toonName+"/";
var tier = " ";
var tier_pieces = [toon.items.head,toon.items.shoulder,toon.items.chest,toon.items.hands,toon.items.legs,toon.items.back];
var set1 = [];
var set2 = [];
//var gemMatch = 0; //check if our rare/uncommon gems match
for (i = 0; i < tier_pieces.length; i++)
{
if (tier_pieces[i] && tier_pieces[i].tooltipParams.set && tier_pieces[i].itemLevel >= CONST_TIER_GEAR_ILVL)
{
if (!set1.length)
{
set1 = tier_pieces[i].tooltipParams.set;
}
if (!set2.length && set1.indexOf(tier_pieces[i].id) ==-1)
{
set2 = tier_pieces[i].tooltipParams.set;
}
}
}
if (set2.length)
{
tier = set1.length + "/" + set2.length;
}
else
{
tier = set1.length;
}
var allItems={
equippedItems:0,
totalIlvl:0,
upgrade: {
total:0,
current:0
}
};
var enchantableItems=["neck","back","finger1","finger2","hands","shoulder"];
var getItemInfo = function (item, slot)
{
allItems[slot] = {
ilvl:"\u2063",
upgrade:"-"
};
if (item)
{
if (item.tooltipParams.upgrade)
{
allItems[slot].upgrade= item.tooltipParams.upgrade.current + "/" + item.tooltipParams.upgrade.total;
allItems.upgrade.total+=item.tooltipParams.upgrade.total;
allItems.upgrade.current+=item.tooltipParams.upgrade.current;
}
//crafted gear upgrade stuff
var obliterum = 11; //current cap for obliterum upgrades
var craftedUpgrade = -1;
for (var j = 0; j < item.bonusLists.length; j++)
{
switch (item.bonusLists[j])
{
case 596:
craftedUpgrade = 0;
break;
case 597:
craftedUpgrade = 1;
break;
case 598:
craftedUpgrade = 2;
break;
case 599:
craftedUpgrade = 3;
break;
case 666:
craftedUpgrade = 4;
break;
case 667:
craftedUpgrade = 5;
break;
case 668:
craftedUpgrade = 6;
break;
case 669:
craftedUpgrade = 7;
break;
case 670:
craftedUpgrade = 8;
break;
case 671:
craftedUpgrade = 9;
break;
case 672:
craftedUpgrade = 10;
break;
default:
craftedUpgrade = "-";
}
}
if (craftedUpgrade > -1)
{
allItems[slot].upgrade= craftedUpgrade + "/" + obliterum;
allItems.upgrade.total+=obliterum;
allItems.upgrade.current+=craftedUpgrade;
}
allItems.equippedItems++;
allItems[slot].ilvl = item.itemLevel;
allItems.totalIlvl += item.itemLevel;
//temporary workaround for armory still returning wrong ilvl (895 instead of 910) for legion legendaries
//provided by @lifeguttter
//modified to use bonuslist for 940 instead of 910
/*if (item.quality == 5)
{
if (item.bonusLists[0] == 3529)
{
allItems[slot].ilvl = 940;
// allItems.totalIlvl += 30; Believe this line was not needed, it was causing ilvl to be too high
}
}*/
if (item.quality === 5 && markLegendary)
{
allItems[slot].ilvl = allItems[slot].ilvl + "+"; // * can be any character you want, use it for your conditional
}
if ((item.id === 154172 || item.id === 154176 || item.id === 154175 || item.id === 154177 || item.id === 154174 || item.id === 154173 || item.id === 147002 ) && markPantheon)
{
allItems[slot].ilvl = allItems[slot].ilvl + "p"; // * can be any character you want, use it for your conditional
}
if (item.itemLevel > CONST_AUDIT_ILVL)
{
if (item.tooltipParams.gem0&&slot!="mainHand"&&slot!="offHand")
{
if (item.tooltipParams.gem0 > 151579) // new epic gems
{
gemStats[item.tooltipParams.gem0-151580+7].value = gemStats[item.tooltipParams.gem0-151580+7].value+11;
}
else if (item.tooltipParams.gem0 > 130245) //(epic) I think this could be beautified/simplifed, basically it adds to the stat value for each quality
{
gemStats[item.tooltipParams.gem0-130246+4].value = gemStats[item.tooltipParams.gem0-130246+4].value+9;
}
else if (item.tooltipParams.gem0 > 130218) //(rare)
{
gemStats[item.tooltipParams.gem0-130219].value = gemStats[item.tooltipParams.gem0-130219].value+9;
}
else if (item.tooltipParams.gem0 > 130214) //(uncommon)
{
gemStats[item.tooltipParams.gem0-130215].value = gemStats [item.tooltipParams.gem0-130215].value+7;
}
if (item.itemLevel>CONST_EPICGEM_ILVL)
{
if (audit_lookup[item.tooltipParams.gem0] == 2) //this was set to != when epic gems weren't unique
{
gemAudit[2].bool = 0;
//gemAudit[2].bool = 1;
//gemAudit[2].issue += " "+ slot;
}
}
else if (audit_lookup[item.tooltipParams.gem0] === 0)
{
gemAudit[1].bool = 1;
gemAudit[1].issue += " " + slot;
}
else if (audit_lookup[item.tooltipParams.gem0] != 1)
{
gemAudit[0].bool = 1;
gemAudit[0].issue += " " + slot;
}
/* //Mixed Gems - if a gem is not epic, check if it has the same stat type, if so, then copy it into gemMatch to compare it to the next one
if (audit_lookup[item.tooltipParams.gem0] != 2 && (gemMatch == 0 || gemMatch === item.tooltipParams.gem0 || gemMatch === item.tooltipParams.gem0+4 || gemMatch === item.tooltipParams.gem0-4))
{
gemMatch = item.tooltipParams.gem0;
}
else if (audit_lookup[item.tooltipParams.gem0] != 2 && audit_lookup[item.tooltipParams.gem0] > -1)
{
gemAudit[3].bool = 1; // if we fail to pass the above if, the stats don't match on our gems
}*/
totalGems[audit_lookup[item.tooltipParams.gem0]]++;
}
if (enchantableItems.indexOf(slot)!=-1)
{
allItems[slot].enchant= "None";
if (item.tooltipParams.enchant)
{
if (audit_lookup[item.tooltipParams.enchant])
{
allItems[slot].enchant = audit_lookup[item.tooltipParams.enchant];
}
else
{
allItems[slot].enchant = "Old";
}
}
}
}
}
};
var sortOrder = [
"head",
"neck",
"shoulder",
"back",
"chest",
"wrist",
"hands",
"waist",
"legs",
"feet",
"finger1",
"finger2",
"trinket1",
"trinket2",
"mainHand",
"offHand"
];
for (i = 0; i < sortOrder.length; i++)
{
getItemInfo(toon.items[sortOrder[i]],sortOrder[i]);
}
//always put the higher level trinket/ring on the leftier column
var bruksOCDswap = function (item1,item2)
{
if (allItems[item1].ilvl<allItems[item2].ilvl)
{
var swapValue = allItems[item1].ilvl;
allItems[item1].ilvl = allItems[item2].ilvl;
allItems[item2].ilvl = swapValue;
}
};
bruksOCDswap("finger1","finger2");
bruksOCDswap("trinket1","trinket2");
// /u/orange_gauss supplied this for fixing the double weight of 2handers
if (allItems.offHand.ilvl == "\u2063" )
{
allItems.totalIlvl += allItems.mainHand.ilvl;
allItems.equippedItems += 1;
}
allItems.averageIlvl = allItems.totalIlvl / allItems.equippedItems;
//fall back to max unequipped ilvl if they're currently partially nude
if (isNaN(allItems.averageIlvl))
{
allItems.averageIlvl = toon.items.averageItemLevel;
}
if (toon.audit.emptySockets !== 0)
{
auditInfo = auditInfo + "Empty Gem Sockets: " + toon.audit.emptySockets + " ";
}
if (totalGems[0]+totalGems[1]+totalGems[2]+totalGems[3]>0) //gems exist!
{
auditInfo = auditInfo + "Gems" ;
if (totalGems[0] > 0)
{
auditInfo = auditInfo + " UnCom:" + totalGems[0];
}
if (totalGems[1] > 0)
{
auditInfo = auditInfo + " Rare:" + totalGems[1];
}
if (totalGems[3] > 0)
{
auditInfo = auditInfo + " Epic:" + totalGems[3];
}
if (totalGems[2] > 0)
{
auditInfo = auditInfo + " PrimeEpic:" + totalGems[2];
}
for (i=0; i<gemStats.length; i++)
{
if (gemStats[i].value > 0)
{
auditInfo = auditInfo + " +" + gemStats[i].value + gemStats[i].stat + " ";
}
}
}
for (i=0; i<gemAudit.length; i++)
{
if (gemAudit[i].bool > 0)
{
auditInfo = auditInfo + gemAudit[i].issue;
}
}
// lock out "Weekly checker"
var todayStamp =new Date();
var today = todayStamp.getDay();
var sinceYesterday = 0;
var now = todayStamp.getHours();
var resetTime = new Date();
var offset = new Date().getTimezoneOffset();
offset=offset/60;
if (region == "us")
{
resetTime.setHours(15-offset,0,0,0);
}
else
{
resetTime.setHours(7-offset,0,0,0);
}
sinceYesterday = resetTime.getTime();
//attempt to fix post-midnight pre-reset
if (now < 15-offset && now > -1 && region == "us") //if it's after midnight but before 11am
{
sinceYesterday-=86400000;
}
if (now < 7-offset && now > -1 && region == "eu") //if it's after midnight but before 7am
{
sinceYesterday-=86400000;
}
// now we have to figure out how long it's been since tuesday
var sinceTuesday =new Date();
var reset = region == "eu" ? 3 : 2; // 2 for tuesday, 3 for wednesday
var midnight = new Date();
midnight.setHours(0,0,0,0);
sinceTuesday = resetTime*1;
if (today == reset) //it IS tuesday!
{
//attempt to fix post-midnight pre-reset
if ((now < 7-offset && now > -1 && region == "eu") || (now < 15-offset && now > -1 && region == "us")) //if it's after midnight but before 7am
{
sinceTuesday-=(86400000*7);
}
}
if (today > reset)
{
// wednesday (thurs eu) - saturday
sinceTuesday = sinceTuesday-(today-reset)*86400000;
}
else if (today < reset)
{
// sunday + monday (tues eu)
sinceTuesday = sinceTuesday-((7+today-reset))*86400000; // this was 6, but to account for EU it was changed to 7-reset to be either 6 or 5 to account for Wednesday resets
}
// Raid stat sub-categories
var STATS_RAIDS_LEGION = 6;
var raidInstancesSortOrder = [];
var raidDifficultySortOrder = ["Raid Finder", "Normal", "Heroic", "Mythic"];
for (i = 35; i <= 39; i++) // legion raids up to ToS increase 38 if new raid comes
{
raidInstancesSortOrder.push(toon.progression.raids[i].name);
}
var instanceDetails = { "dungeons":{},"raids":{} };
for (i in raidInstancesSortOrder)
{
instanceDetails.raids[raidInstancesSortOrder[i]] = {};
}
var getShortInstanceName = function (inputString)
{
var split = inputString.split(" ");
if (split.length !== 1)
{
var retstring = "";
for (i in split)
{
retstring = retstring + split[i].slice(0, 1);
}
return retstring;
}
else
{
return split[0].slice(0,3).toUpperCase();
}
};
var getRaidAndBossName = function(inputString)
{
var info = "";
//attempt to get boss name, raid, and difficulty by splitting based on this string
if (inputString.indexOf("defeats") !== -1)
{
info = inputString.split(" defeats (");
}
else if (inputString.indexOf("redemptions") !== -1)
{
info = inputString.split(" redemptions (");
}
else if (inputString.indexOf("defenses") !== -1)
{
info = inputString.split(" defenses (");
}
else
{
info = inputString.split(" kills (");
}
var bossName = info.shift(); // first we get boss name
info = info[0].split(" ");
var difficultyName = "";
var nameForInstance = "";
if (info[0] === "Raid")
{
difficultyName = info.shift() + " " + info.shift(); // Raid Finder
nameForInstance = info.join(" ").slice(0, -1); // rest is the name and we remove the last ")"
}
else if (info[0] !== "Return")
{
difficultyName = info.shift(); // first info is what difficultie we have
nameForInstance = info.join(" ").slice(0, -1); // rest is the name and we remove the last ")"
}
else // this should only be Return to Karazhan
{
difficultyName = "Mythic";
nameForInstance = info.join(" ").slice(0, -1); // rest is the name and we remove the last ")"
}
return [bossName, nameForInstance, difficultyName];
};
for (var instanceNumber in toon.statistics.subCategories[5].subCategories[STATS_RAIDS_LEGION].statistics)
{
var instanceBoss = toon.statistics.subCategories[5].subCategories[STATS_RAIDS_LEGION].statistics[instanceNumber];
var instanceReturns = getRaidAndBossName(instanceBoss.name);
var bossName = instanceReturns[0];
var nameOfInstance = instanceReturns[1];
var difficultyName = instanceReturns[2];
var typeOfInstance = "Dungeon";
for (var raid in raidInstancesSortOrder)// this is needed this as "the" is missing from instances.
{
if (raidInstancesSortOrder[raid].indexOf(nameOfInstance) !== -1)
{
nameOfInstance = raidInstancesSortOrder[raid];
typeOfInstance = "Raid";
}
}
var thisInstance = typeOfInstance === "Raid" ? instanceDetails.raids : instanceDetails.dungeons;
thisInstance[nameOfInstance] = thisInstance[nameOfInstance] || {};
thisInstance[nameOfInstance][difficultyName] = thisInstance[nameOfInstance][difficultyName] || {};
thisInstance[nameOfInstance][difficultyName].bosses = thisInstance[nameOfInstance][difficultyName].bosses || {};
var infoForBoss = { "kills": instanceBoss.quantity };
if (typeOfInstance === "Dungeon" && difficultyName === "Heroic")
{
infoForBoss.lockout = instanceBoss.lastUpdated > sinceYesterday;
}
else if (typeOfInstance !== "Dungeon" || difficultyName !== "Normal")// everything except normal dungeons
{
infoForBoss.lockout = instanceBoss.lastUpdated > sinceTuesday;
}
if (nameOfInstance.indexOf("Violet Hold")===-1)
{
thisInstance[nameOfInstance][difficultyName].bosses[bossName] = infoForBoss;
}
else
{
var oldInfo = thisInstance[nameOfInstance][difficultyName].bosses["Violet Hold End Boss"] || {};
if (oldInfo.kills)
{
infoForBoss.kills += oldInfo.kills;
infoForBoss.lockout = infoForBoss.lockout || oldInfo.lockout; // since 0 is false and 1 is true this will work.
}
thisInstance[nameOfInstance][difficultyName].bosses["Violet Hold End Boss"] = infoForBoss;
}
thisInstance[nameOfInstance][difficultyName].kills = thisInstance[nameOfInstance][difficultyName].kills || 0;
thisInstance[nameOfInstance][difficultyName].kills += instanceBoss.quantity;
}
var displayInfo = { "raid": {}, "dungeon": {} };
for (var instanceType in instanceDetails)
{
var instances = instanceDetails[instanceType];
var infoOnDifficulty = {};
for (var instanceName in instances)
{
var instance = instances[instanceName];
if (instanceType === "raids") // for dungeons we take lockout for all instances, for raid we do it for each instance.
{
infoOnDifficulty = {};
}
for (var difficulty in instance)
{
infoOnDifficulty[difficulty] = infoOnDifficulty[difficulty] || {
"activeWeeks":0, "lockout":0, "instanceLength": 0, "progress": 0, "kills": 0
};
var thisDifficulty = infoOnDifficulty[difficulty];
var bosses = instance[difficulty].bosses;
for (var boss in bosses)
{
var bossInfo = bosses[boss];
thisDifficulty.activeWeeks = Math.max(thisDifficulty.activeWeeks, bossInfo.kills);
thisDifficulty.instanceLength++;
thisDifficulty.kills += bossInfo.kills;
thisDifficulty.progress += bossInfo.kills === 0 ? 0 : 1;
thisDifficulty.lockout += bossInfo.lockout ? 1 : 0;
if (instanceType === "dungeons" && difficulty === "Mythic" && bossInfo.lockout)
{
thisDifficulty.details = thisDifficulty.details ? thisDifficulty.details + ", " + getShortInstanceName(instanceName) : getShortInstanceName(instanceName);
}
}
}
if (instanceType === "raids")
{
displayInfo.raid[instanceName] = infoOnDifficulty;
}
}
if (instanceType === "dungeons")
{
displayInfo.dungeon = infoOnDifficulty;
}
}
var profession1 = "none";
var profession2 = "none";