This commit is contained in:
aozhiwei 2021-12-08 17:05:58 +08:00
parent 6b276f0353
commit a8e2217c2b
3 changed files with 122 additions and 35 deletions

View File

@ -235,6 +235,8 @@ class SeasonCard(object):
def __init__(self): def __init__(self):
self.fields = [ self.fields = [
['season_id', 0, '赛季id(客户端显示为Sxxx)'], ['season_id', 0, '赛季id(客户端显示为Sxxx)'],
['season_begin_time', 0, '赛季开始时间(utc时间)'],
['season_end_time', 0, '赛季结束时间(utc时间)'],
['card_lv', 0, '手册等级'], ['card_lv', 0, '手册等级'],
['card_exp', 0, '手册经验'], ['card_exp', 0, '手册经验'],
['card_max_exp', 0, '手册经验上限'], ['card_max_exp', 0, '手册经验上限'],

View File

@ -27,19 +27,8 @@ class BagController extends BaseAuthedController {
public function itemList() public function itemList()
{ {
$itemList = array();
SqlHelper::ormSelect(
$this->_getSelfMysql(),
't_bag',
array(
'account_id' => $this->_getAccountId()
),
function ($row) use(&$itemList) {
array_push($itemList, Bag::toDto($row));
}
);
$this->_rspData(array( $this->_rspData(array(
'item_list' => $itemList, 'item_list' => Bag::all(),
)); ));
} }
@ -84,33 +73,58 @@ class BagController extends BaseAuthedController {
} }
} }
public function rename()
{
$itemDto = Bag::findByType(mt\Item::FUNC_TYPE, mt\Item::FUNC_RENAME_CARD_SUBTYPE);
$userInfo = $this->_getOrmUserInfo();
if (!$itemDto || $itemDto['item_num'] < 0) {
if (mt\Parameter::getVal('rename_diamond_cost', 0) <= 0) {
$this->_rspErr(1, '配置表错误');
return;
}
if ($userInfo['diamond'] < mt\Parameter::getVal('rename_diamond_cost', 0)) {
$this->_rspErr(1, '道具不足');
return;
}
}
$errCode = 0;
$errMsg = '';
$this->internalRename(getReqVal('name', ''), getReqVal('name_sign', ''), $errCode, $errMsg);
if ($errCode) {
$this->_rspErr($errCode, $errMsg);
return;
}
if (!$itemDto || $itemDto['item_num'] <= 0) {
$this->_decItems(array(
array(
'item_id' => V_ITEM_DIAMOND,
'item_num' => mt\Parameter::getVal('rename_diamond_cost', 0)
)
));
$this->propertyChgService->addUserChg();
} else {
$this->_decItems(array(
array(
'item_id' => $itemDto['item_id'],
'item_num' => 1
)
));
$this->propertyChgService->addBagChg();
}
$this->_rspData(array(
'property_chg' => $this->propertyChgService->toDto(),
));
}
private function renameCard($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3) private function renameCard($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3)
{ {
if (mb_strlen($param1) < 3) { $errCode = 0;
$this->_rspErr(5, '参数错误名字长度不得小于3'); $errMsg = '';
$this->internalRename($param1, $param2, $errCode, $errMsg);
if ($errCode) {
$this->_rspErr($errCode, $errMsg);
return; return;
} }
if (mb_strlen($param1, 'utf8') > 7) {
$this->_rspErr(5, '参数错误名字长度不得大于7');
return;
}
$nameService = new services\NameService();
if (!$nameService->verifyNameSign($param1, $param2)){
$this->_rspErr(5, '参数错误名,签名校验失败');
return;
}
if ($nameService->nameUsed($param1)){
$this->_rspErr(6, '名字已被占用');
return;
}
$ret = $nameService->useName($param1);
if (!$ret) {
$this->_rspErr(10, '服务器内部错误');
return;
}
$this->_updateUserInfo(array(
'name' => $param1
));
$this->_decItems(array( $this->_decItems(array(
array( array(
'item_id' => $itemMeta['id'], 'item_id' => $itemMeta['id'],
@ -124,4 +138,40 @@ class BagController extends BaseAuthedController {
)); ));
} }
private function internalRename($name, $nameSign, &$errCode, &$errMsg)
{
$errCode = 0;
$errMsg = '';
if (mb_strlen($name) < 3) {
$errCode = 5;
$errMsg = '参数错误名字长度不得小于3';
return;
}
if (mb_strlen($name, 'utf8') > 7) {
$errCode = 5;
$errMsg = '参数错误名字长度不得大于7';
return;
}
$nameService = new services\NameService();
if (!$nameService->verifyNameSign($name, $nameSign)){
$errCode = 5;
$errMsg = '参数错误名,签名校验失败';
return;
}
if ($nameService->nameUsed($name)){
$errCode = 5;
$errMsg = '名字已被占用';
return;
}
$ret = $nameService->useName($name);
if (!$ret) {
$errCode = 10;
$errMsg = '服务器内部错误';
return;
}
$this->_updateUserInfo(array(
'name' => $name
));
}
} }

View File

@ -22,6 +22,25 @@ class Bag extends BaseModel {
return $row; return $row;
} }
public static function findByType($type, $subType = null)
{
foreach (self::all() as $itemDto) {
if ($itemDto['item_num'] > 0) {
$itemMeta = mt\Item::get($itemDto['item_id']);
if ($itemMeta['type'] == $type) {
if (is_null($subType)) {
return $itemDto;
} else {
if ($itemMeta['sub_type'] == $subType) {
return $itemDto;
}
}
}
}
}
return null;
}
public static function toDto($row) public static function toDto($row)
{ {
return array( return array(
@ -30,6 +49,22 @@ class Bag extends BaseModel {
); );
} }
public static function all()
{
$itemList = array();
SqlHelper::ormSelect(
myself()->_getSelfMysql(),
't_bag',
array(
'account_id' => myself()->_getAccountId()
),
function ($row) use(&$itemList) {
array_push($itemList, Bag::toDto($row));
}
);
return $itemList;
}
public static function getItemCount($itemId) public static function getItemCount($itemId)
{ {
$itemDb = self::find($itemId); $itemDb = self::find($itemId);