1
This commit is contained in:
parent
fdd12465aa
commit
7e0e30cc6f
@ -587,7 +587,7 @@ class HeroController extends BaseAuthedController {
|
|||||||
英雄分解
|
英雄分解
|
||||||
*/
|
*/
|
||||||
public function heroSalvage(){
|
public function heroSalvage(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,239 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once('models/Chip.php');
|
|
||||||
require_once('models/Hero.php');
|
|
||||||
require_once('models/Gun.php');
|
|
||||||
require_once('models/User.php');
|
|
||||||
require_once('models/Bag.php');
|
|
||||||
|
|
||||||
require_once('mt/ChipAttr.php');
|
|
||||||
|
|
||||||
require_once('services/FormulaService.php');
|
|
||||||
require_once('services/PropertyChgService.php');
|
|
||||||
require_once('services/LogService.php');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
use models\Chip;
|
|
||||||
use models\Bag;
|
|
||||||
use models\Hero;
|
|
||||||
use models\Gun;
|
|
||||||
use models\User;
|
|
||||||
use services\FormulaService;
|
|
||||||
use services\LogService;
|
|
||||||
use phpcommon\SqlHelper;
|
|
||||||
|
|
||||||
class ChipController extends BaseAuthedController
|
|
||||||
{
|
|
||||||
public function chipList()
|
|
||||||
{
|
|
||||||
$chipList = array();
|
|
||||||
Chip::getChipList(function ($row) use(&$chipList){
|
|
||||||
// if ($row['inlay_state'] != 1){
|
|
||||||
array_push($chipList, Chip::toDto($row));
|
|
||||||
// }
|
|
||||||
});
|
|
||||||
$this->_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(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user