game2006api/webapp/controller/MatchController.class.php
aozhiwei 69fd8c5bd0 1
2023-12-26 14:23:50 +08:00

101 lines
2.4 KiB
PHP

<?php
require_once('models/User.php');
require_once('models/Hero.php');
require_once('models/Gun.php');
require_once('models/ChipPage.php');
require_once('models/HeroPreset.php');
require_once('models/HeroSkin.php');
require_once('mt/PveGemini.php');
require_once('mt/Skill.php');
require_once('mt/StarLevel.php');
require_once('services/PropertyChgService.php');
use phpcommon\SqlHelper;
use models\User;
use models\Hero;
use models\Gun;
use models\ChipPage;
use models\HeroPreset;
use models\HeroSkin;
class MatchController extends BaseAuthedController {
public function getMatchInfo()
{
$teamUuid = getReqVal('team_uuid', '');
$r = $this->_getRedis($teamUuid);
$teamDb = $this->readTeamDb($r, $teamUuid);
if (empty($teamDb)) {
$this->_rspErr(1, 'The team has been disbanded');
return;
}
$matchDb = $this->readCurrMatchTeam($r);
$this->_rspData(array(
'team_info' => $teamDb
));
}
public function cancel()
{
$teamUuid = getReqVal('team_uuid', '');
$r = $this->_getRedis($teamUuid);
$teamDb = $this->readTeamDb($r, $teamUuid);
if (!empty($teamDb)) {
}
$this->_rspOk();
}
private function readTeamDb($r, $teamUuid)
{
$teamDbStr = $r->get(TEAMID_KEY . $teamUuid);
if (empty($teamDbStr)) {
return null;
}
$r->refreshKeyExpire($r, TEAMID_KEY . $teamUuid, 1000*600);
$teamDb = json_decode($teamDbStr, true);
return $teamDb;
}
/*
{
"current_team": "dafsdf"
"match_time": 231434
}
*/
private function readCurrMatchTeam($r)
{
$teamDbStr = $r->get(MATCH_CURRENT_TEAM_KEY);
if (empty($teamDbStr)) {
return null;
}
$teamDb = json_decode($teamDbStr, true);
return $teamDb;
}
/*
{
"target_team": "dafsdf"
"match_time": 231434
}
*/
private function readMatchOk($r, $teamUuid)
{
$teamDbStr = $r->get(MATCH_OK_KEY . $teamUuid);
if (empty($teamDbStr)) {
return null;
}
$this->refreshKeyExpire($r, MATCH_OK_KEY . $teamUuid, 1000*600);
$teamDb = json_decode($teamDbStr, true);
return $teamDb;
}
private function refreshKeyExpire($r, $key, $time)
{
$r->pexpire($key, $time);
}
}