1
This commit is contained in:
parent
a6e2650fb4
commit
2869661d78
155
webapp/controller/RankController.class.php
Normal file
155
webapp/controller/RankController.class.php
Normal file
@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
class RankController{
|
||||
|
||||
protected function getMysql($account_id)
|
||||
{
|
||||
$mysql_conf = getMysqlConfig(crc32($account_id));
|
||||
$conn = new phpcommon\Mysql(array(
|
||||
'host' => $mysql_conf['host'],
|
||||
'port' => $mysql_conf['port'],
|
||||
'user' => $mysql_conf['user'],
|
||||
'passwd' => $mysql_conf['passwd'],
|
||||
'dbname' => 'gamedb2001_' . $mysql_conf['instance_id']
|
||||
));
|
||||
return $conn;
|
||||
}
|
||||
|
||||
public function RankInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$kill_list = array();
|
||||
$kill_rank = 0;
|
||||
$alive_list = array();
|
||||
$alive_rank = 0;
|
||||
$harm_list = array();
|
||||
$harm_rank = 0;
|
||||
$rate_list = array();
|
||||
$rate_rank = 0;
|
||||
$win_list = array();
|
||||
$win_rank = 0;
|
||||
|
||||
//击杀榜
|
||||
$rows = $conn->execQuery('SELECT * FROM user ORDER BY kills / game_times DESC;');
|
||||
$i = 1;
|
||||
if ($rows) {
|
||||
foreach ($rows as $row) {
|
||||
if ($row['accountid'] == $account_id) {
|
||||
$kill_rank = $i;
|
||||
}
|
||||
array_push($kill_list, array(
|
||||
'account_id' => $row['accountid'],
|
||||
'kill' => $row['kills'] / $row['game_times'],
|
||||
'alive'=> $row['alive_time'] / $row['game_times'],
|
||||
'harm' => $row['harm'] / $row['game_times'],
|
||||
'win_rate' => $row['win_times'] / $row['game_times'],
|
||||
'win_game' => $row['win_times']
|
||||
));
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
//生存榜
|
||||
$rows = $conn->execQuery('SELECT * FROM user ORDER BY alive_time / game_times DESC;');
|
||||
$i = 1;
|
||||
if ($rows) {
|
||||
foreach ($rows as $row) {
|
||||
if ($row['accountid'] == $account_id) {
|
||||
$alive_rank = $i;
|
||||
}
|
||||
array_push($alive_list, array(
|
||||
'account_id' => $row['accountid'],
|
||||
'kill' => $row['kills'] / $row['game_times'],
|
||||
'alive'=> $row['alive_time'] / $row['game_times'],
|
||||
'harm' => $row['harm'] / $row['game_times'],
|
||||
'win_rate' => $row['win_times'] / $row['game_times'],
|
||||
'win_game' => $row['win_times']
|
||||
));
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
//伤害榜
|
||||
$rows = $conn->execQuery('SELECT * FROM user ORDER BY harm / game_times DESC;');
|
||||
$i = 1;
|
||||
if ($rows) {
|
||||
foreach ($rows as $row) {
|
||||
if ($row['accountid'] == $account_id) {
|
||||
$harm_rank = $i;
|
||||
}
|
||||
array_push($harm_list, array(
|
||||
'account_id' => $row['accountid'],
|
||||
'kill' => $row['kills'] / $row['game_times'],
|
||||
'alive'=> $row['alive_time'] / $row['game_times'],
|
||||
'harm' => $row['harm'] / $row['game_times'],
|
||||
'win_rate' => $row['win_times'] / $row['game_times'],
|
||||
'win_game' => $row['win_times']
|
||||
));
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
//胜率榜
|
||||
$rows = $conn->execQuery('SELECT * FROM user ORDER BY win_times / game_times DESC;');
|
||||
$i = 1;
|
||||
if ($rows) {
|
||||
foreach ($rows as $row) {
|
||||
if ($row['accountid'] == $account_id) {
|
||||
$rate_rank = $i;
|
||||
}
|
||||
array_push($rate_list, array(
|
||||
'account_id' => $row['accountid'],
|
||||
'kill' => $row['kills'] / $row['game_times'],
|
||||
'alive'=> $row['alive_time'] / $row['game_times'],
|
||||
'harm' => $row['harm'] / $row['game_times'],
|
||||
'win_rate' => $row['win_times'] / $row['game_times'],
|
||||
'win_game' => $row['win_times']
|
||||
));
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
//胜场榜
|
||||
$rows = $conn->execQuery('SELECT * FROM user ORDER BY win_times DESC;');
|
||||
$i = 1;
|
||||
if ($rows) {
|
||||
foreach ($rows as $row) {
|
||||
if ($row['accountid'] == $account_id) {
|
||||
$win_rank = $i;
|
||||
}
|
||||
array_push($win_list, array(
|
||||
'account_id' => $row['accountid'],
|
||||
'kill' => $row['kills'] / $row['game_times'],
|
||||
'alive'=> $row['alive_time'] / $row['game_times'],
|
||||
'harm' => $row['harm'] / $row['game_times'],
|
||||
'win_rate' => $row['win_times'] / $row['game_times'],
|
||||
'win_game' => $row['win_times']
|
||||
));
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => "",
|
||||
'kill_rank' => $kill_rank,
|
||||
'kill_list' => $kill_list,
|
||||
'alive_rank' => $alive_rank,
|
||||
'alive_list' => $alive_list,
|
||||
'harm_rank' => $harm_rank,
|
||||
'harm_list' => $harm_list,
|
||||
'rate_rank' => $rate_rank,
|
||||
'rate_list' => $rate_list,
|
||||
'win_rank' => $win_rank,
|
||||
'win_list' => $win_list
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -148,7 +148,7 @@ class teamController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效2');
|
||||
return;
|
||||
}
|
||||
|
||||
$flag = 0;
|
||||
foreach ($user_db['member_list'] as $member) {
|
||||
if ($member['account_id'] == $_REQUEST['account_id']){
|
||||
if($member['idx'] != 1){
|
||||
@ -201,6 +201,7 @@ class teamController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效2');
|
||||
return;
|
||||
}
|
||||
$flag = 0;
|
||||
foreach ($user_db['member_list'] as $member) {
|
||||
if ($member['account_id'] == $_REQUEST['account_id']){
|
||||
$flag = $member['idx'] - 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user