1
This commit is contained in:
parent
a0a5557663
commit
8169f4219f
@ -98,6 +98,7 @@ class BlockChain(object):
|
|||||||
'group': 'BlockChain',
|
'group': 'BlockChain',
|
||||||
'url': 'webapp/index.php?c=BlockChain&a=shardMixByUser',
|
'url': 'webapp/index.php?c=BlockChain&a=shardMixByUser',
|
||||||
'params': [
|
'params': [
|
||||||
|
['item_id', '', '指定的英雄id或者武器id'],
|
||||||
['token_ids', '', 'token_ids多个用|分割'],
|
['token_ids', '', 'token_ids多个用|分割'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
|
@ -169,9 +169,96 @@ class BlockChainController extends BaseAuthedController {
|
|||||||
public function shardMixByUser()
|
public function shardMixByUser()
|
||||||
{
|
{
|
||||||
$tokenIds = explode('|', getReqVal('token_ids', ''));
|
$tokenIds = explode('|', getReqVal('token_ids', ''));
|
||||||
|
$itemId = getReqVal('item_id', '');
|
||||||
|
|
||||||
$tokenId = '';
|
$tokenId = '';
|
||||||
$tokenType = '';
|
$tokenType = '';
|
||||||
$itemId = 0;
|
|
||||||
|
if (count($tokenIds) <= 0) {
|
||||||
|
myself()->_rspErr(1, 'token_ids paramaer error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$part = 0;
|
||||||
|
$hasSpecHero = false;
|
||||||
|
$hasSpecGun = false;
|
||||||
|
$specCount = 0;
|
||||||
|
foreach ($tokenIds as $itemId) {
|
||||||
|
$itemMeta = mt\Item::get($itemId);
|
||||||
|
if (!$itemMeta || !mt\Item::isFragment($itemMeta)) {
|
||||||
|
myself()->_rspErr(1, 'token_ids paramaer error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($part == 0) {
|
||||||
|
if (!($itemMeta['sub_type'] == 3 ||
|
||||||
|
$itemMeta['sub_type'] == 4)) {
|
||||||
|
$part = $itemMeta['sub_type'];
|
||||||
|
} else {
|
||||||
|
if ($itemMeta['sub_type'] == 3) {
|
||||||
|
$hasSpecHero = true;
|
||||||
|
}
|
||||||
|
if ($itemMeta['sub_type'] == 4) {
|
||||||
|
$hasGunHero = true;
|
||||||
|
}
|
||||||
|
++$specCount;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($part != $itemMeta['sub_type']) {
|
||||||
|
myself()->_rspErr(1, 'token_ids paramaer error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($specCount > 1) {
|
||||||
|
myself()->_rspErr(1, 'token_ids paramaer error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($part == 1) {
|
||||||
|
if ($hasSpecGun) {
|
||||||
|
myself()->_rspErr(1, 'token_ids paramaer error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$tokenType = Nft::HERO_TYPE;
|
||||||
|
if (!mt\Item::canMixHero($tokenIds)) {
|
||||||
|
myself()->_rspErr(1, 'token_ids paramaer error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($hasSpecHero) {
|
||||||
|
$itemMeta = mt\Item::get($itemId);
|
||||||
|
if (!$itemMeta || $itemMeta['type'] != mt\Item::HERO_TYPE) {
|
||||||
|
myself()->_rspErr(1, 'token_ids paramaer error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ($part == 2) {
|
||||||
|
if ($hasSpecHero) {
|
||||||
|
myself()->_rspErr(1, 'token_ids paramaer error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$tokenType = Nft::EQUIP_TYPE;
|
||||||
|
if (!mt\Item::canMixGun($tokenIds)) {
|
||||||
|
myself()->_rspErr(1, 'token_ids paramaer error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($hasSpecGun) {
|
||||||
|
$itemMeta = mt\Item::get($itemId);
|
||||||
|
if (!$itemMeta || $itemMeta['type'] != mt\Item::GUN_TYPE) {
|
||||||
|
myself()->_rspErr(1, 'token_ids paramaer error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
myself()->_rspErr(1, 'token_ids paramaer error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tokenId = BuyRecord::genOrderId
|
||||||
|
(
|
||||||
|
2006,
|
||||||
|
phpcommon\BC_FUNC_CREATION,
|
||||||
|
myself()->_getNowTime(),
|
||||||
|
myself()->_getOpenId()
|
||||||
|
);
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'c' => 'BcService',
|
'c' => 'BcService',
|
||||||
@ -181,7 +268,6 @@ class BlockChainController extends BaseAuthedController {
|
|||||||
'account' => myself()->_getOpenId(),
|
'account' => myself()->_getOpenId(),
|
||||||
'token_id' => $tokenId,
|
'token_id' => $tokenId,
|
||||||
'token_type' => $tokenType,
|
'token_type' => $tokenType,
|
||||||
'item_uniid' => $itemUniId,
|
|
||||||
'item_id' => $itemId,
|
'item_id' => $itemId,
|
||||||
'token_ids' => implode('|', $tokenIds)
|
'token_ids' => implode('|', $tokenIds)
|
||||||
);
|
);
|
||||||
|
@ -270,6 +270,65 @@ class Item {
|
|||||||
return $metaList;
|
return $metaList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isFragment($itemMeta)
|
||||||
|
{
|
||||||
|
return $itemMeta['type'] == self::FRAGMENT_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function canMixHero($itemIds) {
|
||||||
|
$ok = true;
|
||||||
|
$heroItemIds = array(
|
||||||
|
110110,
|
||||||
|
110120,
|
||||||
|
110130,
|
||||||
|
110140,
|
||||||
|
110150,
|
||||||
|
110160,
|
||||||
|
110170,
|
||||||
|
110180
|
||||||
|
);
|
||||||
|
foreach ($heroItemIds as $itemId1) {
|
||||||
|
$found = false;
|
||||||
|
foreach ($itemIds as $itemId2) {
|
||||||
|
if ($itemId1 == $itemId2) {
|
||||||
|
$found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$found) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function canMixGun($itemIds) {
|
||||||
|
$ok = true;
|
||||||
|
$gunItemIds = array(
|
||||||
|
110210,
|
||||||
|
110220,
|
||||||
|
110230,
|
||||||
|
110240,
|
||||||
|
110250,
|
||||||
|
110260,
|
||||||
|
110270,
|
||||||
|
110280
|
||||||
|
);
|
||||||
|
foreach ($gunItemIds as $itemId1) {
|
||||||
|
$found = false;
|
||||||
|
foreach ($itemIds as $itemId2) {
|
||||||
|
if ($itemId1 == $itemId2) {
|
||||||
|
$found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$found) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ok;
|
||||||
|
}
|
||||||
|
|
||||||
protected static function getMetaList()
|
protected static function getMetaList()
|
||||||
{
|
{
|
||||||
if (!self::$metaList) {
|
if (!self::$metaList) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user