This commit is contained in:
hujiabin 2023-07-24 14:22:47 +08:00
parent a537ad0b2e
commit 13787e044c
5 changed files with 105 additions and 12 deletions

View File

@ -1,5 +1,11 @@
<?php
require_once('models/Hero.php');
require_once('mt/NftDesc.php');
require_once('mt/Hero.php');
use models\Hero;
class RestApiController extends BaseController {
public function dispatch()
@ -27,14 +33,60 @@ class RestApiController extends BaseController {
if (count($path) < 5) {
return;
}
$netId = $path[2];
$nftType = $path[3];
$tokenId = $path[4];
echo json_encode(array(
'netId' => $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);
}
}

View File

@ -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){

41
webapp/mt/NftDesc.php Normal file
View File

@ -0,0 +1,41 @@
<?php
namespace mt;
use phpcommon;
class NftDesc {
public static function get($id)
{
return array_key_exists($id, self::getMetaList()) ? self::getMetaList()[$id] : null;
}
public static function getByItemId($itemId)
{
self::mustBeItemIdHash();
return array_key_exists($itemId, self::$itemIdHash) ? self::$itemIdHash[$itemId] : null;
}
protected static function getMetaList()
{
if (!self::$metaList) {
self::$metaList = getMetaTable('Nftdesc@Nftdesc.php');
}
return self::$metaList;
}
protected static function mustBeItemIdHash()
{
if (!self::$itemIdHash) {
self::$itemIdHash = array();
foreach (self::getMetaList() as $meta) {
self::$itemIdHash[$meta['item_id']] = $meta;
}
}
}
protected static $metaList;
protected static $itemIdHash;
}

View File

@ -6,11 +6,11 @@ namespace mt;
class StarLevel
{
const STAR_NUM_CHIP_LIMIT = 125;
const STAR_NUM_CHIP_LIMIT = 150;
const STAR_NUM_EMOJI_LIMIT = 50;
const STAR_NUM_PIECE_LIMIT = 150;
const STAR_NUM_PVE_MATCH_LIMIT = 80;
const STAR_NUM_RANK_MATCH_LIMIT = 225;
const STAR_NUM_RANK_MATCH_LIMIT = 100;
const STAR_NUM_CHIP_PAGE1_MATCH_LIMIT = 325;
const STAR_NUM_CHIP_PAGE2_MATCH_LIMIT = 375;

View File

@ -966,9 +966,9 @@ class TameBattleDataService extends BaseService {
//吃鸡次数
$this->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);