Требование: PHP => 5.3, часть 2
[cswow.git] / module / armory / show_char_skill.php
blob846bc0abaf2e978512ae0e8a21c470abcea50672
1 <?php
2 //==============================================================================
3 // Скрипт предназначен для вывода скилов игрока
4 //==============================================================================
6 function getCharacterSkills($guid_id)
8 global $cDB;
9 return $cDB->select("-- CACHE: 1h
10 SELECT * FROM `character_skills` WHERE `guid` = ?d", $guid_id);
13 function showPlayerSkills($guid)
15 global $wDB, $lang;
16 $skill_category = $wDB->select('-- CACHE: 1h
17 SELECT `id` AS ARRAY_KEY, `name`, `order` FROM `wowd_skill_line_category`');
18 $skill_rev = array();
19 // Помещаем данные о скилах в буфер для сотрировки их по классу
20 $playerSkill=array();
22 $skillcount = getCharacterSkills($guid);
23 if ($skillcount)
24 foreach ($skillcount as $guid)
26 $skillId = $guid['skill']; // skill id
27 if ($skillId == 0)
28 continue;
30 $skill = $guid['value']; // skill
31 $maxskill = $guid['max']; // max skill
33 $skillPerm = 0; // Баф с талантов (добавляется и к skill, и к maxSkill(занулил пока)
34 $skillTemp = 0; // Временный баф, влияет только на skill(занулил пока)
36 if ($skillLine = getSkillLine($skillId))
38 $skill = $skill + $skillPerm;
39 $maxskill = $maxskill + $skillPerm;
40 $category = $skillLine['Category'];
42 // Категория 12 скрыта
43 if ($category == 12)
44 continue;
45 $order = $skill_category[$category]['order'];
46 $skill_rev[$order] = $category;
47 $playerSkill[$order][] =
48 array('id'=>$skillId,
49 'Name'=>$skillLine['Name'],
50 'Category'=>$category,
51 'Description'=>$skillLine['Description'],
52 'icon'=>$skillLine['iconId'],
53 'Skill'=>$skill,
54 'maxSkill'=>$maxskill,
55 'bonus'=>$skillTemp);
58 if ($playerSkill)
60 ksort($playerSkill);
61 // Выводим данные в таблицу
62 echo '<table class=report cellSpacing=0 cellPadding=0><tbody>';
63 echo '<tr><td class=head colspan=3>'.$lang['player_skills'].'</td></tr>';
64 foreach($playerSkill as $id=>$skill_data)
66 $id = $skill_rev[$id];
67 echo '<tr><td class=skill_category colspan=3> '.$skill_category[$id]['name'].'</td></tr>';
68 foreach($skill_data as $skill)
70 if ($skill['Description']!='')
72 $tip = '<table class=skilltip><tr class=top><td>'.$skill['Name'].'</td></tr><tr><td>'.$skill['Description'].'</td></tr></table>';
73 echo '<tr '.addTooltip($tip,'BORDER, false, STICKY, false').'>';
75 else
76 echo '<tr>';
77 $pct = intval($skill['Skill']/$skill['maxSkill']*100);
78 $text = $skill['Skill'];
79 if ($skill['bonus'] > 0) $text.='<font class=posstat>+'.$skill['bonus'].'</font>';
80 else if ($skill['bonus'] < 0) $text.='<font class=negstat>'.$skill['bonus'].'</font>';
81 $text.=' / '.$skill['maxSkill'];
82 // $ico = '';
83 // if ($skill['icon'] > 1)
84 // $ico = '<img src='.getSpellIcon($skill['icon']).'>';
85 // echo '<td class=skill_ico>'.$ico.'</td>';
86 echo '<td class=skill_name><A href="?skill='.$skill['id'].'&guid='.$guid.'">'.$skill['Name'].'</td>';
87 echo '<td class=skill_bar><div class=skill_bar><b class=s1 style="width: '.$pct.'%;"></b><span>'.$text.'</span></div></td>';
88 echo '</tr>';
91 echo '</tbody></table>';