1
This commit is contained in:
parent
f482c0abdf
commit
e782350d25
@ -25,6 +25,52 @@ class RestApiController extends BaseController {
|
|||||||
public function dispatch()
|
public function dispatch()
|
||||||
{
|
{
|
||||||
//REQUEST_URI /api/nft?dafsf=1%26=
|
//REQUEST_URI /api/nft?dafsf=1%26=
|
||||||
|
$requestUri = $_SERVER['REQUEST_URI'];
|
||||||
|
if (!empty($requestUri)) {
|
||||||
|
$idx = strpos($requestUri, '/api/nft/info/');
|
||||||
|
if ($idx === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($idx == 0) {
|
||||||
|
$this->nftInfo(explode($requestUri));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function nftInfo($path)
|
||||||
|
{
|
||||||
|
$tokenId = $path[4];
|
||||||
|
if (empty($tokenId)) {
|
||||||
|
myself()->_rspErr(1, 'nft found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$nftDb = Nft::getNft($tokenId);
|
||||||
|
if (empty($nftDb)) {
|
||||||
|
myself()->_rspErr(1, 'nft not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$heroMeta = mt\Hero::get($nftDb['item_id']);
|
||||||
|
$itemMeta = mt\Item::get($nftDb['item_id']) ;
|
||||||
|
if (!$heroMeta || !$itemMeta) {
|
||||||
|
myself()->_rspErr(2, 'server internal error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$nftDto = array();
|
||||||
|
$nftDto['name'] = $heroMeta['name'];
|
||||||
|
$nftDto['description'] = '';
|
||||||
|
$nftDto['image'] = 'https://www.cebg.games/res/avatars/' . $itemMeta['nft_image_id'] . '.png';
|
||||||
|
|
||||||
|
$nftDto['job'] = $heroMeta['herotype'];
|
||||||
|
$nftDto['level'] = 1;
|
||||||
|
$nftDto['quality'] = 1;
|
||||||
|
$nftDto['hp'] = $heroMeta['hp'];
|
||||||
|
$nftDto['speed'] = $heroMeta['move_speed'];
|
||||||
|
$nftDto['atk'] = $heroMeta['damage'];
|
||||||
|
$nftDto['def'] = $heroMeta['defence'];
|
||||||
|
$nftDto['advanced_count'] = 0;
|
||||||
|
$nftDto['lucky'] = 0;
|
||||||
|
$nftDto['success_rate'] = 0;
|
||||||
|
myself()->_rspData($nftDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user