1
This commit is contained in:
parent
96fd43af5f
commit
47cbe1b215
@ -84,7 +84,7 @@ CREATE TABLE `t_hero` (
|
|||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
UNIQUE KEY `account_id_hero_id` (`account_id`, `hero_id`)
|
KEY `account_id` (`account_id`)
|
||||||
) 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 */;
|
||||||
|
|
||||||
|
@ -51,10 +51,10 @@ class HeroController extends BaseAuthedController {
|
|||||||
|
|
||||||
public function takeonSkin()
|
public function takeonSkin()
|
||||||
{
|
{
|
||||||
$heroId = getReqVal('hero_id', 0);
|
$heroUniId = getReqVal('hero_uniid', 0);
|
||||||
$skinId = getReqVal('skin_id', 0);
|
$skinId = getReqVal('skin_id', 0);
|
||||||
$heroDb = Hero::find($heroId);
|
$heroDb = Hero::find($heroUniId);
|
||||||
$heroSkinDb = Hero::find($skinId);
|
$heroSkinDb = HeroSkin::find($skinId);
|
||||||
if (!$heroDb) {
|
if (!$heroDb) {
|
||||||
$this->_rspErr(1, '你还没这个英雄');
|
$this->_rspErr(1, '你还没这个英雄');
|
||||||
return;
|
return;
|
||||||
@ -63,15 +63,15 @@ class HeroController extends BaseAuthedController {
|
|||||||
$this->_rspErr(2, '你还没这个皮肤');
|
$this->_rspErr(2, '你还没这个皮肤');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Hero::takeonSkin($heroId, $skinId);
|
Hero::takeonSkin($heroUniId, $skinId);
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function upgradeSkill()
|
public function upgradeSkill()
|
||||||
{
|
{
|
||||||
$heroId = getReqVal('hero_id', 0);
|
$heroUniId = getReqVal('hero_uniid', 0);
|
||||||
$skillIdx = getReqVal('skill_idx', 0);
|
$skillIdx = getReqVal('skill_idx', 0);
|
||||||
$heroDb = Hero::find($heroId);
|
$heroDb = Hero::find($heroUniId);
|
||||||
if (!$heroDb) {
|
if (!$heroDb) {
|
||||||
$this->_rspErr(1, '你还没这个英雄');
|
$this->_rspErr(1, '你还没这个英雄');
|
||||||
return;
|
return;
|
||||||
@ -80,15 +80,7 @@ class HeroController extends BaseAuthedController {
|
|||||||
$this->_rspErr(1, 'skill_idx参数必须为0-1');
|
$this->_rspErr(1, 'skill_idx参数必须为0-1');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Hero::upgradeSkill($heroId, $skillIdx);
|
Hero::upgradeSkill($heroUniId, $skillIdx);
|
||||||
$this->_rspOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function useYokeItem()
|
|
||||||
{
|
|
||||||
$heroId = getReqVal('hero_id', 0);
|
|
||||||
$itemId = getReqVal('item_id', 0);
|
|
||||||
$itemNum = getReqVal('item_num', 0);
|
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,31 +10,55 @@ use phpcommon\SqlHelper;
|
|||||||
|
|
||||||
class Hero extends BaseModel {
|
class Hero extends BaseModel {
|
||||||
|
|
||||||
public static function find($heroId)
|
const GETED_STATE = 0;
|
||||||
|
const TRY_STATE = 1;
|
||||||
|
|
||||||
|
const NO_LOCK = 1;
|
||||||
|
const LEVEL_LOCK = 1;
|
||||||
|
const QUALITY_LOCK = 2;
|
||||||
|
|
||||||
|
public static function find($heroUniId)
|
||||||
{
|
{
|
||||||
$row = SqlHelper::ormSelectOne(
|
$row = SqlHelper::ormSelectOne(
|
||||||
myself()->_getSelfMysql(),
|
myself()->_getSelfMysql(),
|
||||||
't_hero',
|
't_hero',
|
||||||
array(
|
array(
|
||||||
'account_id' => myself()->_getAccountId(),
|
'account_id' => myself()->_getAccountId(),
|
||||||
'hero_id' => $heroId,
|
'idx' => $heroUniId,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
if ($row) {
|
||||||
|
$row['hero_uniid'] = $row['idx'];
|
||||||
|
}
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function toDto($row)
|
public static function toDto($row)
|
||||||
{
|
{
|
||||||
return array(
|
$attr = emptyReplace(json_decode($row['attr'], true), array());
|
||||||
|
$lockType = 0;
|
||||||
|
$lockTime = 0;
|
||||||
|
if ($row['lock_type'] != 0 && $row['unlock_time'] - myself()->_getNowTime() > 0) {
|
||||||
|
$lockType = $row['lock_type'];
|
||||||
|
$lockTime = $row['unlock_time'] - myself()->_getNowTime();
|
||||||
|
}
|
||||||
|
$tradeLocktime = max(0, $row['unlock_trade_time'] - myself()->_getNowTime());
|
||||||
|
$dto = array(
|
||||||
'hero_id' => $row['hero_id'],
|
'hero_id' => $row['hero_id'],
|
||||||
'hero_lv' => $row['hero_lv'],
|
'hero_lv' => $row['hero_lv'],
|
||||||
'hero_tili' => $row['hero_tili'],
|
'hero_tili' => $row['hero_tili'],
|
||||||
|
'state' => $row['state'],
|
||||||
'skin_id' => $row['skin_id'],
|
'skin_id' => $row['skin_id'],
|
||||||
|
'quality' => $row['quality'],
|
||||||
'skill_lv1' => $row['skill_lv1'],
|
'skill_lv1' => $row['skill_lv1'],
|
||||||
'skill_lv2' => $row['skill_lv2'],
|
'skill_lv2' => $row['skill_lv2'],
|
||||||
'yoke_lv' => $row['yoke_lv'],
|
'attr' => $attr,
|
||||||
'yoke_exp' => $row['yoke_exp'],
|
'try_count' => $row['try_count'],
|
||||||
|
'lock_type' => $lockType,
|
||||||
|
'lock_time' => $lockTime,
|
||||||
|
'trade_locktime' => $tradeLocktime,
|
||||||
);
|
);
|
||||||
|
return $dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addHero($heroMeta)
|
public static function addHero($heroMeta)
|
||||||
@ -54,63 +78,50 @@ class Hero extends BaseModel {
|
|||||||
'hero_id' => $heroMeta['id'],
|
'hero_id' => $heroMeta['id'],
|
||||||
'hero_lv' => 1,
|
'hero_lv' => 1,
|
||||||
'hero_tili' => $realHeroMeta ? $realHeroMeta['tili'] : 0,
|
'hero_tili' => $realHeroMeta ? $realHeroMeta['tili'] : 0,
|
||||||
|
'state' => self::GETED_STATE,
|
||||||
#'skin_id' => $defSkin,
|
#'skin_id' => $defSkin,
|
||||||
'skill_lv1' => 1,
|
'skill_lv1' => 1,
|
||||||
'skill_lv2' => 1,
|
'skill_lv2' => 1,
|
||||||
'yoke_lv' => 0,
|
'attr' => '[]',
|
||||||
'yoke_exp' => 0,
|
'lock_type' => self::NO_LOCK,
|
||||||
|
'unlock_time' => 0,
|
||||||
|
'unlock_trade_time' => 0,
|
||||||
'createtime' => myself()->_getNowTime(),
|
'createtime' => myself()->_getNowTime(),
|
||||||
'modifytime' => myself()->_getNowTime()
|
'modifytime' => myself()->_getNowTime()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function takeonSkin($heroId, $skinId)
|
public static function takeonSkin($heroUniId, $skinId)
|
||||||
{
|
{
|
||||||
SqlHelper::update(
|
self::update($heroUniId, array(
|
||||||
myself()->_getSelfMysql(),
|
'skin_id' => $skinId,
|
||||||
't_hero',
|
'modifytime' => myself()->_getNowTime()
|
||||||
array(
|
));
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'hero_id' => $heroMeta['id']
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'skin_id' => $skinId,
|
|
||||||
'modifytime' => myself()->_getNowTime()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function upgradeSkill($heroId, $skillIdx)
|
public static function upgradeSkill($heroUniId, $skillIdx)
|
||||||
{
|
{
|
||||||
if (!in_array($skillIdx, array(0, 1))) {
|
if (!in_array($skillIdx, array(0, 1))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$fieldName = 'skill_lv' . ($skillIdx + 1);
|
$fieldName = 'skill_lv' . ($skillIdx + 1);
|
||||||
SqlHelper::update(
|
self::update($heroUniId, array(
|
||||||
myself()->_getSelfMysql(),
|
|
||||||
't_hero',
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'hero_id' => $heroId
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
$fieldName => function () use($fieldName) {
|
$fieldName => function () use($fieldName) {
|
||||||
return "${fieldName} + 1";
|
return "${fieldName} + 1";
|
||||||
},
|
},
|
||||||
'modifytime' => myself()->_getNowTime()
|
'modifytime' => myself()->_getNowTime()
|
||||||
)
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function update($heroId, $fieldsKv)
|
public static function update($heroUniId, $fieldsKv)
|
||||||
{
|
{
|
||||||
SqlHelper::update
|
SqlHelper::update
|
||||||
(myself()->_getSelfMysql(),
|
(myself()->_getSelfMysql(),
|
||||||
't_hero',
|
't_hero',
|
||||||
array(
|
array(
|
||||||
'account_id' => myself()->_getAccountId(),
|
'account_id' => myself()->_getAccountId(),
|
||||||
'hero_id' => $heroId,
|
'idx' => $heroUniId,
|
||||||
),
|
),
|
||||||
$fieldsKv
|
$fieldsKv
|
||||||
);
|
);
|
||||||
|
@ -301,7 +301,7 @@ class BattleDataService extends BaseService {
|
|||||||
|
|
||||||
private function decCost()
|
private function decCost()
|
||||||
{
|
{
|
||||||
$heroDb = Hero::find(getReqVal('hero_id', 0));
|
$heroDb = Hero::find(getReqVal('hero_uniid', 0));
|
||||||
if (!$heroDb) {
|
if (!$heroDb) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -309,7 +309,7 @@ class BattleDataService extends BaseService {
|
|||||||
if ($heroDb['hero_tili'] < $costTili) {
|
if ($heroDb['hero_tili'] < $costTili) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Hero::update($heroDb['hero_id'], array(
|
Hero::update($heroDb['hero_uniid'], array(
|
||||||
'hero_tili' => function () use($costTili) {
|
'hero_tili' => function () use($costTili) {
|
||||||
return "GREATEST(0, hero_tili - ${costTili})";
|
return "GREATEST(0, hero_tili - ${costTili})";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user