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()
{
$tokenId1 = getReqVal('token_id1', '');
$tokenIds = explode('|', getReqVal('token_ids', ''));
}
public function mintShardBatchUser()
@ -242,82 +243,26 @@ class BlockChainController extends BaseAuthedController {
$tokenId = '';
$tokenType = '';
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');
{
$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;
}
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');
if (count($specHeros) + count($specGuns) > 1) {
myself()->_rspErr(101, 'token_ids paramater error');
return;
}
$tokenType = Nft::HERO_TYPE;
if (!mt\Item::canMixHero($tokenIds)) {
myself()->_rspErr(1, 'token_ids paramaer error');
if (count($heros) > 0 && count($guns) > 0) {
myself()->_rspErr(101, 'token_ids paramater 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

View File

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