forked from brewk/wowspreadsheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wow_bfa.js
977 lines (828 loc) · 32.1 KB
/
wow_bfa.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
/* ***********************************
*** 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.
***
************************************* */
// For more info, help, or to contribute: http://bruk.org/wow
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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 349 anything 350 or above will be checked for epic gems)
var CONST_EPICGEM_ILVL = 350;
// This is threshold item level where gear is checked for enchants and gems
var CONST_AUDIT_ILVL = 309;
//If you want to list the uncompleted Mythic dungeons instead of the completed Mythics, change this from false to true
var listMissing = 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 = true;
// Everything below this, you shouldn't have to edit
//***************************************************************
/* globals Utilities, UrlFetchApp */
/* exported wow, vercheck */
var current_version = 4.0125;
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";
}
}
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 = "";
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());
if (toon.detail)
{
return "API Error, check if your API key is entered properly and that the API is working";
}
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: "%XP" },
{ value: 0, stat: "%Move" },
{ value: 0, stat: "Str" },
{ value: 0, stat: "Agi" },
{ value: 0, stat: "Int" },
{ value: 0, stat: "OLD GEMS" },
];
// I love me some look up tables! These are to check if you have a crappy enchant or gem
var audit_lookup = {};
//uncommon gems
audit_lookup["153710"] =
audit_lookup["153711"] =
audit_lookup["153712"] =
audit_lookup["153713"] =
audit_lookup["153714"] = //XP
audit_lookup["153715"] =0; // +Movement
//rare gems
audit_lookup["154126"] =
audit_lookup["154127"] =
audit_lookup["154128"] =
audit_lookup["154129"] = 1;
//unique epic gems
audit_lookup["153707"] = //strengh
audit_lookup["153708"] = //agility
audit_lookup["153709"] = 2; //Int
//ring
audit_lookup["5942"] = "Pact +37C";
audit_lookup["5943"] = "Pact +37H";
audit_lookup["5944"] = "Pact +37M";
audit_lookup["5945"] = "Pact +37V";
audit_lookup["5938"] = "Seal +27C";
audit_lookup["5939"] = "Seal +27H";
audit_lookup["5940"] = "Seal +27M";
audit_lookup["5941"] = "Seal +27V";
//weapons
audit_lookup["5946"] = "Coastal Surge";
audit_lookup["5948"] = "Siphoning";
audit_lookup["5949"] = "Torrent of Elements";
audit_lookup["5950"] = "Gale-Force";
audit_lookup["5962"] = "Versatile Nav";
audit_lookup["5963"] = "Quick Nav";
audit_lookup["5964"] = "Masterful Nav";
audit_lookup["5965"] = "Deadly Nav";
audit_lookup["5966"] = "Stalwart Nav";
//scopes
audit_lookup["5955"] = "Crow's Nest Scope";
audit_lookup["5956"] = "Monelite Scope";
audit_lookup["5957"] = "Incendiary Ammo";
audit_lookup["5958"] = "Frost-Laced Ammo";
audit_lookup["3847"] = "(DK)Stoneskin Gargoyle";
audit_lookup["3368"] = "(DK)Fallen Crusader";
audit_lookup["3366"] = "(DK)Lichbane";
audit_lookup["3367"] = "(DK)Spellshattering";
audit_lookup["3595"] = "(DK)Spellbreaking";
audit_lookup["3370"] = "(DK)Razorice";
//shoulder - Leaving Legion ones in incase they are still useful to have in BfA
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["5932"] = "Herb";
audit_lookup["5933"] = "Mine";
audit_lookup["5934"] = "Skin";
audit_lookup["5935"] = "Survey";
audit_lookup["5937"] = "Crafting";
var thumbnail = "http://render-"+region+".worldofwarcraft.com/character/"+ toon.thumbnail;
var armory = "http://"+region+".battle.net/wow/en/character/"+realmName+"/"+toonName+"/";
var allItems={
equippedItems:0,
totalIlvl:0,
upgrade: {
total:0,
current:0
}
};
// Azerite Info
var heartOfAzeroth = "-";
//thanks to github user bloodrash for this function
function numberWithCommas(x)
{
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
if (toon.items.neck)
{
if (toon.items.neck.quality===6)
{
heartOfAzeroth = toon.items.neck.azeriteItem.azeriteLevel + " (" + numberWithCommas(toon.items.neck.azeriteItem.azeriteExperience) + " / " + numberWithCommas(toon.items.neck.azeriteItem.azeriteExperienceRemaining) + ")";
}
}
var enchantableItems=["mainHand","offHand","finger1","finger2","hands"];
var azeriteItems=["head","shoulder","chest"];
var getItemInfo = function (item, slot)
{
allItems[slot] = {
ilvl:"\u2063",
power:"-"
};
if (item)
{
allItems.equippedItems++;
allItems[slot].ilvl = item.itemLevel;
allItems.totalIlvl += item.itemLevel;
if (item.quality === 5 && markLegendary)
{
allItems[slot].ilvl = allItems[slot].ilvl + "+"; // * can be any character you want, use it for your conditional
}
if (item.itemLevel > CONST_AUDIT_ILVL)
{
if (item.tooltipParams.gem0&&item.quality!=6) // don't check artifacts in case people are still using those!
{
//if statement set up in descending order for gem IDs
if (item.tooltipParams.gem0 > 154125) //rare
{
gemStats[item.tooltipParams.gem0-154126].value = gemStats[item.tooltipParams.gem0-154126].value+40;
}
else if (item.tooltipParams.gem0 > 153714) // +move
{
gemStats[item.tooltipParams.gem0-153715+4].value = gemStats[item.tooltipParams.gem0-153715+4].value+3;
}
else if (item.tooltipParams.gem0 > 153713) // xp
{
gemStats[item.tooltipParams.gem0-153714+4].value = gemStats[item.tooltipParams.gem0-153714+4].value+5;
}
else if (item.tooltipParams.gem0 > 153709) //uncommon
{
gemStats[item.tooltipParams.gem0-153710].value = gemStats[item.tooltipParams.gem0-153710].value+30;
}
else if (item.tooltipParams.gem0 > 153706) //unique epic
{
gemStats[item.tooltipParams.gem0-153707+6].value = gemStats [item.tooltipParams.gem0-153707+6].value+40;
}
else
{
gemStats[9].value = gemStats[9].value + 1;
}
if (item.itemLevel>CONST_EPICGEM_ILVL)
{
if (audit_lookup[item.tooltipParams.gem0] != 2)
{
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;
}
totalGems[audit_lookup[item.tooltipParams.gem0]]++;
}
if (enchantableItems.indexOf(slot)!=-1)
{
if (slot=="offHand" && !toon.items.offHand.weaponInfo)
{
allItems[slot].enchant = ""; //this is just here to make lint happy, wish i could just stick a ; at the end of that if
}
else
{
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";
}
}
}
}
}
//unfortunately it doesn't seem like there's any valuable info in the tooltip params even though azerite power appears there
if (azeriteItems.indexOf(slot)!=-1)
{
allItems[slot].power= "-";
if (item.azeriteEmpoweredItem)
{
if (item.azeriteEmpoweredItem.azeritePowers[0])
{
allItems[slot].power=0;
for (j=0; j<item.azeriteEmpoweredItem.azeritePowers.length; j++)
{
if (item.azeriteEmpoweredItem.azeritePowers[j].spellId > 0)
{
allItems[slot].power = allItems[slot].power+1;
}
}
allItems[slot].power = allItems[slot].power + " unlocked";
}
}
}
}
};
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]);
}
var bruksOCDswap = function (item1,item2)
{
if (allItems[item1].ilvl<allItems[item2].ilvl || allItems[item2].ilvl =="265+" || allItems[item2].ilvl =="240+" )
{
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 CURRENT_XPAC = 7;
var raidInstancesSortOrder = [];
var raidDifficultySortOrder = ["Raid Finder", "Normal", "Heroic", "Mythic"];
for (i = 21; i <= 21; 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[CURRENT_XPAC].statistics)
{
var instanceBoss = toon.statistics.subCategories[5].subCategories[CURRENT_XPAC].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;
}
}
//code for displaying missing mythics instead of completed, needs updating of more mythics are added
var missingMythics ="Missing: ";
// remove the undefined if 0 completed, or the "Missing: " if all completed (increment this if more dungeons added)
if (!displayInfo.dungeon.Mythic.details || displayInfo.dungeon.Mythic.lockout ==10)
{
displayInfo.dungeon.Mythic.details = "";
missingMythics = "";
}
else if (listMissing == true)
{
var mythicList = ["ATA", "FRE", "KR", "SotS", "SoB", "ToS", "TM", "TU", "TD", "WM"]; //add abbrvs to list if more are added
for (i=0; i<mythicList.length; i++)
{
var n=displayInfo.dungeon.Mythic.details.search(mythicList[i]);
if (n==-1)
{
missingMythics = missingMythics + mythicList[i] + " ";
}
}
displayInfo.dungeon.Mythic.details = missingMythics;
}
var profession1 = "none";
var profession2 = "none";
var prof1Icon = "none";
var prof2Icon = "none";
var proftemp = "0";
var prof1array = ["-", "-", "-", "-", "-", "-", "-", "-"];
var prof2array = ["-", "-", "-", "-", "-", "-", "-", "-"];
var prof_lookup = {};
prof_lookup.Kul = 7;
prof_lookup.Zandalari = 7;
prof_lookup.Legion = 6;
prof_lookup.Draenor = 5;
prof_lookup.Pandaria = 4;
prof_lookup.Cataclysm = 3;
prof_lookup.Northrend = 2;
prof_lookup.Outland = 1;
prof_lookup[0] = 0;
for ( i = 0; i < toon.professions.primary.length; i++)
{
if (prof1Icon == "none" || prof1Icon == toon.professions.primary[i].icon)
{
prof1Icon = toon.professions.primary[i].icon;
if (toon.professions.primary[i].id < 900)
{
profession1 = toon.professions.primary[i].name;
proftemp[0] = 0;
}
else
{
proftemp = toon.professions.primary[i].name.split(" ");
}
if (toon.professions.primary[i].rank >= toon.professions.primary[i].max)
{
prof1array[prof_lookup[proftemp[0]]]= "\u2713";
}
else
{
prof1array[prof_lookup[proftemp[0]]]= toon.professions.primary[i].rank;
}
}
else if (prof2Icon == "none" || prof2Icon == toon.professions.primary[i].icon)
{
prof2Icon = toon.professions.primary[i].icon;
if (toon.professions.primary[i].id < 900)
{
profession2 = toon.professions.primary[i].name;
proftemp[0] = 0;
}
else
{
proftemp = toon.professions.primary[i].name.split(" ");
}
if (toon.professions.primary[i].rank >= toon.professions.primary[i].max)
{
prof2array[prof_lookup[proftemp[0]]]= "\u2713";
}
else
{
prof2array[prof_lookup[proftemp[0]]]= toon.professions.primary[i].rank;
}
}
}
profession1 = profession1 + " " + prof1array;
profession2 = profession2 + " " + prof2array;
// IDs for mythic+ were provied by @matdemy on twitter and this post: http://us.battle.net/forums/en/bnet/topic/20752275890
var mythicPlus = "";
for (i=0; i<toon.achievements.criteria.length; i++)
{
switch (toon.achievements.criteria[i])
{
case (33096):
mythicPlus = mythicPlus + "m+2: " + toon.achievements.criteriaQuantity[i];
break;
case (33097):
mythicPlus = mythicPlus + " m+5: " + toon.achievements.criteriaQuantity[i];
break;
case (33098):
mythicPlus = mythicPlus + " m+10: " + toon.achievements.criteriaQuantity[i];
break;
case (32028):
mythicPlus = mythicPlus + " m+15: " + toon.achievements.criteriaQuantity[i];
break;
default:
break;
}
}
var reps = [
{ "id":2164, "text":"" },//Champions of Azeroth
{ "id":2163, "text":"" },//Tortollan Seekers
// alliance factions
{ "id":2160, "text":"" },//Proudmoore Admiralty
{ "id":2161, "text":"" },//Order of Embers
{ "id":2162, "text":"" },//Storm's Wake
{ "id":2159, "text":"" },//7th Legion
// horde factions
{ "id":2103, "text":"" },//Zandalari Empire
{ "id":2156, "text":"" },//Talanji's Expedition
{ "id":2158, "text":"" },//Voldunai
{ "id":2157, "text":"" },//The Honorbound
];
var repCount = 0;
for (i = 0; i<toon.reputation.length; i++)
{
for (var j = 0; j < reps.length; j++)
{
if (toon.reputation[i].id == reps[j].id && toon.reputation[i].standing > 2)
{
reps[repCount].text = toon.reputation[i].name + " - " + rep(toon.reputation[i].standing) + " " + toon.reputation[i].value + "/" + toon.reputation[i].max;
repCount++;
}
}
}
var toonInfo = [
toon_class,
toon.level,
mainspec,
allItems.averageIlvl,
heartOfAzeroth,
auditInfo,
displayInfo.dungeon.Heroic.lockout + "/" + displayInfo.dungeon.Heroic.instanceLength,
displayInfo.dungeon.Heroic.progress + "/" + displayInfo.dungeon.Heroic.instanceLength + " (" + displayInfo.dungeon.Heroic.kills + ")",
displayInfo.dungeon.Mythic.lockout + "/" + displayInfo.dungeon.Mythic.instanceLength + " " + displayInfo.dungeon.Mythic.details,
displayInfo.dungeon.Mythic.progress + "/" + displayInfo.dungeon.Mythic.instanceLength + " [" + displayInfo.dungeon.Mythic.activeWeeks + "] (" + displayInfo.dungeon.Mythic.kills + ") " + mythicPlus,
profession1, profession2, thumbnail, armory,
];
var Position = 4;
for (i = 0; i<sortOrder.length;i++)
{
toonInfo.splice(Position,0,allItems[sortOrder[i]].ilvl);
// toonInfo.splice(Position+12+i,0,allItems[sortOrder[i]].upgrade);
Position++;
}
Position+=1;
for (i = 0; i < azeriteItems.length;i++)
{
toonInfo.splice(Position,0,allItems[azeriteItems[i]].power);
Position++;
}
for (i = 0; i < enchantableItems.length;i++)
{
toonInfo.splice(Position,0,allItems[enchantableItems[i]].enchant);
Position++;
}
var instanceInfoPosition = 30;
for (i = 0; i < raidInstancesSortOrder.length; i++)
{
for (var k = 0; k < raidDifficultySortOrder.length; k++)
{
var cellInfo = displayInfo.raid[raidInstancesSortOrder[i]][raidDifficultySortOrder[k]];
toonInfo.splice(instanceInfoPosition+i*8+k, 0, cellInfo.lockout + "/" + cellInfo.instanceLength);
}
for (k = 0; k < raidDifficultySortOrder.length; k++)
{
var secondCellInfo = displayInfo.raid[raidInstancesSortOrder[i]][raidDifficultySortOrder[k]];
toonInfo.splice(instanceInfoPosition+i*8+k+4, 0, secondCellInfo.progress + "/" + secondCellInfo.instanceLength + " [" + secondCellInfo.activeWeeks + "] (" + secondCellInfo.kills + ")");
}
}
for (i = 0; i < reps.length; i++)
{
toonInfo.push(reps[i].text);
}
return toonInfo;
}
function vercheck()
{
return current_version;
}