Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //removes curly braces in ability text
  2. function placeHeroInformation(heroObject){
  3.    
  4.     //setup
  5.     var heroAbilities = heroObject.abilities;
  6.     var replacerString;
  7.    
  8.     //API MAP
  9.     //.name
  10.     //.description
  11.     //.maxLevel
  12.     //.modifiersByLevel[0-3].damage / .cooldown /
  13.     for(var i = 1; i < 5; i++){
  14.        
  15.         //find {tag} objects
  16.         var matches = heroAbilities[i].description.match(/(\{\w+\})/g);
  17.         var removeCurly = matches;
  18.        
  19.         //if there are {tag} objects
  20.         if(matches != null){
  21.             //print level specific information {tag}
  22.             for (var x = 0; x < matches.length; x++){
  23.                 var noCurly = matches[x].substr(1).slice(0, -1);
  24.                 //create strings to replace tag
  25.                 if(heroAbilities[i].maxLevel == 4){
  26.                     replacerString = "(" + heroAbilities[i].modifiersByLevel[0][noCurly] + '/' + heroAbilities[i].modifiersByLevel[1][noCurly] + '/' + heroAbilities[i].modifiersByLevel[2][noCurly] + '/' + heroAbilities[i].modifiersByLevel[3][noCurly] + ')';
  27.                 }else{
  28.                     replacerString = "(" + heroAbilities[i].modifiersByLevel[0][noCurly] + '/' + heroAbilities[i].modifiersByLevel[1][noCurly] + '/' + heroAbilities[i].modifiersByLevel[2][noCurly] + ')';
  29.             }
  30.            
  31.             if(noCurly == 'damage'){
  32.                 replacerString += '(+' +  heroAbilities[i].modifiersByLevel[0].attackratingcoefficient * 100 + "% Power)";;
  33.             }
  34.            
  35.             //replace in description
  36.             var reg = new RegExp(matches[x], "g");
  37.             heroAbilities[i].description = heroAbilities[i].description.replace(reg,replacerString);   
  38.             }
  39.         }
  40.        
  41.         //replace entags
  42.         if(heroAbilities[i].description.includes("{attr:endmg}")){
  43.             heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:endmg}/g, "Ability Damage");
  44.                
  45.         }
  46.        
  47.         //replace phystags
  48.         if(heroAbilities[i].description.includes("{attr:physmg}")){
  49.             heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:physmg}/g, "Basic Damage");
  50.         }
  51.        
  52.         //replace spd tags
  53.         if(heroAbilities[i].description.includes("{attr:spd}")){
  54.             heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:spd}/g, "speed");
  55.                
  56.         }
  57.        
  58.         //replace mp tags
  59.         if(heroAbilities[i].description.includes("{attr:mp}")){
  60.             heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:mp}/g, "mana");
  61.                
  62.         }
  63.        
  64.         //replace slow tags
  65.         if(heroAbilities[i].description.includes("{status:slow}")){
  66.             heroAbilities[i].description = heroAbilities[i].description.replace(/{status:slow}/g, "slow");
  67.                
  68.         }
  69.        
  70.        
  71.         //replace stun tags
  72.         if(heroAbilities[i].description.includes("{status:stun}")){
  73.             heroAbilities[i].description = heroAbilities[i].description.replace(/{status:stun}/g, "stun");
  74.                
  75.         }
  76.        
  77.         //replace silence tags
  78.         if(heroAbilities[i].description.includes("{status:slnc}")){
  79.             heroAbilities[i].description = heroAbilities[i].description.replace(/{status:slnc}/g, "slience");
  80.                
  81.         }
  82.        
  83.         //replace ability armor tags
  84.         if(heroAbilities[i].description.includes("{attr:enar}")){
  85.             heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:enar}/g, "Ability Armor");
  86.                
  87.         }
  88.        
  89.         //replace basic armor tags
  90.         if(heroAbilities[i].description.includes("{attr:physar}")){
  91.             heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:physar}/g, "Basic Armor");
  92.                
  93.         }
  94.        
  95.         //replace physical penetration tags
  96.         if(heroAbilities[i].description.includes("{attr:physpen}")){
  97.             heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:physpen}/g, "Basic Armor Penetration");
  98.                
  99.         }
  100.        
  101.         //replace ability penetration tags
  102.         if(heroAbilities[i].description.includes("{attr:enpen}")){
  103.             heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:enpen}/g, "Ability Armor Penetration");
  104.                
  105.         }
  106.         //health tags
  107.         if(heroAbilities[i].description.includes("{attr:hp}")){
  108.             heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:hp}/g, "Health");
  109.                
  110.         }
  111.        
  112.         //health tags
  113.         if(heroAbilities[i].description.includes("{attr:physdmg}")){
  114.             heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:physdmg}/g, "Basic Damage");
  115.                
  116.         }
  117.        
  118.         //dmg bonus
  119.         if(heroAbilities[i].description.includes("{attr:dmgbns}")){
  120.             heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:dmgbns}/g, "Bonus Damage");
  121.                
  122.         }
  123.        
  124.         //hpreg
  125.         if(heroAbilities[i].description.includes("{attr:hpreg}")){
  126.             heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:hpreg}/g, "Health Regen");
  127.                
  128.         }
  129.        
  130.         //shadow plane
  131.         if(heroAbilities[i].description.includes("{status:shadowplane}")){
  132.             heroAbilities[i].description = heroAbilities[i].description.replace(/{status:shadowplane}/g, "Shadow Plane");
  133.                
  134.         }
  135.        
  136.        
  137.         //shield
  138.         if(heroAbilities[i].description.includes("{attr:shld}")){
  139.             heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:shld}/g, "Shield");
  140.                
  141.         }
  142.        
  143.        
  144.     }
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement