2 //==============================================================================
3 // Скрипт предназначен для вывода репутации игрока
4 //==============================================================================
6 // Сортируем по возрастанию
9 if (isset($a['childs']))
10 return isset($b['childs']) ?
strcmp($a['name'], $b['name']) : 1;
11 return !isset($b['childs']) ?
strcmp($a['name'], $b['name']) : -1;
14 define('FACTION_FLAG_VISIBLE', 0x01); // makes visible in client (set or can be set at interaction with target of this faction)
15 define('FACTION_FLAG_AT_WAR', 0x02); // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation
16 define('FACTION_FLAG_HIDDEN', 0x04); // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client)
17 define('FACTION_FLAG_INVISIBLE_FORCED', 0x08);// always overwrite FACTION_FLAG_VISIBLE and hide faction in rep.list, used for hide opposite team factions
18 define('FACTION_FLAG_PEACE_FORCED', 0x10); // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions
19 define('FACTION_FLAG_INACTIVE', 0x20); // player controlled, state
20 define('FACTION_FLAG_RIVAL', 0x40); // flag for the two competing outland factions
22 function dumpRep($depth, $tree, &$rep)
27 for ($i=0;$i<$depth;$i++
)
28 $pre.=' ';
30 uasort($tree, 'rcmp');
31 foreach($tree as $id=>$t)
35 $tip = '<table class=skilltip><tr class=top><td>'.$t['name'].'</td></tr><tr><td>'.$t['details'].'</td></tr></table>';
36 echo '<tr '.addTooltip($tip, 'STICKY, false, BORDER, false').'>';
40 if (isset($t['childs']))
42 echo '<td class=teamreputation colspan=3><a id="no_tip" href="?faction='.$t['id'].'">'.$pre.$t['name'].'</a></td></tr>';
43 dumpRep($depth+
1, $t['childs'], $rep);
47 $rep_data = getReputationDataFromReputation($rep[$id]['standing']);
48 echo '<td class=reputation><a id="no_tip" href="?faction='.$id.'">'.$pre.$t['name'].'</a></td>';
49 echo '<td class=rep_value>'.$rep_data['rank_name'].'</td>';
50 echo '<td class=rep_bar><div class=rep_bar><b class=rep'.$rep_data['rank'].' style="width: '.intval($rep_data['rep']/$rep_data['max']*100).'%;"></b><span>'.$rep_data['rep'].'/'.$rep_data['max'].'</span></div></td>';
56 function showPlayerReputation($guid, $class, $race)
58 global $lang, $game_text, $cDB;
59 // Load player reputation
62 $reputation = $cDB->select(
64 `faction` AS ARRAY_KEY,
67 FROM `character_reputation` WHERE `guid` = ?d", $guid);
73 // Load reputation tree
74 foreach($reputation as $id=>$r)
76 $rep=&$reputation[$id];
78 if (!($rep['flags']&FACTION_FLAG_VISIBLE
) OR $rep['flags']&(FACTION_FLAG_HIDDEN|FACTION_FLAG_INVISIBLE_FORCED
))
80 // Upload faction if not set
81 if (!isset($rep_tree[$id]))
82 $rep_tree[$id] = getFaction($id);
83 // Correct reputation amount
84 $rep['standing']+
= getBaseReputationForFaction($rep_tree[$id], $race, $class);
85 // Insert faction in tree if exist parent
86 while($tid = $rep_tree[$id]['team'])
88 // Load parent faction data if not loaded
89 if (!isset($rep_tree[$tid]))
90 $rep_tree[$tid] = getFaction($tid);
91 // Insert child if not inserted
92 if (!isset($rep_tree[$tid]['childs'][$id]))
93 $rep_tree[$tid]['childs'][$id] =& $rep_tree[$id];
97 // Remove inserted as childs nodes
98 foreach($rep_tree as $id=>$r)
100 unset($rep_tree[$id]);
102 if (empty($rep_tree))
107 echo '<table class=report cellSpacing=0 cellPadding=0><tbody>';
108 echo '<tr><td class=head colspan=3>'.$lang['player_reputation'].'</td></tr>';
109 dumpRep(0, $rep_tree, $reputation);
110 echo '</tbody></table>';