添加链相关功能
This commit is contained in:
parent
af4c87b503
commit
40ac9dae9f
@ -12,6 +12,9 @@ define('V_ITEM_ACTIVE', 10004); //活跃度
|
|||||||
define('V_ITEM_BCEG', 10010); //BCEG
|
define('V_ITEM_BCEG', 10010); //BCEG
|
||||||
define('V_ITEM_STAR', 10011); //星星
|
define('V_ITEM_STAR', 10011); //星星
|
||||||
define('V_ITEM_REVIVE_COIN', 140001); //复活币
|
define('V_ITEM_REVIVE_COIN', 140001); //复活币
|
||||||
|
define('V_ITEM_HERO_META', 100005); //英雄升级材料
|
||||||
|
define('V_ITEM_GUN_META', 100006); //枪械升级材料
|
||||||
|
define('V_ITEM_CHIP_META', 100007); //芯片升级材料
|
||||||
|
|
||||||
define('TN_BEGIN', 8001);
|
define('TN_BEGIN', 8001);
|
||||||
define('TN_ACTIVE', 8002);
|
define('TN_ACTIVE', 8002);
|
||||||
@ -23,7 +26,7 @@ define('TN_END', 8007);
|
|||||||
define('TN_HERO_MAX_LEVEL', 8008);
|
define('TN_HERO_MAX_LEVEL', 8008);
|
||||||
define('TN_LAST_RANKING_TIME', 8009);
|
define('TN_LAST_RANKING_TIME', 8009);
|
||||||
define('TN_MISSION_STAR_SEASON', 8010);
|
define('TN_MISSION_STAR_SEASON', 8010);
|
||||||
define('TN_RANK_STATUS', 99999);
|
define('TN_RANK_STATUS', 8011);
|
||||||
|
|
||||||
|
|
||||||
define('TN_DAILY_BEGIN', 9001);
|
define('TN_DAILY_BEGIN', 9001);
|
||||||
|
@ -13,10 +13,10 @@ class GMController extends BaseAuthedController {
|
|||||||
public function _handlePre()
|
public function _handlePre()
|
||||||
{
|
{
|
||||||
parent::_handlePre();
|
parent::_handlePre();
|
||||||
if (SERVER_ENV == _ONLINE) {
|
// if (SERVER_ENV == _ONLINE) {
|
||||||
die("can't create GMController");
|
// die("can't create GMController");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execCmd()
|
public function execCmd()
|
||||||
@ -35,9 +35,9 @@ class GMController extends BaseAuthedController {
|
|||||||
'.additem' => function () use($params) {
|
'.additem' => function () use($params) {
|
||||||
$this->addItem($params);
|
$this->addItem($params);
|
||||||
},
|
},
|
||||||
// '.addnft' => function () use($params) {
|
'.addnft' => function () use($params) {
|
||||||
// $this->addNft($params);
|
$this->addNft($params);
|
||||||
// },
|
},
|
||||||
'.addtili' => function () use($params) {
|
'.addtili' => function () use($params) {
|
||||||
$this->addTili($params);
|
$this->addTili($params);
|
||||||
},
|
},
|
||||||
@ -92,44 +92,44 @@ END
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// private function addNft($params)
|
private function addNft($params)
|
||||||
// {
|
{
|
||||||
// $itemId = getXVal($params, 0, 0);
|
$itemId = getXVal($params, 0, 0);
|
||||||
// $propertyChgService = new services\PropertyChgService();
|
$propertyChgService = new services\PropertyChgService();
|
||||||
// $awardService = new services\AwardService();
|
$awardService = new services\AwardService();
|
||||||
//
|
|
||||||
// $itemMeta = mt\Item::get($itemId);
|
$itemMeta = mt\Item::get($itemId);
|
||||||
// if ($itemMeta) {
|
if ($itemMeta) {
|
||||||
// $tokenType = Nft::getTokenType($itemMeta);
|
$tokenType = Nft::getTokenType($itemMeta);
|
||||||
// if ($tokenType == Nft::NONE_TYPE) {
|
if ($tokenType == Nft::NONE_TYPE) {
|
||||||
// myself()->_rspErr(1, 'param item_id error');
|
myself()->_rspErr(1, 'param item_id error');
|
||||||
// return;
|
return;
|
||||||
// } else {
|
} else {
|
||||||
// SqlHelper::insert(
|
SqlHelper::insert(
|
||||||
// myself()->_getMarketMysql(),
|
myself()->_getMarketMysql(),
|
||||||
// 't_nft',
|
't_nft',
|
||||||
// array(
|
array(
|
||||||
// 'token_id' => Nft::genTempTokenId(),
|
'token_id' => Nft::genTempTokenId(),
|
||||||
// 'token_type' => $tokenType,
|
'token_type' => $tokenType,
|
||||||
// 'game_id' => 2006,
|
'game_id' => 2006,
|
||||||
// 'item_id' => $itemId,
|
'item_id' => $itemId,
|
||||||
// 'owner_address' => myself()->_getOpenId(),
|
'owner_address' => myself()->_getOpenId(),
|
||||||
// 'createtime' => myself()->_getNowTime(),
|
'createtime' => myself()->_getNowTime(),
|
||||||
// 'modifytime' => myself()->_getNowTime(),
|
'modifytime' => myself()->_getNowTime(),
|
||||||
// )
|
)
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// myself()->_rspErr(1, 'param item_id error');
|
myself()->_rspErr(1, 'param item_id error');
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// $this->_rspData(array(
|
$this->_rspData(array(
|
||||||
// 'text' => 'add nft success',
|
'text' => 'add nft success',
|
||||||
// 'award' => $awardService->toDto(),
|
'award' => $awardService->toDto(),
|
||||||
// 'property_chg' => $propertyChgService->toDto(),
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
// ));
|
));
|
||||||
// }
|
}
|
||||||
|
|
||||||
private function addTili($params)
|
private function addTili($params)
|
||||||
{
|
{
|
||||||
|
@ -131,14 +131,21 @@ class HeroController extends BaseAuthedController {
|
|||||||
'item_id' => V_ITEM_GOLD,
|
'item_id' => V_ITEM_GOLD,
|
||||||
'item_num' => $nextLevelMeta['gold']
|
'item_num' => $nextLevelMeta['gold']
|
||||||
),
|
),
|
||||||
// array(
|
array(
|
||||||
// 'item_id' => V_ITEM_DIAMOND,
|
'item_id' => V_ITEM_HERO_META,
|
||||||
// 'item_num' => $nextLevelMeta['diamond']
|
'item_num' => $nextLevelMeta['serum']
|
||||||
// )
|
)
|
||||||
);
|
);
|
||||||
|
$metaList = mt\Item::getMetaListByType(mt\Item::FRAGMENT_TYPE);
|
||||||
|
foreach ($metaList as $meta){
|
||||||
|
if ($meta['relationship'] == $heroDb['hero_id']) {
|
||||||
|
array_push($costItems,array(
|
||||||
|
'item_id' => $meta['id'],
|
||||||
|
'item_num' => $nextLevelMeta['piece'],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
$heroDto = Hero::toDto($heroDb);
|
$heroDto = Hero::toDto($heroDb);
|
||||||
|
|
||||||
$newHeroDto = $heroDto;
|
$newHeroDto = $heroDto;
|
||||||
$newHeroDto['hero_lv'] += 1;
|
$newHeroDto['hero_lv'] += 1;
|
||||||
$attrs_min = Hero::LvUpAddAttr($heroDb,\mt\HeroLevelAttr::MIN_RAND_ATTR);
|
$attrs_min = Hero::LvUpAddAttr($heroDb,\mt\HeroLevelAttr::MIN_RAND_ATTR);
|
||||||
@ -152,59 +159,54 @@ class HeroController extends BaseAuthedController {
|
|||||||
'cost' => $costItems
|
'cost' => $costItems
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
public function test(){
|
|
||||||
$levelAttrMeta= \mt\HeroLevelAttr::find(30100);
|
|
||||||
$attr= \mt\HeroLevelAttr::addRandAttr($levelAttrMeta,2);
|
|
||||||
print_r($attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function upgradeLv()
|
public function upgradeLv()
|
||||||
{
|
{
|
||||||
$heroUniId = getReqVal('hero_uniid', 0);
|
$heroUniId = getReqVal('hero_uniid', 0);
|
||||||
$costHeroUniId = getReqVal('cost_hero_uniid', 0);
|
// $costHeroUniId = getReqVal('cost_hero_uniid', 0);
|
||||||
$heroDb = Hero::find($heroUniId);
|
$heroDb = Hero::find($heroUniId);
|
||||||
$oldHero = Hero::toDto($heroDb);
|
$oldHero = Hero::toDto($heroDb);
|
||||||
$costHeroDb = Hero::findEx($costHeroUniId);
|
// $costHeroDb = Hero::findEx($costHeroUniId);
|
||||||
if (!$heroDb) {
|
if (!$heroDb) {
|
||||||
$this->_rspErr(100, 'param error or null');
|
$this->_rspErr(100, 'param error or null');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($heroDb['hero_lv'] == Hero::LV_1 ||
|
// if ($heroDb['hero_lv'] == Hero::LV_1 ||
|
||||||
$heroDb['hero_lv'] == Hero::LV_2 ||
|
// $heroDb['hero_lv'] == Hero::LV_2 ||
|
||||||
$heroDb['hero_lv'] == Hero::LV_3 ){
|
// $heroDb['hero_lv'] == Hero::LV_3 ){
|
||||||
if (! $costHeroDb){
|
// if (! $costHeroDb){
|
||||||
$this->_rspErr(100, 'material param error or null');
|
// $this->_rspErr(100, 'material param error or null');
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($costHeroDb['token_id']){
|
|
||||||
$this->_rspErr(100, 'NFT cannot be a material');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// if ($costHeroDb['state'] == Hero::FREE_STATE){
|
|
||||||
// $this->_rspErr(100, 'Unable to use free hero');
|
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
switch ($heroDb['hero_lv']){
|
// if ($costHeroDb['token_id']){
|
||||||
case Hero::LV_1:{
|
// $this->_rspErr(100, 'NFT cannot be a material');
|
||||||
if ($heroDb['hero_lv'] < $costHeroDb['hero_lv']){
|
// return;
|
||||||
$this->_rspErr(100, 'Grade discrepancy');
|
// }
|
||||||
return;
|
//// if ($costHeroDb['state'] == Hero::FREE_STATE){
|
||||||
}
|
//// $this->_rspErr(100, 'Unable to use free hero');
|
||||||
};break;
|
//// return;
|
||||||
case Hero::LV_2:{
|
//// }
|
||||||
if ($heroDb['hero_lv'] < $costHeroDb['hero_lv'] && $costHeroDb['hero_lv'] <= Hero::LV_1){
|
// switch ($heroDb['hero_lv']){
|
||||||
$this->_rspErr(100, 'Grade discrepancy');
|
// case Hero::LV_1:{
|
||||||
return;
|
// if ($heroDb['hero_lv'] < $costHeroDb['hero_lv']){
|
||||||
}
|
// $this->_rspErr(100, 'Grade discrepancy');
|
||||||
};break;
|
// return;
|
||||||
case Hero::LV_3:{
|
// }
|
||||||
if ($heroDb['hero_lv'] < $costHeroDb['hero_lv'] && $costHeroDb['hero_lv'] <= Hero::LV_2){
|
// };break;
|
||||||
$this->_rspErr(100, 'Grade discrepancy');
|
// case Hero::LV_2:{
|
||||||
return;
|
// if ($heroDb['hero_lv'] < $costHeroDb['hero_lv'] && $costHeroDb['hero_lv'] <= Hero::LV_1){
|
||||||
}
|
// $this->_rspErr(100, 'Grade discrepancy');
|
||||||
}
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// };break;
|
||||||
|
// case Hero::LV_3:{
|
||||||
|
// if ($heroDb['hero_lv'] < $costHeroDb['hero_lv'] && $costHeroDb['hero_lv'] <= Hero::LV_2){
|
||||||
|
// $this->_rspErr(100, 'Grade discrepancy');
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
$heroMeta = mt\Hero::get($heroDb['hero_id']);
|
$heroMeta = mt\Hero::get($heroDb['hero_id']);
|
||||||
if (!$heroMeta) {
|
if (!$heroMeta) {
|
||||||
$this->_rspErr(100, 'server internal error');
|
$this->_rspErr(100, 'server internal error');
|
||||||
@ -215,7 +217,7 @@ class HeroController extends BaseAuthedController {
|
|||||||
$this->_rspErr(5, "It's already the highest level");
|
$this->_rspErr(5, "It's already the highest level");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
die;
|
||||||
//升级所需消耗
|
//升级所需消耗
|
||||||
$costItems = array(
|
$costItems = array(
|
||||||
array(
|
array(
|
||||||
|
99
webapp/controller/NftController.class.php
Normal file
99
webapp/controller/NftController.class.php
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
require_once('models/Nft.php');
|
||||||
|
require_once('models/Hero.php');
|
||||||
|
require_once('models/Gun.php');
|
||||||
|
require_once('models/Chip.php');
|
||||||
|
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
use models\Nft;
|
||||||
|
use models\Hero;
|
||||||
|
use models\Gun;
|
||||||
|
use models\Chip;
|
||||||
|
class NftController extends BaseAuthedController
|
||||||
|
{
|
||||||
|
public function getNftList(){
|
||||||
|
$nftList = Nft::getNftList($this->_getAddress());
|
||||||
|
$listInfo = array();
|
||||||
|
if ($nftList){
|
||||||
|
foreach ($nftList as $nft){
|
||||||
|
$info = array(
|
||||||
|
"idx" => $nft['idx'],
|
||||||
|
"token_id" => $nft['token_id'],
|
||||||
|
"token_type" => $nft['token_type'],
|
||||||
|
"createtime" => $nft['createtime'],
|
||||||
|
"details" => array(),
|
||||||
|
);
|
||||||
|
switch ($nft['token_type']){
|
||||||
|
case Nft::HERO_TYPE : {
|
||||||
|
$heroDb = Hero::findByTokenId($nft['token_id']);
|
||||||
|
if ($heroDb){
|
||||||
|
$info['details'] = Hero::toDto($heroDb);
|
||||||
|
}
|
||||||
|
array_push($listInfo,$info);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Nft::EQUIP_TYPE : {
|
||||||
|
$gunDb = Gun::findByTokenId($nft['token_id']);
|
||||||
|
if ($gunDb){
|
||||||
|
$info['details'] = Gun::toDto($gunDb);
|
||||||
|
}
|
||||||
|
array_push($listInfo,$info);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Nft::CHIP_TYPE : {
|
||||||
|
$chipDb = Chip::findByTokenId($nft['token_id']);
|
||||||
|
if ($chipDb){
|
||||||
|
$info['details'] = Chip::toDto($chipDb);
|
||||||
|
}
|
||||||
|
array_push($listInfo,$info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->_rspData(array(
|
||||||
|
'nfts' => $listInfo,
|
||||||
|
));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function NftDetail(){
|
||||||
|
$netId = trim(getReqVal('net_id', 0));
|
||||||
|
$tokenId = trim(getReqVal('token_id', 0));
|
||||||
|
if (! $tokenId){
|
||||||
|
$this->_rspErr(1, 'Please enter parameter token_id');
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
$nftDb = Nft::getNft($tokenId);
|
||||||
|
if (! $nftDb){
|
||||||
|
$this->_rspErr(1, 'parameter error');
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
$details = array();
|
||||||
|
switch ($nftDb['token_type']){
|
||||||
|
case Nft::HERO_TYPE : {
|
||||||
|
$heroDb = Hero::findByTokenId($nftDb['token_id']);
|
||||||
|
if ($heroDb){
|
||||||
|
$details = Hero::toDto($heroDb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Nft::EQUIP_TYPE : {
|
||||||
|
$gunDb = Gun::findByTokenId($nftDb['token_id']);
|
||||||
|
if ($gunDb){
|
||||||
|
$details = Gun::toDto($gunDb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Nft::CHIP_TYPE : {
|
||||||
|
$chipDb = Chip::findByTokenId($nftDb['token_id']);
|
||||||
|
if ($chipDb){
|
||||||
|
$details = Chip::toDto($chipDb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->_rspData(array(
|
||||||
|
'info' => $details,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -34,7 +34,7 @@ class Chip extends BaseModel
|
|||||||
);
|
);
|
||||||
if ($row) {
|
if ($row) {
|
||||||
if ($row['account_id'] != myself()->_getAccountId()) {
|
if ($row['account_id'] != myself()->_getAccountId()) {
|
||||||
if (NftService::getChipBlance(myself()->_getOpenId(), $row['token_id']) <= 0) {
|
if (NftService::getChipBlance(myself()->_getAddress(), $row['token_id']) <= 0) {
|
||||||
$row = null;
|
$row = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ class Chip extends BaseModel
|
|||||||
);
|
);
|
||||||
if ($row) {
|
if ($row) {
|
||||||
$row['chip_uniid'] = $row['idx'];
|
$row['chip_uniid'] = $row['idx'];
|
||||||
if (NftService::getChipBlance(myself()->_getOpenId(), $tokenId) <= 0) {
|
if (NftService::getChipBlance(myself()->_getAddress(), $tokenId) <= 0) {
|
||||||
$row = null;
|
$row = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ class Chip extends BaseModel
|
|||||||
);
|
);
|
||||||
$sql = "select * from t_nft1155 where owner_address=:owner_address and token_id>10000000 and balance>0";
|
$sql = "select * from t_nft1155 where owner_address=:owner_address and token_id>10000000 and balance>0";
|
||||||
$whereKv =array(
|
$whereKv =array(
|
||||||
'owner_address' => myself()->_getOpenId(),
|
'owner_address' => myself()->_getAddress(),
|
||||||
);
|
);
|
||||||
foreach (myself()->_getMarketMysql()->execQuery($sql,$whereKv) as $nftDb) {
|
foreach (myself()->_getMarketMysql()->execQuery($sql,$whereKv) as $nftDb) {
|
||||||
$row = SqlHelper::ormSelectOne(
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
@ -42,7 +42,7 @@ class Gun extends BaseModel {
|
|||||||
if ($row) {
|
if ($row) {
|
||||||
$row['gun_uniid'] = $row['idx'];
|
$row['gun_uniid'] = $row['idx'];
|
||||||
if ($row['account_id'] != myself()->_getAccountId()) {
|
if ($row['account_id'] != myself()->_getAccountId()) {
|
||||||
if (!NftService::isEquipOwner(myself()->_getOpenId(), $row['token_id'])) {
|
if (!NftService::isEquipOwner(myself()->_getAddress(), $row['token_id'])) {
|
||||||
$row = null;
|
$row = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ class Gun extends BaseModel {
|
|||||||
);
|
);
|
||||||
if ($row) {
|
if ($row) {
|
||||||
$row['gun_uniid'] = $row['idx'];
|
$row['gun_uniid'] = $row['idx'];
|
||||||
if (!NftService::isEquipOwner(myself()->_getOpenId(), $row['token_id'])) {
|
if (!NftService::isEquipOwner(myself()->_getAddress(), $row['token_id'])) {
|
||||||
$row = null;
|
$row = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ class Gun extends BaseModel {
|
|||||||
$cb($row);
|
$cb($row);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
foreach (NftService::getEquips(myself()->_getOpenId()) as $nftDb) {
|
foreach (NftService::getEquips(myself()->_getAddress()) as $nftDb) {
|
||||||
if (! $nftDb['deleted']){
|
if (! $nftDb['deleted']){
|
||||||
$row = SqlHelper::ormSelectOne(
|
$row = SqlHelper::ormSelectOne(
|
||||||
myself()->_getSelfMysql(),
|
myself()->_getSelfMysql(),
|
||||||
|
@ -76,7 +76,7 @@ class Hero extends BaseModel {
|
|||||||
);
|
);
|
||||||
if ($row) {
|
if ($row) {
|
||||||
$row['hero_uniid'] = $row['idx'];
|
$row['hero_uniid'] = $row['idx'];
|
||||||
if (!NftService::isHeroOwner(myself()->_getOpenId(), $row['token_id'])) {
|
if (!NftService::isHeroOwner(myself()->_getAddress(), $row['token_id'])) {
|
||||||
$row = null;
|
$row = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ class Hero extends BaseModel {
|
|||||||
$cb($row);
|
$cb($row);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
foreach (NftService::getHeros(myself()->_getOpenId()) as $nftDb) {
|
foreach (NftService::getHeros(myself()->_getAddress()) as $nftDb) {
|
||||||
if (! $nftDb['deleted']){
|
if (! $nftDb['deleted']){
|
||||||
$row = SqlHelper::ormSelectOne(
|
$row = SqlHelper::ormSelectOne(
|
||||||
myself()->_getSelfMysql(),
|
myself()->_getSelfMysql(),
|
||||||
|
10
webapp/services/ContractConfig.php
Normal file
10
webapp/services/ContractConfig.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
|
||||||
|
use mt\Item;
|
||||||
|
|
||||||
|
class ContractConfig extends BaseService {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user