This commit is contained in:
hujiabin 2023-02-28 14:58:21 +08:00
parent 084b2bd9aa
commit 3475b9260c
5 changed files with 80 additions and 40 deletions

View File

@ -71,10 +71,24 @@ class ChipPage(object):
['!data', [_common.ChipPage()], '页信息']
]
},{
'name': 'removeChip',
'name': 'removeChipOne',
'desc': '芯片移除',
'group': 'ChipPage',
'url': 'webapp/index.php?c=ChipPage&a=removeChipOne',
'params': [
_common.ReqHead(),
['page', '', '页id'],
['slot_id', '', '卡槽id'],
],
'response': [
_common.RspHead(),
['!data', [_common.ChipPage()], '页信息']
]
},{
'name': 'removeChipAll',
'desc': '芯片移除(一键移除)',
'group': 'ChipPage',
'url': 'webapp/index.php?c=ChipPage&a=removeChip',
'url': 'webapp/index.php?c=ChipPage&a=removeChipAll',
'params': [
_common.ReqHead(),
['page', '', '页id'],

View File

@ -164,10 +164,6 @@ CREATE TABLE `t_hero` (
`last_mission_get_ceg_time` bigint NOT NULL DEFAULT '0' COMMENT '最后悬赏任务获取金币的时间',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
`chip_ids` varchar(100) NOT NULL DEFAULT '' COMMENT '已镶嵌的芯片idx组',
`skill_common` varchar(255) NOT NULL DEFAULT '100100|100120|100140|100160|100180|100200|100220|100240|100260|100280' COMMENT '通用技能',
`skill_points` int(11) NOT NULL DEFAULT '0' COMMENT '技能点',
`labour` int(11) NOT NULL DEFAULT '0' COMMENT '劳力值',
`active_token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'active_token_id',
`active_count` int(11) NOT NULL DEFAULT '0' COMMENT 'active_count',
`activate` int(11) NOT NULL DEFAULT '0' COMMENT '是否激活 1已初始激活',
@ -242,22 +238,13 @@ CREATE TABLE `t_chip` (
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
`item_num` int(11) NOT NULL DEFAULT '1' COMMENT '数量',
`chip_grade` int(11) NOT NULL DEFAULT '1' COMMENT '芯片等级',
`chip_type` int(11) NOT NULL DEFAULT '1' COMMENT '1:角色芯片 2:武器芯片',
`state` int(11) NOT NULL DEFAULT '0' COMMENT '芯片添加状态:0 正常;1 选择;-1 锁定',
`supper_state` int(11) NOT NULL DEFAULT '0' COMMENT '是否锁定0 正常;1 锁住',
`inlay_state` int(11) NOT NULL DEFAULT '0' COMMENT '镶嵌状态0 未镶嵌;1 镶嵌了',
`chip_type` int(11) NOT NULL DEFAULT '1' COMMENT '1 攻击2 防御3 辅助',
`state` int(11) NOT NULL DEFAULT '0' COMMENT '0已购买 1免费GIFT标签',
`inlay_state` varchar(60) COMMENT '所镶嵌的芯片页id1|2|3',
`rand_attr` mediumblob COMMENT '随机属性',
`today_get_gold` bigint NOT NULL DEFAULT '0' COMMENT '金币',
`last_get_gold_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后获取金币的时间',
`lucky_temporary` varchar(10) NOT NULL DEFAULT '0' COMMENT '临时幸运值',
`lucky_final` varchar(10) NOT NULL DEFAULT '0' COMMENT '最终幸运值',
`strength_max` varchar(10) NOT NULL DEFAULT '0' COMMENT '最大体力值',
`strength` varchar(10) NOT NULL DEFAULT '0' COMMENT '前一天体力值',
`upgrade_mint` double NOT NULL DEFAULT '0' COMMENT 'mint费用',
`activate` int(11) NOT NULL DEFAULT '0' COMMENT '是否激活 1已初始激活',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
`labour` int(11) NOT NULL DEFAULT '0' COMMENT '劳力值',
PRIMARY KEY (`idx`),
UNIQUE KEY `token_id` (`token_id`),
KEY `item_id` (`item_id`),
@ -294,8 +281,6 @@ CREATE TABLE `t_gun` (
`last_mission_get_ceg_time` bigint NOT NULL DEFAULT '0' COMMENT '最后悬赏任务获取金币的时间',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
`chip_ids` varchar(100) NOT NULL DEFAULT '' COMMENT '已镶嵌的芯片idx组',
`labour` int(11) NOT NULL DEFAULT '0' COMMENT '劳力值',
`active_token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'active_token_id',
`active_count` int(11) NOT NULL DEFAULT '0' COMMENT 'active_count',
`activate` int(11) NOT NULL DEFAULT '0' COMMENT '是否激活 1已初始激活',

View File

@ -160,6 +160,10 @@ class ChipController extends BaseAuthedController
$this->_rspErr(1, "Unable to use free chip");
return;
}
if (count(array_filter(explode("|",$chipDbParam['inlay_state']))) > 0){
$this->_rspErr(1, "The used chip");
return;
}
if ($chipDbParam['chip_grade'] != $chipDbMain['chip_grade']){
$this->_rspErr(1, "Material chip grade does not meet");
return;

View File

@ -84,8 +84,6 @@ class ChipPageController extends BaseAuthedController
return ;
}
$data = emptyReplace(json_decode($chipPageDb['data'], true), array());
// $data[$slotId-1]['chip_id'] = $uniqueId;
// print_r($data);die;
if ( $data[$slotId-1]['state'] != 1){
$this->_rspErr(1,'Unlocked state');
return ;
@ -95,7 +93,8 @@ class ChipPageController extends BaseAuthedController
$this->_rspErr(1, "You don't have the chip yet");
return;
}
if ($chipDb['inlay_state'] == 1){
if (in_array($page,array_filter(explode("|",$chipDb['inlay_state'])))){
$this->_rspErr(1, "The used chip");
return;
}
@ -105,23 +104,18 @@ class ChipPageController extends BaseAuthedController
case 0 : $type = 3;break;
default:$type = 0;
}
if ($chipDb['chip_type'] != $type){
$this->_rspErr(1, "Type mismatch");
return;
}
if ( $data[$slotId-1]['chip_id'] ){
Chip::update2($data[$slotId-1]['chip_id'] ,
array(
'inlay_state' => 0,
)
);
Chip::updateInlayState($data[$slotId-1]['chip_id'],$page);
}
$data[$slotId-1]['chip_id'] = $uniqueId;
Chip::update2($uniqueId ,
array(
'inlay_state' => 1,
)
);
Chip::updateInlayState($uniqueId,$page);
ChipPage::update($page,array(
'data' => json_encode($data)
));
@ -132,8 +126,13 @@ class ChipPageController extends BaseAuthedController
));
}
public function removeChip(){
public function removeChipOne(){
$page = getReqVal('page',0);
$slotId = getReqVal('slot_id',0);
if (!$page || !$slotId){
$this->_rspErr(1, 'Missing parameter');
return ;
}
$chipPageDb = ChipPage::find($page);
if (!$chipPageDb){
$this->_rspErr(1,'page parameter error');
@ -141,12 +140,8 @@ class ChipPageController extends BaseAuthedController
}
$data = emptyReplace(json_decode($chipPageDb['data'], true), array());
foreach ($data as &$value){
if ($value['chip_id']){
Chip::update2($value['chip_id'] ,
array(
'inlay_state' => 0,
)
);
if ($value['slot_id'] == $slotId){
Chip::updateInlayState($value['chip_id'],$page);
$value['chip_id'] = 0;
}
}
@ -159,4 +154,30 @@ class ChipPageController extends BaseAuthedController
'data' => $chipPageDto,
));
}
public function removeChipAll(){
$page = getReqVal('page',0);
$chipPageDb = ChipPage::find($page);
if (!$chipPageDb){
$this->_rspErr(1,'page parameter error');
return ;
}
$data = emptyReplace(json_decode($chipPageDb['data'], true), array());
foreach ($data as &$value){
if ($value['chip_id']){
Chip::updateInlayState($value['chip_id'],$page);
$value['chip_id'] = 0;
}
}
ChipPage::update($page,array(
'data' => json_encode($data)
));
$newChipPageDb = ChipPage::find($page);
$chipPageDto = ChipPage::toDtoInfo($newChipPageDb);
$this->_rspData(array(
'data' => $chipPageDto,
));
}
}

View File

@ -296,6 +296,22 @@ class Chip extends BaseModel
);
}
public static function updateInlayState($idx,$page){
$row = self::find($idx);
if ($row){
$inlayState = array_filter (explode("|",$row['inlay_state']) );
if (in_array($page,$inlayState)){
unset($inlayState[array_search($page,$inlayState)]);
}else{
array_push($inlayState,$page);
}
self::update2($idx,array(
'inlay_state' => implode('|',$inlayState)
));
}
}
// public static function updateRandAttr($accountId,$chip){
// $attr_pool = mt\ChipAttr::generateOneAttr($chip['chip_type']);