1
This commit is contained in:
parent
e3ba6fe330
commit
da07c61b1e
@ -31,6 +31,19 @@ class Circuit(object):
|
|||||||
['!rank_list', [rankingInfo()], '榜信息'],
|
['!rank_list', [rankingInfo()], '榜信息'],
|
||||||
['my_rank', rankingInfo(), '个人榜信息'],
|
['my_rank', rankingInfo(), '个人榜信息'],
|
||||||
]
|
]
|
||||||
|
},{
|
||||||
|
'name': 'getCircuitPhaseRanking',
|
||||||
|
'desc': '巡回赛阶段排行',
|
||||||
|
'group': 'Circuit',
|
||||||
|
'url': 'webapp/index.php?c=Circuit&a=getCircuitPhaseRanking',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
['!rank_list', [rankingInfo()], '榜信息'],
|
||||||
|
['my_rank', rankingInfo(), '个人榜信息'],
|
||||||
|
]
|
||||||
},{
|
},{
|
||||||
'name': 'CircuitTaskList',
|
'name': 'CircuitTaskList',
|
||||||
'desc': '巡回赛任务',
|
'desc': '巡回赛任务',
|
||||||
|
@ -2060,6 +2060,27 @@ CREATE TABLE `t_circuit_battle` (
|
|||||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10000 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_circuit_battle_phase`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_circuit_battle_phase`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `t_circuit_battle_phase` (
|
||||||
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||||
|
`season` int(11) NOT NULL DEFAULT '0' COMMENT '赛季',
|
||||||
|
`phase` int(11) NOT NULL DEFAULT '0' COMMENT '阶段',
|
||||||
|
`cumulative_score` int(11) NOT NULL DEFAULT '0' COMMENT '积分',
|
||||||
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`),
|
||||||
|
KEY `idx_account_season_phase` (`account_id`, `season`, `phase`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `t_circuit_reward`
|
-- Table structure for table `t_circuit_reward`
|
||||||
--
|
--
|
||||||
|
@ -95,6 +95,17 @@ CREATE TABLE `t_lucky_symbol_record` (
|
|||||||
UNIQUE KEY `uk_room_uuid_account_id` (`room_uuid`, `account_id`)
|
UNIQUE KEY `uk_room_uuid_account_id` (`room_uuid`, `account_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
|
||||||
|
CREATE TABLE `t_circuit_battle_phase` (
|
||||||
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||||
|
`season` int(11) NOT NULL DEFAULT '0' COMMENT '赛季',
|
||||||
|
`phase` int(11) NOT NULL DEFAULT '0' COMMENT '阶段',
|
||||||
|
`cumulative_score` int(11) NOT NULL DEFAULT '0' COMMENT '积分',
|
||||||
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`),
|
||||||
|
KEY `idx_account_season_phase` (`account_id`, `season`, `phase`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
|
||||||
insert into version (version) values(2024092401);
|
insert into version (version) values(2024092401);
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ use models\CircuitTask;
|
|||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
class CircuitController extends BaseAuthedController {
|
class CircuitController extends BaseAuthedController {
|
||||||
private $redis_key_circuit_ranking = 'circuit_ranking';
|
private $redis_key_circuit_ranking = 'circuit_ranking';
|
||||||
|
private $redis_key_circuit_phase_ranking = 'circuit_phase_ranking';
|
||||||
|
|
||||||
public function _handlePre()
|
public function _handlePre()
|
||||||
{
|
{
|
||||||
@ -94,6 +95,32 @@ class CircuitController extends BaseAuthedController {
|
|||||||
'my_rank' => $myRankedInfo,
|
'my_rank' => $myRankedInfo,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
public function getCircuitPhaseRanking(){
|
||||||
|
$currentCircuitMeta = mt\CircuitTime::getCurrentCircuit();
|
||||||
|
if (!$currentCircuitMeta){
|
||||||
|
$this->_rspErr(1, 'current stage Have not yet started');
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
$currentStageMeta = mt\CircuitTime::getCurrentStage();
|
||||||
|
if (!$currentStageMeta){
|
||||||
|
$currentStageMeta = mt\CircuitTime::getPrevStage();
|
||||||
|
}
|
||||||
|
$redis = $this->_getRedis($this->redis_key_circuit_phase_ranking);
|
||||||
|
if (! $redis->exists(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_phase_ranking)){
|
||||||
|
$rows = Circuit::getPhaseRankingList($currentStageMeta['circuit_season'],$currentStageMeta['circuit_phase']);
|
||||||
|
$list = $this->_extractRankingInfo($rows);
|
||||||
|
$redis->set(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_phase_ranking , json_encode($list));
|
||||||
|
$redis->pexpire(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_phase_ranking , 10*60*1000);
|
||||||
|
}else{
|
||||||
|
$listStr = $redis->get(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_phase_ranking);
|
||||||
|
$list = emptyReplace(json_decode($listStr, true), array());
|
||||||
|
}
|
||||||
|
$myRankedInfo = $this->_celMyRankingInfo($list);
|
||||||
|
$this->_rspData(array(
|
||||||
|
'rank_list' => $list,
|
||||||
|
'my_rank' => $myRankedInfo,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
private function _extractRankingInfo($data){
|
private function _extractRankingInfo($data){
|
||||||
$rankingList = array();
|
$rankingList = array();
|
||||||
|
@ -29,6 +29,30 @@ class Circuit extends BaseModel
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function updatePhaseScore($season,$phase,$score){
|
||||||
|
SqlHelper::upsert(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_circuit_battle_phase',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'season' => $season,
|
||||||
|
'phase' => $phase,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'cumulative_score' => $score,
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'season' => $season,
|
||||||
|
'phase' => $phase,
|
||||||
|
'cumulative_score' => $score,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static function getMyScore($season){
|
public static function getMyScore($season){
|
||||||
$row = SqlHelper::ormSelectOne(
|
$row = SqlHelper::ormSelectOne(
|
||||||
myself()->_getSelfMysql(),
|
myself()->_getSelfMysql(),
|
||||||
@ -41,11 +65,37 @@ class Circuit extends BaseModel
|
|||||||
return $row ? $row['cumulative_score'] : 0;
|
return $row ? $row['cumulative_score'] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getMyPhaseScore($season,$phase){
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_circuit_battle_phase',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'season' => $season,
|
||||||
|
'phase' => $phase,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $row ? $row['cumulative_score'] : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function getRankingList($season){
|
public static function getRankingList($season){
|
||||||
$sql = "select * from t_circuit_battle where season=:season order by cumulative_score desc,modifytime asc";
|
$sql = "select * from t_circuit_battle where season=:season order by cumulative_score desc,modifytime asc";
|
||||||
$whereKv = array(
|
$whereKv = array(
|
||||||
"season" => $season,
|
":season" => $season,
|
||||||
|
);
|
||||||
|
$rows = myself()->_getMysql('')->execQuery($sql,$whereKv);
|
||||||
|
if (!$rows){
|
||||||
|
$rows = array();
|
||||||
|
}
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPhaseRankingList($season,$phase){
|
||||||
|
$sql = "select * from t_circuit_battle_phase where season=:season and phase=:phase order by cumulative_score desc,modifytime asc";
|
||||||
|
$whereKv = array(
|
||||||
|
":season" => $season,
|
||||||
|
":phase" => $phase,
|
||||||
);
|
);
|
||||||
$rows = myself()->_getMysql('')->execQuery($sql,$whereKv);
|
$rows = myself()->_getMysql('')->execQuery($sql,$whereKv);
|
||||||
if (!$rows){
|
if (!$rows){
|
||||||
|
@ -133,14 +133,18 @@ class RoomBattleDataService extends BaseService {
|
|||||||
//巡回模式排位分计算
|
//巡回模式排位分计算
|
||||||
if ($this->mapMode == mt\MapMode::CIRCUIT_MODE){
|
if ($this->mapMode == mt\MapMode::CIRCUIT_MODE){
|
||||||
$circuitMeta = mt\CircuitTime::getCurrentCircuit();
|
$circuitMeta = mt\CircuitTime::getCurrentCircuit();
|
||||||
if ($circuitMeta ){
|
$circuitStageMeta = mt\CircuitTime::getCurrentStage();
|
||||||
|
if ($circuitMeta && $circuitStageMeta){
|
||||||
$minScore = mt\Parameter::getVal('circuit_rank_score_min',0);
|
$minScore = mt\Parameter::getVal('circuit_rank_score_min',0);
|
||||||
$multConstant = mt\Parameter::getVal('circuit_score_mult_constant',1);
|
$multConstant = mt\Parameter::getVal('circuit_score_mult_constant',1);
|
||||||
$shiftConstant = mt\Parameter::getVal('circuit_score_shift_constant',1);
|
$shiftConstant = mt\Parameter::getVal('circuit_score_shift_constant',1);
|
||||||
$circuitScore = $battleScore * $multConstant + $shiftConstant;
|
$circuitScore = $battleScore * $multConstant + $shiftConstant;
|
||||||
$myScore = Circuit::getMyScore($circuitMeta['circuit_season']);
|
$myScore = Circuit::getMyScore($circuitMeta['circuit_season']);
|
||||||
|
$myPhaseScore = Circuit::getMyPhaseScore($circuitStageMeta['circuit_season'],$circuitStageMeta['circuit_phase']);
|
||||||
$finalScore = max($minScore, $myScore+$circuitScore);
|
$finalScore = max($minScore, $myScore+$circuitScore);
|
||||||
|
$finalPhaseScore = max($minScore, $myPhaseScore+$circuitScore);
|
||||||
Circuit::updateScore($circuitMeta['circuit_season'],$finalScore);
|
Circuit::updateScore($circuitMeta['circuit_season'],$finalScore);
|
||||||
|
Circuit::updatePhaseScore($circuitStageMeta['circuit_season'],$circuitStageMeta['circuit_phase'],$finalPhaseScore);
|
||||||
$member['new_circuit_score'] = $finalScore;
|
$member['new_circuit_score'] = $finalScore;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user