This commit is contained in:
hujiabin 2024-01-10 14:28:48 +08:00
parent 586d9a1001
commit 9a1c176960
4 changed files with 96 additions and 125 deletions

View File

@ -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', [], '英雄或枪械的基本信息']
]
},
]

View File

@ -1,79 +1,64 @@
<?php
require_once('models/Fragment.php');
require_once('models/Nft.php');
require_once('models/Bag.php');
require_once('models/Hero.php');
require_once('models/Gun.php');
require_once('models/Chip.php');
require_once('services/PropertyChgService.php');
require_once('services/LogService.php');
use models\Fragment;
use models\Nft;
use models\Bag;
use models\Hero;
use models\Gun;
use models\Chip;
use services\FormulaService;
use services\LogService;
use phpcommon\SqlHelper;
class FragmentController extends BaseAuthedController
{
private $hero_count = 9;
private $gun_count = 9;
public function fragmentList()
{
$fragmentList = array();
foreach (Fragment::getFragmentList() as $val){
array_push($fragmentList,Fragment::ToDto($val));
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();
$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','');

View File

@ -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);

View File

@ -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)