1
This commit is contained in:
parent
fb3a022de9
commit
ac9b9f1411
@ -249,6 +249,22 @@ CREATE TABLE `t_mission` (
|
|||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `t_battle`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_battle`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `t_battle` (
|
||||||
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||||
|
`data` mediumblob COMMENT 'data',
|
||||||
|
PRIMARY KEY (`idx`),
|
||||||
|
UNIQUE KEY `account_id` (`account_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `t_season`
|
-- Table structure for table `t_season`
|
||||||
--
|
--
|
||||||
|
2
third_party/phpcommon
vendored
2
third_party/phpcommon
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 07323361e8abd576aa74a7fab9d2def0d7bee089
|
Subproject commit 80d7222a4a31e295fffbf09fc1880940b4eb630b
|
@ -14,6 +14,7 @@ require_once('mt/Robot.php');
|
|||||||
|
|
||||||
require_once('services/PropertyChgService.php');
|
require_once('services/PropertyChgService.php');
|
||||||
require_once('services/SeasonService.php');
|
require_once('services/SeasonService.php');
|
||||||
|
require_once('services/BattleDataService.php');
|
||||||
|
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use models\User;
|
use models\User;
|
||||||
@ -29,7 +30,6 @@ class BattleController extends BaseAuthedController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->updateUserBaseInfo($userInfo);
|
$this->updateUserBaseInfo($userInfo);
|
||||||
$this->updateSeason($userInfo);
|
|
||||||
$this->updateMission($userInfo);
|
$this->updateMission($userInfo);
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
@ -93,190 +93,9 @@ class BattleController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateSeason($userInfo)
|
|
||||||
{
|
|
||||||
$fieldsKv = array(
|
|
||||||
'total_battle_times' => function () {
|
|
||||||
return 'total_battle_times + 1';
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if (getReqVal('rank', 0) == 1) {
|
|
||||||
$fieldsKv['total_win_times'] = function () {
|
|
||||||
return 'total_win_times + 1';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
$kills = getReqVal('kills', 0);
|
|
||||||
if ($kills > 0) {
|
|
||||||
$fieldsKv['total_kills_times'] = function () {
|
|
||||||
return "total_kills_times + ${kills}";
|
|
||||||
};
|
|
||||||
$fieldsKv['max_kills_times'] = function () {
|
|
||||||
return "GREATEST(max_kills_times, ${kills})";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
$damageOut = getReqVal('damage_out', 0);
|
|
||||||
if ($damageOut > 0) {
|
|
||||||
$fieldsKv['total_damage_out'] = function () {
|
|
||||||
return "total_damage_out + ${damageOut}";
|
|
||||||
};
|
|
||||||
$fieldsKv['max_damage_out'] = function () {
|
|
||||||
return "GREATEST(max_damage_out, ${damageOut})";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
$damageIn = getReqVal('damage_in', 0);
|
|
||||||
if ($damageIn > 0) {
|
|
||||||
$fieldsKv['total_damage_in'] = function () {
|
|
||||||
return "total_damage_in + ${damageIn}";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
$recoverHp = getReqVal('recover_hp', 0);
|
|
||||||
if ($recoverHp > 0) {
|
|
||||||
$fieldsKv['total_recover_hp'] = function () {
|
|
||||||
return "total_recover_hp + ${recoverHp}";
|
|
||||||
};
|
|
||||||
$fieldsKv['max_recover_hp'] = function () {
|
|
||||||
return "GREATEST(max_recover_hp, ${recoverHp})";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
$aliveTime = getReqVal('alive_time', 0);
|
|
||||||
if ($aliveTime > 0) {
|
|
||||||
$fieldsKv['total_alive_time'] = function () {
|
|
||||||
return "total_alive_time + ${aliveTime}";
|
|
||||||
};
|
|
||||||
$fieldsKv['max_alive_time'] = function () {
|
|
||||||
return "GREATEST(max_alive_time, ${aliveTime})";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
$currSeasonMeta = mt\Season::getCurrentSeason();
|
|
||||||
if ($currSeasonMeta && count($fieldsKv) > 0) {
|
|
||||||
$seasonService = new services\SeasonService();
|
|
||||||
if (!$seasonService->checkSeason($userInfo)) {
|
|
||||||
$userInfo = $this->_safeGetOrmUserInfo();
|
|
||||||
}
|
|
||||||
$seasonDb = Season::find($currSeasonMeta['id']);
|
|
||||||
if (!$seasonDb) {
|
|
||||||
Season::add($currSeasonMeta['id']);
|
|
||||||
$seasonDb = Season::find($currSeasonMeta['id']);
|
|
||||||
}
|
|
||||||
Season::update($fieldsKv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function updateMission($userInfo)
|
private function updateMission($userInfo)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function old()
|
|
||||||
{
|
|
||||||
//更新击杀信息时间
|
|
||||||
$k = 0;
|
|
||||||
if ($userInfo['game_times'] != 0) {
|
|
||||||
$k = $userInfo['kill_his'] / $userInfo['game_times'];
|
|
||||||
}
|
|
||||||
if (($userInfo['kill_his'] + $kills) / ($userInfo['game_times'] + 1) != $k) {
|
|
||||||
$this->_updateUserInfo(array(
|
|
||||||
'kill_modifytime' => $this->_getNowTime(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
//更新胜场信息时间
|
|
||||||
if ($rank == 1) {
|
|
||||||
$this->_updateUserInfo(array(
|
|
||||||
'win_times' => $userInfo['win_times'] + 1,
|
|
||||||
'season_win' => $userInfo['season_win'] + 1,
|
|
||||||
'win_modifytime' => $this->_getNowTime(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
//更新排位积分信息时间
|
|
||||||
if ($integral > 0) {
|
|
||||||
$update_maxscore = $integral + $userInfo['max_integral'];
|
|
||||||
$update_score = $integral + $userInfo['integral'];
|
|
||||||
$isProtect = false;
|
|
||||||
$minScore = 0;
|
|
||||||
mt\SeasonPoint::calcScore($intergral, $isProtect, $minScore);
|
|
||||||
if ($isProtect && $minScore > $updateScore) {
|
|
||||||
$update_score = $minScore;
|
|
||||||
}
|
|
||||||
$this->_updateUserInfo(array(
|
|
||||||
'integral' => $update_score,
|
|
||||||
'rank_modifytime' => $this->_getNowTime(),
|
|
||||||
'max_integral' => $update_maxscore,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
//更新历史最高信息
|
|
||||||
$kill_his = max($kill_his, $userInfo['kill_his']);
|
|
||||||
$harm_his = max($harm_his, $userInfo['harm_his']);
|
|
||||||
$sea_max_hart = max($harm, $userInfo['sea_max_hart']);
|
|
||||||
$sea_max_kill = max($kills, $userInfo['sea_max_kill']);
|
|
||||||
$alive_time_his = max($alive_time_his, $userInfo['alive_time_his']);
|
|
||||||
$add_HP_his = max($add_HP_his, $userInfo['add_HP_his']);
|
|
||||||
//添加空投箱
|
|
||||||
$box_num = min($userInfo['box_num'] + 1, 20);
|
|
||||||
|
|
||||||
$newhand = $userInfo['newhand'];
|
|
||||||
$newhand2 = $userInfo['newhand2'];
|
|
||||||
$game_times2 = $userInfo['game_times2'];
|
|
||||||
{
|
|
||||||
$fight_times = mt\Parameter::getByName('newhand_num1')['param_value'];
|
|
||||||
$view_times = mt\Parameter::getByName('newhand_num2')['param_value'];
|
|
||||||
$fight_times2 = mt\Parameter::getByName('cream_task_01')['param_value'];
|
|
||||||
$view_times2 = mt\Parameter::getByName('cream_task_02')['param_value'];
|
|
||||||
if ($userInfo['game_times'] + 1 == $fight_times && $userInfo['vip_score'] >= $view_times) {
|
|
||||||
$newhand = 1;
|
|
||||||
}
|
|
||||||
if ($newhand == 2) {
|
|
||||||
if ($userInfo['game_times2'] + 1 == $fight_times2 && $userInfo['view_times2'] >= $view_times2) {
|
|
||||||
$newhand2 = 1;
|
|
||||||
}
|
|
||||||
$game_times2++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->_updateUserInfo(array(
|
|
||||||
'game_times' => function () {
|
|
||||||
return 'game_times + 1';
|
|
||||||
},
|
|
||||||
'kill_his' => $kill_his,
|
|
||||||
'kills' => function () use($kills) {
|
|
||||||
return "kills + ${kills}";
|
|
||||||
},
|
|
||||||
'harm_his' => $harm_his,
|
|
||||||
'harm' => function () use($harm) {
|
|
||||||
return "harm + ${harm}";
|
|
||||||
},
|
|
||||||
'add_HP' => function () use($add_HP) {
|
|
||||||
return "add_HP + ${add_HP}";
|
|
||||||
},
|
|
||||||
'alive_time' => function () use($alive_time) {
|
|
||||||
return "alive_time + ${alive_time}";
|
|
||||||
},
|
|
||||||
'alive_time_his' => $alive_time_his,
|
|
||||||
'add_HP_his' => $add_HP_his,
|
|
||||||
'coin_num' => function () use($coin_num) {
|
|
||||||
return "coin_num + ${coin_num}";
|
|
||||||
},
|
|
||||||
'modify_time' => $this->_getNowTime(),
|
|
||||||
'box_num' => $box_num,
|
|
||||||
'score' => function () {
|
|
||||||
return 'score'; //??
|
|
||||||
},
|
|
||||||
'daily_time' => function () use($nowDaySeconds) {
|
|
||||||
return 'GREATEST(daily_time, ${nowDaySeconds})';
|
|
||||||
},
|
|
||||||
'season_games' => function () {
|
|
||||||
return 'season_games + 1';
|
|
||||||
},
|
|
||||||
'sea_max_kill' => $sea_max_kill,
|
|
||||||
'sea_max_hart' => $sea_max_hart,
|
|
||||||
'sea_avg_kill' => function () use($kills) {
|
|
||||||
return "sea_avg_kill + ${kills}"; //??
|
|
||||||
},
|
|
||||||
'first_fight' => 1,
|
|
||||||
));
|
|
||||||
|
|
||||||
echo json_encode(array(
|
|
||||||
'errcode' => 0,
|
|
||||||
'errmsg' => '',
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,54 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once('models/User.php');
|
||||||
|
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
|
use models\User;
|
||||||
|
|
||||||
class RankingController extends BaseAuthedController {
|
class RankingController extends BaseAuthedController {
|
||||||
|
|
||||||
public function rankingList()
|
public function rankingList()
|
||||||
{
|
{
|
||||||
$userInfo = $this->_getOrmUserInfo();
|
$userInfo = $this->_getOrmUserInfo();
|
||||||
$type = getReqVal('type', 0);
|
$type = getReqVal('type', 0);
|
||||||
|
$userList = array();
|
||||||
|
{
|
||||||
|
SqlHelper::ormSelect(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_user',
|
||||||
|
array(
|
||||||
|
),
|
||||||
|
function ($row) use(&$userList) {
|
||||||
|
array_push($userList, User::info($row));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$rankingList = array();
|
||||||
|
$ranked = 1;
|
||||||
|
foreach ($userList as $user) {
|
||||||
|
array_push($rankingList, array(
|
||||||
|
'ranked' => $ranked++,
|
||||||
|
'account_id' => $user['account_id'],
|
||||||
|
'name' => $user['name'],
|
||||||
|
'name' => $user['name'],
|
||||||
|
'sex' => $user['sex'],
|
||||||
|
'head_id' => $user['hero_id'],
|
||||||
|
'head_frame' => $user['head_frame'],
|
||||||
|
'level' => $user['level'],
|
||||||
|
'exp' => $user['exp'],
|
||||||
|
'rank' => $user['rank'],
|
||||||
|
'score' => $user['score'],
|
||||||
|
'gold' => $user['gold'],
|
||||||
|
'diamond' => $user['diamond'],
|
||||||
|
'hero_id' => $user['hero_id'],
|
||||||
|
'first_fight' => $user['first_fight'],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
$rankingData = array(
|
$rankingData = array(
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'ranking_list' => array(),
|
'ranking_list' => $rankingList,
|
||||||
'my_ranked' => array(
|
'my_ranked' => array(
|
||||||
'ranked' => -1,
|
'ranked' => -1,
|
||||||
'account_id' => $this->_getAccountId(),
|
'account_id' => $this->_getAccountId(),
|
||||||
|
7
webapp/services/BattleDataService.php
Normal file
7
webapp/services/BattleDataService.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
|
||||||
|
class BattleDataService extends BaseService {
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user