From 3475b9260c24b86c78e62f492b55db1788061a8e Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 28 Feb 2023 14:58:21 +0800 Subject: [PATCH] 1 --- doc/ChipPage.py | 18 +++++- sql/gamedb.sql | 21 +------ webapp/controller/ChipController.class.php | 4 ++ .../controller/ChipPageController.class.php | 61 +++++++++++++------ webapp/models/Chip.php | 16 +++++ 5 files changed, 80 insertions(+), 40 deletions(-) diff --git a/doc/ChipPage.py b/doc/ChipPage.py index cc29d477..6871c4e8 100644 --- a/doc/ChipPage.py +++ b/doc/ChipPage.py @@ -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'], diff --git a/sql/gamedb.sql b/sql/gamedb.sql index b6df5415..639a0421 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -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 '所镶嵌的芯片页id:1|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:已初始激活', diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index d1440c68..dfa04c5d 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -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; diff --git a/webapp/controller/ChipPageController.class.php b/webapp/controller/ChipPageController.class.php index 274e90c0..b482565e 100644 --- a/webapp/controller/ChipPageController.class.php +++ b/webapp/controller/ChipPageController.class.php @@ -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, + )); + } + + } \ No newline at end of file diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index 38c1e38c..80f4275f 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -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']);