diff --git a/webapp/models/Nft.php b/webapp/models/Nft.php index 14ac81d1..617c34eb 100644 --- a/webapp/models/Nft.php +++ b/webapp/models/Nft.php @@ -274,129 +274,6 @@ class Nft extends BaseModel return $row; } - public static function toDto($nftDb) - { - $itemMeta = mt\Item::get($nftDb['item_id']); - if (!$itemMeta) { - return null; - } - $tags = self::parseTags($nftDb['tags']); - $image = 'https://www.cebg.games/res/avatars/' . $itemMeta['id'] . '.png'; - $full_image = 'https://www.cebg.games/res/avatars/full_' . $itemMeta['id'] . '.png'; - if (in_array(self::GENESIS_TAG, $tags)) { - $image = 'https://www.cebg.games/res/avatars/' . $itemMeta['id'] . '_1' . '.png'; - $full_image = 'https://www.cebg.games/res/avatars/full_' . $itemMeta['id'] . '_1' . '.png'; - } - if ($nftDb['token_type'] == self::CHIP_TYPE) { - $image = 'https://www.cebg.games/res/avatars/' . $itemMeta['id'] . '_a' . '.png'; - $full_image = 'https://www.cebg.games/res/avatars/full_' . $itemMeta['id'] . '_a' . '.png'; - } - $nft = array( - 'token_id' => $nftDb['token_id'], - 'owner_address' => $nftDb['owner_address'], - 'owner_name' => '', - 'item_id' => $nftDb['item_id'], - 'type' => $nftDb['token_type'], - 'state' => $nftDb['token_state'], - 'lock_time' => 0, - 'hide_attr' => 0, - 'is_genesis' => in_array(self::GENESIS_TAG, $tags), - 'image' => $image, - 'full_image' => $full_image, - 'currency_list' => array(), - 'transaction_recrod' => array(), - 'info' => array( - 'name' => $itemMeta['name'], - 'attr' => array() - ), - 'mint_time' => $nftDb['createtime'] - ); - switch ($nftDb['token_type']) { - case Nft::HERO_TYPE: - { - $heroMeta = mt\Hero::get($nftDb['item_id']); - if ($heroMeta) { - //$nft['info']['name'] = $heroMeta['name']; - $nft['info']['job'] = $heroMeta['herotype']; - $nft['info']['level'] = 1; - $nft['info']['quality'] = 1; - $nft['info']['hp'] = $heroMeta['hp']; - $nft['info']['speed'] = $heroMeta['move_speed']; - $nft['info']['atk'] = $heroMeta['damage']; - $nft['info']['def'] = $heroMeta['defence']; - $nft['info']['advanced_count'] = 0; - $nft['info']['lucky'] = $heroMeta['hero_lucky']; - $nft['info']['success_rate'] = 0; - } - } - break; - case Nft::EQUIP_TYPE: - { - $equipMeta = mt\Equip::get($itemMeta['relationship']); - /*error_log(json_encode(array( - 'equpMeta' => $equipMeta, - 'nftDb' => $nftDb - )));*/ - $nft['full_image'] = $nft['image']; - $nft['info']['level'] = 1; - $nft['info']['quality'] = 1; - $nft['info']['lucky'] = $equipMeta ? $equipMeta['gun_lucky'] : 0; - $randAttr = array(); - if (!is_null($nftDb['rand_attr'])) { - $initQualityMeta = mt\GunQuality::getByQuality(1); - if ($initQualityMeta) { - $randAttr = mt\GunQuality::getRandAttr($initQualityMeta); - } -// SqlHelper::update( -// myself()->_getMarketMysql(), -// 't_nft', -// array( -// 'token_id' => $nft['token_id'] -// ), -// array( -// 'rand_attr' => json_encode($randAttr) -// ) -// ); - } - { - foreach ($randAttr as &$attr) { - $attrMeta = mt\Attr::get($attr['attr_id']); - if ($attrMeta) { - $attr['name'] = $attrMeta['attr_ename']; - } else { - $attr['name'] = ''; - } - } - } - { - $nft['info']['clip_volume'] = getXVal($equipMeta, 'clip_volume', 0); - $nft['info']['reload_time'] = getXVal($equipMeta, 'reload_time', 0); - $nft['info']['fire_rate'] = getXVal($equipMeta, 'fire_rate', 0); - $nft['info']['atk'] = getXVal($equipMeta, 'atk', 0); - $nft['info']['bullet_speed'] = getXVal($equipMeta, 'bullet_speed', 0); - $nft['info']['range'] = getXVal($equipMeta, 'range', 0); - } - $nft['info']['attr'] = $randAttr; - } - break; - case Nft::CHIP_TYPE: - { - $nft['hide_attr'] = 1; - } - break; - case Nft::FRAGMENT_TYPE: - { - - } - break; - default: - { - return null; - } - } - return $nft; - } - // public static function addNftByFragmentBox($itemMeta,$num=0){ // if ($itemMeta) { // $tokenType = Nft::getTokenType($itemMeta);