diff --git a/doc/Fragment.py b/doc/Fragment.py new file mode 100644 index 00000000..80adf0b6 --- /dev/null +++ b/doc/Fragment.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- + +import _common + +class Fragment(object): + + def __init__(self): + self.apis = [ + { + 'name': 'fragmentList', + 'desc': '获取碎片列表', + 'group': 'Chip', + 'url': 'webapp/index.php?c=Fragment&a=fragmentList', + 'params': [ + _common.ReqHead(), + ['type', '', '碎片类型:1 英雄;2 枪械'], + ], + 'response': [ + _common.RspHead(), + ['!data', [_common.Fragment()], '芯片列表'] + ] + },{ + 'name': 'syntheticFragmentPreview', + 'desc': '碎片合成前', + 'group': 'Chip', + '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': 'Chip', + 'url': 'webapp/index.php?c=Fragment&a=syntheticFragment', + 'params': [ + _common.ReqHead(), + ['type', '', '类型:1 英雄;2 枪械'], + ['unique_ids', '', '普通碎片unique id,用“|”分开;例:id1|id2|id3...'], + ['unique_id_special', '', '特殊碎片unique id'], + ['item_id', '', '英雄或枪械的道具id'], + ], + 'response': [ + _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], + ['item_id', 0, '道具id'] + ] + }, + + ] \ No newline at end of file diff --git a/doc/_common.py b/doc/_common.py index 3d65e767..440da83e 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -33,7 +33,7 @@ class Attr(object): def __init__(self): self.fields = [ ['attr_id', 0, '属性id'], - ['type', 0, '1: 绝对值 2:百分比'], + ['type', 0, '1: 绝对值 2:百分比 ---弃用字段'], ['val', 0, '属性值'], ] @@ -43,7 +43,7 @@ class AttrDesc(object): self.fields = [ ['name', '', '属性名'], ['attr_id', 0, '属性id'], - ['type', 0, '1: 绝对值 2:百分比'], + ['type', 0, '1: 绝对值 2:百分比 ---弃用字段' ], ['val', 0, '属性值'], ] @@ -642,7 +642,7 @@ class ChipAttr(object): def __init__(self): self.fields = [ ['attr_id', 0, '属性id'], - ['type', 0, '1: 绝对值 2:百分比'], + ['type', 0, '1: 绝对值 2:百分比 ---弃用字段'], ['val', 0, '综合属性值'], ['chip_type', 0, '1:英雄芯片 2:枪械芯片'], ['attr_num', 0, '成长属性值'], @@ -658,7 +658,7 @@ class ChipCore(object): ['chip_core_lv', 0, '核心等级'], ['attr_id', 0, '芯片属性id'], ['attr_number', 0, '属性加成'], - ['attr_add_type', 0, '加成类型:1 绝对值;2 百分比 '], + ['attr_add_type', 0, '加成类型:1 绝对值;2 百分比 ---弃用字段'], ] class Chip(object): @@ -725,4 +725,17 @@ class Cost(object): ['CEG', '', '金币'], ['CEC', '', '钻石'], + ] + +class Fragment(object): + + def __init__(self): + self.fields = [ + ['idx', 0, '主键id'], + ['token_id', '', 'token id'], + ['item_id', '', '道具id'], + ['type', '', '碎片类型 1:英雄碎片 2:枪械碎片 3:特殊英雄碎片 4:特殊枪械碎片'], + ['parts', '', '碎片部位 0:特殊碎片的部位 1-8:普通部位'], + ['createtime', 0, '创建时间'], + ['modifytime', 0, '修改时间'], ] \ No newline at end of file diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 6aaae28e..ffcfe64d 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -207,6 +207,26 @@ CREATE TABLE `t_bag` ( ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `t_bag` +-- + +DROP TABLE IF EXISTS `t_fragment`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_fragment` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `token_id` varchar(60) COMMENT 'token_id', + `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', + `type` int(11) NOT NULL DEFAULT '1' COMMENT '1:角色碎片 2:武器碎片 3:角色特殊碎片 4:武器特殊碎片', + `parts` int(11) NOT NULL DEFAULT '1' COMMENT '部位', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `token_id` (`token_id`), + KEY `item_id` (`item_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `t_chip` @@ -566,7 +586,7 @@ CREATE TABLE `t_nft_active` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', `token_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'token id', - `token_type` int(11) NOT NULL DEFAULT '0' COMMENT 'nft类型 1:英雄 2:枪支 3:芯片', + `token_type` int(11) NOT NULL DEFAULT '0' COMMENT 'nft类型 1:英雄 2:枪支 3:芯片 5:碎片箱子', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index 36ee5f94..afcd576a 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -8,6 +8,7 @@ require_once('mt/Hero.php'); require_once('models/Bag.php'); require_once('models/Hero.php'); require_once('models/Gun.php'); +require_once('models/Nft.php'); require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); @@ -18,6 +19,7 @@ use phpcommon\SqlHelper; use models\Bag; use models\Hero; use models\Gun; +use models\Nft; class BagController extends BaseAuthedController { @@ -91,6 +93,8 @@ class BagController extends BaseAuthedController { } } else if ($itemMeta['type'] == mt\Item::GIFT_PACKAGE_TYPE) { $this->openGiftPackage($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3); + } else if ($itemMeta['type'] == mt\Item::FRAGMENT_BOX_TYPE) { + $this->openFragmentBox($itemDb, $itemMeta, $itemNum); } else { $this->_rspErr(4, 'The prop function has not been realized yet'); } @@ -270,4 +274,22 @@ class BagController extends BaseAuthedController { )); } + private function openFragmentBox($itemDb, $itemMeta, $itemNum){ + if ($itemDb['item_num']<$itemNum){ + $this->_rspErr(1, "The shard chest is insufficient"); + return; + } + for ($i=1;$i<=$itemNum;$i++){ + if (! Nft::addNftByFragmentBox($itemMeta,$i)){ + $this->_rspErr(1, "server internal error"); + return; + } + Bag::decItemByUnIid($itemDb['item_uniid'], 1); + } + $this->propertyChgService->addBagChg(); + $this->_rspData(array( + 'property_chg' => $this->propertyChgService->toDto(), + )); + } + } diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 49204979..8d267265 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -327,6 +327,12 @@ class BaseAuthedController extends BaseController { $propertyService->addGunSkinChg(); } break; + case mt\Item::FRAGMENT_BOX_TYPE: + { + Bag::addItem($item['item_id'], $item['item_num']); + $propertyService->addBagChg(); + } + break; default: { $this->_addLog('additems', 'invalid_item', array( diff --git a/webapp/controller/FragmentController.class.php b/webapp/controller/FragmentController.class.php new file mode 100644 index 00000000..709db4dc --- /dev/null +++ b/webapp/controller/FragmentController.class.php @@ -0,0 +1,310 @@ +_rspErr(1,'type parameter error'); + return ; + } + $fragmentList = []; + Fragment::getFragmentList(function ($row) use(&$fragmentList,$type) { + switch ($type){ + case 1: + { + if ( $row['type'] == 1 || $row['type'] == 3){ + array_push($fragmentList, $row); + } + } + break; + case 2: + { + if ( $row['type'] == 2 || $row['type'] == 4){ + array_push($fragmentList, $row); + }; + } + } + }); + $this->_rspData(array( + 'fragment_list' => $fragmentList + )); + } + + 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']); + } + $mint = \services\FormulaService::Hero_Parts_Synthetic_Cost($this->hero_count); + $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']); + } + $mint = \services\FormulaService::Weapon_Parts_Synthetic_Cost($this->gun_count); + $this->_rspData(array( + 'list' => $gun, + 'mint' => $mint + )); + } + break; + default: + { + $this->_rspErr(1, 'type parameter error'); + return; + } + } + } + + public function syntheticFragment(){ + $type = getReqVal('type', 0); + $unique_ids = getReqVal('unique_ids',''); + $unique_id_special = getReqVal('unique_id_special',''); + $item_id = getReqVal('item_id',''); + $unique_id_arr = explode('|',$unique_ids); + if (count($unique_id_arr) != 8){ + $this->_rspErr(1,'Insufficient number of parameters'); + return ; + } + switch ($type) { + case 1: + { + if ($unique_id_special){ + //指定合成英雄 + $itemMeta = mt\Item::get($item_id); + if (!$itemMeta){ + $this->_rspErr(1,'item_id param error'); + return ; + } + $fragmentDbSpecial = Fragment::getFragmentByIdx($unique_id_special); + if (!$fragmentDbSpecial){ + $this->_rspErr(1,'unique_id_special param error'); + return ; + } + if ($fragmentDbSpecial['type'] != 3){ + $this->_rspErr(1,'unique_id_special param error(type)'); + return ; + } + $token_id_arr = array(); + foreach ($unique_id_arr as $val){ + $fragmentDb = Fragment::getFragmentByIdx($val); + if (!$fragmentDb){ + $this->_rspErr(1,'unique_ids param error'); + return ; + } + if ($fragmentDb['type'] != 1){ + $this->_rspErr(1,'unique_ids param error(type)'); + return ; + } + array_push($token_id_arr,$fragmentDb['token_id']); + } + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => \services\FormulaService::Hero_Parts_Synthetic_Cost($this->hero_count) + ) + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + //销毁碎片 + foreach ($token_id_arr as $val){ + Fragment::deleteFragment(['token_id'=>$val]); + } + $this->_decItems($costItems); + //生成NFT英雄 + Nft::addNft($itemMeta); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addUserChg(); + $propertyChgService->addFragment(); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + 'item_id' => $itemMeta['id'] + )); + }else{ + //随机合成英雄 + $token_id_arr = array(); + foreach ($unique_id_arr as $val){ + $fragmentDb = Fragment::getFragmentByIdx($val); + if (!$fragmentDb){ + $this->_rspErr(1,'unique_id param error'); + return ; + } + if ($fragmentDb['type'] != 1){ + $this->_rspErr(1,'unique_id param error(type)'); + return ; + } + array_push($token_id_arr,$fragmentDb['token_id']); + } + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => \services\FormulaService::Hero_Parts_Synthetic_Cost($this->hero_count) + ) + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + //销毁碎片 + foreach ($token_id_arr as $val){ + Fragment::deleteFragment(['token_id'=>$val]); + } + $this->_decItems($costItems); + $itemMetaList = mt\Item::getMetaListByType(mt\Item::HERO_TYPE); + $key = rand(0,count($itemMetaList)-1); + $itemMeta = $itemMetaList[$key]; + //生成NFT英雄 + Nft::addNft($itemMeta); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addUserChg(); + $propertyChgService->addFragment(); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + 'item_id' => $itemMeta['id'] + )); + } + } + break; + case 2: + { + if ($unique_id_special){ + //指定合成枪械 + $itemMeta = mt\Item::get($item_id); + if (!$itemMeta){ + $this->_rspErr(1,'item_id param error'); + return ; + } + $fragmentDbSpecial = Fragment::getFragmentByIdx($unique_id_special); + if (!$fragmentDbSpecial){ + $this->_rspErr(1,'unique_id_special param error'); + return ; + } + if ($fragmentDbSpecial['type'] != 4){ + $this->_rspErr(1,'unique_id_special param error(type)'); + return ; + } + $token_id_arr = array(); + foreach ($unique_id_arr as $val){ + $fragmentDb = Fragment::getFragmentByIdx($val); + if (!$fragmentDb){ + $this->_rspErr(1,'unique_ids param error'); + return ; + } + if ($fragmentDb['type'] != 2){ + $this->_rspErr(1,'unique_ids param error(type)'); + return ; + } + array_push($token_id_arr,$fragmentDb['token_id']); + } + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => \services\FormulaService::Weapon_Parts_Synthetic_Cost($this->gun_count) + ) + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + //销毁碎片 + foreach ($token_id_arr as $val){ + Fragment::deleteFragment(['token_id'=>$val]); + } + $this->_decItems($costItems); + //生成NFT英雄 + Nft::addNft($itemMeta); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addUserChg(); + $propertyChgService->addFragment(); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + 'item_id' => $itemMeta['id'] + )); + + }else{ + //随机合成枪械 + $token_id_arr = array(); + foreach ($unique_id_arr as $val){ + $fragmentDb = Fragment::getFragmentByIdx($val); + if (!$fragmentDb){ + $this->_rspErr(1,'unique_id param error'); + return ; + } + if ($fragmentDb['type'] != 2){ + $this->_rspErr(1,'unique_id param error(type)'); + return ; + } + array_push($token_id_arr,$fragmentDb['token_id']); + } + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => \services\FormulaService::Weapon_Parts_Synthetic_Cost($this->gun_count) + ) + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + //销毁碎片 + foreach ($token_id_arr as $val){ + Fragment::deleteFragment(['token_id'=>$val]); + } + $this->_decItems($costItems); + $itemMetaList = mt\Item::getMetaListByType(mt\Item::GUN_TYPE); + $key = rand(0,count($itemMetaList)-1); + $itemMeta = $itemMetaList[$key]; + //生成NFT英雄 + Nft::addNft($itemMeta); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addUserChg(); + $propertyChgService->addFragment(); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + 'item_id' => $itemMeta['id'] + )); + } + } + break; + default: + { + $this->_rspErr(1, 'type parameter error'); + return; + } + } + } + +} \ No newline at end of file diff --git a/webapp/models/Bag.php b/webapp/models/Bag.php index ef91db80..1d7405e5 100644 --- a/webapp/models/Bag.php +++ b/webapp/models/Bag.php @@ -272,4 +272,5 @@ class Bag extends BaseModel { ); } + } diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index ebbc9c0d..2bdc9ee1 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -31,7 +31,7 @@ class Chip extends BaseModel 't_nft', array( 'owner_address' => myself()->_getOpenId(), - 'token_type' =>3, + 'token_type' =>Nft::CHIP_TYPE, 'deleted' => 0 ) ); @@ -124,7 +124,6 @@ class Chip extends BaseModel $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$grade); } $fieldsKv = array( - 'account_id' => myself()->_getAccountId(), 'item_id' => $itemId, 'item_num' => 1, 'rand_attr' => json_encode($randAttr), diff --git a/webapp/models/Fragment.php b/webapp/models/Fragment.php new file mode 100644 index 00000000..afa6f91a --- /dev/null +++ b/webapp/models/Fragment.php @@ -0,0 +1,108 @@ +_getMarketMysql(), + 't_nft', + array( + 'owner_address' => myself()->_getOpenId(), + 'token_type' =>Nft::FRAGMENT_TYPE, + 'deleted' => 0 + ) + ); +// print_r($nft);die; + foreach ($nft as $nftDb) { + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_fragment', + array( + 'token_id' => $nftDb['token_id'], + ) + ); + if (!$row) { + $itemMeta = mt\Item::get($nftDb['item_id']); + if ($itemMeta) { + self::addNftHero($itemMeta, $nftDb['token_id']); + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_fragment', + array( + 'token_id' => $nftDb['token_id'], + ) + ); + } + } + if ($row) { + $cb($row); + } + } + + } + + public static function addNftHero($fragmentMeta, $tokenId) + { + return self::internalAddHero( + myself()->_getMysql($tokenId), + $fragmentMeta, + null, + $tokenId); + } + + public static function internalAddHero($conn, $fragmentMeta, $accountId, $tokenId) + { + $fieldsKv = array( + 'item_id' => $fragmentMeta['id'], + 'type' => $fragmentMeta['sub_type'], + 'parts' => substr($fragmentMeta['id'],-2,1), + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ); + if ($accountId) { + $fieldsKv['account_id'] = $accountId; + } + if ($tokenId) { + $fieldsKv['token_id'] = $tokenId; + } + + SqlHelper::insert( + myself()->_getSelfMysql(), + 't_fragment', + $fieldsKv + ); + } + + public static function getFragmentByIdx($idx){ + return SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_fragment', + array( + 'idx' => $idx, + ) + ); + + } + + public static function deleteFragment($whereKv){ + SqlHelper::update( + myself()->_getMarketMysql(), + 't_nft', + $whereKv, + ['deleted'=>1] + ); + } + + +} \ No newline at end of file diff --git a/webapp/models/Nft.php b/webapp/models/Nft.php index 8bd46d87..f128e6ea 100644 --- a/webapp/models/Nft.php +++ b/webapp/models/Nft.php @@ -14,10 +14,11 @@ use phpcommon\SqlHelper; class Nft extends BaseModel { const NONE_TYPE = 0; - const HERO_TYPE = 1; - const EQUIP_TYPE = 2; - const CHIP_TYPE = 3; + const HERO_TYPE = 1; //英雄 + const EQUIP_TYPE = 2; //枪械 + const CHIP_TYPE = 3; //芯片 const BLIND_BOX_TYPE = 4; + const FRAGMENT_TYPE = 5; //碎片 const GENESIS_TAG = 1; @@ -50,6 +51,11 @@ class Nft extends BaseModel { { return self::CHIP_TYPE; } + break; + case mt\Item::FRAGMENT_BOX_TYPE: + { + return self::FRAGMENT_TYPE; + } } return self::NONE_TYPE; } @@ -236,6 +242,58 @@ class Nft extends BaseModel { } } + public static function addNftByFragmentBox($itemMeta,$num=0){ + if ($itemMeta) { + $tokenType = Nft::getTokenType($itemMeta); + if ($tokenType == Nft::NONE_TYPE) { + return false; + } else { + SqlHelper::insert( + myself()->_getMarketMysql(), + 't_nft', + array( + 'token_id' => myself()->_getNowTime()+$num, + 'token_type' => $tokenType, + 'game_id' => 2006, + 'item_id' => $itemMeta['include_item_id'], + 'owner_address' => myself()->_getOpenId(), + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + return true; + } + } else { + return false; + } + } + + public static function addNft($itemMeta){ + if ($itemMeta) { + $tokenType = Nft::getTokenType($itemMeta); + if ($tokenType == Nft::NONE_TYPE) { + return false; + } else { + SqlHelper::insert( + myself()->_getMarketMysql(), + 't_nft', + array( + 'token_id' => myself()->_getNowTime(), + 'token_type' => $tokenType, + 'game_id' => 2006, + 'item_id' => $itemMeta['id'], + 'owner_address' => myself()->_getOpenId(), + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + return true; + } + } else { + return false; + } + } + private static function parseTags($tagsStr) { $tags = explode('|', $tagsStr); diff --git a/webapp/mt/Item.php b/webapp/mt/Item.php index 84ad1e82..895015d1 100644 --- a/webapp/mt/Item.php +++ b/webapp/mt/Item.php @@ -24,6 +24,7 @@ class Item { 11 碎片 12 盲盒 13 芯片 + 15 碎片透明箱子 */ /* @@ -68,6 +69,10 @@ class Item { type类型为13时,配置一下子类id 1.角色芯片 2.枪械芯片 + + type类型为15时,配置一下子类id + 1.角色碎片 + 2.枪械碎片 */ const NONE_TYPE = 0; const VIRTUAL_TYPE = 1; @@ -83,6 +88,7 @@ class Item { const FRAGMENT_TYPE = 11; const BLIND_BOX_TYPE = 12; const CHIP_TYPE = 13; + const FRAGMENT_BOX_TYPE = 15; const FUNC_RENAME_CARD_SUBTYPE = 1; const MATERIAL_CHIP_SUBTYPE = 3; @@ -247,6 +253,17 @@ class Item { )); } + public static function getMetaListByType($type) + { + $metaList = array(); + foreach (self::getMetaList() as $meta){ + if ($meta['type'] == $type){ + array_push($metaList,$meta); + } + } + return $metaList; + } + protected static function getMetaList() { if (!self::$metaList) { diff --git a/webapp/services/FormulaService.php b/webapp/services/FormulaService.php index 6c68cecb..9a017119 100644 --- a/webapp/services/FormulaService.php +++ b/webapp/services/FormulaService.php @@ -449,4 +449,15 @@ class FormulaService extends BaseService { return $lucky*round(1.1714+0.0286*$quality,3); } + //英雄NFT碎片合成费用 + public static function Hero_Parts_Synthetic_Cost($hero_count){ + //ROUND(每日新增1阶英雄NFT数量(前1天官方商城正价购买)*6%,0)*30%*2000*CEG折扣比率 + return round($hero_count*0.06,0)*0.3*2000*self::CEG_Discount_Rate(); + } + + //枪械NFT碎片合成费用 + public static function Weapon_Parts_Synthetic_Cost($gun_count){ + //ROUND(每日新增1阶枪械NFT数量(前1天官方商城正价购买)*6%,0)*30%*600*CEG折扣比率 + return round($gun_count*0.06,0)*0.3*600*self::CEG_Discount_Rate(); + } } diff --git a/webapp/services/NftService.php b/webapp/services/NftService.php index 120fce52..80184c6b 100644 --- a/webapp/services/NftService.php +++ b/webapp/services/NftService.php @@ -16,6 +16,7 @@ class NftService extends BaseService { 'hero' => Nft::HERO_TYPE, 'equip' => Nft::EQUIP_TYPE, 'chip' => Nft::CHIP_TYPE, + 'fragment' => Nft::FRAGMENT_BOX_TYPE, ); public static function isHeroOwner($openId, $tokenId) @@ -48,6 +49,11 @@ class NftService extends BaseService { return self::internalGetList($openId, 'chip'); } + public static function getFragments($openId) + { + return self::internalGetList($openId, 'fragment'); + } + private static function internalGetList($openId, $name) { self::loadNft($openId, $name); diff --git a/webapp/services/PropertyChgService.php b/webapp/services/PropertyChgService.php index 41df1621..e345270e 100644 --- a/webapp/services/PropertyChgService.php +++ b/webapp/services/PropertyChgService.php @@ -41,6 +41,11 @@ class PropertyChgService extends BaseService { $this->internalAddChg('gun'); } + public function addFragment() + { + $this->internalAddChg('fragment'); + } + public function toDto() { return array(