This commit is contained in:
hujiabin 2023-10-13 14:57:28 +08:00
parent 74e93a6016
commit 0e59a42078
3 changed files with 340 additions and 327 deletions

View File

@ -189,8 +189,8 @@ class Season {
['ranking', ranking], ['ranking', ranking],
['season', seasonId], ['season', seasonId],
['ranking_point', ponit], ['ranking_point', ponit],
['createtime', element.createtime], ['createtime', nowTime],
['modifytime', element.score_modifytime], ['modifytime', nowTime],
] ]
) )
} }

View File

@ -1,10 +1,12 @@
<?php <?php
require_once('models/Hero.php'); require_once('models/Hero.php');
require_once('models/Nft.php');
require_once('mt/NftDesc.php'); require_once('mt/NftDesc.php');
require_once('mt/Hero.php'); require_once('mt/Hero.php');
use models\Hero; use models\Hero;
use models\Nft;
class RestApiController extends BaseController { class RestApiController extends BaseController {
@ -25,7 +27,7 @@ class RestApiController extends BaseController {
/* /*
https://game2006api.cebggame.com/api/nft/$netId/$nftType/$tokenId https://game2006api.cebggame.com/api/nft/$netId/$nftType/$tokenId
$netId: 链id(网络id) $netId: 链id(网络id)
$nftType: 目前就hero $nftType: 目前就hero,planet
$tokenIdtokenid $tokenIdtokenid
*/ */
private function nftInfo($path) private function nftInfo($path)
@ -36,67 +38,78 @@ class RestApiController extends BaseController {
$netId = $path[3]; $netId = $path[3];
$nftType = $path[4]; $nftType = $path[4];
$tokenId = $path[5]; $tokenId = $path[5];
$heroDb = Hero::findByTokenId2($tokenId);
if (!$heroDb){
echo json_encode(array(
"name" => "",
"description" => "",
"image" => "",
"attributes" => array(),
));
die;
}
$heroMeta = \mt\Hero::get($heroDb['hero_id']);
$NftMeta = \mt\NftDesc::getByItemId($heroDb['hero_id']);
//https://www.cebg.games/res/nfts/30100.png
$info = array( $info = array(
"name" => $heroMeta['name'], "name" => "",
"description" => $NftMeta['desc'], "description" => "",
"image" => "https://www.cebg.games/res/nfts/".$heroDb['hero_id'].".png", "image" => "",
"attributes" => array(), "attributes" => array(),
); );
array_push($info['attributes'],array( switch ($nftType){
"trait_type" => "level", case "hero" :{
"value" => intval($heroDb['hero_lv']), $heroDb = Hero::findByTokenId2($tokenId);
"max_value" => 15, if (!$heroDb){
)); echo json_encode($info);
$randAttr = emptyReplace(json_decode($heroDb['rand_attr'], true), array()); die;
foreach ($randAttr as $attr){ }
switch ($attr['quality']){ $heroMeta = \mt\Hero::get($heroDb['hero_id']);
case 1 : $quality = "D";break; $NftMeta = \mt\NftDesc::getByItemId($heroDb['hero_id']);
case 2 : $quality = "C";break; //https://www.cebg.games/res/nfts/30100.png
case 3 : $quality = "B";break; $info['name'] = $heroMeta['name'];
case 4 : $quality = "A";break; $info['description'] = $NftMeta['desc'];
case 5 : $quality = "S";break; $info['image'] = "https://www.cebg.games/res/nfts/".$heroDb['hero_id'].".png";
default : $quality = ""; array_push($info['attributes'],array(
"trait_type" => "level",
"value" => intval($heroDb['hero_lv']),
"max_value" => 15,
));
$randAttr = emptyReplace(json_decode($heroDb['rand_attr'], true), array());
foreach ($randAttr as $attr){
switch ($attr['quality']){
case 1 : $quality = "D";break;
case 2 : $quality = "C";break;
case 3 : $quality = "B";break;
case 4 : $quality = "A";break;
case 5 : $quality = "S";break;
default : $quality = "";
}
switch ($attr['attr_id']){
case kHAT_Hp : {
array_push($info['attributes'],array(
"trait_type" => "Hp",
"value" => $quality,
));
}
break;
case kHAT_Atk : {
array_push($info['attributes'],array(
"trait_type" => "Atk",
"value" => $quality,
));
}
break;
case kHAT_Def : {
array_push($info['attributes'],array(
"trait_type" => "Def",
"value" => $quality,
));
}
}
}
} }
switch ($attr['attr_id']){ break;
case kHAT_Hp : { case "planet" : {
array_push($info['attributes'],array( $planetDb = Nft::getNft($tokenId);
"trait_type" => "Hp", if (!$planetDb){
// "value" => intval($attr['val']), echo json_encode($info);
"value" => $quality, die;
));
}
break;
case kHAT_Atk : {
array_push($info['attributes'],array(
"trait_type" => "Atk",
// "value" => intval($attr['val']),
"value" => $quality,
));
}
break;
case kHAT_Def : {
array_push($info['attributes'],array(
"trait_type" => "Def",
// "value" => intval($attr['val']),
"value" => $quality,
));
} }
$NftMeta = \mt\NftDesc::getByItemId($planetDb['item_id']);
$info['name'] = $NftMeta['name'] ? : "planet";
$info['description'] = $NftMeta['desc'] ? : "planet";
$info['image'] = "https://www.cebg.games/res/nfts/".$planetDb['item_id'].".png";
} }
} }
echo json_encode($info); echo json_encode($info);
} }