From 9a1c1769601485cece9eca5190653b8257fdb010 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Wed, 10 Jan 2024 14:28:48 +0800 Subject: [PATCH] 1 --- doc/Fragment.py | 121 ++++++++---------- .../controller/FragmentController.class.php | 95 ++++++-------- webapp/controller/HeroController.class.php | 1 + webapp/mt/Item.php | 4 +- 4 files changed, 96 insertions(+), 125 deletions(-) diff --git a/doc/Fragment.py b/doc/Fragment.py index 88918818..ae7c2901 100644 --- a/doc/Fragment.py +++ b/doc/Fragment.py @@ -1,68 +1,55 @@ -# -*- coding: utf-8 -*- - -import _common - -class Fragment(object): - - def __init__(self): - self.apis = [ - { - 'name': 'fragmentList', - 'desc': '获取碎片列表', - 'group': 'Fragment', - 'url': 'webapp/index.php?c=Fragment&a=fragmentList', - 'params': [ - _common.ReqHead(), - ['type', '', '碎片类型:1 英雄;2 枪械'], - ], - 'response': [ - _common.RspHead(), - ['!data', [_common.Fragment()], '芯片列表'] - ] - },{ - 'name': 'syntheticFragmentPreview', - 'desc': '碎片合成前', - 'group': 'Fragment', - 'url': 'webapp/index.php?c=Fragment&a=syntheticFragmentPreview', - 'params': [ - _common.ReqHead(), - ['type', '', '类型:1 英雄;2 枪械'], - ], - 'response': [ - _common.RspHead(), - ['!list', [], '英雄或枪械id列表'], - ['mint', 0, '费用'] - ] - },{ - 'name': 'syntheticFragment', - 'desc': '碎片合成', - 'group': 'Fragment', - 'url': 'webapp/index.php?c=Fragment&a=syntheticFragment', - 'params': [ - _common.ReqHead(), - ['type', '', '类型:1 英雄;2 枪械'], - ['params', '', '普通碎片 item id,用“|”分开;例:item id1|item id2|item id3...'], - ['param', '', '特殊碎片 item id'], - ['item_id', '', '英雄或枪械 item id'], - ], - 'response': [ - _common.RspHead(), - ['property_chg', _common.PropertyChg(), '属性变更'], - ['item_id', 0, '道具id'] - ] - },{ - 'name': 'showBaseByItemId', - 'desc': '查看item的基本信息', - 'group': 'Fragment', - 'url': 'webapp/index.php?c=Fragment&a=showBaseByItemId', - 'params': [ - _common.ReqHead(), - ['item_id', '', '英雄或枪械的道具id'], - ], - 'response': [ - _common.RspHead(), - ['data', [], '英雄或枪械的基本信息'] - ] - }, - +# -*- coding: utf-8 -*- + +import _common + +class Fragment(object): + + def __init__(self): + self.apis = [ + { + 'name': 'syntheticFragment', + 'desc': '碎片合成', + 'group': 'Fragment', + 'url': 'webapp/index.php?c=Fragment&a=syntheticFragment', + 'params': [ + _common.ReqHead(), + ['item_id', 0, '碎片itemID'], + ], + 'response': [ + _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], + ['item_id', 0, '道具id'] + ] + },{ + 'name': 'syntheticFragmentOld', + 'desc': '碎片合成', + 'group': 'Fragment', + 'url': 'webapp/index.php?c=Fragment&a=syntheticFragment', + 'params': [ + _common.ReqHead(), + ['type', '', '类型:1 英雄;2 枪械'], + ['params', '', '普通碎片 item id,用“|”分开;例:item id1|item id2|item id3...'], + ['param', '', '特殊碎片 item id'], + ['item_id', '', '英雄或枪械 item id'], + ], + 'response': [ + _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], + ['item_id', 0, '道具id'] + ] + },{ + 'name': 'showBaseByItemId', + 'desc': '查看item的基本信息', + 'group': 'Fragment', + 'url': 'webapp/index.php?c=Fragment&a=showBaseByItemId', + 'params': [ + _common.ReqHead(), + ['item_id', '', '英雄或枪械的道具id'], + ], + 'response': [ + _common.RspHead(), + ['data', [], '英雄或枪械的基本信息'] + ] + }, + ] \ No newline at end of file diff --git a/webapp/controller/FragmentController.class.php b/webapp/controller/FragmentController.class.php index 531a8f16..2e6f343f 100644 --- a/webapp/controller/FragmentController.class.php +++ b/webapp/controller/FragmentController.class.php @@ -1,79 +1,64 @@ _rspErr(1, "param item_id error"); + return; } + $pieceNum = $itemMeta['param1']; + $bagDb = Bag::find($itemId); + if (!$bagDb || $bagDb['item_num'] < $pieceNum){ + $this->_rspErr(1, "Insufficient material"); + return; + } + $itemMetaDto = \mt\Item::get($itemMeta['relationship']); + if ( !$itemMetaDto ){ + $this->_rspErr(1, "param error"); + return; + } + Bag::decItem($itemId,$pieceNum); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addBagChg(); + $Info = array(); + if ($itemMeta['sub_type'] == \mt\Item::HERO_FRAGMENT_SUBTYPE){ + Hero::addFreeHero($itemMetaDto); +// $heroIdx = SqlHelper::getLastInsertId($this->_getSelfMysql()); +// $Info = Hero::toDto(Hero::find($heroIdx)); + $propertyChgService->addHeroChg(); + } + if ($itemMeta['sub_type'] == \mt\Item::CHIP_FRAGMENT_SUBTYPE){ + Chip::addFreeChip($itemMetaDto); +// $chipIdx = SqlHelper::getLastInsertId($this->_getSelfMysql()); +// $Info = Chip::toDto(Chip::find($chipIdx)); + $propertyChgService->addChip(); + } + $this->_rspData(array( - 'fragment_list' => $fragmentList, + 'item_id' => $itemMetaDto['id'], + 'property_chg' => $propertyChgService->toDto(), )); } - public function syntheticFragmentPreview() - { - $type = getReqVal('type', 0); - switch ($type) { - case 1: - { - $itemMetaList = mt\Item::getMetaListByType(mt\Item::HERO_TYPE); - $hero = array(); - foreach ($itemMetaList as $meta){ - array_push($hero,$meta['id']); - } - $meta = mt\Parameter::getByName('jigsaw_merge_h_price'); - $mint = $meta ? $meta['param_value'] : 100; - $this->_rspData(array( - 'list' => $hero, - 'mint' => $mint - )); - } - break; - case 2: - { - $itemMetaList = mt\Item::getMetaListByType(mt\Item::GUN_TYPE); - $gun = array(); - foreach ($itemMetaList as $meta){ - array_push($gun,$meta['id']); - } - $meta = mt\Parameter::getByName('jigsaw_merge_w_price'); - $mint = $meta ? $meta['param_value'] : 20; - $this->_rspData(array( - 'list' => $gun, - 'mint' => $mint - )); - } - break; - default: - { - $this->_rspErr(1, 'type parameter error'); - return; - } - } - } private function _verificationFragment($itemId,$type,$sub_type){ $itemMetaParam = mt\Item::get($itemId); @@ -93,7 +78,7 @@ class FragmentController extends BaseAuthedController } } - public function syntheticFragment(){ + public function syntheticFragmentOld(){ $type = getReqVal('type', 0); $params = getReqVal('params',''); $param = getReqVal('param',''); diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 434bd933..6cd71415 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -448,6 +448,7 @@ class HeroController extends BaseAuthedController { 英雄碎片合成 */ public function heroPieceSys(){ + return error_log("HERO PRICE : " . json_encode($_REQUEST)); $itemId = getReqVal('item_id',0); $pieceNum = \mt\Parameter::getVal('hero_piece_synthesis_num',0); diff --git a/webapp/mt/Item.php b/webapp/mt/Item.php index 9151fade..71e74ba1 100644 --- a/webapp/mt/Item.php +++ b/webapp/mt/Item.php @@ -116,9 +116,7 @@ class Item { const MATERIAL_CHIP_SUBTYPE = 3; const HERO_FRAGMENT_SUBTYPE = 1; - const HERO_FRAGMENT_SUBTYPE_PRO = 3; - const GUN_FRAGMENT_SUBTYPE = 2; - const GUN_FRAGMENT_SUBTYPE_PRO = 4; + const CHIP_FRAGMENT_SUBTYPE = 2; public static function get($id)