From 13787e044c27c011fd6c5b78bce91d7f520d803d Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Mon, 24 Jul 2023 14:22:47 +0800 Subject: [PATCH] nft desc --- webapp/controller/RestApiController.class.php | 66 +++++++++++++++++-- webapp/controller/SeasonController.class.php | 2 +- webapp/mt/NftDesc.php | 41 ++++++++++++ webapp/mt/StarLevel.php | 4 +- webapp/services/TameBattleDataService.php | 4 +- 5 files changed, 105 insertions(+), 12 deletions(-) create mode 100644 webapp/mt/NftDesc.php diff --git a/webapp/controller/RestApiController.class.php b/webapp/controller/RestApiController.class.php index ee1f6814..a4376bbe 100644 --- a/webapp/controller/RestApiController.class.php +++ b/webapp/controller/RestApiController.class.php @@ -1,5 +1,11 @@ $netId, - 'nftType' => $nftType, - 'tokenId' => $tokenId + $netId = $path[3]; + $nftType = $path[4]; + $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( + "name" => $heroMeta['name'], + "description" => $NftMeta['desc'], + "image" => "https://www.cebg.games/res/nfts/".$heroDb['hero_id'].".png", + "attributes" => array(), + ); + array_push($info['attributes'],array( + "trait_type" => "level", + "value" => $heroDb['hero_lv'], + "max_value" => 15, )); + $randAttr = emptyReplace(json_decode($heroDb['rand_attr'], true), array()); + foreach ($randAttr as $attr){ + switch ($attr['attr_id']){ + case kHAT_Hp : { + array_push($info['attributes'],array( + "trait_type" => "Hp", + "value" => $attr['val'], + )); + } + break; + case kHAT_Atk : { + array_push($info['attributes'],array( + "trait_type" => "Atk", + "value" => $attr['val'], + )); + } + break; + case kHAT_Def : { + array_push($info['attributes'],array( + "trait_type" => "Def", + "value" => $attr['val'], + )); + } + } + } + echo json_encode($info); } } diff --git a/webapp/controller/SeasonController.class.php b/webapp/controller/SeasonController.class.php index 54603c6c..605c7929 100644 --- a/webapp/controller/SeasonController.class.php +++ b/webapp/controller/SeasonController.class.php @@ -118,7 +118,7 @@ class SeasonController extends BaseAuthedController { $seasonBattleData = isset($battleData) ? getXVal($battleData, 'season_data', array()) : array(); $gameTimes = getXVal($seasonBattleData, 'total_battle_times', 0); $winTimes = getXVal($seasonBattleData, 'total_win_times', 0); - $topTenTimes = getXVal($seasonBattleData, 'total_top_ten_times', 0); + $topTenTimes = getXVal($seasonBattleData, 'total_top_three_times', 0); $totalKills = getXVal($seasonBattleData, 'total_kills_times', 0); $temp = $gameTimes-$winTimes ? $gameTimes-$winTimes:0; if (! $temp){ diff --git a/webapp/mt/NftDesc.php b/webapp/mt/NftDesc.php new file mode 100644 index 00000000..b6481f0f --- /dev/null +++ b/webapp/mt/NftDesc.php @@ -0,0 +1,41 @@ +incValue($battleData, 'total_win_times', 1); } - if ($ranked <= 10 && $ranked>0){ + if ($ranked <= 3 && $ranked>0){ //排名前十 总次数 - $this->incValue($battleData, 'total_top_ten_times', 1); + $this->incValue($battleData, 'total_top_three_times', 1); } //击杀 $kills = getXVal($this->battleInfo,'kills', 0);