nft desc
This commit is contained in:
parent
a537ad0b2e
commit
13787e044c
@ -1,5 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once('models/Hero.php');
|
||||||
|
require_once('mt/NftDesc.php');
|
||||||
|
require_once('mt/Hero.php');
|
||||||
|
|
||||||
|
use models\Hero;
|
||||||
|
|
||||||
class RestApiController extends BaseController {
|
class RestApiController extends BaseController {
|
||||||
|
|
||||||
public function dispatch()
|
public function dispatch()
|
||||||
@ -27,14 +33,60 @@ class RestApiController extends BaseController {
|
|||||||
if (count($path) < 5) {
|
if (count($path) < 5) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$netId = $path[2];
|
$netId = $path[3];
|
||||||
$nftType = $path[3];
|
$nftType = $path[4];
|
||||||
$tokenId = $path[4];
|
$tokenId = $path[5];
|
||||||
echo json_encode(array(
|
$heroDb = Hero::findByTokenId2($tokenId);
|
||||||
'netId' => $netId,
|
|
||||||
'nftType' => $nftType,
|
if (!$heroDb){
|
||||||
'tokenId' => $tokenId
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ class SeasonController extends BaseAuthedController {
|
|||||||
$seasonBattleData = isset($battleData) ? getXVal($battleData, 'season_data', array()) : array();
|
$seasonBattleData = isset($battleData) ? getXVal($battleData, 'season_data', array()) : array();
|
||||||
$gameTimes = getXVal($seasonBattleData, 'total_battle_times', 0);
|
$gameTimes = getXVal($seasonBattleData, 'total_battle_times', 0);
|
||||||
$winTimes = getXVal($seasonBattleData, 'total_win_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);
|
$totalKills = getXVal($seasonBattleData, 'total_kills_times', 0);
|
||||||
$temp = $gameTimes-$winTimes ? $gameTimes-$winTimes:0;
|
$temp = $gameTimes-$winTimes ? $gameTimes-$winTimes:0;
|
||||||
if (! $temp){
|
if (! $temp){
|
||||||
|
41
webapp/mt/NftDesc.php
Normal file
41
webapp/mt/NftDesc.php
Normal 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;
|
||||||
|
|
||||||
|
}
|
@ -6,11 +6,11 @@ namespace mt;
|
|||||||
|
|
||||||
class StarLevel
|
class StarLevel
|
||||||
{
|
{
|
||||||
const STAR_NUM_CHIP_LIMIT = 125;
|
const STAR_NUM_CHIP_LIMIT = 150;
|
||||||
const STAR_NUM_EMOJI_LIMIT = 50;
|
const STAR_NUM_EMOJI_LIMIT = 50;
|
||||||
const STAR_NUM_PIECE_LIMIT = 150;
|
const STAR_NUM_PIECE_LIMIT = 150;
|
||||||
const STAR_NUM_PVE_MATCH_LIMIT = 80;
|
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_PAGE1_MATCH_LIMIT = 325;
|
||||||
const STAR_NUM_CHIP_PAGE2_MATCH_LIMIT = 375;
|
const STAR_NUM_CHIP_PAGE2_MATCH_LIMIT = 375;
|
||||||
|
|
||||||
|
@ -966,9 +966,9 @@ class TameBattleDataService extends BaseService {
|
|||||||
//吃鸡次数
|
//吃鸡次数
|
||||||
$this->incValue($battleData, 'total_win_times', 1);
|
$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);
|
$kills = getXVal($this->battleInfo,'kills', 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user