_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(); if ($itemMeta['sub_type'] == \mt\Item::HERO_FRAGMENT_SUBTYPE){ Hero::addSyntheticHero($itemMetaDto,$itemMeta['quality']); $propertyChgService->addHeroChg(); } if ($itemMeta['sub_type'] == \mt\Item::CHIP_FRAGMENT_SUBTYPE){ Chip::addSyntheticChip($itemMetaDto,$itemMeta['quality']); $propertyChgService->addChip(); } $this->_rspData(array( 'item_id' => $itemMetaDto['id'], 'property_chg' => $propertyChgService->toDto(), )); } //新合成 public function synHero(){ $itemId = getReqVal('item_id',0); $itemNum = getReqVal('item_num',0); $itemMeta = \mt\Item::get($itemId); if (!$itemMeta || $itemMeta['type'] != \mt\Item::FRAGMENT_TYPE){ $this->_rspErr(1, "param error"); return; } if ($itemMeta['sub_type'] != \mt\Item::HERO_FRAGMENT_SUBTYPE){ $this->_rspErr(1, "param error"); return; } if ($itemNum < 1){ $this->_rspErr(1, "param error"); return; } $heroMeta = \mt\Item::get($itemMeta['relationship']); if ( !$heroMeta ){ $this->_rspErr(1, "param error"); return; } $manufactureMeta = \mt\Manufacture::findHeroAction(\mt\Manufacture::SYN_ACTION,$itemMeta['quality']); if (!$manufactureMeta){ $this->_rspErr(1, "Error operation"); return; } $itemNum = min($itemNum,$manufactureMeta['numTop']); $costItems = array( array( 'item_id' => V_ITEM_GOLD, 'item_num' => $manufactureMeta['gold'] ), array( 'item_id' => $itemId, 'item_num' => $itemNum ), ); $lackItem = null; if (!$this->_hasEnoughItems($costItems, $lackItem)) { $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); return; } //消耗材料 $this->_decItems($costItems); $propertyChgService = new services\PropertyChgService(); $propertyChgService->addBagChg(); $propertyChgService->addUserChg(); $hashChance = \mt\Manufacture::hashChance($manufactureMeta['chance']); $weight = isset($hashChance[$itemNum]) ? $hashChance[$itemNum] : 0; $rnd = rand(1,100); $status = 0; if ($rnd <= $weight*100){ $status = 1; $propertyChgService->addHeroChg(); // if ($itemMeta['quality'] > 1){ // 上链 // }else{ Hero::addSyntheticHero($heroMeta,$itemMeta['quality']); $lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql()); $heroInfo = Hero::toDto(Hero::find($lastIdx)); // } } $event = array( 'ID' => 'hero', 'SUB_ID' => 'synthesis', 'SUB_KEY' => 'hero_synthesis', 'cost_fragment' => array( 'item_id' => $itemId, 'item_num' => $itemNum, 'item_quality' => $itemMeta['quality'], ), 'cost_gold' => array( 'item_id' => V_ITEM_GOLD, 'item_num' => $manufactureMeta['gold'] ), 'chance' => $weight, 'result' => $status, 'outcome_hero' => isset($heroInfo) ? $heroInfo : array(), ); LogService::burialPointEvent($event); $this->_rspData(array( 'item_id' => $heroMeta['id'], 'status' => $status, 'property_chg' => $propertyChgService->toDto(), )); } public function synChip(){ $itemId = getReqVal('item_id',0); $itemNum = getReqVal('item_num',0); $itemMeta = \mt\Item::get($itemId); if (!$itemMeta || $itemMeta['type'] != \mt\Item::FRAGMENT_TYPE){ $this->_rspErr(1, "param error"); return; } if ($itemMeta['sub_type'] != \mt\Item::CHIP_FRAGMENT_SUBTYPE){ $this->_rspErr(1, "param error"); return; } if ($itemNum < 1){ $this->_rspErr(1, "param error"); return; } $chipMeta = \mt\Item::get($itemMeta['relationship']); if ( !$chipMeta ){ $this->_rspErr(1, "param error"); return; } $manufactureMeta = \mt\Manufacture::findChipAction(\mt\Manufacture::SYN_ACTION,$itemMeta['quality']); if (!$manufactureMeta){ $this->_rspErr(1, "Error operation"); return; } $itemNum = min($itemNum,$manufactureMeta['numTop']); $costItems = array( array( 'item_id' => V_ITEM_GOLD, 'item_num' => $manufactureMeta['gold'] ), array( 'item_id' => $itemId, 'item_num' => $itemNum ), ); $lackItem = null; if (!$this->_hasEnoughItems($costItems, $lackItem)) { $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); return; } //消耗材料 $this->_decItems($costItems); $propertyChgService = new services\PropertyChgService(); $propertyChgService->addBagChg(); $propertyChgService->addUserChg(); $hashChance = \mt\Manufacture::hashChance($manufactureMeta['chance']); $weight = isset($hashChance[$itemNum]) ? $hashChance[$itemNum] : 0; $rnd = rand(1,100); $status = 0; if ($rnd <= $weight*100){ $status = 1; Chip::addSyntheticChip($chipMeta,$itemMeta['quality']); $propertyChgService->addChip(); $lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql()); $chipInfo = Chip::toDto(Chip::find($lastIdx)); } $event = array( 'ID' => 'chip', 'SUB_ID' => 'synthesis', 'SUB_KEY' => 'chip_synthesis', 'cost_fragment' => array( 'item_id' => $itemId, 'item_num' => $itemNum, 'item_quality' => $itemMeta['quality'], ), 'cost_gold' => array( 'item_id' => V_ITEM_GOLD, 'item_num' => $manufactureMeta['gold'] ), 'chance' => $weight, 'result' => $status, 'outcome_chip' => isset($chipInfo) ? $chipInfo : array(), ); LogService::burialPointEvent($event); $this->_rspData(array( 'item_id' => $chipMeta['id'], 'status' => $status, 'property_chg' => $propertyChgService->toDto(), )); } public function showBaseByItemId(){ $item_id = getReqVal('item_id',''); $itemMeta = mt\Item::get($item_id); if (! $itemMeta){ $this->_rspErr(1, 'item_id parameter error'); return; } if ($itemMeta['type'] == self::HERO_TYPE){ $heroMeta = mt\Hero::get($itemMeta['id']); $baseAttr =[]; if ($heroMeta) { $baseAttr = mt\Hero::getHeroAttr($heroMeta); } $heroLucky = FormulaService::Hero_Advanced_Lucky_Value(1); $hero = array( 'hero_id' => $itemMeta['id'], 'hero_lv' => 1, 'quality' => 1, 'skill_lv1' => 1, 'skill_lv2' => 1, 'rand_attr' => $baseAttr, 'lucky' => strval($heroLucky), 'hero_tili' => strval(round(FormulaService::Hero_NFT_Maximum_Physical_Strength(1,$heroLucky),3)), 'hero_tili_max' => strval(round(FormulaService::Hero_NFT_Maximum_Physical_Strength(1,$heroLucky),3)), 'chip_strength_sum' =>0, 'labour'=>0 ); $hero['current_pvp_get_ceg'] = strval(round(FormulaService::getHeroPvpDailyCegUpLimit($hero),2)); $hero['pvp_ceg_uplimit'] = strval(round(FormulaService::getHeroPvpDailyCegUpLimit($hero),2)); $hero['current_pve_get_ceg'] = strval(round(FormulaService::getHeroPveDailyCegUpLimit($hero),2)); $hero['pve_ceg_uplimit'] = strval(round(FormulaService::getHeroPveDailyCegUpLimit($hero),2)); $this->_rspData(array( 'data' => $hero )); }else if ($itemMeta['type'] == self::GUN_TYPE){ $baseAttr = mt\Equip::getGunBaseAttrs($itemMeta['relationship']); $gunLucky = FormulaService::Weapon_Advanced_Lucky_Value(1); $gun = array( 'gun_id' => $itemMeta['id'], 'gun_lv' => 1, 'quality' => 1, 'rand_attr' => $baseAttr, 'lucky' => strval($gunLucky), 'durability' => strval(round(FormulaService::Weapon_NFT_Maximum_Durability(1,$gunLucky),3)), 'durability_max' => strval(round(FormulaService::Weapon_NFT_Maximum_Durability(1,$gunLucky),3)), 'chip_strength_sum' =>0, 'labour'=>0 ); $gun['current_pvp_get_ceg'] = strval(round(FormulaService::getWeaponPvpDailyCegUpLimit($gun),2)) ; $gun['pvp_ceg_uplimit'] = strval(round(FormulaService::getWeaponPvpDailyCegUpLimit($gun),2)) ; $gun['current_pve_get_ceg'] = strval(round(FormulaService::getWeaponPveDailyCegUpLimit($gun),2)) ; $gun['pve_ceg_uplimit'] = strval(round(FormulaService::getWeaponPveDailyCegUpLimit($gun),2)) ; $this->_rspData(array( 'data' => $gun )); }else{ $this->_rspErr(1, 'item_id parameter error'); return; } } const HERO_TYPE = 3; const GUN_TYPE = 7; }