This commit is contained in:
aozhiwei 2022-11-04 12:50:41 +08:00
parent f489a12fd3
commit ddd78b4659
2 changed files with 38 additions and 100 deletions

View File

@ -197,7 +197,8 @@ class BlockChainController extends BaseAuthedController {
public function evolveChip() public function evolveChip()
{ {
$tokenId1 = getReqVal('token_id1', '');
$tokenIds = explode('|', getReqVal('token_ids', ''));
} }
public function mintShardBatchUser() public function mintShardBatchUser()
@ -242,83 +243,27 @@ class BlockChainController extends BaseAuthedController {
$tokenId = ''; $tokenId = '';
$tokenType = ''; $tokenType = '';
if (count($tokenIds) <= 0) { {
myself()->_rspErr(1, 'token_ids paramaer error'); $heros = array();
$guns = array();
$specHeros = array();
$specGuns = array();
mt\Item::groupFragment($tokenIds, $heros, $guns, $specHeros, $specGuns);
if (count($tokenIds) != (
count($heros) + count($guns) + count($specHeros) + count($specGuns)
)) {
myself()->_rspErr(101, 'token_ids paramater error');
return; return;
} }
if (count($specHeros) + count($specGuns) > 1) {
$part = 0; myself()->_rspErr(101, 'token_ids paramater error');
$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; return;
} }
if ($part == 0) { if (count($heros) > 0 && count($guns) > 0) {
if (!($itemMeta['sub_type'] == 3 || myself()->_rspErr(101, 'token_ids paramater error');
$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; 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 $tokenId = BuyRecord::genOrderId
( (

View File

@ -275,8 +275,8 @@ class Item {
return $itemMeta['type'] == self::FRAGMENT_TYPE; return $itemMeta['type'] == self::FRAGMENT_TYPE;
} }
public static function canMixHero($itemIds) { public static function groupFragment($tokenIds, &$heros, &$guns, &$specHeros, &$specGuns)
$ok = true; {
$heroItemIds = array( $heroItemIds = array(
110110, 110110,
110120, 110120,
@ -287,23 +287,6 @@ class Item {
110170, 110170,
110180 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( $gunItemIds = array(
110210, 110210,
110220, 110220,
@ -314,20 +297,30 @@ class Item {
110270, 110270,
110280 110280
); );
foreach ($gunItemIds as $itemId1) { foreach ($tokenIds as $tokenId) {
$found = false; if (in_array($tokenId, $heroItemIds)) {
foreach ($itemIds as $itemId2) { array_push($heros, $tokenId);
if ($itemId1 == $itemId2) { }
$found = true; if (in_array($tokenId, $gunItemIds)) {
array_push($gun, $tokenId);
}
switch ($tokenId) {
case 110100:
{
array_push($specHeros, $tokenId);
}
break; break;
case 110200:
{
array_push($gunHeros, $tokenId);
}
break;
default:
{
} }
} }
if (!$found) {
return false;
} }
} }
return $ok;
}
protected static function getMetaList() protected static function getMetaList()
{ {