mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
Feature/better highscores (#141)
* Move highscores to twig * Add highscores frags for TFS 1.x * Change $config to config() * Cache highscores The most asked and long awaited feature? :> * Fix highscores_per_page and rename configurable * Fix next page link (some typo) * Fix too many players being shown * Fix when changing config.highscores_per_page * Update system/pages/highscores.php Co-authored-by: whiteblXK <krzys16001@gmail.com> Co-authored-by: whiteblXK <krzys16001@gmail.com>
This commit is contained in:
parent
5d5875d540
commit
cf2c5e36bc
@ -204,13 +204,14 @@ $config = array(
|
||||
// highscores page
|
||||
'highscores_vocation_box' => true, // show 'Choose a vocation' box on the highscores (allowing peoples to sort highscores by vocation)?
|
||||
'highscores_vocation' => true, // show player vocation under his nickname?
|
||||
'highscores_frags' => false, // show 'Frags' tab (best fraggers on the server)? Only 0.3
|
||||
'highscores_frags' => false, // show 'Frags' tab (best fraggers on the server)?
|
||||
'highscores_balance' => false, // show 'Balance' tab (richest players on the server)
|
||||
'highscores_outfit' => true, // show player outfit?
|
||||
'highscores_country_box' => false, // doesnt work yet! (not implemented)
|
||||
'highscores_groups_hidden' => 3, // this group id and higher won't be shown on the highscores
|
||||
'highscores_ids_hidden' => array(0), // this ids of players will be hidden on the highscores (should be ids of samples)
|
||||
'highscores_length' => 100, // how many records per page on highscores
|
||||
'highscores_per_page' => 100, // how many records per page on highscores
|
||||
'highscores_cache_ttl' => 15, // how often to update highscores from database in minutes (default 15 minutes)
|
||||
|
||||
// characters page
|
||||
'characters' => array( // what things to display on character view page (true/false in each option)
|
||||
|
@ -11,25 +11,30 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Highscores';
|
||||
|
||||
if($config['account_country'] && $config['highscores_country_box'])
|
||||
$configHighscoresCountryBox = config('highscores_country_box');
|
||||
if(config('account_country') && $configHighscoresCountryBox)
|
||||
require SYSTEM . 'countries.conf.php';
|
||||
|
||||
$list = isset($_GET['list']) ? $_GET['list'] : '';
|
||||
$_page = isset($_GET['page']) ? $_GET['page'] : 0;
|
||||
$vocation = isset($_GET['vocation']) ? $_GET['vocation'] : NULL;
|
||||
$vocation = isset($_GET['vocation']) ? $_GET['vocation'] : 'all';
|
||||
|
||||
$add_sql = '';
|
||||
$config_vocations = $config['vocations'];
|
||||
if($config['highscores_vocation_box'] && isset($vocation))
|
||||
|
||||
$configHighscoresVocationBox = config('highscores_vocation_box');
|
||||
$configVocations = config('vocations');
|
||||
$configVocationsAmount = config('vocations_amount');
|
||||
|
||||
if($configHighscoresVocationBox && $vocation !== 'all')
|
||||
{
|
||||
foreach($config['vocations'] as $id => $name) {
|
||||
foreach($configVocations as $id => $name) {
|
||||
if(strtolower($name) == $vocation) {
|
||||
$add_vocs = array($id);
|
||||
|
||||
$i = $id + $config['vocations_amount'];
|
||||
while(isset($config['vocations'][$i])) {
|
||||
$i = $id + $configVocationsAmount;
|
||||
while(isset($configVocations[$i])) {
|
||||
$add_vocs[] = $i;
|
||||
$i += $config['vocations_amount'];
|
||||
$i += $configVocationsAmount;
|
||||
}
|
||||
|
||||
$add_sql = 'AND `vocation` IN (' . implode(', ', $add_vocs) . ')';
|
||||
@ -45,7 +50,7 @@ $skill = POT::SKILL__LEVEL;
|
||||
if(is_numeric($list))
|
||||
{
|
||||
$list = (int) $list;
|
||||
if($list >= POT::SKILL_FIRST && $list <= SKILL__LAST)
|
||||
if($list >= POT::SKILL_FIRST && $list <= POT::SKILL__LAST)
|
||||
$skill = $list;
|
||||
}
|
||||
else
|
||||
@ -90,12 +95,12 @@ else
|
||||
break;
|
||||
|
||||
case 'frags':
|
||||
if($config['highscores_frags'] && $config['otserv_version'] == TFS_03)
|
||||
if(config('highscores_frags'))
|
||||
$skill = SKILL_FRAGS;
|
||||
break;
|
||||
|
||||
case 'balance':
|
||||
if($config['highscores_balance'])
|
||||
if(config('highscores_balance'))
|
||||
$skill = SKILL_BALANCE;
|
||||
break;
|
||||
}
|
||||
@ -115,7 +120,10 @@ if($db->hasColumn('players', 'deletion'))
|
||||
|
||||
$outfit_addons = false;
|
||||
$outfit = '';
|
||||
if($config['highscores_outfit']) {
|
||||
|
||||
$configHighscoresOutfit = config('highscores_outfit');
|
||||
|
||||
if($configHighscoresOutfit) {
|
||||
$outfit = ', lookbody, lookfeet, lookhead, looklegs, looktype';
|
||||
if($db->hasColumn('players', 'lookaddons')) {
|
||||
$outfit .= ', lookaddons';
|
||||
@ -123,82 +131,85 @@ if($config['highscores_outfit']) {
|
||||
}
|
||||
}
|
||||
|
||||
$offset = $_page * $config['highscores_length'];
|
||||
if($skill >= POT::SKILL_FIRST && $skill <= POT::SKILL_LAST) { // skills
|
||||
if($db->hasColumn('players', 'skill_fist')) {// tfs 1.0
|
||||
$skill_ids = array(
|
||||
POT::SKILL_FIST => 'skill_fist',
|
||||
POT::SKILL_CLUB => 'skill_club',
|
||||
POT::SKILL_SWORD => 'skill_sword',
|
||||
POT::SKILL_AXE => 'skill_axe',
|
||||
POT::SKILL_DIST => 'skill_dist',
|
||||
POT::SKILL_SHIELD => 'skill_shielding',
|
||||
POT::SKILL_FISH => 'skill_fishing',
|
||||
);
|
||||
$configHighscoresPerPage = config('highscores_per_page');
|
||||
$limit = $configHighscoresPerPage + 1;
|
||||
|
||||
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,vocation' . $promotion . $outfit . ', ' . $skill_ids[$skill] . ' as value FROM accounts,players WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden'].' '.$add_sql.' AND accounts.id = players.account_id ORDER BY ' . $skill_ids[$skill] . ' DESC LIMIT 101 OFFSET '.$offset)->fetchAll();
|
||||
}
|
||||
else
|
||||
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',value,level,vocation' . $promotion . $outfit . ' FROM accounts,players,player_skills WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden'].' '.$add_sql.' AND players.id = player_skills.player_id AND player_skills.skillid = '.$skill.' AND accounts.id = players.account_id ORDER BY value DESC, count DESC LIMIT 101 OFFSET '.$offset)->fetchAll();
|
||||
}
|
||||
else if($skill == SKILL_FRAGS && $config['otserv_version'] == TFS_03) // frags
|
||||
{
|
||||
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,vocation' . $promotion . $outfit . ',COUNT(`player_killers`.`player_id`) as value' .
|
||||
' FROM `accounts`, `players`, `player_killers` ' .
|
||||
' WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden'].' '.$add_sql.' AND players.id = player_killers.player_id AND accounts.id = players.account_id' .
|
||||
' GROUP BY `player_id`' .
|
||||
' ORDER BY value DESC' .
|
||||
' LIMIT 101 OFFSET '.$offset)->fetchAll();
|
||||
}
|
||||
else if($skill == SKILL_BALANCE) // balance
|
||||
{
|
||||
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,balance as value,vocation' . $promotion . $outfit . ' FROM accounts,players WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden'].' '.$add_sql.' AND accounts.id = players.account_id ORDER BY value DESC LIMIT 101 OFFSET '.$offset)->fetchAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
if($skill == POT::SKILL__MAGLEVEL) {
|
||||
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',maglevel,level,vocation' . $promotion . $outfit . ' FROM accounts, players WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 '.$add_sql.' AND players.group_id < '.$config['highscores_groups_hidden'].' AND accounts.id = players.account_id ORDER BY maglevel DESC, manaspent DESC LIMIT 101 OFFSET '.$offset)->fetchAll();
|
||||
}
|
||||
else { // level
|
||||
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,experience,vocation' . $promotion . $outfit . ' FROM accounts, players WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 '.$add_sql.' AND players.group_id < '.$config['highscores_groups_hidden'].' AND accounts.id = players.account_id ORDER BY level DESC, experience DESC LIMIT 101 OFFSET '.$offset)->fetchAll();
|
||||
$list = 'experience';
|
||||
$needReCache = true;
|
||||
$cacheKey = 'highscores_' . $skill . '_' . $vocation . '_' . $_page . '_' . $configHighscoresPerPage;
|
||||
|
||||
$cache = Cache::getInstance();
|
||||
if ($cache->enabled()) {
|
||||
$tmp = '';
|
||||
if ($cache->fetch($cacheKey, $tmp)) {
|
||||
$highscores = unserialize($tmp);
|
||||
$needReCache = false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td><img src="<?php echo $template_path; ?>/images/general/blank.gif" width="10" height="1" border="0"></td>
|
||||
<td>
|
||||
<div style="text-align:center"><h2>Ranking for <?php echo ($skill == SKILL_FRAGS ? 'Frags' : ($skill == SKILL_BALANCE ? 'Balance' : getSkillName($skill))); if(isset($vocation)) echo ' (' . $vocation . ')';?> on <?php echo $config['lua']['serverName']; ?></h2></div><br/>
|
||||
<table border="0" cellpadding="4" cellspacing="1" width="100%"></table>
|
||||
<table border="0" cellpadding="4" cellspacing="1" width="100%">
|
||||
<tr bgcolor="<?php echo $config['vdarkborder']; ?>">
|
||||
<?php if($config['account_country']): ?>
|
||||
<td width="11px" class="white">#</td>
|
||||
<?php endif; ?>
|
||||
<td width="10%" class="white"><b>Rank</b></td>
|
||||
<?php if($config['highscores_outfit']): ?>
|
||||
<td class="white"><b>Outfit</b></td>
|
||||
<?php endif; ?>
|
||||
<td width="75%" class="white"><b>Name</b></td>
|
||||
<td width="15%" class="white"><b><?php echo ($skill != SKILL_FRAGS && $skill != SKILL_BALANCE ? 'Level' : ($skill == SKILL_BALANCE ? 'Balance' : 'Frags')); ?></b></td>
|
||||
<?php if($skill == POT::SKILL__LEVEL): ?>
|
||||
<td class="white"><b>Points</b></td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<?php
|
||||
$offset = $_page * $configHighscoresPerPage;
|
||||
if (!isset($highscores) || empty($highscores)) {
|
||||
if ($skill >= POT::SKILL_FIRST && $skill <= POT::SKILL_LAST) { // skills
|
||||
if ($db->hasColumn('players', 'skill_fist')) {// tfs 1.0
|
||||
$skill_ids = array(
|
||||
POT::SKILL_FIST => 'skill_fist',
|
||||
POT::SKILL_CLUB => 'skill_club',
|
||||
POT::SKILL_SWORD => 'skill_sword',
|
||||
POT::SKILL_AXE => 'skill_axe',
|
||||
POT::SKILL_DIST => 'skill_dist',
|
||||
POT::SKILL_SHIELD => 'skill_shielding',
|
||||
POT::SKILL_FISH => 'skill_fishing',
|
||||
);
|
||||
|
||||
$show_link_to_next_page = false;
|
||||
$i = 0;
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,vocation' . $promotion . $outfit . ', ' . $skill_ids[$skill] . ' as value FROM accounts,players WHERE players.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 AND players.group_id < ' . config('highscores_groups_hidden') . ' ' . $add_sql . ' AND accounts.id = players.account_id ORDER BY ' . $skill_ids[$skill] . ' DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
} else
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',value,level,vocation' . $promotion . $outfit . ' FROM accounts,players,player_skills WHERE players.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 AND players.group_id < ' . config('highscores_groups_hidden') . ' ' . $add_sql . ' AND players.id = player_skills.player_id AND player_skills.skillid = ' . $skill . ' AND accounts.id = players.account_id ORDER BY value DESC, count DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
} else if ($skill == SKILL_FRAGS) // frags
|
||||
{
|
||||
if ($db->hasTable('player_killers')) {
|
||||
$highscores = $db->query('SELECT accounts.country, players.id, players.name' . $online . ',level, vocation' . $promotion . $outfit . ', COUNT(`player_killers`.`player_id`) as value' .
|
||||
' FROM `accounts`, `players`, `player_killers` ' .
|
||||
' WHERE players.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 AND players.group_id < ' . config('highscores_groups_hidden') . ' ' . $add_sql . ' AND players.id = player_killers.player_id AND accounts.id = players.account_id' .
|
||||
' GROUP BY `player_id`' .
|
||||
' ORDER BY value DESC' .
|
||||
' LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
} else {
|
||||
$db->query("SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));");
|
||||
|
||||
$highscores = $db->query('SELECT `a`.country, `p`.id, `p`.name' . $online . ',`p`.level, vocation' . $promotion . $outfit . ', COUNT(`pd`.`killed_by`) as value
|
||||
FROM `players` p
|
||||
LEFT JOIN `accounts` a ON `a`.`id` = `p`.`account_id`
|
||||
LEFT JOIN `player_deaths` pd ON `pd`.`killed_by` = `p`.`name`
|
||||
WHERE `p`.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ')
|
||||
AND `p`.' . $deleted . ' = 0
|
||||
AND `p`.group_id < ' . config('highscores_groups_hidden') . ' ' . $add_sql . '
|
||||
AND `pd`.`unjustified` = 1
|
||||
GROUP BY `killed_by`
|
||||
ORDER BY value DESC
|
||||
LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
}
|
||||
} else if ($skill == SKILL_BALANCE) // balance
|
||||
{
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,balance as value,vocation' . $promotion . $outfit . ' FROM accounts,players WHERE players.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 AND players.group_id < ' . config('highscores_groups_hidden') . ' ' . $add_sql . ' AND accounts.id = players.account_id ORDER BY value DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
} else {
|
||||
if ($skill == POT::SKILL__MAGLEVEL) {
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',maglevel,level,vocation' . $promotion . $outfit . ' FROM accounts, players WHERE players.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 ' . $add_sql . ' AND players.group_id < ' . config('highscores_groups_hidden') . ' AND accounts.id = players.account_id ORDER BY maglevel DESC, manaspent DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
} else { // level
|
||||
$highscores = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,experience,vocation' . $promotion . $outfit . ' FROM accounts, players WHERE players.id NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND players.' . $deleted . ' = 0 ' . $add_sql . ' AND players.group_id < ' . config('highscores_groups_hidden') . ' AND accounts.id = players.account_id ORDER BY level DESC, experience DESC LIMIT ' . $limit . ' OFFSET ' . $offset)->fetchAll();
|
||||
$list = 'experience';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($cache->enabled() && $needReCache) {
|
||||
$cache->set($cacheKey, serialize($highscores), config('highscores_cache_ttl') * 60);
|
||||
}
|
||||
|
||||
$online_exist = false;
|
||||
if($db->hasColumn('players', 'online'))
|
||||
$online_exist = true;
|
||||
|
||||
$players = array();
|
||||
foreach($skills as $player) {
|
||||
foreach($highscores as $player) {
|
||||
$players[] = $player['id'];
|
||||
}
|
||||
|
||||
@ -209,158 +220,105 @@ if($db->hasTable('players_online') && count($players) > 0) {
|
||||
}
|
||||
}
|
||||
|
||||
foreach($skills as $player)
|
||||
{
|
||||
if(isset($is_online)) {
|
||||
$player['online'] = (isset($is_online[$player['id']]) ? 1 : 0);
|
||||
} else {
|
||||
if(!isset($player['online'])) {
|
||||
$player['online'] = 0;
|
||||
}
|
||||
}
|
||||
$show_link_to_next_page = false;
|
||||
$i = 0;
|
||||
|
||||
if(++$i <= $config['highscores_length'])
|
||||
$configHighscoresVocation = config('highscores_vocation');
|
||||
|
||||
foreach($highscores as $id => &$player)
|
||||
{
|
||||
if(isset($is_online)) {
|
||||
$player['online'] = (isset($is_online[$player['id']]) ? 1 : 0);
|
||||
} else {
|
||||
if(!isset($player['online'])) {
|
||||
$player['online'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(++$i <= $configHighscoresPerPage)
|
||||
{
|
||||
if($skill == POT::SKILL__MAGIC)
|
||||
$player['value'] = $player['maglevel'];
|
||||
else if($skill == POT::SKILL__LEVEL)
|
||||
else if($skill == POT::SKILL__LEVEL) {
|
||||
$player['value'] = $player['level'];
|
||||
echo '
|
||||
<tr bgcolor="' . getStyle($i) . '">';
|
||||
if($config['account_country'])
|
||||
echo '<td>' . getFlagImage($player['country']) . '</td>';
|
||||
echo '
|
||||
<td>' . ($offset + $i) . '.</td>';
|
||||
if($config['highscores_outfit'])
|
||||
echo '<td><img style="position:absolute;margin-top:' . (in_array($player['looktype'], array(75, 266, 302)) ? '-15px;margin-left:5px' : '-45px;margin-left:-25px') . ';" src="' . $config['outfit_images_url'] . '?id=' . $player['looktype'] . ($outfit_addons ? '&addons=' . $player['lookaddons'] : '') . '&head=' . $player['lookhead'] . '&body=' . $player['lookbody'] . '&legs=' . $player['looklegs'] . '&feet=' . $player['lookfeet'] . '" alt="" /></td>';
|
||||
$player['experience'] = number_format($player['experience']);
|
||||
}
|
||||
|
||||
echo '
|
||||
<td>
|
||||
<a href="' . getPlayerLink($player['name'], false) . '">
|
||||
<span style="color: ' . ($player['online'] > 0 ? 'green' : 'red') . '">' . $player['name'] . '</span>
|
||||
</a>';
|
||||
if($config['highscores_vocation']) {
|
||||
if(isset($player['promotion'])) {
|
||||
if((int)$player['promotion'] > 0)
|
||||
$player['vocation'] += ($player['promotion'] * $config['vocations_amount']);
|
||||
}
|
||||
|
||||
$tmp = 'Unknown';
|
||||
if(isset($config['vocations'][$player['vocation']])) {
|
||||
$tmp = $config['vocations'][$player['vocation']];
|
||||
}
|
||||
echo '<br/><small>' . $tmp . '</small>';
|
||||
if($configHighscoresVocation) {
|
||||
if(isset($player['promotion'])) {
|
||||
if((int)$player['promotion'] > 0) {
|
||||
$player['vocation'] += ($player['promotion'] * $configVocationsAmount);
|
||||
}
|
||||
echo '
|
||||
</td>
|
||||
<td>
|
||||
<div style="text-align:center">'.$player['value'].'</div>
|
||||
</td>';
|
||||
}
|
||||
|
||||
if($skill == POT::SKILL__LEVEL)
|
||||
echo '<td><div style="text-align:center">' . number_format($player['experience']) . '</div></td>';
|
||||
$tmp = 'Unknown';
|
||||
if(isset($configVocations[$player['vocation']])) {
|
||||
$tmp = $configVocations[$player['vocation']];
|
||||
}
|
||||
|
||||
echo '</tr>';
|
||||
$player['vocation'] = $tmp;
|
||||
}
|
||||
|
||||
|
||||
$player['link'] = getPlayerLink($player['name'], false);
|
||||
$player['flag'] = getFlagImage($player['country']);
|
||||
if($configHighscoresOutfit) {
|
||||
$player['outfit'] = '<img style="position:absolute;margin-top:' . (in_array($player['looktype'], array(75, 266, 302)) ? '-15px;margin-left:5px' : '-45px;margin-left:-25px') . ';" src="' . config('outfit_images_url') . '?id=' . $player['looktype'] . ($outfit_addons ? '&addons=' . $player['lookaddons'] : '') . '&head=' . $player['lookhead'] . '&body=' . $player['lookbody'] . '&legs=' . $player['looklegs'] . '&feet=' . $player['lookfeet'] . '" alt="" />';
|
||||
}
|
||||
$player['rank'] = $offset + $i;
|
||||
}
|
||||
else
|
||||
else {
|
||||
unset($highscores[$id]);
|
||||
$show_link_to_next_page = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$i) {
|
||||
$extra = ($config['highscores_outfit'] ? 1 : 0);
|
||||
echo '<tr bgcolor="' . $config['darkborder'] . '"><td colspan="' . ($skill == POT::SKILL__LEVEL ? 5 + $extra : 4 + $extra) . '">No records yet.</td></tr>';
|
||||
$extra = ($configHighscoresOutfit ? 1 : 0);
|
||||
echo '<tr bgcolor="' . config('darkborder') . '"><td colspan="' . ($skill == POT::SKILL__LEVEL ? 5 + $extra : 4 + $extra) . '">No records yet.</td></tr>';
|
||||
}
|
||||
|
||||
?>
|
||||
</table>
|
||||
<table border="0" cellpadding="4" cellspacing="1" width="100%">
|
||||
<?php
|
||||
//link to previous page if actual page is not first
|
||||
if($_page > 0)
|
||||
echo '<TR><TD WIDTH=100% ALIGN=right VALIGN=bottom><A HREF="' . getLink('highscores') . '/' . $list . (isset($vocation) ? '/' . $vocation : '') . '/' . ($_page - 1) . '" CLASS="size_xxs">Previous Page</A></TD></TR>';
|
||||
$linkPreviousPage = '';
|
||||
if($_page > 0) {
|
||||
$linkPreviousPage = getLink('highscores') . '/' . $list . ($vocation !== 'all' ? '/' . $vocation : '') . '/' . ($_page - 1);
|
||||
}
|
||||
|
||||
//link to next page if any result will be on next page
|
||||
if($show_link_to_next_page)
|
||||
echo '<TR><TD WIDTH=100% ALIGN=right VALIGN=bottom><A HREF="' . getLink('highscores') . '/' . $list . (isset($vocation) ? '/' . $vocation : '') . '/' . ($_page + 1) . '" CLASS="size_xxs">Next Page</A></TD></TR>';
|
||||
|
||||
//end of page
|
||||
echo '</TABLE>
|
||||
</TD>
|
||||
<TD WIDTH=5%>
|
||||
<IMG SRC="'.$template_path.'/images/general/blank.gif" WIDTH=1 HEIGHT=1 BORDER=0></TD>
|
||||
<TD WIDTH=15% VALIGN=top ALIGN=right>';
|
||||
/*
|
||||
if($config['highscores_country_box'])
|
||||
{
|
||||
echo
|
||||
'<TABLE BORDER=0 width="100%" CELLPADDING=4 CELLSPACING=1>
|
||||
<TR BGCOLOR="' . $config['vdarkborder'] . '">
|
||||
<TD CLASS=white><B>Choose a country</B></TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="'.$config['lightborder'].'">
|
||||
<TD>
|
||||
<A HREF="?subtopic=highscores&list=' . $list . '" CLASS="size_xs">[ALL]</A><BR>';
|
||||
for($i = 1; $i < count($config_vocations); $i++)
|
||||
echo '<A HREF="?subtopic=highscores&list=' . $list . '&vocation=' . strtolower($config_vocations[$i]) . '" CLASS="size_xs">' . $config_vocations[$i] . '</A><BR>';
|
||||
echo '
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>';
|
||||
}*/
|
||||
|
||||
echo '
|
||||
<TABLE BORDER=0 width="100%" CELLPADDING=4 CELLSPACING=1>
|
||||
<TR BGCOLOR="'.$config['vdarkborder'].'">
|
||||
<TD CLASS=white><B>Choose a skill</B></TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="'.$config['lightborder'].'">
|
||||
<TD>';
|
||||
$types = array(
|
||||
'experience' => 'Experience',
|
||||
'magic' => 'Magic',
|
||||
'shield' => 'Shielding',
|
||||
'distance' => 'Distance',
|
||||
'club' => 'Club',
|
||||
'sword' => 'Sword',
|
||||
'axe' => 'Axe',
|
||||
'fist' => 'Fist',
|
||||
'fishing' => 'Fishing',
|
||||
);
|
||||
|
||||
if($config['highscores_frags']) {
|
||||
$types['frags'] = 'Frags';
|
||||
}
|
||||
if(isset($config['highscores_balance']) && $config['highscores_balance'])
|
||||
$types['balance'] = 'Balance';
|
||||
|
||||
foreach($types as $link => $name) {
|
||||
echo '<A HREF="' . getLink('highscores') . '/' . $link . (isset($vocation) ? '/' . $vocation : '') . '" CLASS="size_xs">' . $name . '</A><BR>';
|
||||
}
|
||||
|
||||
echo '</td>
|
||||
</tr>
|
||||
</table><br>';
|
||||
|
||||
if($config['highscores_vocation_box'])
|
||||
{
|
||||
echo
|
||||
'<table border="0" width="100%" cellpadding="4" cellspacing="1">
|
||||
<tr bgcolor="' . $config['vdarkborder'] . '">
|
||||
<td class="white"><b>Choose a vocation</b></td>
|
||||
</tr>
|
||||
<tr bgcolor="'.$config['lightborder'].'">
|
||||
<td>
|
||||
<a href="' . getLink('highscores') . '/' . $list . '" class="size_xs">[ALL]</A><BR>';
|
||||
for($i = 1; $i <= $config['vocations_amount']; $i++) {
|
||||
echo '<a href="' . getLink('highscores') . '/' . $list . '/' . strtolower($config_vocations[$i]) . '" class="size_xs">' . $config_vocations[$i] . '</a><br/>';
|
||||
}
|
||||
echo '
|
||||
</td>
|
||||
</tr>
|
||||
</table>';
|
||||
$linkNextPage = '';
|
||||
if($show_link_to_next_page) {
|
||||
$linkNextPage = getLink('highscores') . '/' . $list . ($vocation !== 'all' ? '/' . $vocation : '') . '/' . ($_page + 1);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><img src="<?php echo $template_path; ?>/images/general/blank.gif" width="10" height="1" border="0"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
$types = array(
|
||||
'experience' => 'Experience',
|
||||
'magic' => 'Magic',
|
||||
'shield' => 'Shielding',
|
||||
'distance' => 'Distance',
|
||||
'club' => 'Club',
|
||||
'sword' => 'Sword',
|
||||
'axe' => 'Axe',
|
||||
'fist' => 'Fist',
|
||||
'fishing' => 'Fishing',
|
||||
);
|
||||
|
||||
if(config('highscores_frags')) {
|
||||
$types['frags'] = 'Frags';
|
||||
}
|
||||
if(config('highscores_balance'))
|
||||
$types['balance'] = 'Balance';
|
||||
|
||||
/** @var Twig\Environment $twig */
|
||||
$twig->display('highscores.html.twig', [
|
||||
'highscores' => $highscores,
|
||||
'list' => $list,
|
||||
'skill' => $skill,
|
||||
'skillName' => ($skill == SKILL_FRAGS ? 'Frags' : ($skill == SKILL_BALANCE ? 'Balance' : getSkillName($skill))),
|
||||
'levelName' => ($skill != SKILL_FRAGS && $skill != SKILL_BALANCE ? 'Level' : ($skill == SKILL_BALANCE ? 'Balance' : 'Frags')),
|
||||
'vocation' => $vocation !== 'all' ? $vocation : null,
|
||||
'types' => $types,
|
||||
'linkPreviousPage' => $linkPreviousPage,
|
||||
'linkNextPage' => $linkNextPage,
|
||||
]);
|
||||
|
105
system/templates/highscores.html.twig
Normal file
105
system/templates/highscores.html.twig
Normal file
@ -0,0 +1,105 @@
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td style="width: 17px"></td>
|
||||
<td>
|
||||
<div style="text-align:center"><h2>Ranking for {{ skillName }}{% if vocation is not null %} ({{ vocation }}){% endif %} on {{ config.lua.serverName }}</h2></div><br/>
|
||||
<table border="0" cellpadding="4" cellspacing="1" width="100%"></table>
|
||||
<table border="0" cellpadding="4" cellspacing="1" width="100%">
|
||||
<tr bgcolor="{{ config.vdarkborder }}">
|
||||
{% if config.account_country %}
|
||||
<td style="width: 11px" class="white">#</td>
|
||||
{% endif %}
|
||||
|
||||
<td style="width: 10%" class="white"><b>Rank</b></td>
|
||||
|
||||
{% if config.highscores_outfit %}
|
||||
<td class="white"><b>Outfit</b></td>
|
||||
{% endif %}
|
||||
|
||||
<td width="75%" class="white"><b>Name</b></td>
|
||||
|
||||
<td width="15%" class="white"><b>{{ levelName }}</b></td>
|
||||
|
||||
{% if skill == constant('POT::SKILL__LEVEL') %}
|
||||
<td class="white"><b>Points</b></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
|
||||
{% set row = 0 %}
|
||||
{% for player in highscores %}
|
||||
<tr bgcolor="{{ getStyle(row) }}">
|
||||
{% set row = row + 1 %}
|
||||
|
||||
{% if config.account_country %}
|
||||
<td>{{ player.flag|raw }}</td>
|
||||
{% endif %}
|
||||
|
||||
<td>{{ player.rank }}.</td>
|
||||
|
||||
{% if config.highscores_outfit %}
|
||||
<td>{{ player.outfit|raw }}</td>
|
||||
{% endif %}
|
||||
|
||||
<td>
|
||||
<a href="{{ player.link }}">
|
||||
<span style="color: {% if player.online > 0 %}green{% else %}red{% endif %}">{{ player.name }}</span>
|
||||
</a>
|
||||
{% if config.highscores_vocation %}
|
||||
<br/><small>{{ player.vocation }}</small>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<div style="text-align:center">{{ player.value }}</div>
|
||||
</td>
|
||||
|
||||
{% if skill == constant('POT::SKILL__LEVEL') %}
|
||||
<td><div style="text-align:center">{{ player.experience }}</div></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<table border="0" cellpadding="4" cellspacing="1" width="100%">
|
||||
{% if linkPreviousPage|length > 0 %}
|
||||
<tr><td style="width: 100%" align="right" valign="bottom"><a href="{{ linkPreviousPage }}" class="size_xxs">Previous Page</a></td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% if linkNextPage|length > 0 %}
|
||||
<tr><td style="width: 100%" align="right" valign="bottom"><a href="{{ linkNextPage }}" class="size_xxs">Next Page</a></td></tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
</td>
|
||||
<td width="5%"></td>
|
||||
<td width="15%" valign="top" align="right">
|
||||
<table style="border: 0; width: 100%" cellpadding="4" cellspacing="1">
|
||||
<tr bgcolor="{{ config.vdarkborder }}">
|
||||
<td class="white"><B>Choose a skill</B></TD>
|
||||
</tr>
|
||||
<tr bgcolor="{{ config.lightborder }}">
|
||||
<td>
|
||||
{% for link, name in types %}
|
||||
<a href="{{ getLink('highscores') }}/{{ link }}{% if vocation is defined %}/{{ vocation }}{% endif %}" class="size_xs">{{ name }}</a><br/>
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br/>
|
||||
{% if config.highscores_vocation_box %}
|
||||
<table border="0" width="100%" cellpadding="4" cellspacing="1">
|
||||
<tr bgcolor="{{ config.vdarkborder }}">
|
||||
<td class="white"><b>Choose a vocation</b></td>
|
||||
</tr>
|
||||
<tr bgcolor="{{ config.lightborder }}">
|
||||
<td>
|
||||
<a href="{{ getLink('highscores') }}/{{ list }}" class="size_xs">[ALL]</a><br/>
|
||||
{% for i in 1..config.vocations_amount %}
|
||||
<a href="{{ getLink('highscores') }}/{{ list }}/{{ config.vocations[i]|lower }}" class="size_xs">{{ config.vocations[i]}}</a><br/>
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td style="width: 18px"></td>
|
||||
</tr>
|
||||
</table>
|
Loading…
x
Reference in New Issue
Block a user