Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //removes curly braces in ability text
- function placeHeroInformation(heroObject){
- //setup
- var heroAbilities = heroObject.abilities;
- var replacerString;
- //API MAP
- //.name
- //.description
- //.maxLevel
- //.modifiersByLevel[0-3].damage / .cooldown /
- for(var i = 1; i < 5; i++){
- //find {tag} objects
- var matches = heroAbilities[i].description.match(/(\{\w+\})/g);
- var removeCurly = matches;
- //if there are {tag} objects
- if(matches != null){
- //print level specific information {tag}
- for (var x = 0; x < matches.length; x++){
- var noCurly = matches[x].substr(1).slice(0, -1);
- //create strings to replace tag
- if(heroAbilities[i].maxLevel == 4){
- replacerString = "(" + heroAbilities[i].modifiersByLevel[0][noCurly] + '/' + heroAbilities[i].modifiersByLevel[1][noCurly] + '/' + heroAbilities[i].modifiersByLevel[2][noCurly] + '/' + heroAbilities[i].modifiersByLevel[3][noCurly] + ')';
- }else{
- replacerString = "(" + heroAbilities[i].modifiersByLevel[0][noCurly] + '/' + heroAbilities[i].modifiersByLevel[1][noCurly] + '/' + heroAbilities[i].modifiersByLevel[2][noCurly] + ')';
- }
- if(noCurly == 'damage'){
- replacerString += '(+' + heroAbilities[i].modifiersByLevel[0].attackratingcoefficient * 100 + "% Power)";;
- }
- //replace in description
- var reg = new RegExp(matches[x], "g");
- heroAbilities[i].description = heroAbilities[i].description.replace(reg,replacerString);
- }
- }
- //replace entags
- if(heroAbilities[i].description.includes("{attr:endmg}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:endmg}/g, "Ability Damage");
- }
- //replace phystags
- if(heroAbilities[i].description.includes("{attr:physmg}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:physmg}/g, "Basic Damage");
- }
- //replace spd tags
- if(heroAbilities[i].description.includes("{attr:spd}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:spd}/g, "speed");
- }
- //replace mp tags
- if(heroAbilities[i].description.includes("{attr:mp}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:mp}/g, "mana");
- }
- //replace slow tags
- if(heroAbilities[i].description.includes("{status:slow}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{status:slow}/g, "slow");
- }
- //replace stun tags
- if(heroAbilities[i].description.includes("{status:stun}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{status:stun}/g, "stun");
- }
- //replace silence tags
- if(heroAbilities[i].description.includes("{status:slnc}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{status:slnc}/g, "slience");
- }
- //replace ability armor tags
- if(heroAbilities[i].description.includes("{attr:enar}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:enar}/g, "Ability Armor");
- }
- //replace basic armor tags
- if(heroAbilities[i].description.includes("{attr:physar}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:physar}/g, "Basic Armor");
- }
- //replace physical penetration tags
- if(heroAbilities[i].description.includes("{attr:physpen}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:physpen}/g, "Basic Armor Penetration");
- }
- //replace ability penetration tags
- if(heroAbilities[i].description.includes("{attr:enpen}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:enpen}/g, "Ability Armor Penetration");
- }
- //health tags
- if(heroAbilities[i].description.includes("{attr:hp}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:hp}/g, "Health");
- }
- //health tags
- if(heroAbilities[i].description.includes("{attr:physdmg}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:physdmg}/g, "Basic Damage");
- }
- //dmg bonus
- if(heroAbilities[i].description.includes("{attr:dmgbns}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:dmgbns}/g, "Bonus Damage");
- }
- //hpreg
- if(heroAbilities[i].description.includes("{attr:hpreg}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:hpreg}/g, "Health Regen");
- }
- //shadow plane
- if(heroAbilities[i].description.includes("{status:shadowplane}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{status:shadowplane}/g, "Shadow Plane");
- }
- //shield
- if(heroAbilities[i].description.includes("{attr:shld}")){
- heroAbilities[i].description = heroAbilities[i].description.replace(/{attr:shld}/g, "Shield");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement