diff --git a/data.php b/data.php index c8702272..0a0a247b 100644 --- a/data.php +++ b/data.php @@ -18,6 +18,7 @@ foreach ($datasets as $data) // locale independant case 'zones': case 'weight-presets': + case 'item-scaling': case 'realms': if (file_exists('datasets/'.$data)) echo file_get_contents('datasets/'.$data); diff --git a/datasets/item-scaling b/datasets/item-scaling new file mode 100644 index 00000000..8ecfd02b --- /dev/null +++ b/datasets/item-scaling @@ -0,0 +1,176 @@ +$WH.g_convertRatingToPercent.RB = { + 12: 1.5, + 13: 12, + 14: 15, + 15: 5, + 16: 10, + 17: 10, + 18: 8, + 19: 14, + 20: 14, + 21: 14, + 22: 10, + 23: 10, + 24: 0, + 25: 0, + 26: 0, + 27: 0, + 28: 10, + 29: 10, + 30: 10, + 31: 10, + 32: 14, + 33: 0, + 34: 0, + 35: 25, + 36: 10, + 37: 2.5, + 44: 3.756097412109376 +}; + +$WH.g_convertScalingFactor.SV = { + 1: [ 2, 2, 1, 3, 1, 10, 32, 32, 64, 6, 8, 6, 8, 6, 8, 1, 0, 0, 1, 7, 13, 43, 43, 85], + 2: [ 3, 3, 1, 3, 1, 12, 35, 35, 70, 6, 9, 6, 9, 7, 9, 2, 0, 0, 2, 8, 16, 47, 47, 93], + 3: [ 3, 3, 1, 4, 1, 13, 39, 39, 76, 7, 9, 7, 9, 7, 10, 3, 0, 0, 2, 9, 17, 52, 52, 101], + 4: [ 3, 3, 1, 4, 1, 14, 42, 42, 83, 7, 10, 7, 10, 8, 11, 3, 0, 0, 2, 9, 19, 56, 56, 111], + 5: [ 4, 4, 2, 5, 2, 16, 45, 45, 89, 8, 10, 8, 10, 8, 12, 4, 0, 0, 3, 11, 21, 60, 60, 119], + 6: [ 4, 4, 2, 5, 2, 17, 48, 48, 95, 8, 11, 8, 11, 9, 12, 5, 0, 0, 3, 11, 23, 64, 64, 127], + 7: [ 4, 4, 3, 6, 2, 19, 51, 51, 101, 9, 11, 9, 11, 9, 13, 6, 0, 0, 3, 13, 25, 68, 68, 135], + 8: [ 5, 5, 3, 7, 2, 20, 54, 54, 107, 9, 12, 9, 12, 9, 14, 7, 0, 0, 4, 13, 27, 72, 72, 143], + 9: [ 5, 5, 3, 7, 2, 22, 56, 56, 113, 10, 13, 10, 13, 10, 15, 7, 0, 0, 4, 15, 29, 75, 75, 151], + 10: [ 6, 6, 3, 8, 2, 23, 57, 57, 119, 10, 13, 10, 13, 10, 16, 8, 0, 0, 4, 15, 31, 76, 76, 159], + 11: [ 6, 6, 4, 8, 3, 24, 59, 59, 125, 11, 14, 11, 14, 11, 16, 9, 0, 0, 5, 16, 32, 79, 79, 167], + 12: [ 7, 7, 4, 9, 3, 25, 60, 60, 131, 11, 15, 11, 15, 12, 17, 10, 0, 0, 5, 17, 33, 80, 80, 175], + 13: [ 7, 7, 4, 9, 3, 26, 61, 61, 133, 12, 16, 12, 16, 12, 18, 10, 0, 0, 5, 17, 35, 81, 81, 177], + 14: [ 8, 8, 4, 10, 3, 27, 63, 63, 136, 12, 16, 12, 16, 13, 19, 11, 0, 0, 6, 18, 36, 84, 84, 181], + 15: [ 8, 8, 5, 11, 3, 28, 64, 64, 138, 13, 17, 13, 17, 13, 20, 12, 0, 0, 6, 19, 37, 85, 85, 184], + 16: [ 8, 8, 5, 11, 4, 29, 65, 65, 141, 14, 18, 14, 18, 14, 21, 13, 0, 0, 6, 19, 39, 87, 87, 188], + 17: [ 9, 9, 5, 12, 4, 30, 67, 67, 143, 14, 19, 14, 19, 14, 22, 14, 0, 0, 7, 20, 40, 89, 89, 191], + 18: [ 9, 9, 5, 12, 4, 30, 68, 68, 146, 15, 19, 15, 19, 15, 23, 14, 0, 0, 7, 20, 40, 91, 91, 195], + 19: [10, 10, 6, 13, 4, 31, 69, 69, 148, 15, 20, 15, 20, 15, 24, 15, 0, 0, 7, 21, 41, 92, 92, 197], + 20: [10, 10, 6, 14, 4, 32, 71, 71, 151, 16, 21, 16, 21, 16, 25, 16, 0, 0, 8, 21, 43, 95, 95, 201], + 21: [11, 11, 6, 14, 5, 33, 72, 72, 153, 16, 21, 16, 21, 16, 26, 17, 0, 0, 8, 22, 44, 96, 96, 204], + 22: [11, 11, 6, 15, 5, 34, 73, 73, 156, 17, 22, 17, 22, 17, 27, 18, 0, 0, 8, 23, 45, 97, 97, 208], + 23: [12, 12, 7, 15, 5, 34, 75, 75, 158, 17, 23, 17, 23, 17, 28, 18, 0, 0, 9, 23, 45, 100, 100, 211], + 24: [12, 12, 7, 16, 5, 35, 76, 76, 161, 18, 23, 18, 23, 18, 29, 19, 0, 0, 9, 23, 47, 101, 101, 215], + 25: [12, 12, 7, 17, 5, 35, 77, 77, 163, 19, 24, 19, 24, 19, 29, 20, 0, 0, 9, 23, 47, 103, 103, 217], + 26: [13, 13, 7, 17, 5, 36, 78, 78, 166, 19, 25, 19, 25, 19, 30, 21, 0, 0, 10, 24, 48, 104, 104, 221], + 27: [13, 13, 8, 18, 6, 37, 80, 80, 168, 20, 26, 20, 26, 20, 31, 22, 0, 0, 10, 25, 49, 107, 107, 224], + 28: [14, 14, 8, 18, 6, 37, 81, 81, 171, 21, 27, 21, 27, 21, 32, 22, 0, 0, 10, 25, 49, 108, 108, 228], + 29: [14, 14, 8, 19, 6, 38, 82, 82, 173, 22, 29, 22, 29, 22, 32, 23, 0, 0, 11, 25, 51, 109, 109, 231], + 30: [15, 15, 8, 20, 6, 38, 84, 84, 176, 23, 30, 23, 30, 22, 33, 24, 0, 0, 11, 25, 51, 112, 112, 235], + 31: [15, 15, 9, 20, 6, 39, 85, 85, 178, 24, 31, 24, 31, 23, 34, 25, 0, 0, 11, 26, 52, 113, 113, 237], + 32: [16, 16, 9, 21, 7, 40, 86, 86, 181, 25, 32, 25, 32, 24, 34, 25, 0, 0, 12, 27, 53, 115, 115, 241], + 33: [16, 16, 9, 21, 7, 41, 88, 88, 184, 25, 33, 25, 33, 25, 35, 26, 0, 0, 12, 27, 55, 117, 117, 245], + 34: [16, 16, 9, 22, 7, 43, 90, 90, 187, 26, 34, 26, 34, 26, 36, 27, 0, 0, 12, 29, 57, 120, 120, 249], + 35: [17, 17, 10, 23, 7, 44, 91, 91, 190, 27, 35, 27, 35, 26, 37, 28, 0, 0, 13, 29, 59, 121, 121, 253], + 36: [17, 17, 10, 23, 7, 44, 93, 93, 193, 28, 36, 28, 36, 27, 38, 29, 0, 0, 13, 29, 59, 124, 124, 257], + 37: [18, 18, 10, 24, 8, 46, 95, 95, 196, 28, 37, 28, 37, 28, 39, 29, 0, 0, 13, 31, 61, 127, 127, 261], + 38: [18, 18, 10, 24, 8, 47, 97, 97, 199, 29, 38, 29, 38, 28, 40, 30, 0, 0, 14, 31, 63, 129, 129, 265], + 39: [19, 19, 11, 25, 8, 48, 99, 99, 202, 29, 38, 29, 38, 29, 41, 31, 0, 0, 14, 32, 64, 132, 132, 269], + 40: [19, 19, 11, 26, 8, 49, 100, 205, 360, 30, 39, 30, 39, 30, 42, 32, 0, 0, 14, 33, 65, 133, 273, 480], + 41: [20, 20, 11, 26, 8, 50, 102, 209, 368, 31, 40, 31, 40, 30, 43, 33, 0, 0, 15, 33, 67, 136, 279, 491], + 42: [20, 20, 11, 27, 8, 51, 104, 213, 375, 31, 41, 31, 41, 31, 44, 33, 0, 0, 15, 34, 68, 139, 284, 500], + 43: [20, 20, 12, 27, 9, 52, 106, 217, 382, 32, 41, 32, 41, 31, 45, 34, 0, 0, 15, 35, 69, 141, 289, 509], + 44: [21, 21, 12, 28, 9, 53, 108, 221, 389, 32, 42, 32, 42, 32, 47, 35, 0, 0, 16, 35, 71, 144, 295, 519], + 45: [21, 21, 12, 28, 9, 54, 109, 225, 396, 33, 43, 33, 43, 33, 48, 36, 0, 0, 16, 36, 72, 145, 300, 528], + 46: [22, 22, 12, 29, 9, 55, 111, 229, 403, 34, 44, 34, 44, 33, 50, 37, 0, 0, 16, 37, 73, 148, 305, 537], + 47: [22, 22, 13, 30, 9, 56, 113, 233, 410, 34, 45, 34, 45, 34, 51, 37, 0, 0, 17, 37, 75, 151, 311, 547], + 48: [23, 23, 13, 30, 10, 57, 115, 238, 418, 35, 45, 35, 45, 34, 52, 38, 0, 0, 17, 38, 76, 153, 317, 557], + 49: [23, 23, 13, 31, 10, 58, 117, 242, 425, 35, 46, 35, 46, 35, 53, 39, 0, 0, 17, 39, 77, 156, 323, 567], + 50: [24, 24, 13, 31, 10, 59, 118, 246, 433, 36, 47, 36, 47, 36, 54, 40, 0, 0, 18, 39, 79, 157, 328, 577], + 51: [24, 24, 14, 32, 10, 60, 120, 250, 440, 37, 48, 37, 48, 36, 54, 40, 0, 0, 18, 40, 80, 160, 333, 587], + 52: [24, 24, 14, 33, 10, 61, 122, 254, 448, 37, 49, 37, 49, 37, 55, 41, 0, 0, 18, 41, 81, 163, 339, 597], + 53: [25, 25, 14, 33, 11, 62, 124, 258, 455, 38, 49, 38, 49, 38, 57, 42, 0, 0, 19, 41, 83, 165, 344, 607], + 54: [25, 25, 14, 34, 11, 63, 126, 262, 463, 38, 50, 38, 50, 38, 58, 43, 0, 0, 19, 42, 84, 168, 349, 617], + 55: [26, 26, 15, 34, 11, 64, 127, 266, 470, 39, 51, 39, 51, 39, 59, 44, 0, 0, 19, 43, 85, 169, 355, 627], + 56: [26, 26, 15, 35, 11, 65, 129, 270, 478, 40, 52, 40, 52, 39, 61, 44, 0, 0, 20, 43, 87, 172, 360, 637], + 57: [27, 27, 15, 36, 11, 66, 131, 274, 485, 40, 53, 40, 53, 40, 62, 45, 0, 0, 20, 44, 88, 175, 365, 647], + 58: [34, 34, 19, 46, 14, 83, 159, 344, 611, 50, 65, 46, 60, 48, 85, 46, 0, 0, 25, 55, 111, 212, 459, 815], + 59: [36, 36, 20, 47, 15, 86, 164, 356, 633, 51, 67, 47, 61, 50, 88, 52, 0, 0, 27, 57, 115, 219, 475, 844], + 60: [37, 37, 21, 49, 16, 88, 169, 368, 655, 53, 68, 47, 62, 51, 91, 57, 0, 0, 28, 59, 117, 225, 491, 873], + 61: [39, 39, 22, 51, 16, 91, 174, 380, 677, 54, 70, 48, 63, 52, 94, 63, 0, 0, 29, 61, 121, 232, 507, 903], + 62: [40, 40, 22, 53, 17, 94, 178, 392, 699, 55, 72, 49, 64, 53, 97, 68, 0, 0, 30, 63, 125, 237, 523, 932], + 63: [41, 41, 23, 54, 17, 97, 183, 404, 721, 56, 73, 50, 65, 54, 100, 73, 0, 0, 31, 65, 129, 244, 539, 961], + 64: [42, 42, 24, 55, 18, 100, 187, 416, 742, 58, 75, 50, 66, 55, 104, 80, 0, 0, 31, 67, 133, 249, 555, 989], + 65: [43, 43, 24, 57, 18, 102, 192, 428, 764, 60, 78, 52, 67, 57, 109, 89, 0, 0, 32, 68, 136, 256, 571, 1019], + 66: [44, 44, 25, 58, 18, 105, 197, 440, 786, 62, 81, 53, 69, 59, 113, 98, 0, 0, 33, 70, 140, 263, 587, 1048], + 67: [45, 45, 25, 59, 19, 108, 203, 452, 808, 65, 84, 54, 71, 61, 117, 107, 0, 0, 34, 72, 144, 271, 603, 1077], + 68: [62, 62, 36, 84, 26, 157, 294, 654, 1169, 91, 119, 70, 91, 82, 168, 220, 0, 0, 47, 105, 209, 392, 872, 1559], + 69: [64, 64, 37, 87, 27, 161, 303, 675, 1206, 93, 121, 71, 92, 84, 172, 228, 0, 0, 48, 107, 215, 404, 900, 1608], + 70: [67, 67, 39, 90, 28, 166, 312, 695, 1242, 95, 124, 72, 94, 86, 175, 238, 0, 0, 50, 111, 221, 416, 927, 1656], + 71: [69, 69, 40, 93, 29, 171, 321, 715, 1278, 97, 127, 73, 95, 88, 179, 246, 0, 0, 52, 114, 228, 428, 953, 1704], + 72: [72, 72, 42, 97, 30, 176, 331, 736, 1315, 99, 129, 75, 97, 90, 183, 255, 0, 0, 54, 117, 235, 441, 981, 1753], + 73: [75, 75, 43, 101, 32, 181, 340, 756, 1351, 102, 132, 76, 99, 92, 187, 265, 0, 0, 56, 121, 241, 453, 1008, 1801], + 74: [78, 78, 45, 104, 33, 186, 349, 776, 1387, 104, 135, 77, 100, 94, 191, 275, 0, 0, 58, 124, 248, 465, 1035, 1849], + 75: [81, 81, 46, 108, 34, 191, 358, 797, 1423, 106, 138, 79, 102, 96, 196, 285, 0, 0, 60, 127, 255, 477, 1063, 1897], + 76: [84, 84, 48, 113, 35, 196, 367, 817, 1460, 109, 141, 80, 104, 98, 200, 296, 0, 0, 63, 131, 261, 489, 1089, 1947], + 77: [87, 87, 50, 117, 37, 200, 376, 837, 1496, 111, 145, 81, 106, 101, 205, 307, 0, 0, 65, 133, 267, 501, 1116, 1995], + 78: [90, 90, 52, 121, 38, 205, 386, 858, 1532, 114, 148, 83, 108, 103, 210, 319, 0, 0, 68, 137, 273, 515, 1144, 2043], + 79: [94, 94, 54, 126, 40, 208, 390, 868, 1551, 117, 152, 85, 110, 105, 215, 331, 0, 0, 71, 139, 277, 520, 1157, 2068], + 80: [97, 97, 56, 131, 41, 210, 395, 878, 1570, 120, 156, 86, 112, 108, 220, 343, 0, 0, 73, 140, 280, 527, 1171, 2093] +}; + +$WH.g_convertScalingFactor.SD = { + 1: [ 4, 7, 32, -1, -1, -1, -1, -1, -1, -1, 5259, 7888, 5259, 0, 0, 0, 0, 0, 0, 0, 80], + 2: [38, 3, 31, -1, -1, -1, -1, -1, -1, -1, 14532, 4106, 3193, 0, 0, 0, 0, 0, 0, 0, 80], + 3: [38, 7, 32, -1, -1, -1, -1, -1, -1, -1, 5068, 5065, 6666, 0, 0, 0, 0, 0, 0, 0, 80], + 4: [38, 32, 31, -1, -1, -1, -1, -1, -1, -1, 13332, 4767, 3900, 0, 0, 0, 0, 0, 0, 0, 80], + 5: [ 7, 5, 32, -1, -1, -1, -1, -1, -1, -1, 7150, 5850, 4766, 0, 0, 0, 0, 0, 0, 0, 80], + 6: [ 7, 5, 43, -1, -1, -1, -1, -1, -1, -1, 5067, 7601, 1350, 0, 0, 0, 0, 0, 0, 0, 80], + 7: [ 4, 7, 32, -1, -1, -1, -1, -1, -1, -1, 6666, 6666, 4445, 0, 0, 0, 0, 0, 0, 0, 80], + 8: [38, 3, 7, 5, -1, -1, -1, -1, -1, -1, 10518, 5258, 5641, 3076, 0, 0, 0, 0, 0, 0, 80], + 9: [45, 7, 5, 43, -1, -1, -1, -1, -1, -1, 5201, 6666, 4444, 1778, 0, 0, 0, 0, 0, 0, 80], + 10: [38, 31, 7, -1, -1, -1, -1, -1, -1, -1, 14532, 4106, 4789, 0, 0, 0, 0, 0, 0, 0, 80], + 11: [45, 7, 5, 6, -1, -1, -1, -1, -1, -1, 6153, 3996, 3997, 5258, 0, 0, 0, 0, 0, 0, 80], + 12: [ 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 5000, 5000, 0, 0, 0, 0, 0, 0, 0, 0, 10], + 13: [42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10], + 14: [38, 39, 40, 41, 42, 43, 0, 0, 0, 0, 6500, 6500, 10000, 10000, 10000, 10000, 0, 0, 0, 0, 15], + 15: [40, 41, 42, 0, 0, 0, 0, 0, 0, 0, 4200, 5200, 6200, 0, 0, 0, 0, 0, 0, 0, 10], + 16: [45, 7, 5, 6, -1, -1, -1, -1, -1, -1, 6153, 3996, 3997, 5258, 0, 0, 0, 0, 0, 0, 80], + 21: [12, 13, 14, 15, 16, 0, 0, 0, 0, 0, 5000, 6000, 7000, 8000, 9000, 0, 0, 0, 0, 0, 10], + 41: [ 3, 4, 5, 6, 7, 12, 13, 14, 15, 16, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10], + 42: [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10], + 43: [27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10], + 102: [44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15], + 103: [ 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + 104: [32, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80], + 105: [13, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + 221: [ 4, 7, 32, 36, -1, -1, -1, -1, -1, -1, 4844, 7266, 4106, 3193, 0, 0, 0, 0, 0, 0, 80], + 222: [ 3, 44, 7, -1, -1, -1, -1, -1, -1, -1, 5259, 3506, 5259, 0, 0, 0, 0, 0, 0, 0, 80], + 223: [ 7, 5, 32, -1, -1, -1, -1, -1, -1, -1, 4859, 5732, 2519, 0, 0, 0, 0, 0, 0, 0, 80], + 224: [38, 3, 31, 7, -1, -1, -1, -1, -1, -1, 9688, 4844, 3193, 6159, 0, 0, 0, 0, 0, 0, 80], + 241: [45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80], + 251: [36, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6666, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80], + 271: [45, -1, -1, -1, -1, -1, -1, -1, -1, -1, 7800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80], + 291: [38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 23252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + 292: [38, 7, 35, -1, -1, -1, -1, -1, -1, -1, 10518, 7888, 5258, 0, 0, 0, 0, 0, 0, 0, 80], + 293: [ 4, 7, 35, -1, -1, -1, -1, -1, -1, -1, 7266, 4789, 4106, 0, 0, 0, 0, 0, 0, 0, 80], + 294: [38, 32, 35, -1, -1, -1, -1, -1, -1, -1, 8212, 7266, 3193, 0, 0, 0, 0, 0, 0, 0, 80], + 295: [ 7, 35, 43, -1, -1, -1, -1, -1, -1, -1, 6666, 6666, 1777, 0, 0, 0, 0, 0, 0, 0, 80], + 296: [ 7, 31, 35, -1, -1, -1, -1, -1, -1, -1, 7888, 5259, 5258, 0, 0, 0, 0, 0, 0, 0, 80], + 297: [35, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5259, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80], + 298: [35, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6667, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80], + 299: [35, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6667, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80], + 300: [ 4, 7, 35, -1, -1, -1, -1, -1, -1, -1, 5259, 7888, 5258, 0, 0, 0, 0, 0, 0, 0, 80], + 301: [45, 7, 43, 35, -1, -1, -1, -1, -1, -1, 5200, 6666, 1776, 4444, 0, 0, 0, 0, 0, 0, 80], + 302: [38, 3, 7, 35, -1, -1, -1, -1, -1, -1, 8888, 4444, 6668, 4444, 0, 0, 0, 0, 0, 0, 80], + 303: [45, 7, 5, 35, -1, -1, -1, -1, -1, -1, 6153, 5259, 3506, 5258, 0, 0, 0, 0, 0, 0, 80], + 304: [38, 3, 7, 35, -1, -1, -1, -1, -1, -1, 8888, 3899, 6666, 4767, 0, 0, 0, 0, 0, 0, 80], + 305: [45, 7, 6, 35, -1, -1, -1, -1, -1, -1, 6153, 5259, 3506, 5258, 0, 0, 0, 0, 0, 0, 80], + 306: [45, 7, 32, 35, -1, -1, -1, -1, -1, -1, 6153, 5259, 3506, 5258, 0, 0, 0, 0, 0, 0, 80], + 311: [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + 331: [38, 3, 7, 5, -1, -1, -1, -1, -1, -1, 10518, 5258, 5259, 3506, 0, 0, 0, 0, 0, 0, 80], + 332: [45, 7, 5, 43, -1, -1, -1, -1, -1, -1, 6153, 3997, 3997, 2629, 0, 0, 0, 0, 0, 0, 80], + 333: [ 4, 7, 32, -1, -1, -1, -1, -1, -1, -1, 5996, 5996, 5258, 0, 0, 0, 0, 0, 0, 0, 80], + 334: [45, 7, 5, 6, -1, -1, -1, -1, -1, -1, 6153, 3997, 3997, 5259, 0, 0, 0, 0, 0, 0, 80], + 335: [38, 7, 31, -1, -1, -1, -1, -1, -1, -1, 10518, 7888, 5259, 0, 0, 0, 0, 0, 0, 0, 80], + 336: [45, 7, 5, 6, -1, -1, -1, -1, -1, -1, 6153, 3997, 3997, 5259, 0, 0, 0, 0, 0, 0, 80], + 351: [ 3, 38, 7, 32, -1, -1, -1, -1, -1, -1, 5259, 7012, 7889, 3506, 0, 0, 0, 0, 0, 0, 80], + 352: [ 3, 44, 7, 38, -1, -1, -1, -1, -1, -1, 5259, 3506, 7889, 7012, 0, 0, 0, 0, 0, 0, 80], + 371: [32, 31, 7, -1, -1, -1, -1, -1, -1, -1, 7266, 4106, 4789, 0, 0, 0, 0, 0, 0, 0, 80] +}; + +if ($WH.isset('$WowheadPower')) { + $WowheadPower.loadScales(3); +} diff --git a/power/aowowPower.js b/power/aowowPower.js index 6de2c10c..a8ad930f 100644 --- a/power/aowowPower.js +++ b/power/aowowPower.js @@ -1,25 +1,25 @@ if (typeof $WH == "undefined") { - $WH = { - wowheadRemote: true - } + $WH = { + wowheadRemote: true + } - /* custom */ - for (i in document.scripts) { - if (!document.scripts[i].src) - continue; + /* custom */ + for (i in document.scripts) { + if (!document.scripts[i].src) + continue; - var match = document.scripts[i].src.match(/(.*)\/power\/aowowPower.js/i); - if (match) { - var g_staticUrl = match[1]; - break; - } - } + var match = document.scripts[i].src.match(/(.*)\/power\/aowowPower.js/i); + if (match) { + var g_staticUrl = match[1]; + break; + } + } } if (typeof $WowheadPower == "undefined") { - var $WowheadPower = new function () { - var isRemote = $WH.wowheadRemote; - var + var $WowheadPower = new function () { + var isRemote = $WH.wowheadRemote; + var opt = { applyto: 3 }, @@ -48,6 +48,7 @@ if (typeof $WowheadPower == "undefined") { STATUS_ERROR = 2, STATUS_NOTFOUND = 3, STATUS_OK = 4, + STATUS_SCALES = 5, TYPE_NPC = 1, TYPE_OBJECT = 2, TYPE_ITEM = 3, @@ -71,6 +72,11 @@ if (typeof $WowheadPower == "undefined") { 10 : [achievements, "achievement", "Achievement"], 100 : [profiles, "profile", "Profile"] }, + SCALES = { + 3 : { + url: "?data=item-scaling" + } + }, LOCALES = { 0 : "enus", 2 : "frfr", @@ -83,104 +89,104 @@ if (typeof $WowheadPower == "undefined") { ptr: "www" }; - if (isRemote) { - var Locale = { - id: 0, - name: "enus" - }; - } + if (isRemote) { + var Locale = { + id: 0, + name: "enus" + }; + } - function init() { - if (isRemote) { - var script = document.createElement("script"); - // script.src = "http://static.wowhead.com/js/basic.js?4"; - script.src = g_staticUrl + "/template/js/basic.js"; - head.appendChild(script); - } + function init() { + if (isRemote) { + var script = document.createElement("script"); + // script.src = "http://static.wowhead.com/js/basic.js?4"; + script.src = g_staticUrl + "/template/js/basic.js"; + head.appendChild(script); + } else { - attachEvent(); - } - } + attachEvent(); + } + } - function attachEvent() { - if (eventAttached) { - return; - } + function attachEvent() { + if (eventAttached) { + return; + } - eventAttached = true; - $WH.aE(document, "mouseover", onMouseOver); - } + eventAttached = true; + $WH.aE(document, "mouseover", onMouseOver); + } - this.init = function () { - if (isRemote) { - $WH.ae(head, $WH.ce("link", { - type: "text/css", - // href: "http://static.wowhead.com/css/basic.css?4", - href: g_staticUrl + "/template/css/basic.css", - rel: "stylesheet" - })); + this.init = function () { + if (isRemote) { + $WH.ae(head, $WH.ce("link", { + type: "text/css", + // href: "http://static.wowhead.com/css/basic.css?4", + href: g_staticUrl + "/template/css/basic.css", + rel: "stylesheet" + })); - if ($WH.Browser.ie67) { - $WH.ae(head, $WH.ce("link", { - type: "text/css", - // href: "http://static.wowhead.com/css/basic_ie67.css?4", - href: g_staticUrl + "/template/css/global_ie67.css", - rel: "stylesheet" - })); + if ($WH.Browser.ie67) { + $WH.ae(head, $WH.ce("link", { + type: "text/css", + // href: "http://static.wowhead.com/css/basic_ie67.css?4", + href: g_staticUrl + "/template/css/global_ie67.css", + rel: "stylesheet" + })); - if ($WH.Browser.ie6) { - $WH.ae(head, $WH.ce("link", { - type: "text/css", - // href: "http://static.wowhead.com/css/basic_ie6.css?4", - href: g_staticUrl + "/template/css/global_ie6.css", - rel: "stylesheet" - })); - } - } - } - attachEvent(); - }; + if ($WH.Browser.ie6) { + $WH.ae(head, $WH.ce("link", { + type: "text/css", + // href: "http://static.wowhead.com/css/basic_ie6.css?4", + href: g_staticUrl + "/template/css/global_ie6.css", + rel: "stylesheet" + })); + } + } + } + attachEvent(); + }; - function updateCursorPos(e) { - var pos = $WH.g_getCursorPos(e); - cursorX = pos.x; - cursorY = pos.y; - } + function updateCursorPos(e) { + var pos = $WH.g_getCursorPos(e); + cursorX = pos.x; + cursorY = pos.y; + } - function scanElement(t, e) { - if (t.nodeName != "A" && t.nodeName != "AREA") { - return -2323; - } + function scanElement(t, e) { + if (t.nodeName != "A" && t.nodeName != "AREA") { + return -2323; + } - if (!t.href.length) { - return; - } + if (!t.href.length) { + return; + } - if (!t.href.length && !t.rel) { - return; - } + if (!t.href.length && !t.rel) { + return; + } - if (t.rel && t.rel.indexOf("np") != -1) { - return; - } + if (t.rel && t.rel.indexOf("np") != -1) { + return; + } - var + var i0, i1, i2, url, params = {}; - currentParams = params; + currentParams = params; - var p = function (url, k, v) { - if (k == "buff" || k == "sock") { + var p = function (url, k, v) { + if (k == "buff" || k == "sock" || k == "map") { params[k] = true; } else if (k == "rand" || k == "ench" || k == "lvl" || k == "c") { params[k] = parseInt(v); } - else if (k == "gems" || k == "pcs") { + else if (k == "gems" || k == "pcs" || k == "know") { params[k] = v.split(":"); } else if (k == "who" || k == "domain") { @@ -189,433 +195,489 @@ if (typeof $WowheadPower == "undefined") { else if (k == "when") { params[k] = new Date(parseInt(v)); } - }; + }; - if (opt.applyto & 1) { - i1 = 2; - i2 = 3; - if (t.href.indexOf("http://") == 0) { - i0 = 1; - // url = t.href.match(/^http:\/\/(.+?)?\.?wowhead\.com\/\?(item|quest|spell|achievement|npc|object)=([0-9]+)/); - url = t.href.match(/^http:\/\/(.*)\/\??(item|quest|spell|achievement|npc|object)=([0-9]+)/); - if (url == null) { - // url = t.href.match(/^http:\/\/(.+?)?\.?wowhead\.com\/\?(profile)=([^&#]+)/) - url = t.href.match(/^http:\/\/(.*)\/\??(profile)=([^&#]+)/); - } + if (opt.applyto & 1) { + i1 = 2; + i2 = 3; + if (t.href.indexOf("http://") == 0) { + i0 = 1; + // url = t.href.match(/^http:\/\/(.+?)?\.?wowhead\.com\/\?(item|quest|spell|achievement|npc|object)=([0-9]+)/); + url = t.href.match(/^http:\/\/(.*)\/\??(item|quest|spell|achievement|npc|object)=([0-9]+)/); + if (url == null) { + // url = t.href.match(/^http:\/\/(.+?)?\.?wowhead\.com\/\?(profile)=([^&#]+)/) + url = t.href.match(/^http:\/\/(.*)\/\??(profile)=([^&#]+)/); + } - showLogo = 0; - } + showLogo = 0; + } else { - url = t.href.match(/()\?(item|quest|spell|achievement|npc|object)=([0-9]+)/); - if (url == null) { - url = t.href.match(/()\?(profile)=([^&#]+)/); - } + url = t.href.match(/()\?(item|quest|spell|achievement|npc|object)=([0-9]+)/); + if (url == null) { + url = t.href.match(/()\?(profile)=([^&#]+)/); + } - showLogo = 1; - } - } + showLogo = 1; + } + } - if (url == null && t.rel && (opt.applyto & 2)) { - i0 = 0; - i1 = 1; - i2 = 2; - url = t.rel.match(/(item|quest|spell|achievement|npc|object).?([0-9]+)/); - if (url == null) { - url = t.rel.match(/(profile).?([^&#]+)/); - } - showLogo = 1; - } + if (url == null && t.rel && (opt.applyto & 2)) { + i0 = 0; + i1 = 1; + i2 = 2; + url = t.rel.match(/(item|quest|spell|achievement|npc|object).?([0-9]+)/); + if (url == null) { + url = t.rel.match(/(profile).?([^&#]+)/); + } + showLogo = 1; + } - t.href.replace(/([a-zA-Z]+)=?([a-zA-Z0-9:-]*)/g, p); - if (t.rel) { - t.rel.replace(/([a-zA-Z]+)=?([a-zA-Z0-9:-]*)/g, p); - } + t.href.replace(/([a-zA-Z]+)=?([a-zA-Z0-9:-]*)/g, p); + if (t.rel) { + t.rel.replace(/([a-zA-Z]+)=?([a-zA-Z0-9:-]*)/g, p); + } - if (params.gems && params.gems.length > 0) { - var i; - for (i = Math.min(3, params.gems.length - 1); i >= 0; --i) { - if (parseInt(params.gems[i])) { - break; - } - } + if (params.gems && params.gems.length > 0) { + var i; + for (i = Math.min(3, params.gems.length - 1); i >= 0; --i) { + if (parseInt(params.gems[i])) { + break; + } + } ++i; - if (i == 0) { - delete params.gems; - } + if (i == 0) { + delete params.gems; + } else { - if (i < params.gems.length) { - params.gems = params.gems.slice(0, i); - } - } - } + if (i < params.gems.length) { + params.gems = params.gems.slice(0, i); + } + } + } - if (url) { - var + if (url) { + var locale, domain = "www"; - currentA = t; - if (params.domain) { - domain = params.domain; - } + currentA = t; + if (params.domain) { + domain = params.domain; + } else if (i0 && url[i0]) { domain = url[i0].split(".")[0]; } - if (REDIRECTS[domain]) { - domain = REDIRECTS[domain]; - } + if (REDIRECTS[domain]) { + domain = REDIRECTS[domain]; + } - locale = $WH.g_getLocaleFromDomain(domain); + locale = $WH.g_getLocaleFromDomain(domain); - /* edit start */ - if ($WH.in_array(['fr', 'de', 'es', 'ru', 'en'], domain) == -1) { - for (i in document.scripts) { - if (!document.scripts[i].src) - continue; + /* edit start */ + if ($WH.in_array(['fr', 'de', 'es', 'ru', 'en'], domain) == -1) { + for (i in document.scripts) { + if (!document.scripts[i].src) + continue; - var dmn = document.scripts[i].src.match(/power\/aowowPower.js\?(lang|locale)=(en|fr|de|es|ru)/i); - if (dmn) { - domain = dmn[2]; - locale = $WH.g_getLocaleFromDomain(dmn[2]); - break; - } - } - } - /* end of edit */ + var dmn = document.scripts[i].src.match(/power\/aowowPower.js\?(lang|locale)=(en|fr|de|es|ru)/i); + if (dmn) { + domain = dmn[2]; + locale = $WH.g_getLocaleFromDomain(dmn[2]); + break; + } + } + } + /* end of edit */ - currentDomain = domain; - if (t.href.indexOf("#") != -1 && document.location.href.indexOf(url[i1] + "=" + url[i2]) != -1) { - return; - } + currentDomain = domain; + if (t.href.indexOf("#") != -1 && document.location.href.indexOf(url[i1] + "=" + url[i2]) != -1) { + return; + } - mode = ((t.parentNode.className.indexOf("icon") == 0 && t.parentNode.nodeName == "DIV") ? 1 : 0); - if (!t.onmouseout) { - if (mode == 0) { - t.onmousemove = onMouseMove; - } - t.onmouseout = onMouseOut; - } + mode = ((t.parentNode.className.indexOf("icon") == 0 && t.parentNode.nodeName == "DIV") ? 1 : 0); + if (!t.onmouseout) { + if (mode == 0) { + t.onmousemove = onMouseMove; + } + t.onmouseout = onMouseOut; + } - updateCursorPos(e); + if (e) { + updateCursorPos(e); + } - var + var type = $WH.g_getIdFromTypeName(url[i1]), typeId = url[i2]; - if (type == TYPE_PROFILE) { - locale = 0; - } + if (type == TYPE_PROFILE) { + locale = 0; + } - display(type, typeId, locale, params); - } - } + display(type, typeId, locale, params); + } + } - function onMouseOver(e) { - e = $WH.$E(e); - var t = e._target; - var i = 0; - while (t != null && i < 5 && scanElement(t, e) == -2323) { - t = t.parentNode; ++i - } - } + function onMouseOver(e) { + e = $WH.$E(e); + var t = e._target; + var i = 0; + while (t != null && i < 5 && scanElement(t, e) == -2323) { + t = t.parentNode; ++i + } + } - function onMouseMove(e) { - e = $WH.$E(e); - updateCursorPos(e); - $WH.Tooltip.move(cursorX, cursorY, 0, 0, CURSOR_HSPACE, CURSOR_VSPACE); - } + function onMouseMove(e) { + e = $WH.$E(e); + updateCursorPos(e); + $WH.Tooltip.move(cursorX, cursorY, 0, 0, CURSOR_HSPACE, CURSOR_VSPACE); + } - function onMouseOut() { - currentType = null; - currentA = null; - $WH.Tooltip.hide(); - } + function onMouseOut() { + currentType = null; + currentA = null; + $WH.Tooltip.hide(); + } - function getTooltipField(locale) { - return (currentParams && currentParams.buff ? "buff_" : "tooltip_") + LOCALES[locale]; - } + function getTooltipField(locale, n) { + return (currentParams && currentParams.buff ? "buff" : "tooltip") + (n ? n : "") + "_" + LOCALES[locale]; + } - function initElement(type, id, locale) { - var arr = LOOKUPS[type][0]; + function getSpellsField(locale) { + return (currentParams && currentParams.buff ? "buff" : "") + "spells_" + LOCALES[locale]; + } - if (arr[id] == null) { - arr[id] = {}; - } + function initElement(type, id, locale) { + var arr = LOOKUPS[type][0]; - if (arr[id].status == null) { - arr[id].status = {}; - } + if (arr[id] == null) { + arr[id] = {}; + } - if (arr[id].status[locale] == null) { - arr[id].status[locale] = STATUS_NONE; - } - } + if (arr[id].status == null) { + arr[id].status = {}; + } - function display(type, id, locale, params) { - if (!params) { - params = {}; - } + if (arr[id].response == null) { + arr[id].response = {} + } - var fullId = getFullId(id, params); - currentType = type; - currentId = fullId; - currentLocale = locale; - currentParams = params; + if (arr[id].status[locale] == null) { + arr[id].status[locale] = STATUS_NONE; + } + } - initElement(type, fullId, locale); + function display(type, id, locale, params) { + if (!params) { + params = {}; + } - var arr = LOOKUPS[type][0]; - if (arr[fullId].status[locale] == STATUS_OK || arr[fullId].status[locale] == STATUS_NOTFOUND) { - showTooltip(arr[fullId][getTooltipField(locale)], arr[fullId].icon); - } - else if (arr[fullId].status[locale] == STATUS_QUERYING) { + var fullId = getFullId(id, params); + currentType = type; + currentId = fullId; + currentLocale = locale; + currentParams = params; + + initElement(type, fullId, locale); + + var arr = LOOKUPS[type][0]; + if (arr[fullId].status[locale] == STATUS_OK || arr[fullId].status[locale] == STATUS_NOTFOUND) { + showTooltip(arr[fullId][getTooltipField(locale)], arr[fullId].icon, arr[fullId].map, arr[fullId][getSpellsField(locale)], arr[fullId][getTooltipField(locale, 2)]); + } + else if (arr[fullId].status[locale] == STATUS_QUERYING || arr[fullId].status[locale] == STATUS_SCALES) { showTooltip(_LANG.loading); } else { request(type, id, locale, null, params); } - } + } - function request(type, id, locale, stealth, params) { - var fullId = getFullId(id, params); - var arr = LOOKUPS[type][0]; + function request(type, id, locale, stealth, params) { + var fullId = getFullId(id, params); + var arr = LOOKUPS[type][0]; - if (arr[fullId].status[locale] != STATUS_NONE && arr[fullId].status[locale] != STATUS_ERROR) { - return; - } + if (arr[fullId].status[locale] != STATUS_NONE && arr[fullId].status[locale] != STATUS_ERROR) { + return; + } - arr[fullId].status[locale] = STATUS_QUERYING; + arr[fullId].status[locale] = STATUS_QUERYING; if (!stealth) { - arr[fullId].timer = setTimeout(function () { - showLoading.apply(this, [type, fullId, locale]); - }, 333); - } + arr[fullId].timer = setTimeout(function () { + showLoading.apply(this, [type, fullId, locale]); + }, 333); + } - var p = ""; - for (var i in params) { - if (i != "rand" && i != "ench" && i != "gems" && i != "sock") { - continue; - } + var p = ""; + for (var i in params) { + if (i != "rand" && i != "ench" && i != "gems" && i != "sock") { + continue; + } - if (typeof params[i] == "object") { - p += "&" + i + "=" + params[i].join(":"); - } + if (typeof params[i] == "object") { + p += "&" + i + "=" + params[i].join(":"); + } else if (i == "sock") { p += "&sock"; } else { p += "&" + i + "=" + params[i]; - } - } + } + } - // var url = "http://" + $WH.g_getDomainFromLocale(locale) + ".wowhead.com" - // url += "ajax.php?" + LOOKUPS[type][1] + "=" + id + "&power" + p; - var url = g_staticUrl + "/"; - url += "?" + LOOKUPS[type][1] + "=" + id + "&domain=" + $WH.g_getDomainFromLocale(locale) + "&power" + p; - $WH.g_ajaxIshRequest(url); - } + // var url = "http://" + $WH.g_getDomainFromLocale(locale) + ".wowhead.com" + // url += "ajax.php?" + LOOKUPS[type][1] + "=" + id + "&power" + p; + var + localeDomain = $WH.g_getDomainFromLocale(locale), + url = g_staticUrl + "/"; - function showTooltip(html, icon) { - if (currentA && currentA._fixTooltip) { - html = currentA._fixTooltip(html, currentType, currentId, currentA); - } + $WH.g_ajaxIshRequest(url + "?" + LOOKUPS[type][1] + "=" + id + "&domain=" + localeDomain + "&power" + p); + if (SCALES[type] && !SCALES[type][locale]) { + $WH.g_ajaxIshRequest(url + SCALES[type].url); + } + } - var notFound = false; - if (!html) { - html = LOOKUPS[currentType][2] + " not found :("; - icon = "inv_misc_questionmark"; - notFound = true; - } + function showTooltip(html, icon, map, spellData, html2) { + if (currentA && currentA._fixTooltip) { + html = currentA._fixTooltip(html, currentType, currentId, currentA); + } + + var notFound = false; + if (!html) { + html = LOOKUPS[currentType][2] + " not found :("; + icon = "inv_misc_questionmark"; + notFound = true; + } else { - if (currentParams != null) { - if (currentParams.pcs && currentParams.pcs.length) { - var n = 0; - for (var i = 0, len = currentParams.pcs.length; i < len; ++i) { - var ak; - if (ak = html.match(new RegExp("(.+?)'))) { - html = html.replace(ak[0], '' + (($WH.isset("g_items") && g_items[currentParams.pcs[i]]) ? g_items[currentParams.pcs[i]]["name_" + LOCALES[currentLocale]] : ak[4]) + ""); + if (currentParams != null) { + if (currentParams.pcs && currentParams.pcs.length) { + var n = 0; + for (var i = 0, len = currentParams.pcs.length; i < len; ++i) { + var ak; + if (ak = html.match(new RegExp("(.+?)'))) { + html = html.replace(ak[0], '' + (($WH.isset("g_items") && g_items[currentParams.pcs[i]]) ? g_items[currentParams.pcs[i]]["name_" + LOCALES[currentLocale]] : ak[4]) + ""); ++n; - } - } + } + } - if (n > 0) { - html = html.replace("(0/", "(" + n + "/"); - html = html.replace(new RegExp("\\(([0-" + n + "])\\)", "g"), '($1)'); - } - } + if (n > 0) { + html = html.replace("(0/", "(" + n + "/"); + html = html.replace(new RegExp("\\(([0-" + n + "])\\)", "g"), '($1)'); + } + } - if (currentParams.c) { - html = html.replace(/(.+?)<\/span>
/g, ''); + if (currentParams.c) { + html = html.replace(/(.+?)<\/span>
/g, ''); html = html.replace(new RegExp('', "g"), '$2
'); - } + } - // custom start - if ($WH.gc('compare_level') && window.location.href.match(/\?compare/i)) { - html = $WH.g_setTooltipItemLevel(html, $WH.gc('compare_level')); - } - // custom end + // custom start + if ($WH.gc('compare_level') && window.location.href.match(/\?compare/i)) { + html = $WH.g_setTooltipLevel(html, $WH.gc('compare_level'), currentParams.buff); + } + // custom end - if (currentParams.lvl) { - html = $WH.g_setTooltipItemLevel(html, currentParams.lvl); - } + if (currentParams.know && currentParams.know.length) { + html = $WH.g_setTooltipSpells(html, currentParams.know, spellData); + } - if (currentParams.who && currentParams.when) { - html = html.replace("

", '

' + $WH.sprintf(_LANG.achievementcomplete, currentParams.who, currentParams.when.getMonth() + 1, currentParams.when.getDate(), currentParams.when.getFullYear()) + "

"); - html = html.replace(/class="q0"/g, 'class="r3"'); - } - } - } + if (currentParams.lvl) { + html = $WH.g_setTooltipLevel(html, currentParams.lvl, currentParams.buff); + } - if (mode == 1) { - $WH.Tooltip.setIcon(null); - $WH.Tooltip.show(currentA, html); - } + if (currentParams.who && currentParams.when) { + html = html.replace("

", '

' + $WH.sprintf(_LANG.achievementcomplete, currentParams.who, currentParams.when.getMonth() + 1, currentParams.when.getDate(), currentParams.when.getFullYear()) + "

"); + html = html.replace(/class="q0"/g, 'class="r3"'); + } + } + } + + if (currentParams.map && map && map.getMap) { + html2 = map.getMap(); + } + + if (mode == 1) { + $WH.Tooltip.setIcon(null); + $WH.Tooltip.show(currentA, html, null, null, null, html2); + } else { - $WH.Tooltip.setIcon(icon); - $WH.Tooltip.showAtXY(html, cursorX, cursorY, CURSOR_HSPACE, CURSOR_VSPACE); - } + $WH.Tooltip.setIcon(icon); + $WH.Tooltip.showAtXY(html, cursorX, cursorY, CURSOR_HSPACE, CURSOR_VSPACE, html2); + } - if (isRemote && $WH.Tooltip.logo) { - $WH.Tooltip.logo.style.display = (showLogo ? "block": "none"); - } - } + if (isRemote && $WH.Tooltip.logo) { + $WH.Tooltip.logo.style.display = (showLogo ? "block": "none"); + } + } - function showLoading(type, id, locale) { - if (currentType == type && currentId == id && currentLocale == locale) { - showTooltip(_LANG.loading); - var arr = LOOKUPS[type][0]; + function showLoading(type, id, locale) { + if (currentType == type && currentId == id && currentLocale == locale) { + showTooltip(_LANG.loading); + var arr = LOOKUPS[type][0]; - arr[id].timer = setTimeout(function () { - notFound.apply(this, [type, id, locale]); - }, 3850); - } - } + arr[id].timer = setTimeout(function () { + notFound.apply(this, [type, id, locale]); + }, 3850); + } + } - function notFound(type, id, locale) { - var arr = LOOKUPS[type][0]; - arr[id].status[locale] = STATUS_ERROR; + function notFound(type, id, locale) { + var arr = LOOKUPS[type][0]; + arr[id].status[locale] = STATUS_ERROR; - if (currentType == type && currentId == id && currentLocale == locale) { - showTooltip(_LANG.noresponse); - } - } + if (currentType == type && currentId == id && currentLocale == locale) { + showTooltip(_LANG.noresponse); + } + } - function getFullId(id, params) { - return id + (params.rand ? "r" + params.rand: "") + (params.ench ? "e" + params.ench: "") + (params.gems ? "g" + params.gems.join(",") : "") + (params.sock ? "s": ""); - } + function getFullId(id, params) { + return id + (params.rand ? "r" + params.rand: "") + (params.ench ? "e" + params.ench: "") + (params.gems ? "g" + params.gems.join(",") : "") + (params.sock ? "s": ""); + } - this.register = function (type, id, locale, json) { - var arr = LOOKUPS[type][0]; - initElement(type, id, locale); + this.loadScales = function (type, locale) { + var arr = LOOKUPS[type][0]; + for (var i in LOCALES) { + if (locale == i || (!locale && !isNaN(i))) { + SCALES[type][i] = 1; + for (var id in arr) { + if (arr[id].status[i] == STATUS_SCALES && arr[id].response[i]) { + arr[id].response[i]() + } + } + } + } + }; - if (arr[id].timer) { - clearTimeout(arr[id].timer); - arr[id].timer = null; - } + this.register = function (type, id, locale, json) { + var arr = LOOKUPS[type][0]; + initElement(type, id, locale); - $WH.cO(arr[id], json); + if (SCALES[type] && !SCALES[type][locale]) { + arr[id].status[locale] = STATUS_SCALES; + arr[id].response[locale] = this.register.bind(this, type, id, locale, json); + return + } - if (arr[id].status[locale] == STATUS_QUERYING) { - if (arr[id][getTooltipField(locale)]) { - arr[id].status[locale] = STATUS_OK; - } + if (arr[id].timer) { + clearTimeout(arr[id].timer); + arr[id].timer = null; + } + + if (!$WH.wowheadRemote && json.map) { + if (arr[id].map == null) { + arr[id].map = new Mapper({ + parent: $WH.ce("div"), + zoom: 3, + zoomable: false, + buttons: false + }) + } + arr[id].map.update(json.map); + delete json.map + } + + $WH.cO(arr[id], json); + + if (arr[id].status[locale] == STATUS_QUERYING || arr[id].status[locale] == STATUS_SCALES) { + if (arr[id][getTooltipField(locale)]) { + arr[id].status[locale] = STATUS_OK; + } else { - arr[id].status[locale] = STATUS_NOTFOUND; - } - } + arr[id].status[locale] = STATUS_NOTFOUND; + } + } - if (currentType == type && id == currentId && currentLocale == locale) { - showTooltip(arr[id][getTooltipField(locale)], arr[id].icon); - } - }; + if (currentType == type && id == currentId && currentLocale == locale) { + showTooltip(arr[id][getTooltipField(locale)], arr[id].icon, arr[id].map, arr[id][getSpellsField(locale)], arr[id][getTooltipField(locale, 2)]); + } + }; - this.registerNpc = function (id, locale, json) { - this.register(TYPE_NPC, id, locale, json); - }; + this.registerNpc = function (id, locale, json) { + this.register(TYPE_NPC, id, locale, json); + }; - this.registerObject = function (id, locale, json) { - this.register(TYPE_OBJECT, id, locale, json); - }; + this.registerObject = function (id, locale, json) { + this.register(TYPE_OBJECT, id, locale, json); + }; - this.registerItem = function (id, locale, json) { - this.register(TYPE_ITEM, id, locale, json); - }; + this.registerItem = function (id, locale, json) { + this.register(TYPE_ITEM, id, locale, json); + }; - this.registerQuest = function (id, locale, json) { - this.register(TYPE_QUEST, id, locale, json); - }; + this.registerQuest = function (id, locale, json) { + this.register(TYPE_QUEST, id, locale, json); + }; - this.registerSpell = function (id, locale, json) { - this.register(TYPE_SPELL, id, locale, json); - }; + this.registerSpell = function (id, locale, json) { + this.register(TYPE_SPELL, id, locale, json); + }; - this.registerAchievement = function (id, locale, json) { - this.register(TYPE_ACHIEVEMENT, id, locale, json); - }; + this.registerAchievement = function (id, locale, json) { + this.register(TYPE_ACHIEVEMENT, id, locale, json); + }; - this.registerProfile = function (id, locale, json) { - this.register(TYPE_PROFILE, id, locale, json); - }; + this.registerProfile = function (id, locale, json) { + this.register(TYPE_PROFILE, id, locale, json); + }; - this.request = function (type, id, locale, params) { - if (!params) { - params = {}; - } + this.request = function (type, id, locale, params) { + if (!params) { + params = {}; + } - var fullId = getFullId(id, params); - initElement(type, fullId, locale); + var fullId = getFullId(id, params); + initElement(type, fullId, locale); - request(type, id, locale, 1, params); - }; + request(type, id, locale, 1, params); + }; - this.requestItem = function (id, params) { - this.request(TYPE_ITEM, id, Locale.id, params); - }; + this.requestItem = function (id, params) { + this.request(TYPE_ITEM, id, Locale.id, params); + }; - this.requestSpell = function (id) { - this.request(TYPE_SPELL, id, Locale.id); - }; + this.requestSpell = function (id) { + this.request(TYPE_SPELL, id, Locale.id); + }; - this.getStatus = function (type, id, locale) { - var arr = LOOKUPS[type][0]; - if (arr[id] != null) { - return arr[id].status[locale]; - } + this.getStatus = function (type, id, locale) { + var arr = LOOKUPS[type][0]; + if (arr[id] != null) { + return arr[id].status[locale]; + } else { - return STATUS_NONE; - } - }; + return STATUS_NONE; + } + }; - this.getItemStatus = function (id, locale) { - this.getStatus(TYPE_ITEM, id, locale); - }; + this.getItemStatus = function (id, locale) { + this.getStatus(TYPE_ITEM, id, locale); + }; - this.getSpellStatus = function (id, locale) { - this.getStatus(TYPE_SPELL, id, locale); - }; + this.getSpellStatus = function (id, locale) { + this.getStatus(TYPE_SPELL, id, locale); + }; - if (isRemote) { - this.set = function (foo) { - $WH.cO(opt, foo); - }; + if (isRemote) { + this.set = function (foo) { + $WH.cO(opt, foo); + }; - this.showTooltip = function (e, tooltip, icon) { - updateCursorPos(e); - showTooltip(tooltip, icon); - }; + this.showTooltip = function (e, tooltip, icon) { + updateCursorPos(e); + showTooltip(tooltip, icon); + }; - this.hideTooltip = function () { - $WH.Tooltip.hide(); - }; + this.hideTooltip = function () { + $WH.Tooltip.hide(); + }; - this.moveTooltip = function (e) { - onMouseMove(e); - } - } + this.moveTooltip = function (e) { + onMouseMove(e); + } + } - init(); - } + init(); + } }; \ No newline at end of file diff --git a/template/js/Summary.js b/template/js/Summary.js index a3596c90..df7784fc 100644 --- a/template/js/Summary.js +++ b/template/js/Summary.js @@ -770,9 +770,7 @@ Summary.prototype = { $WH.de(o); - // $('#su_classes, #su_presets').change(); - $WH.ge('su_classes').onchange(); - $WH.ge('su_presets').onchange(); + $('#su_classes, #su_presets').change(); } } }, @@ -811,7 +809,7 @@ Summary.prototype = { var checkTrait = function(json, tj, trait, col, f, c, e, s) { var _json = $WH.dO(json); if (_json.scadist && _json.scaflags) { - g_setJsonItemLevel(_json, level); + $WH.g_setJsonItemLevel(_json, level); } var @@ -2175,7 +2173,7 @@ Summary.prototype = { if (result != null) { if (row.rating && !isNaN(result)) { - var percent = (result < 0 ? -1 : 1) * g_convertRatingToPercent(this.level, row.rating, Math.abs(result)); + var percent = (result < 0 ? -1 : 1) * $WH.g_convertRatingToPercent(this.level, row.rating, Math.abs(result)); percent = $WH.number_format((Math.round(percent * 100) / 100)); if (row.rating != 12 && row.rating != 37) { // Neither Defense, nor Expertise @@ -2468,7 +2466,7 @@ Summary.prototype = { $WH.aE(this.searchName, 'keydown', this.onSearchKeyDown.bind(this)); $WH.ae(sm, this.searchName); - this.searchMsg = $WH.sp; + this.searchMsg = sp; this.searchMsg.style.fontWeight = 'bold'; $WH.ae(sm, this.searchMsg); $WH.ae(div, sm); @@ -4164,7 +4162,7 @@ Summary.templates = { $WH.ae(td, $WH.ct(value + ' ' + LANG.traits[trait][1])); if (this.ratings[trait] != null) { - var percent = g_convertRatingToPercent(this.level, this.ratings[trait], value); + var percent = $WH.g_convertRatingToPercent(this.level, this.ratings[trait], value); percent = $WH.number_format((Math.round(percent * 100) / 100)); diff --git a/template/js/TalentCalc.js b/template/js/TalentCalc.js index a0c349a0..2c8da699 100644 --- a/template/js/TalentCalc.js +++ b/template/js/TalentCalc.js @@ -2523,7 +2523,7 @@ function TalentCalc() { buffer += '
'; - Tooltip.show(_this, g_setTooltipItemLevel(buffer, _getRequiredLevel())); + Tooltip.show(_this, $WH.g_setTooltipLevel(buffer, _getRequiredLevel())); } function _simplifyGlyphName(name) { diff --git a/template/js/basic.js b/template/js/basic.js index 6b1d4acc..984fabfa 100644 --- a/template/js/basic.js +++ b/template/js/basic.js @@ -64,25 +64,25 @@ if (!Function.prototype.bind) { $WH.bindfunc = function() { args = $WH.$A(arguments); - var __method = args.shift(); - var object = args.shift(); + var __method = args.shift(); + var object = args.shift(); - return function() { - return __method.apply(object, args.concat($WH.$A(arguments))); - }; + return function() { + return __method.apply(object, args.concat($WH.$A(arguments))); + }; }; if (!String.prototype.ltrim) { - String.prototype.ltrim = function () { return this.replace(/^\s*/, ""); } + String.prototype.ltrim = function () { return this.replace(/^\s*/, ""); } } if (!String.prototype.rtrim) { - String.prototype.rtrim = function () { return this.replace(/\s*$/, ""); } + String.prototype.rtrim = function () { return this.replace(/\s*$/, ""); } } if (!String.prototype.trim) { - String.prototype.trim = function () { return this.ltrim().rtrim(); } + String.prototype.trim = function () { return this.ltrim().rtrim(); } } if (!String.prototype.removeAllWhitespace) { - String.prototype.removeAllWhitespace = function () { return this.replace("/s+/g", ""); } + String.prototype.removeAllWhitespace = function () { return this.replace("/s+/g", ""); } } $WH.strcmp = function(a, b) { @@ -205,7 +205,7 @@ $WH.number_format = function(z) { } $WH.is_array = function (arr) { - return !!(arr && arr.constructor == Array); + return !!(arr && arr.constructor == Array); }; $WH.in_array = function(arr, val, func, idx) { @@ -236,26 +236,26 @@ $WH.in_arrayf = function (arr, val, func, idx) { } $WH.rs = function () { - var c = $WH.rs.random; - var r = ''; - for (var i = 0; i < 16; i++) { - var n = Math.floor(Math.random() * c.length); - if (i == 0 && n < 11) { - n += 10; - } - r += c.substring(n, n + 1); - } + var c = $WH.rs.random; + var r = ''; + for (var i = 0; i < 16; i++) { + var n = Math.floor(Math.random() * c.length); + if (i == 0 && n < 11) { + n += 10; + } + r += c.substring(n, n + 1); + } - return r; + return r; }; $WH.rs.random = "0123456789abcdefghiklmnopqrstuvwxyz"; $WH.isset = function (a) { - return typeof window[a] != "undefined"; + return typeof window[a] != "undefined"; }; if (!$WH.isset('console')) { - console = { log: function() {} }; + console = { log: function() {} }; } $WH.array_walk = function(a, f, ud) { @@ -276,68 +276,68 @@ $WH.array_apply = function(a, f, ud) { } $WH.array_filter = function(a, f) { - var res = []; - for (var i = 0, len = a.length; i < len; ++i) { - if (f(a[i])) { - res.push(a[i]); - } - } + var res = []; + for (var i = 0, len = a.length; i < len; ++i) { + if (f(a[i])) { + res.push(a[i]); + } + } - return res; + return res; } $WH.array_index = function(a, r, f, z) { - if (!$WH.is_array(a)) { + if (!$WH.is_array(a)) { return false; - } + } - if (!a.__R || z) { - a.__R = {}; - if (!f) { + if (!a.__R || z) { + a.__R = {}; + if (!f) { f = function(x) { return x; }; - } + } - for (var i = 0, len = a.length; i < len; ++i) { - a.__R[f(a[i])] = i; - } - } + for (var i = 0, len = a.length; i < len; ++i) { + a.__R[f(a[i])] = i; + } + } - return (r == null ? a.__R : !isNaN(a.__R[r])); + return (r == null ? a.__R : !isNaN(a.__R[r])); } $WH.array_compare = function(a, b) { - if (a.length != b.length) { - return false; - } + if (a.length != b.length) { + return false; + } - var o = {}; - for (var i = a.length; i >= 0; --i) { - o[a[i]] = true; - } + var o = {}; + for (var i = a.length; i >= 0; --i) { + o[a[i]] = true; + } - var match = true; - for (var i = b.length; i >= 0; --i) { - if (o[b[i]] === undefined) { - match = false; - } - } + var match = true; + for (var i = b.length; i >= 0; --i) { + if (o[b[i]] === undefined) { + match = false; + } + } - return match; + return match; } $WH.array_unique = function(a) { - var out = []; - var tmp = {}; + var out = []; + var tmp = {}; - for (var i = a.length-1; i >= 0; --i) { - tmp[a[i]] = 1; - } - - for (var i in tmp) { - out.push(i); + for (var i = a.length-1; i >= 0; --i) { + tmp[a[i]] = 1; } - return out; + for (var i in tmp) { + out.push(i); + } + + return out; } // Get element @@ -602,11 +602,11 @@ $WH.cOr = function (d, s) { } $WH.Browser = { - ie: !!(window.attachEvent && !window.opera), - opera: !!window.opera, - safari: navigator.userAgent.indexOf('Safari') != -1, - firefox: navigator.userAgent.indexOf('Firefox') != -1, - chrome: navigator.userAgent.indexOf('Chrome') != -1 + ie: !!(window.attachEvent && !window.opera), + opera: !!window.opera, + safari: navigator.userAgent.indexOf('Safari') != -1, + firefox: navigator.userAgent.indexOf('Firefox') != -1, + chrome: navigator.userAgent.indexOf('Chrome') != -1 }; $WH.Browser.ie9 = $WH.Browser.ie && navigator.userAgent.indexOf('MSIE 9.0') != -1; $WH.Browser.ie8 = $WH.Browser.ie && navigator.userAgent.indexOf('MSIE 8.0') != -1 && !$WH.Browser.ie9; @@ -621,9 +621,9 @@ navigator.userAgent.match(/Gecko\/([0-9]+)/); $WH.Browser.geckoVersion = parseInt(RegExp.$1) | 0; $WH.OS = { - windows: navigator.appVersion.indexOf('Windows') != -1, - mac: navigator.appVersion.indexOf('Macintosh') != -1, - linux: navigator.appVersion.indexOf('Linux') != -1 + windows: navigator.appVersion.indexOf('Windows') != -1, + mac: navigator.appVersion.indexOf('Macintosh') != -1, + linux: navigator.appVersion.indexOf('Linux') != -1 }; //****************************************************************************// @@ -994,499 +994,615 @@ $WH.g_intersectRect = function(a, b) { //****************************************************************************// //****************************************************************************// -$WH.g_convertRatingToPercent = function (g, b, f, d) { - var e = $WH.g_convertRatingToPercent.RB; - if (g < 0) { - g = 1 - } else { - if (g > 80) { - g = 80 - } - } - if ((b == 14 || b == 12 || b == 15) && g < 34) { - g = 34 - } - if ((b == 28 || b == 36) && (d == 2 || d == 6 || d == 7 || d == 11)) { - e[b] /= 1.3 - } - if (f < 0) { - f = 0 - } - var a; - if (e[b] == null) { - a = 0 - } else { - var c; - if (g > 70) { - c = (82 / 52) * Math.pow((131 / 63), ((g - 70) / 10)) - } else { - if (g > 60) { - c = (82 / (262 - 3 * g)) - } else { - if (g > 10) { - c = ((g - 8) / 52) - } else { - c = 2 / 52 - } - } - } - a = f / e[b] / c - } - return a -}; -$WH.g_convertRatingToPercent.RB = { - 12 : 1.5, - 13 : 12, - 14 : 15, - 15 : 5, - 16 : 10, - 17 : 10, - 18 : 8, - 19 : 14, - 20 : 14, - 21 : 14, - 22 : 10, - 23 : 10, - 24 : 0, - 25 : 0, - 26 : 0, - 27 : 0, - 28 : 10, - 29 : 10, - 30 : 10, - 31 : 10, - 32 : 14, - 33 : 0, - 34 : 0, - 35 : 25, - 36 : 10, - 37 : 2.5, - 44 : 4.69512176513672 / 1.1 -}; -$WH.g_statToJson = { - 1 : "health", - 2 : "mana", - 3 : "agi", - 4 : "str", - 5 : "int", - 6 : "spi", - 7 : "sta", - 12 : "defrtng", - 13 : "dodgertng", - 14 : "parryrtng", - 15 : "blockrtng", - 16 : "mlehitrtng", - 17 : "rgdhitrtng", - 18 : "splhitrtng", - 19 : "mlecritstrkrtng", - 20 : "rgdcritstrkrtng", - 21 : "splcritstrkrtng", - 22 : "_mlehitrtng", - 23 : "_rgdhitrtng", - 24 : "_splhitrtng", - 25 : "_mlecritstrkrtng", - 26 : "_rgdcritstrkrtng", - 27 : "_splcritstrkrtng", - 28 : "mlehastertng", - 29 : "rgdhastertng", - 30 : "splhastertng", - 31 : "hitrtng", - 32 : "critstrkrtng", - 33 : "_hitrtng", - 34 : "_critstrkrtng", - 35 : "resirtng", - 36 : "hastertng", - 37 : "exprtng", - 38 : "atkpwr", - 43 : "manargn", - 44 : "armorpenrtng", - 45 : "splpwr" -}; -$WH.g_convertScalingFactor = function (c, b, g, d, j) { - var f = $WH.g_convertScalingFactor.SV; - var e = $WH.g_convertScalingFactor.SD; - var i = {}, - h = f[c], - a = e[g]; - if (!a || !(d >= 0 && d <= 9)) { - i.v = h[b] - } else { - i.n = $WH.g_statToJson[a[d]]; - i.s = a[d]; - i.v = Math.floor(h[b] * a[d + 10] / 10000) - } - return (j ? i: i.v) -}; -$WH.g_convertScalingFactor.SV = { - 1 : [2, 2, 1, 3, 1, 10, 32, 32, 64, 6, 8, 6, 8, 6, 8, 1, 0, 0, 1, 7, 13, 43, 43, 85], - 2 : [3, 3, 1, 3, 1, 12, 35, 35, 70, 6, 9, 6, 9, 7, 9, 2, 0, 0, 2, 8, 16, 47, 47, 93], - 3 : [3, 3, 1, 4, 1, 13, 39, 39, 76, 7, 9, 7, 9, 7, 10, 3, 0, 0, 2, 9, 17, 52, 52, 101], - 4 : [3, 3, 1, 4, 1, 14, 42, 42, 83, 7, 10, 7, 10, 8, 11, 3, 0, 0, 2, 9, 19, 56, 56, 111], - 5 : [4, 4, 2, 5, 2, 16, 45, 45, 89, 8, 10, 8, 10, 8, 12, 4, 0, 0, 3, 11, 21, 60, 60, 119], - 6 : [4, 4, 2, 5, 2, 17, 48, 48, 95, 8, 11, 8, 11, 9, 12, 5, 0, 0, 3, 11, 23, 64, 64, 127], - 7 : [4, 4, 3, 6, 2, 19, 51, 51, 101, 9, 11, 9, 11, 9, 13, 6, 0, 0, 3, 13, 25, 68, 68, 135], - 8 : [5, 5, 3, 7, 2, 20, 54, 54, 107, 9, 12, 9, 12, 9, 14, 7, 0, 0, 4, 13, 27, 72, 72, 143], - 9 : [5, 5, 3, 7, 2, 22, 56, 56, 113, 10, 13, 10, 13, 10, 15, 7, 0, 0, 4, 15, 29, 75, 75, 151], - 10 : [6, 6, 3, 8, 2, 23, 57, 57, 119, 10, 13, 10, 13, 10, 16, 8, 0, 0, 4, 15, 31, 76, 76, 159], - 11 : [6, 6, 4, 8, 3, 24, 59, 59, 125, 11, 14, 11, 14, 11, 16, 9, 0, 0, 5, 16, 32, 79, 79, 167], - 12 : [7, 7, 4, 9, 3, 25, 60, 60, 131, 11, 15, 11, 15, 12, 17, 10, 0, 0, 5, 17, 33, 80, 80, 175], - 13 : [7, 7, 4, 9, 3, 26, 61, 61, 133, 12, 16, 12, 16, 12, 18, 10, 0, 0, 5, 17, 35, 81, 81, 177], - 14 : [8, 8, 4, 10, 3, 27, 63, 63, 136, 12, 16, 12, 16, 13, 19, 11, 0, 0, 6, 18, 36, 84, 84, 181], - 15 : [8, 8, 5, 11, 3, 28, 64, 64, 138, 13, 17, 13, 17, 13, 20, 12, 0, 0, 6, 19, 37, 85, 85, 184], - 16 : [8, 8, 5, 11, 4, 29, 65, 65, 141, 14, 18, 14, 18, 14, 21, 13, 0, 0, 6, 19, 39, 87, 87, 188], - 17 : [9, 9, 5, 12, 4, 30, 67, 67, 143, 14, 19, 14, 19, 14, 22, 14, 0, 0, 7, 20, 40, 89, 89, 191], - 18 : [9, 9, 5, 12, 4, 30, 68, 68, 146, 15, 19, 15, 19, 15, 23, 14, 0, 0, 7, 20, 40, 91, 91, 195], - 19 : [10, 10, 6, 13, 4, 31, 69, 69, 148, 15, 20, 15, 20, 15, 24, 15, 0, 0, 7, 21, 41, 92, 92, 197], - 20 : [10, 10, 6, 14, 4, 32, 71, 71, 151, 16, 21, 16, 21, 16, 25, 16, 0, 0, 8, 21, 43, 95, 95, 201], - 21 : [11, 11, 6, 14, 5, 33, 72, 72, 153, 16, 21, 16, 21, 16, 26, 17, 0, 0, 8, 22, 44, 96, 96, 204], - 22 : [11, 11, 6, 15, 5, 34, 73, 73, 156, 17, 22, 17, 22, 17, 27, 18, 0, 0, 8, 23, 45, 97, 97, 208], - 23 : [12, 12, 7, 15, 5, 34, 75, 75, 158, 17, 23, 17, 23, 17, 28, 18, 0, 0, 9, 23, 45, 100, 100, 211], - 24 : [12, 12, 7, 16, 5, 35, 76, 76, 161, 18, 23, 18, 23, 18, 29, 19, 0, 0, 9, 23, 47, 101, 101, 215], - 25 : [12, 12, 7, 17, 5, 35, 77, 77, 163, 19, 24, 19, 24, 19, 29, 20, 0, 0, 9, 23, 47, 103, 103, 217], - 26 : [13, 13, 7, 17, 5, 36, 78, 78, 166, 19, 25, 19, 25, 19, 30, 21, 0, 0, 10, 24, 48, 104, 104, 221], - 27 : [13, 13, 8, 18, 6, 37, 80, 80, 168, 20, 26, 20, 26, 20, 31, 22, 0, 0, 10, 25, 49, 107, 107, 224], - 28 : [14, 14, 8, 18, 6, 37, 81, 81, 171, 21, 27, 21, 27, 21, 32, 22, 0, 0, 10, 25, 49, 108, 108, 228], - 29 : [14, 14, 8, 19, 6, 38, 82, 82, 173, 22, 29, 22, 29, 22, 32, 23, 0, 0, 11, 25, 51, 109, 109, 231], - 30 : [15, 15, 8, 20, 6, 38, 84, 84, 176, 23, 30, 23, 30, 22, 33, 24, 0, 0, 11, 25, 51, 112, 112, 235], - 31 : [15, 15, 9, 20, 6, 39, 85, 85, 178, 24, 31, 24, 31, 23, 34, 25, 0, 0, 11, 26, 52, 113, 113, 237], - 32 : [16, 16, 9, 21, 7, 40, 86, 86, 181, 25, 32, 25, 32, 24, 34, 25, 0, 0, 12, 27, 53, 115, 115, 241], - 33 : [16, 16, 9, 21, 7, 41, 88, 88, 184, 25, 33, 25, 33, 25, 35, 26, 0, 0, 12, 27, 55, 117, 117, 245], - 34 : [16, 16, 9, 22, 7, 43, 90, 90, 187, 26, 34, 26, 34, 26, 36, 27, 0, 0, 12, 29, 57, 120, 120, 249], - 35 : [17, 17, 10, 23, 7, 44, 91, 91, 190, 27, 35, 27, 35, 26, 37, 28, 0, 0, 13, 29, 59, 121, 121, 253], - 36 : [17, 17, 10, 23, 7, 44, 93, 93, 193, 28, 36, 28, 36, 27, 38, 29, 0, 0, 13, 29, 59, 124, 124, 257], - 37 : [18, 18, 10, 24, 8, 46, 95, 95, 196, 28, 37, 28, 37, 28, 39, 29, 0, 0, 13, 31, 61, 127, 127, 261], - 38 : [18, 18, 10, 24, 8, 47, 97, 97, 199, 29, 38, 29, 38, 28, 40, 30, 0, 0, 14, 31, 63, 129, 129, 265], - 39 : [19, 19, 11, 25, 8, 48, 99, 99, 202, 29, 38, 29, 38, 29, 41, 31, 0, 0, 14, 32, 64, 132, 132, 269], - 40 : [19, 19, 11, 26, 8, 49, 100, 205, 360, 30, 39, 30, 39, 30, 42, 32, 0, 0, 14, 33, 65, 133, 273, 480], - 41 : [20, 20, 11, 26, 8, 50, 102, 209, 368, 31, 40, 31, 40, 30, 43, 33, 0, 0, 15, 33, 67, 136, 279, 491], - 42 : [20, 20, 11, 27, 8, 51, 104, 213, 375, 31, 41, 31, 41, 31, 44, 33, 0, 0, 15, 34, 68, 139, 284, 500], - 43 : [20, 20, 12, 27, 9, 52, 106, 217, 382, 32, 41, 32, 41, 31, 45, 34, 0, 0, 15, 35, 69, 141, 289, 509], - 44 : [21, 21, 12, 28, 9, 53, 108, 221, 389, 32, 42, 32, 42, 32, 47, 35, 0, 0, 16, 35, 71, 144, 295, 519], - 45 : [21, 21, 12, 28, 9, 54, 109, 225, 396, 33, 43, 33, 43, 33, 48, 36, 0, 0, 16, 36, 72, 145, 300, 528], - 46 : [22, 22, 12, 29, 9, 55, 111, 229, 403, 34, 44, 34, 44, 33, 50, 37, 0, 0, 16, 37, 73, 148, 305, 537], - 47 : [22, 22, 13, 30, 9, 56, 113, 233, 410, 34, 45, 34, 45, 34, 51, 37, 0, 0, 17, 37, 75, 151, 311, 547], - 48 : [23, 23, 13, 30, 10, 57, 115, 238, 418, 35, 45, 35, 45, 34, 52, 38, 0, 0, 17, 38, 76, 153, 317, 557], - 49 : [23, 23, 13, 31, 10, 58, 117, 242, 425, 35, 46, 35, 46, 35, 53, 39, 0, 0, 17, 39, 77, 156, 323, 567], - 50 : [24, 24, 13, 31, 10, 59, 118, 246, 433, 36, 47, 36, 47, 36, 54, 40, 0, 0, 18, 39, 79, 157, 328, 577], - 51 : [24, 24, 14, 32, 10, 60, 120, 250, 440, 37, 48, 37, 48, 36, 54, 40, 0, 0, 18, 40, 80, 160, 333, 587], - 52 : [24, 24, 14, 33, 10, 61, 122, 254, 448, 37, 49, 37, 49, 37, 55, 41, 0, 0, 18, 41, 81, 163, 339, 597], - 53 : [25, 25, 14, 33, 11, 62, 124, 258, 455, 38, 49, 38, 49, 38, 57, 42, 0, 0, 19, 41, 83, 165, 344, 607], - 54 : [25, 25, 14, 34, 11, 63, 126, 262, 463, 38, 50, 38, 50, 38, 58, 43, 0, 0, 19, 42, 84, 168, 349, 617], - 55 : [26, 26, 15, 34, 11, 64, 127, 266, 470, 39, 51, 39, 51, 39, 59, 44, 0, 0, 19, 43, 85, 169, 355, 627], - 56 : [26, 26, 15, 35, 11, 65, 129, 270, 478, 40, 52, 40, 52, 39, 61, 44, 0, 0, 20, 43, 87, 172, 360, 637], - 57 : [27, 27, 15, 36, 11, 66, 131, 274, 485, 40, 53, 40, 53, 40, 62, 45, 0, 0, 20, 44, 88, 175, 365, 647], - 58 : [34, 34, 19, 46, 14, 83, 159, 344, 611, 50, 65, 46, 60, 48, 85, 46, 0, 0, 25, 55, 111, 212, 459, 815], - 59 : [36, 36, 20, 47, 15, 86, 164, 356, 633, 51, 67, 47, 61, 50, 88, 52, 0, 0, 27, 57, 115, 219, 475, 844], - 60 : [37, 37, 21, 49, 16, 88, 169, 368, 655, 53, 68, 47, 62, 51, 91, 57, 0, 0, 28, 59, 117, 225, 491, 873], - 61 : [39, 39, 22, 51, 16, 91, 174, 380, 677, 54, 70, 48, 63, 52, 94, 63, 0, 0, 29, 61, 121, 232, 507, 903], - 62 : [40, 40, 22, 53, 17, 94, 178, 392, 699, 55, 72, 49, 64, 53, 97, 68, 0, 0, 30, 63, 125, 237, 523, 932], - 63 : [41, 41, 23, 54, 17, 97, 183, 404, 721, 56, 73, 50, 65, 54, 100, 73, 0, 0, 31, 65, 129, 244, 539, 961], - 64 : [42, 42, 24, 55, 18, 100, 187, 416, 742, 58, 75, 50, 66, 55, 104, 80, 0, 0, 31, 67, 133, 249, 555, 989], - 65 : [43, 43, 24, 57, 18, 102, 192, 428, 764, 60, 78, 52, 67, 57, 109, 89, 0, 0, 32, 68, 136, 256, 571, 1019], - 66 : [44, 44, 25, 58, 18, 105, 197, 440, 786, 62, 81, 53, 69, 59, 113, 98, 0, 0, 33, 70, 140, 263, 587, 1048], - 67 : [45, 45, 25, 59, 19, 108, 203, 452, 808, 65, 84, 54, 71, 61, 117, 107, 0, 0, 34, 72, 144, 271, 603, 1077], - 68 : [62, 62, 36, 84, 26, 157, 294, 654, 1169, 91, 119, 70, 91, 82, 168, 220, 0, 0, 47, 105, 209, 392, 872, 1559], - 69 : [64, 64, 37, 87, 27, 161, 303, 675, 1206, 93, 121, 71, 92, 84, 172, 228, 0, 0, 48, 107, 215, 404, 900, 1608], - 70 : [67, 67, 39, 90, 28, 166, 312, 695, 1242, 95, 124, 72, 94, 86, 175, 238, 0, 0, 50, 111, 221, 416, 927, 1656], - 71 : [69, 69, 40, 93, 29, 171, 321, 715, 1278, 97, 127, 73, 95, 88, 179, 246, 0, 0, 52, 114, 228, 428, 953, 1704], - 72 : [72, 72, 42, 97, 30, 176, 331, 736, 1315, 99, 129, 75, 97, 90, 183, 255, 0, 0, 54, 117, 235, 441, 981, 1753], - 73 : [75, 75, 43, 101, 32, 181, 340, 756, 1351, 102, 132, 76, 99, 92, 187, 265, 0, 0, 56, 121, 241, 453, 1008, 1801], - 74 : [78, 78, 45, 104, 33, 186, 349, 776, 1387, 104, 135, 77, 100, 94, 191, 275, 0, 0, 58, 124, 248, 465, 1035, 1849], - 75 : [81, 81, 46, 108, 34, 191, 358, 797, 1423, 106, 138, 79, 102, 96, 196, 285, 0, 0, 60, 127, 255, 477, 1063, 1897], - 76 : [84, 84, 48, 113, 35, 196, 367, 817, 1460, 109, 141, 80, 104, 98, 200, 296, 0, 0, 63, 131, 261, 489, 1089, 1947], - 77 : [87, 87, 50, 117, 37, 200, 376, 837, 1496, 111, 145, 81, 106, 101, 205, 307, 0, 0, 65, 133, 267, 501, 1116, 1995], - 78 : [90, 90, 52, 121, 38, 205, 386, 858, 1532, 114, 148, 83, 108, 103, 210, 319, 0, 0, 68, 137, 273, 515, 1144, 2043], - 79 : [94, 94, 54, 126, 40, 208, 390, 868, 1551, 117, 152, 85, 110, 105, 215, 331, 0, 0, 71, 139, 277, 520, 1157, 2068], - 80 : [97, 97, 56, 131, 41, 210, 395, 878, 1570, 120, 156, 86, 112, 108, 220, 343, 0, 0, 73, 140, 280, 527, 1171, 2093] -}; -$WH.g_convertScalingFactor.SD = { - 1 : [4, 7, 32, -1, -1, -1, -1, -1, -1, -1, 5259, 7888, 5259, 0, 0, 0, 0, 0, 0, 0, 80], - 2 : [38, 3, 31, -1, -1, -1, -1, -1, -1, -1, 14532, 4106, 3193, 0, 0, 0, 0, 0, 0, 0, 80], - 3 : [38, 7, 32, -1, -1, -1, -1, -1, -1, -1, 5068, 5065, 6666, 0, 0, 0, 0, 0, 0, 0, 80], - 4 : [38, 32, 31, -1, -1, -1, -1, -1, -1, -1, 13332, 4767, 3900, 0, 0, 0, 0, 0, 0, 0, 80], - 5 : [7, 5, 32, -1, -1, -1, -1, -1, -1, -1, 7150, 5850, 4766, 0, 0, 0, 0, 0, 0, 0, 80], - 6 : [7, 5, 43, -1, -1, -1, -1, -1, -1, -1, 5067, 7601, 1350, 0, 0, 0, 0, 0, 0, 0, 80], - 7 : [4, 7, 32, -1, -1, -1, -1, -1, -1, -1, 6666, 6666, 4445, 0, 0, 0, 0, 0, 0, 0, 80], - 8 : [38, 3, 7, 5, -1, -1, -1, -1, -1, -1, 10518, 5258, 5641, 3076, 0, 0, 0, 0, 0, 0, 80], - 9 : [45, 7, 5, 43, -1, -1, -1, -1, -1, -1, 5201, 6666, 4444, 1778, 0, 0, 0, 0, 0, 0, 80], - 10 : [38, 31, 7, -1, -1, -1, -1, -1, -1, -1, 14532, 4106, 4789, 0, 0, 0, 0, 0, 0, 0, 80], - 11 : [45, 7, 5, 6, -1, -1, -1, -1, -1, -1, 6153, 3996, 3997, 5258, 0, 0, 0, 0, 0, 0, 80], - 12 : [0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 5000, 5000, 0, 0, 0, 0, 0, 0, 0, 0, 10], - 13 : [42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10], - 14 : [38, 39, 40, 41, 42, 43, 0, 0, 0, 0, 6500, 6500, 10000, 10000, 10000, 10000, 0, 0, 0, 0, 15], - 15 : [40, 41, 42, 0, 0, 0, 0, 0, 0, 0, 4200, 5200, 6200, 0, 0, 0, 0, 0, 0, 0, 10], - 16 : [45, 7, 5, 6, -1, -1, -1, -1, -1, -1, 6153, 3996, 3997, 5258, 0, 0, 0, 0, 0, 0, 80], - 21 : [12, 13, 14, 15, 16, 0, 0, 0, 0, 0, 5000, 6000, 7000, 8000, 9000, 0, 0, 0, 0, 0, 10], - 41 : [3, 4, 5, 6, 7, 12, 13, 14, 15, 16, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10], - 42 : [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10], - 43 : [27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10], - 102 : [44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15], - 103 : [3, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - 104 : [32, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80], - 105 : [13, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - 221 : [4, 7, 32, 36, -1, -1, -1, -1, -1, -1, 4844, 7266, 4106, 3193, 0, 0, 0, 0, 0, 0, 80], - 222 : [3, 44, 7, -1, -1, -1, -1, -1, -1, -1, 5259, 3506, 5259, 0, 0, 0, 0, 0, 0, 0, 80], - 223 : [7, 5, 32, -1, -1, -1, -1, -1, -1, -1, 4859, 5732, 2519, 0, 0, 0, 0, 0, 0, 0, 80], - 224 : [38, 3, 31, 7, -1, -1, -1, -1, -1, -1, 9688, 4844, 3193, 6159, 0, 0, 0, 0, 0, 0, 80], - 241 : [45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80], - 251 : [36, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6666, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80], - 271 : [45, -1, -1, -1, -1, -1, -1, -1, -1, -1, 7800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80], - 291 : [38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 23252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - 292 : [38, 7, 35, -1, -1, -1, -1, -1, -1, -1, 10518, 7888, 5258, 0, 0, 0, 0, 0, 0, 0, 80], - 293 : [4, 7, 35, -1, -1, -1, -1, -1, -1, -1, 7266, 4789, 4106, 0, 0, 0, 0, 0, 0, 0, 80], - 294 : [38, 32, 35, -1, -1, -1, -1, -1, -1, -1, 8212, 7266, 3193, 0, 0, 0, 0, 0, 0, 0, 80], - 295 : [7, 35, 43, -1, -1, -1, -1, -1, -1, -1, 6666, 6666, 1777, 0, 0, 0, 0, 0, 0, 0, 80], - 296 : [7, 31, 35, -1, -1, -1, -1, -1, -1, -1, 7888, 5259, 5258, 0, 0, 0, 0, 0, 0, 0, 80], - 297 : [35, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5259, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80], - 298 : [35, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6667, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80], - 299 : [35, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6667, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80], - 300 : [4, 7, 35, -1, -1, -1, -1, -1, -1, -1, 5259, 7888, 5258, 0, 0, 0, 0, 0, 0, 0, 80], - 301 : [45, 7, 43, 35, -1, -1, -1, -1, -1, -1, 5200, 6666, 1776, 4444, 0, 0, 0, 0, 0, 0, 80], - 302 : [38, 3, 7, 35, -1, -1, -1, -1, -1, -1, 8888, 4444, 6668, 4444, 0, 0, 0, 0, 0, 0, 80], - 303 : [45, 7, 5, 35, -1, -1, -1, -1, -1, -1, 6153, 5259, 3506, 5258, 0, 0, 0, 0, 0, 0, 80], - 304 : [38, 3, 7, 35, -1, -1, -1, -1, -1, -1, 8888, 3899, 6666, 4767, 0, 0, 0, 0, 0, 0, 80], - 305 : [45, 7, 6, 35, -1, -1, -1, -1, -1, -1, 6153, 5259, 3506, 5258, 0, 0, 0, 0, 0, 0, 80], - 306 : [45, 7, 32, 35, -1, -1, -1, -1, -1, -1, 6153, 5259, 3506, 5258, 0, 0, 0, 0, 0, 0, 80], - 311 : [ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - 331 : [38, 3, 7, 5, -1, -1, -1, -1, -1, -1, 10518, 5258, 5259, 3506, 0, 0, 0, 0, 0, 0, 80], - 332 : [45, 7, 5, 43, -1, -1, -1, -1, -1, -1, 6153, 3997, 3997, 2629, 0, 0, 0, 0, 0, 0, 80], - 333 : [4, 7, 32, -1, -1, -1, -1, -1, -1, -1, 5996, 5996, 5258, 0, 0, 0, 0, 0, 0, 0, 80], - 334 : [45, 7, 5, 6, -1, -1, -1, -1, -1, -1, 6153, 3997, 3997, 5259, 0, 0, 0, 0, 0, 0, 80], - 335 : [38, 7, 31, -1, -1, -1, -1, -1, -1, -1, 10518, 7888, 5259, 0, 0, 0, 0, 0, 0, 0, 80], - 336 : [45, 7, 5, 6, -1, -1, -1, -1, -1, -1, 6153, 3997, 3997, 5259, 0, 0, 0, 0, 0, 0, 80], - 351 : [3, 38, 7, 32, -1, -1, -1, -1, -1, -1, 5259, 7012, 7889, 3506, 0, 0, 0, 0, 0, 0, 80], - 352 : [3, 44, 7, 38, -1, -1, -1, -1, -1, -1, 5259, 3506, 7889, 7012, 0, 0, 0, 0, 0, 0, 80], - 371 : [32, 31, 7, -1, -1, -1, -1, -1, -1, -1, 7266, 4106, 4789, 0, 0, 0, 0, 0, 0, 0, 80] -}; -$WH.g_setJsonItemLevel = function (s, a) { - if (!s.scadist || !s.scaflags) { - return - } - s.bonuses = s.bonuses || {}; - var c = -1, - r = -1, - k = -1, - p = -1, - f = 262175, - o = 16253408, - d = 32256, - g = 32768, - b = 5120; - for (var h = 0; h < 24; ++h) { - var l = 1 << h; - if (l & s.scaflags) { - if (l & f && c < 0) { - c = h - } else { - if (l & o && r < 0) { - r = h - } else { - if (l & d && k < 0) { - k = h - } else { - if (l & g && p < 0) { - p = h - } - } - } - } - } - } - if (c >= 0) { - for (var h = 0; h < 10; ++h) { - var q = $WH.g_convertScalingFactor(a, c, s.scadist, h, 1); - if (q.n) { - s[q.n] = q.v - } - s.bonuses[q.s] = q.v - } - } - if (r >= 0) { - s.armor = $WH.g_convertScalingFactor(a, r) - } - if (k >= 0) { - var j = (s.scaflags & b ? 0.2 : 0.3), - m = (s.mledps ? "mle": "rgd"); - s.speed /= s.speed > 1000 ? 1000 : 1; // summary expects speed in sec; different version of script is different - s.dps = s[m + "dps"] = g_convertScalingFactor(a, k); - s.dmgmin = s[m + "dmgmin"] = Math.floor(s.dps * s.speed * (1 - j)); - s.dmgmax = s[m + "dmgmax"] = Math.floor(s.dps * s.speed * (1 + j)) +$WH.g_convertRatingToPercent = function(level, rating, value, classs) { + var ratingBases = $WH.g_convertRatingToPercent.RB; - if (s.feratkpwr) { // yes thats custom too.. - s.feratkpwr = Math.max(0, Math.floor((s.dps - 54.8) * 14)); - } - } - if (p >= 0) { - s.splpwr = s.bonuses[45] = $WH.g_convertScalingFactor(a, p) - } - if (s.gearscore != null) { - if (s._gearscore == null) { - s._gearscore = s.gearscore - } - var e = Math.min(80, a + 1); - if (e >= 70) { - n = ((e - 70) * 9.5) + 105 - } else { - if (e >= 60) { - n = ((e - 60) * 4.5) + 60 - } else { - n = e + 5 - } - } - s.gearscore = (s._gearscore * n) / 1.8 - } + if (level < 0) { + level = 1; + } + else { + if (level > 80) { + level = 80; + } + } + + // Patch 2.4.3: Defense Skill, Dodge Rating, Parry Rating, Block Rating + if ((rating == 14 || rating == 12 || rating == 15) && level < 34) { + level = 34; + } + + // Patch 3.1: Melee Haste for Death Knights, Druids, Paladins, and Shamans + if ((rating == 28 || rating == 36) && (classs == 2 || classs == 6 || classs == 7 || classs == 11)) { + ratingBases[rating] /= 1.3; + } + + if (value < 0) { + value = 0 + } + + var percent; + if (!ratingBases || ratingBases[rating] == null) { + percent = 0 + } + else { + var H; + + if (level > 70) { + H = (82 / 52) * Math.pow((131 / 63), ((level - 70) / 10)); + } + else if (level > 60) { + H = (82 / (262 - 3 * level)); + } + else if (level > 10) { + H = ((level - 8) / 52); + } + else { + H = 2 / 52; + } + + percent = value / ratingBases[rating] / H; + } + + return percent; +} + +$WH.g_statToJson = { + // Converts a numeric stat id into a json property + 1: 'health', + 2: 'mana', // note: mana is on idx 0 in 5.4 + 3: 'agi', + 4: 'str', + 5: 'int', + 6: 'spi', + 7: 'sta', + 8: 'energy', + 9: 'rage', + 10: 'focus', + 12: 'defrtng', + 13: 'dodgertng', + 14: 'parryrtng', + 15: 'blockrtng', + 16: 'mlehitrtng', + 17: 'rgdhitrtng', + 18: 'splhitrtng', + 19: 'mlecritstrkrtng', + 20: 'rgdcritstrkrtng', + 21: 'splcritstrkrtng', + 22: '_mlehitrtng', + 23: '_rgdhitrtng', + 24: '_splhitrtng', + 25: '_mlecritstrkrtng', + 26: '_rgdcritstrkrtng', + 27: '_splcritstrkrtng', + 28: 'mlehastertng', + 29: 'rgdhastertng', + 30: 'splhastertng', + 31: 'hitrtng', + 32: 'critstrkrtng', + 33: '_hitrtng', + 34: '_critstrkrtng', + 35: 'resirtng', + 36: 'hastertng', + 37: 'exprtng', + 38: 'atkpwr', + 39: 'rgdatkpwr', + 40: 'feratkpwr', + 41: 'splheal', + 42: 'spldmg', + 43: 'manargn', + 44: 'armorpenrtng', + 45: 'splpwr', + 46: 'healthrgn', + 47: 'splpen', + 48: 'block', + 49: 'mastrtng', + 50: 'armor', + 51: 'firres', + 52: 'frores', + 53: 'holres', + 54: 'shares', + 55: 'natres', + 56: 'arcres', + 57: 'firsplpwr', + 58: 'frosplpwr', + 59: 'holsplpwr', + 60: 'shasplpwr', + 61: 'natsplpwr', + 62: 'arcsplpwr' }; -$WH.g_setTooltipItemLevel = function (a, g) { - var d = typeof a; - if (d == "number") { - if ($WH.isset("g_items") && g_items[a] && g_items[a]["tooltip_" + g_locale.name]) { - a = g_items[a]["tooltip_" + g_locale.name] - } else { - return a - } - } else { - if (d != "string") { - return a - } - } - d = a.match(//); - if (!d) { - return a - } - var b = d[2] || 0, - c = d[3] || 0; - if (b && c) { - var f = a.match(/(\d\.\d+)/); - if (f) { - f = Math.floor(parseFloat(f[1]) * 1000) - } - var e = { - scadist: b, - scaflags: c, - speed: f || 0 - }; - $WH.g_setJsonItemLevel(e, g); - a = a.replace(/()([^<]+)/, function (j, h, i) { - d = i; - if (g < 40 && (i == 3 || i == 4)) {--d - } - return h + g_itemset_types[d] - }); - a = a.replace(/()\d+(\D+)\d+/, function (j, h, i) { - return h + e.dmgmin + i + e.dmgmax - }); - a = a.replace(/(\D*?)(\d+\.\d)/, function (i, h) { - return h + e.dps.toFixed(1) - }); - a = a.replace(/(\D*?)(\d+)(\D*?)<\/span>(
)?/i, function (l, h, i, m, j) { - var k; - i = Math.floor((e.dps - 54.8) * 14); - if (e.dps > 54.8 && i > 0) { - k = ""; - j = (j ? "
": "") - } else { - i = 0; - k = ' style="display: none"'; - j = (j ? "": "") - } - return '" + h + i + m + "" + j - }); - a = a.replace(/()\d+/, function (i, h) { - return h + e.armor - }); - a = a.replace(/[-+]\d+(\D*?)<\/span>()?()?(
)?/gi, function (l, i, h, o, p, j) { - var k, m = e.bonuses[i]; - if (m) { - m = (m > 0 ? "+": "-") + m; - k = ""; - j = (j ? "
": "") - } else { - m = "+0"; - k = ' style="display: none"'; - j = (j ? "": "") - } - return "" + m + h + "
" + (o || "") + (p || "") + j - }); - a = a.replace(/(.*?)\d+(.*?)<\/span>(
)?/gi, function (h, k, m, p, l, i, q) { - var j, o = e.bonuses[m]; - if (o) { - j = ""; - q = (q ? "
": "") - } else { - j = ' style="display: none"'; - q = (q ? "": "") - } - return '" + k + "" + o + p + "" + q - }) - } - a = a.replace(/()([\.0-9]+)/g, function (j, h, k, i) { - d = a.match(new RegExp("(\\d+)")); - if (!d) { - return j - } - return h + Math.round($WH.g_convertRatingToPercent(g, k, d[1]) * 100) / 100 - }); - a = a.replace(/()/, "$1" + g + "$2"); - a = a.replace(/\d+/g, "" + g); - return a + +// Reverse lookup +$WH.g_jsonToStat = {}; +for (var i in $WH.g_statToJson) { + $WH.g_jsonToStat[$WH.g_statToJson[i]] = i; +} + +$WH.g_individualToGlobalStat = { + 16: 31, // Hit + 17: 31, + 18: 31, + 19: 32, // Crit + 20: 32, + 21: 32, + 22: 33, // Hit taken + 23: 33, + 24: 33, + 25: 34, // Crit taken + 26: 34, + 27: 34, + 28: 36, // Haste + 29: 36, + 30: 36 }; -$WH.g_enhanceTooltip = function (a, e, d) { - var c = typeof a; - if (c == "number") { - if ($WH.isset("g_items") && g_items[a] && g_items[a]["tooltip_" + g_locale.name]) { - a = g_items[a]["tooltip_" + g_locale.name] - } else { - return a - } - } else { - if (c != "string") { - return a - } + +$WH.g_convertScalingFactor = function(level, factor, dist, stat, json) { + var scalingValues = $WH.g_convertScalingFactor.SV; + var scalingDistributions = $WH.g_convertScalingFactor.SD; + + if(!scalingValues[level]) { + if (g_user.roles & U_GROUP_ADMIN) { + alert('There are no item scaling values for level ' + level); + } + + return (json ? {} : 0); } - if (d) { - var b = $WH.g_getGets(); - if (b.lvl) { - a = $WH.g_setTooltipItemLevel(a, b.lvl) - } + + var + result = {}, + scaleValue = scalingValues[level], + scaleDistribution = scalingDistributions[dist]; + + if (!scaleDistribution || !(stat >= 0 && stat <= 9)) { + result.v = scaleValue[factor]; + } + else { + result.n = $WH.g_statToJson[scaleDistribution[stat]]; + result.s = scaleDistribution[stat]; + result.v = Math.floor(scaleValue[factor] * scaleDistribution[stat + 10] / 10000.0); } - if (e) { - a = a.replace(/.*?<\/span><\/span>/i, function (f, g) { - return '' + f + "" - }); - a = a.replace(/\(([^\)]*?[^\(]*?)\)/gi, function (g, f) { - return '(' + f + ")" - }) - } - return a -}; -$WH.g_staticTooltipLevelClick = function (g, f) { - while (g.className.indexOf("tooltip") == -1) { - g = g.parentNode - } - var c = g.innerHTML; - c = c.match(//); + if (!_) { + return tooltip; // Error + } + _ = _[1].split(':'); + + var + level = Math.min(parseInt(_[2]), Math.max(parseInt(_[1]), level)), + scaDist = parseInt(_[4]) || 0; + + // Update the tooltip + if (scaDist) { + if (!tooltip.match(//g)) { // Not a spell + var + scaFlags = parseInt(_[5]) || 0, + speed = tooltip.match(/(\d\.\d+)/); + + if (speed) { + speed = parseFloat(speed[1]) || 0; + } + + var json = { + scadist: scaDist, + scaflags: scaFlags, + speed: speed + }; + + $WH.g_setJsonItemLevel(json, level); + + // Update armor type based on level + tooltip = tooltip.replace(/()([^<]+)/, function(_all, prefix, armorType) { + _ = armorType; + + if (level < 40 && (armorType == 3 || armorType == 4)) { + --_; + } + + // Always keep the base armor type + return prefix + g_itemset_types[_]; + }); + + // Update min-max damage + tooltip = tooltip.replace(/()\d+(\D+)\d+/, function(_all, prefix, infix) { + return prefix + json.dmgmin + infix + json.dmgmax; + }); + + // Update dps + tooltip = tooltip.replace(/(\D*?)(\d+\.\d)/, function(_all, prefix) { + return prefix + json.dps.toFixed(1); + }); + + // Update fap + tooltip = tooltip.replace(/(\D*?)(\d+)(\D*?)<\/span>(
)?/i, function(_all, prefix, value, statText, br) { + var style; + value = Math.floor((json.dps - 54.8) * 14); + if (json.dps > 54.8 && value > 0) { + style = ''; + br = (br ? '
': ''); + } + else { + value = 0; + style = ' style="display: none"'; + br = (br ? '': ''); + } + return '' + prefix + value + statText + '' + br; + }); + + // Update armor + tooltip = tooltip.replace(/()\d+/, function(_all, prefix) { + return prefix + json.armor; + }); + + // Stats + tooltip = tooltip.replace(/[-+]\d+(\D*?)<\/span>()?()?(
)?/gi, function(_all, statId, statText, e, ps, br) { + var + style, + value = json.bonuses[statId]; + + if (value) { + value = (value > 0 ? '+': '-') + value; + style = ''; + br = (br ? '
': ''); + } + else { + value = '+0'; + style = ' style="display: none"'; + br = (br ? '': ''); + } + + return '' + value + statText + '
' + (e || '') + (ps || '') + br; + }); + + // Ratings + tooltip = tooltip.replace(/(.*?)\d+(.*?)<\/span>(
)?/gi, function(_all, prefix, ratingId, suffix, e, ps, br) { + var + style, + value = json.bonuses[$WH.g_individualToGlobalStat[ratingId] || ratingId]; + + if (value) { + style = ''; + br = (br ? '
': ''); + } + else { + style = ' style="display: none"'; + br = (br ? '': ''); + } + + return '' + prefix + '' + value + suffix + '' + br; + }); + } + else { + var json = { + scadist: scaDist + }; + + $WH.g_setJsonSpellLevel(json, level); + // just check for known spells + } + } + + // Points per level + tooltip = tooltip.replace(/\s*\d+/gi, function(_all, minLvl, maxLvl, base, ppl) { + return '' + Math.round(parseInt(base) + (Math.min(Math.max(level, minLvl), maxLvl) - minLvl) * ppl / 100); + }); + + // Rating to percent + tooltip = tooltip.replace(/()([\.0-9]+)/g, function(_all, prefix, ratingId, percent) { + _ = tooltip.match(new RegExp('(\\d+)')); + if (!_) { + return _all; + } + + return prefix + Math.round($WH.g_convertRatingToPercent(level, ratingId, _[1]) * 100) / 100; + }); + + // Level + tooltip = tooltip.replace(/()/, '$1' + level + '$2'); + tooltip = tooltip.replace(/\d+/g, '' + level); + + return tooltip; +} + +$WH.g_setTooltipSpells = function(tooltip, spells, spellData, position) { + var + known = {}, + regex = '.+?', + effects; + + if (spells == null) { + spells = []; + } + + if (position == null) { + position = {}; + } + + for (var i = 0; i < spells.length; ++i) { + known[spells[i]] = 1; + } + + if (effects = tooltip.match(new RegExp(regex, 'g'))) { + for (var i = 0; i < effects.length; ++i) { + var spellId = effects[i].match(regex)[1]; + + known[spellId] = (known[spellId] | 0); + + if (position[spellId] == null) { + position[spellId] = -1; + } + + position[spellId]++; + + if (spellData[spellId] == null || spellData[spellId][position[spellId]] == null || spellData[spellId][position[spellId]][known[spellId]] == null) { + continue; + } + + var effect = spellData[spellId][position[spellId]][known[spellId]]; + effect = $WH.g_setTooltipSpells(effect, spells, spellData, position); + + tooltip = tooltip.replace(effects[i], '' + effect + ''); + } + } + + return tooltip; +} + +$WH.g_enhanceTooltip = function(tooltip, isStatic, useGets, showSlider, buff, knownSpells, chooseSpells) { + var _ = typeof tooltip, spellJson; + if (_ == 'number') { + var + arr = $WH.g_getDataSource(), + id = tooltip; + + if (arr[id] && arr[id][(buff ? 'buff_' : 'tooltip_') + g_locale.name]) { + tooltip = arr[id][(buff ? 'buff_' : 'tooltip_') + g_locale.name]; + spellJson = arr[id][(buff ? 'buff' : '') + 'spells_' + g_locale.name]; + + if (spellJson) { + tooltip = $WH.g_setTooltipSpells(tooltip, knownSpells, spellJson); + } + } + else { + return tooltip; // Error + } + } + else if (_ != 'string') { + return tooltip; // Error + } + + if (useGets) { + var get = $WH.g_getGets(); + if (get.lvl) { + tooltip = $WH.g_setTooltipLevel(tooltip, get.lvl, buff); + } + } + + if (isStatic) { + // Additional armor + tooltip = tooltip.replace(/.*?<\/span><\/span>/i, function(_all, addArmor) { + return '' + _all + ''; + }); + + // Add links (scaling items and ratings) + tooltip = tooltip.replace(/\(([^\)]*?[^\(]*?)\)/gi, function(_all, inner) { + return '(' + inner + ')'; + }); + } + + if (showSlider && Slider) { // Make sure the class exists + if (buff && buff.slider) { + buff.bufftip = this; + } + else { + // Retrieve tooltip's global information + var _ = tooltip.match(//); - if (!d) { - return a - } - var b = d[2] || 0, - c = d[3] || 0; - if (b && c) { - var f = a.match(/(\d\.\d+)/); - if (f) { - f = Math.floor(parseFloat(f[1]) * 1000) - } - var e = { - scadist: b, - scaflags: c, - speed: f || 0 - }; - g_setJsonItemLevel(e, g); - a = a.replace(/()([^<]+)/, function(j, h, i) { - d = i; - if (g < 40 && (i == 3 || i == 4)) {--d - } - return h + g_itemset_types[d] - }); - a = a.replace(/()\d+(\D+)\d+/, function(j, h, i) { - return h + e.dmgmin + i + e.dmgmax - }); - a = a.replace(/(\D*?)(\d+\.\d)/, function(i, h) { - return h + e.dps.toFixed(1) - }); - a = a.replace(/(\D*?)(\d+)(\D*?)<\/span>(
)?/i, function(l, h, i, m, j) { - var k; - i = Math.floor((e.dps - 54.8) * 14); - if (e.dps > 54.8 && i > 0) { - k = ""; - j = (j ? "
": "") - } else { - i = 0; - k = ' style="display: none"'; - j = (j ? "": "") - } - return '" + h + i + m + "" + j - }); - a = a.replace(/()\d+/, function(i, h) { - return h + e.armor - }); - a = a.replace(/[-+]\d+(\D*?)<\/span>()?()?(
)?/gi, function(l, i, h, o, p, j) { - var k, m = e.bonuses[i]; - if (m) { - m = (m > 0 ? "+": "-") + m; - k = ""; - j = (j ? "
": "") - } else { - m = "+0"; - k = ' style="display: none"'; - j = (j ? "": "") - } - return "" + m + h + "
" + (o || "") + (p || "") + j - }); - a = a.replace(/(.*?)\d+(.*?)<\/span>(
)?/gi, function(h, k, m, p, l, i, q) { - var j, o = e.bonuses[m]; - if (o) { - j = ""; - q = (q ? "
": "") - } else { - j = ' style="display: none"'; - q = (q ? "": "") - } - return '" + k + "" + o + p + "" + q - }) - } - a = a.replace(/()([\.0-9]+)/g, function(j, h, k, i) { - d = a.match(new RegExp("(\\d+)")); - if (!d) { - return j - } - return h + Math.round(g_convertRatingToPercent(g, k, d[1]) * 100) / 100 - }); - a = a.replace(/()/, "$1" + g + "$2"); - a = a.replace(/\d+/g, "" + g); - return a -} -function g_enhanceTooltip(a, c) { - var b = typeof a; - if (b == "number") { - if ($WH.isset("g_items") && g_items[a] && g_items[a]["tooltip_" + g_locale.name]) { - a = g_items[a]["tooltip_" + g_locale.name] - } else { - return a - } - } else { - if (b != "string") { - return a - } - } - if (c) { - a = a.replace(/.*?<\/span><\/span>/i, function(d, e) { - return '' + d + "" - }); - a = a.replace(/\(([^\)]*?[^\(]*?)\)/gi, function(e, d) { - return '(' + d + ")" - }) - } - return a -} - -function g_staticTooltipLevelClick(div, level) { - while (div.className.indexOf('tooltip') == -1) { - div = div.parentNode; - } - - var _ = div.innerHTML; - - // Retrieve tooltip's global information - _ = _.match(/