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 empty_tag($tag, $attribs = array()) { $attribs = attribute_list($attribs); return "<{$tag}{$attribs}/>"; }
function add_spirit_health($attr, $desc) { $list = attribute_list($attr); //Get Spirit's level if (preg_match('@Create a level <span class="variable">([0-9]+)</span> Spirit@', $desc, $reg)) { $spirit_level = $reg[1]; //Get Binding Ritual level $spawning_level = isset($list['Spawning Power']) ? $list['Spawning Power'] : 0; //Compute the Spirit's Health and armor $spirit_health = 50 + $spirit_level * 20; //Thanks to GuildWiki.org for this equation $spawning_bonus = ''; if ($spawning_level > 0) { $spawning_health = round($spirit_health * ($spawning_level * 0.04)); $spawning_bonus = ' (+' . $spawning_health . ')'; } $spirit_armor = round(88 / 15 * $spirit_level + 3); //Add Spirit's health to description $desc = preg_replace('@Create a level <span class="variable">[0-9]+</span> Spirit@', '${0} <span class="expert"> with ' . $spirit_health . $spawning_bonus . ' Health and ' . $spirit_armor . ' armor</span>', $desc); } return $desc; }