Advertisement
krames12

warcraft progression sorting with warcraftLogs report id's

Sep 27th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // overall sorting and filtering of data
  2. function sortParsedData(data) {
  3.   // sorting out character info and progress info
  4.   var sortData = {
  5.     name: data[0].name,
  6.     class: classIdentity(data[0].class),
  7.     realm: data[0].realm,
  8.     itemLevel: data[0].items.averageItemLevel,
  9.     progress: data[0].progression.raids
  10.       .filter((item, index) => {
  11.         if(item.name == "The Emerald Nightmare") {
  12.           return item;
  13.         }
  14.       })
  15.       .map((item, index) => {
  16.         return {
  17.           name: item.name,
  18.           bosses: item.bosses.map((item, index) => {
  19.             return {
  20.               name: item.name,
  21.               bossId: wclBossId(item.name),
  22.               lfrKills: item.lfrKills,
  23.               normalKills: item.normalKills,
  24.               heroicKills: item.heroicKills,
  25.               mythicKills: item.mythicKills,
  26.               warcraftLogs: false
  27.             }
  28.           }),
  29.           totalBosses: bossTotal(item.bosses),
  30.           lfrProgress: difficultyProgress("lfr", item),
  31.           normalProgress: difficultyProgress("normal", item),
  32.           heroicProgress: difficultyProgress("heroic", item),
  33.           mythicProgress: difficultyProgress("mythic", item)
  34.         };
  35.       })
  36.   };
  37.  
  38.   sortData.progress[0].bosses.map((item, index) => {
  39.     var difficulty = 2;
  40.  
  41.     if(item.mythicKills > 0) {
  42.       difficulty = 5;
  43.     } else if(item.heroicKills > 0) {
  44.       difficulty = 4;
  45.     } else if(item.normalKills > 0) {
  46.       difficulty = 3;
  47.     }
  48.  
  49.     var updatedData;
  50.  
  51.     for(var p = 0; p < data[1].length; p++) {
  52.       console.log('log item difficulty', data[1][p].difficulty);
  53.       if (item.bossId == data[1][p].encounter && difficulty == data[1][p].difficulty) {
  54.         console.log(item.name, '!!!');
  55.         var reportUrl = "https://www.warcraftlogs.com/report/" + data[1][p].reportID;
  56.         updatedData = {
  57.           name: item.name,
  58.           bossId: wclBossId(item.name),
  59.           lfrKills: item.lfrKills,
  60.           normalKills: item.normalKills,
  61.           heroicKills: item.heroicKills,
  62.           mythicKills: item.mythicKills,
  63.           warcraftLogs: true,
  64.           reportUrl: reportUrl,
  65.           precentile: calculatePercentile(data[1][p].rank, data[1][p].outOf)
  66.         };
  67.       } else {
  68.         console.log('nope!!!');
  69.         updatedData = {
  70.           name: item.name,
  71.           bossId: wclBossId(item.name),
  72.           lfrKills: item.lfrKills,
  73.           normalKills: item.normalKills,
  74.           heroicKills: item.heroicKills,
  75.           mythicKills: item.mythicKills,
  76.           warcraftLogs: false
  77.         };
  78.       }
  79.     }
  80.  
  81.     return updatedData;
  82.  
  83.   });
  84.  
  85.   console.log('sortData', sortData.progress[0].bosses[0]);
  86.   return sortData;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement