This commit is contained in:
aozhiwei 2022-01-05 13:41:11 +08:00
parent f8d29ae26d
commit d4b5f02603
3 changed files with 114 additions and 0 deletions

View File

@ -84,4 +84,36 @@ class HeroController extends BaseAuthedController {
$this->_rspOk(); $this->_rspOk();
} }
public function upgradeLevel()
{
$heroUniId = getReqVal('hero_uniid', 0);
$heroDb = Hero::find($heroUniId);
if (!$heroDb) {
$this->_rspErr(1, '英雄不存在');
return;
}
if ($heroDb['state'] == Hero::GETED_STATE) {
$this->_rspErr(3, '试用英雄不能操作');
return;
}
if ($heroDb['unlock_time'] > $this->_getNowTime()) {
$this->_rspErr(2, '锁定期间不能操作');
return;
}
if ($heroDb['unlock_trade_time'] > $this->_getNowTime()) {
$this->_rspErr(2, '锁定期间不能操作');
return;
}
$heroMeta = mt\Hero::get($heroDb['hero_id']);
if (!$heroMeta) {
$this->_rspErr(100, '服务器内部错误');
return;
}
}
public function upgradeQuality()
{
$heroUniId = getReqVal('hero_uniid', 0);
}
} }

41
webapp/mt/HeroLevel.php Normal file
View File

@ -0,0 +1,41 @@
<?php
namespace mt;
use phpcommon;
class HeroLevel {
public static function get($id)
{
return getXVal(self::getMetaList(), $id);
}
public static function getByQualityLevel($quality, $level)
{
self::mustBeQualityLevelHash();
return getXVal(self::$qualityLevelHash, $quality . '_' . $level, null);
}
protected static function getMetaList()
{
if (!self::$metaList) {
self::$metaList = getMetaTable('heroLevel@heroLevel.php');
}
return self::$metaList;
}
protected static function mustBeQualityLevelHash()
{
if (!self::$qualityLevelHash) {
self::$qualityLevelHash = array();
foreach (self::getMetaList() as $meta) {
self::$qualityLevelHash[$meta['quality'] . '_' . $meta['level']] = $meta;
}
}
}
protected static $metaList;
protected static $qualityLevelHash;
}

41
webapp/mt/HeroQuality.php Normal file
View File

@ -0,0 +1,41 @@
<?php
namespace mt;
use phpcommon;
class HeroQuality {
public static function get($id)
{
return getXVal(self::getMetaList(), $id);
}
public static function getByQuality($quality)
{
self::mustBeQualityHash();
return getXVal(self::$qualityHash, $level, null);
}
protected static function getMetaList()
{
if (!self::$metaList) {
self::$metaList = getMetaTable('heroQuality@heroQuality.php');
}
return self::$metaList;
}
protected static function mustBeQualityLevelHash()
{
if (!self::$qualityHash) {
self::$qualityHash = array();
foreach (self::getMetaList() as $meta) {
self::$qualityHash[$meta['quality']] = $meta;
}
}
}
protected static $metaList;
protected static $qualityHash;
}