game2006api/webapp/controller/FragmentController.class.php
hujiabin 2cb9bc1bc8 1
2024-01-25 16:04:16 +08:00

123 lines
4.8 KiB
PHP

<?php
require_once('models/Fragment.php');
require_once('models/Bag.php');
require_once('models/Hero.php');
require_once('models/Chip.php');
require_once('services/PropertyChgService.php');
require_once('services/LogService.php');
use models\Fragment;
use models\Bag;
use models\Hero;
use models\Chip;
use services\FormulaService;
use services\LogService;
use phpcommon\SqlHelper;
class FragmentController extends BaseAuthedController
{
public function syntheticFragment(){
$itemId = getReqVal('item_id',0);
$itemMeta = \mt\Item::get($itemId);
if (!$itemMeta || $itemMeta['type'] != \mt\Item::FRAGMENT_TYPE){
$this->_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 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;
}