function skill_replace($reg) { global $gwbbcode_tpl; $gwbbcode_root_path = GWBBCODE_ROOT; $gwbbcode_img_path = GWBBCODE_IMG_PATH; list($all, $att, $name) = $reg; $att = html_safe_decode($att); $name = html_safe_decode($name); //Handle specified db $db_suffix = ''; if (preg_match('/db=([^\\] ]*)/', $att, $reg)) { $db_suffix = preg_replace('@[\\] <>/\\":*?|]@', '', $reg[1]); //Play it safe $att = preg_replace('/[ ]*db=[^\\] ]*/', '', $att); } //Handle alternative text $shown_name = $name; if (preg_match('/show="([^\\]]*)"/', $att, $reg)) { $shown_name = html_safe_decode($reg[1]); //Play it safe $att = preg_replace('/[ ]*db="[^\\]]*"/', '', $att); } //Exit if skill doesn't exist if (($id = gws_skill_id($name)) === false) { return $all; } //else $details = gws_details($id, $db_suffix); if ($details === false) { die("Missing skill. Id={$id}; Name={$name}"); } //Handle faction-less skills if ($details['attr'] == 'kur' && strpos($name, '(') === false) { //By default, unaligned skills are kurzick //Change to default allegiance if (strtolower(GWBBCODE_ALLEGIANCE) !== 'kurzick') { $id = gws_skill_id($name . ' (luxon)'); $details = gws_details($id, $db_suffix); } } extract($details, EXTR_OVERWRITE); $load = rand(); //Blank skill slot if ($name == 'No Skill') { $tpl = $gwbbcode_tpl['blank_icon']; } else { //Get the skill attribute level $attr_list = attribute_list($att); $attr_value = isset($attr_list[$attribute]) ? $attr_list[$attribute] : ''; //Skill name or image on which to move cursor if (gws_noicon($att)) { if (GWSHACK) { $tpl = $gwbbcode_tpl['noicon_gwshack']; } else { $tpl = $gwbbcode_tpl['noicon']; } } else { $name_link = str_replace("\"", """, $name); $name_link = str_replace(" (Kurzick)", "", $name_link); $name_link = str_replace(" (Luxon)", "", $name_link); $tpl = $gwbbcode_tpl['icon']; } $tpl .= $gwbbcode_tpl['skill']; //What adrenaline/energy/energyregen is required? $required = array(); if ($recharge != 0) { $required[] = infuse_values($gwbbcode_tpl['requirement'], array('type' => 'rech', 'value' => $recharge)); } //Format casting time if ($casting != 0) { switch ($casting) { case 0.25: $casting_frac = '¼'; break; case 0.5: $casting_frac = '½'; break; case 0.75: $casting_frac = '¾'; break; default: $casting_frac = $casting; } //Handle fast casting $fast_casting = calc_fastcasting($attr_list, $type, $casting); if ($fast_casting && $fast_casting != $casting) { $fast_casting = sprintf('%.1f', $fast_casting); $casting_html = infuse_values($gwbbcode_tpl['modified_requirement_value'], array('initial_value' => $casting_frac, 'modified_value' => $fast_casting)); } else { $casting_html = $casting_frac; } $required[] = infuse_values($gwbbcode_tpl['requirement'], array('type' => 'cast', 'value' => $casting_html)); } //Format energy, adrenaline and upkeep if ($adrenaline != 0) { $required[] = infuse_values($gwbbcode_tpl['requirement'], array('type' => 'adre', 'value' => $adrenaline)); //Handle leadership $leader_energy = calc_leadership($name, $attr_list, $type, 0, $pve_only); if ($leader_energy) { $energy_html = infuse_values($gwbbcode_tpl['modified_requirement_value'], array('initial_value' => '', 'modified_value' => $leader_energy)); $required[] = infuse_values($gwbbcode_tpl['requirement'], array('type' => 'ener', 'value' => $energy_html)); } else { $energy_html = $energy; } } else { if ($energy != 0) { //Handle expertise $expert_energy = calc_expertise($name, $attr_list, $type, $energy, $profession, $desc); if ($expert_energy && $expert_energy != $energy) { $energy_html = infuse_values($gwbbcode_tpl['modified_requirement_value'], array('initial_value' => $energy, 'modified_value' => $expert_energy)); } else { $leader_energy = calc_leadership($name, $attr_list, $type, $energy, $pve_only); if ($leader_energy) { $energy_html = infuse_values($gwbbcode_tpl['modified_requirement_value'], array('initial_value' => $energy, 'modified_value' => $energy)); } else { $energy_html = $energy; } } $required[] = infuse_values($gwbbcode_tpl['requirement'], array('type' => 'ener', 'value' => $energy_html)); } } if ($eregen != 0) { $required[] = infuse_values($gwbbcode_tpl['requirement'], array('type' => 'eregen', 'value' => -$eregen)); } $required = implode('', $required); //Campaign names $campaign_names = array('Core', 'Prophecies', 'Factions', 'Nightfall', 'EotN'); if (isset($campaign_names[$chapter])) { $chapter = $campaign_names[$chapter]; } //PvE only $pve_only = $pve_only ? '<br/>PvE only' : ''; //Descriptions variables -> green and adapted to their attribute. (0..12..16 -> green 8) $extra_desc = ''; gws_adapt_description($desc, $extra_desc, $name, $attribute, $attr_list, $type, $pve_only); $attr_html = $attribute == 'No Attribute' ? $gwbbcode_tpl['tpl_skill_no_attr'] : $gwbbcode_tpl['tpl_skill_attr']; $extra_desc = empty($extra_desc) ? '' : infuse_values($gwbbcode_tpl['tpl_extra_desc'], array('extra_desc' => $extra_desc)); $desc_len = strlen($desc) / 2.5 + 340; //Change the skill aspect if skill is elite if (isset($elite) && $elite) { $elite_or_normal = 'elite_skill'; $type = 'Elite ' . $type; } else { $elite_or_normal = 'normal_skill'; } //Profession icon if ($prof == '?') { $prof_img = "{$gwbbcode_img_path}/img_interface/void2.gif"; } else { $prof_img = "{$gwbbcode_img_path}/img_interface/{$profession}.gif"; } } //Replace all "{var_name}" by $var_name till there is none to replace (i.e a tag replacement can contain other tags) do { $prev_tpl = $tpl; $tpl = preg_replace("#\\{\\{(.*?)\\}\\}#ise", "isset(\$gwbbcode_tpl['\\1'])?\$gwbbcode_tpl['\\1']:'\\0'", $tpl); //"{{skill_description}}" is replaced by $gwbbcode_tpl['skill_description'] $tpl = preg_replace("#\\{(.*?)\\}#ise", "isset(\$\\1)?\$\\1:'\\0'", $tpl); //"{desc}" is replaced by $desc } while ($prev_tpl != $tpl); //Adds a space entity if the skill tag is followed by a space //Necessary cause IE doesn't show spaces following divs if ($all[strlen($all) - 1] === ' ') { $tpl .= ' '; } return $tpl; }
function skill_replace($reg) { global $gwbbcode_tpl; $gwbbcode_root_path = GWBBCODE_ROOT; list($all, $att, $name) = $reg; $att = html_safe_decode($att); $name = html_safe_decode($name); //Exit if skill doesn't exist if (($id = gws_skill_id($name)) === false) { return $all; } //else $details = gws_details($id); if ($details === false) { die("Missing skill {$id}."); } extract($details, EXTR_OVERWRITE); $load = rand(); //Blank skill slot if ($name == 'No Skill') { $skill = $gwbbcode_tpl['blank_icon']; } else { //Skill name or image on which to move cursor if (gws_noicon($att)) { if (GWSHACK) { $skill = $gwbbcode_tpl['noicon_gwshack']; } else { $skill = $gwbbcode_tpl['noicon']; } } else { $name = str_replace("\"", """, $name); $skill = $gwbbcode_tpl['icon']; } $skill .= $gwbbcode_tpl['skill']; //What adrenaline/energy/energyregen is required? $required = array(); $img_html = '<div class="bbcode_att_box"><span class="bbcode_att_span">%s</span><img src="http://images.pvxbuilds.com/att_%s.png" /></div>'; if ($recharge != 0) { $required[] = sprintf($img_html, $recharge, 'rech'); } //Format casting time if ($casting != 0) { $fastcast = calc_fastcasting($att, $type, $casting); switch ($casting) { case 0.25: $casting_frac = '¼'; break; case 0.5: $casting_frac = '½'; break; case 0.75: $casting_frac = '¾'; break; default: $casting_frac = $casting; } if ($fastcast && $fastcast != $casting) { $casting_frac .= '<span class="bbcode_expert">[' . sprintf('%.2f', $fastcast) . ']</span>'; } $casting = $casting_frac; $required[] = sprintf($img_html, $casting, 'cast'); } //Format energy, adrenaline and upkeep if ($adrenaline != 0) { $required[] = sprintf($img_html, $adrenaline, 'adre'); } else { if ($energy != 0) { $ex_energy = calc_expertise($att, $type, $energy, $profession, $desc); if ($ex_energy && $ex_energy != $energy) { $energy .= '<span class="bbcode_expert">[' . $ex_energy . ']</span>'; } $required[] = sprintf($img_html, $energy, 'ener'); } } if ($eregen != 0) { $required[] = sprintf($img_html, -$eregen, 'eregen'); } $required = implode(array_reverse($required)); //Have a nice golden background if skill is elite if (isset($elite) && $elite) { $elite_background = 'bbcode_name_elite'; $type = 'Elite ' . $type; } else { $elite_background = 'bbcode_name_normal'; $yellow_elite = ''; } //Campaign names switch ($chapter) { case 0: $chapter = "Core"; break; case 1: $chapter = "Prophecies"; break; case 2: $chapter = "Factions"; break; case 3: $chapter = "Nightfall"; break; } //Descriptions variables -> green and adapted to their attribute. (1..16 -> green 8) $desc = gws_adapt_description($name, $attribute, $att, $desc); $block_size = strlen($desc) * 1.33; if ($block_size < 280) { $block_size = 295; } //Profession icon if ($prof == '?') { $prof_img = "http://images.pvxbuilds.com/img_interface/No-Profession.png"; } else { $prof_img = "http://images.pvxbuilds.com/img_interface/{$profession}.png"; } //TODO: No profession img } $skill = preg_replace("#\\{(.*?)\\}#ise", "isset(\$\\1)?\$\\1:'\\0'", $skill); //Adds a space entity if the skill tag is followed by a space //Necessary cause IE doesn't show spaces following divs if ($all[strlen($all) - 1] === ' ') { $skill .= ' '; } return $skill; }