diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 18cdc58e..434bd933 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -448,7 +448,6 @@ 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); @@ -465,7 +464,7 @@ class HeroController extends BaseAuthedController { $heroMeta = \mt\Item::get($itemMeta['relationship']); Bag::decItem($itemId,$pieceNum); - Hero::addHero($heroMeta); + Hero::addFreeHero($heroMeta); $heroIdx = SqlHelper::getLastInsertId($this->_getSelfMysql()); $heroInfo = Hero::toDto(Hero::find($heroIdx)); $propertyChgService = new services\PropertyChgService(); diff --git a/webapp/controller/MapController.class.php b/webapp/controller/MapController.class.php new file mode 100644 index 00000000..6a4ab0d5 --- /dev/null +++ b/webapp/controller/MapController.class.php @@ -0,0 +1,239 @@ +_rspData(array( + 'data' => $chipList, + )); + } + + public function chipDetails(){ + $unique_id = trim(getReqVal('unique_id', 0)); + if (! $unique_id){ + $this->_rspErr(1, 'Please enter parameter unique_id'); + return ; + } + $chipDb = Chip::find($unique_id); + if (! $chipDb){ + $this->_rspErr(1, "You don't have the chip yet"); + return; + } + $chip = Chip::toDto($chipDb); + $this->_rspData(array( + 'data' => $chip, + )); + } + + public function upgradeLevelPreview(){ + $unique_id = trim(getReqVal('unique_id', 0)); + if (! $unique_id) { + $this->_rspErr(1, 'Please enter parameter unique_id'); + return; + } + $chipDb = Chip::find($unique_id); + if (!$chipDb){ + $this->_rspErr(1,'unique_id parameter error'); + return; + } + if ($chipDb['chip_grade'] == Chip::CHIP_LV_MAX){ + $this->_rspErr(1,' Level upper limit'); + return; + } + $paramMeta = mt\Parameter::getByName('chip_upgrade_cost'); + if (!$paramMeta){ + $this->_rspErr(1, ' parameter null'); + return; + } + $chip = Chip::toDto($chipDb); + $rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array()); + $chipMeta = mt\ChipAttr::getAttrByItemId($chipDb['item_id']); + if ($chipMeta){ + array_unshift($rand_attr,array( + 'attr_id'=>$chipMeta['attr_id'], + 'val' => $chipMeta['lv'.($chipDb['chip_grade']+1)] + )); + } + $chip['rand_attr_after'] = $rand_attr; + + $paramValue = explode('|',$paramMeta['param_value']); + $gold = 0; + $stone = 0; + switch ($chipDb['chip_grade']){ + case 1: { + $lv2 = explode(':',$paramValue[0]); + $gold = $lv2[0]; + $stone = $lv2[1]; + };break; + case 2: { + $lv3 = explode(':',$paramValue[1]); + $gold = $lv3[0]; + $stone = $lv3[1]; + };break; + } + + $chip['cost'] = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $gold + ), + array( + 'item_id' => V_ITEM_CHIP_META, + 'item_num' => $stone + ) + ); + $this->_rspData(array( + 'data' => $chip + )); + } + + public function selectChip(){ + $unique_id = trim(getReqVal('unique_id', 0)); + $idxArr = explode(' ',$unique_id); + if (count($idxArr)<0){ + $this->_rspErr(1, 'Please enter instructions'); + return; + } + $chipDbMain = Chip::find($idxArr[0]); + $chipDbParam = Chip::find($idxArr[1]); + if (!$chipDbMain || !$chipDbParam){ + $this->_rspErr(1,'unique_id parameter error'); + return; + } + if ($chipDbParam['token_id']) { + $this->_rspErr(1, "Unable to use nft chip"); + return; + } + if (!$chipDbParam['state']) { + $this->_rspErr(1, "Unable to use free chip"); + return; + } + if ($chipDbParam['chip_grade']>$chipDbMain['chip_grade']){ + $this->_rspErr(1, "The selected material is too high grade"); + return; + } + $cost = \services\FormulaService::getChipCumulativeCost($chipDbParam['chip_grade']); + $this->_rspData(['cost'=>$cost]); + } + + public function upgradeLevel(){ + $chipUniId = trim(getReqVal('chip_uniid', 0)); + if (!$chipUniId) { + $this->_rspErr(1, 'Please enter parameter'); + return; + } + $chipDb = Chip::find($chipUniId); + if (!$chipDb){ + $this->_rspErr(1,'unique_id_main parameter error'); + return; + } + if ($chipDb['chip_grade'] == Chip::CHIP_LV_MAX){ + $this->_rspErr(1,' Level upper limit'); + return; + } + + $paramMeta = mt\Parameter::getByName('chip_upgrade_cost'); + if (!$paramMeta){ + $this->_rspErr(1, ' parameter null'); + return; + } + $paramValue = explode('|',$paramMeta['param_value']); + $gold = 0; + $stone = 0; + switch ($chipDb['chip_grade']){ + case 1: { + $lv2 = explode(':',$paramValue[0]); + $gold = $lv2[0]; + $stone = $lv2[1]; + };break; + case 2: { + $lv3 = explode(':',$paramValue[1]); + $gold = $lv3[0]; + $stone = $lv3[1]; + };break; + } + + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $gold + ), + array( + 'item_id' => V_ITEM_CHIP_META, + 'item_num' => $stone + ), + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $this->_decItems($costItems); +// Bag::decItem(V_ITEM_CHIP_META,$stone); + + { + //埋点 + $event = [ + 'name' => LogService::CHIP_LEVEL_UP, + 'val' => $gold + ]; + LogService::consumeGold($event); + } + + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addChip(); + $propertyChgService->addBagChg(); + $propertyChgService->addUserChg(); + $rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array()); + $attrProMeta = \mt\ChipAttr::getAttrPool($chipDb); + array_push($rand_attr,array( + 'attr_id'=>$attrProMeta['attr_id'], + 'val'=>$attrProMeta['val'], + )); + Chip::update2($chipUniId, + array( + 'chip_grade' => $chipDb['chip_grade']+1, + //'state' => Chip::GETED_STATE, + 'rand_attr' => json_encode($rand_attr), + ) + ); + $chipDbNew = Chip::toDto(Chip::find($chipUniId)); + $this->_rspData([ + 'data'=>$chipDbNew, + 'property_chg' => $propertyChgService->toDto(), + ]); + } + +}