添加链相关功能
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_STAR', 10011); //星星
|
||||
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_ACTIVE', 8002);
|
||||
@ -23,7 +26,7 @@ define('TN_END', 8007);
|
||||
define('TN_HERO_MAX_LEVEL', 8008);
|
||||
define('TN_LAST_RANKING_TIME', 8009);
|
||||
define('TN_MISSION_STAR_SEASON', 8010);
|
||||
define('TN_RANK_STATUS', 99999);
|
||||
define('TN_RANK_STATUS', 8011);
|
||||
|
||||
|
||||
define('TN_DAILY_BEGIN', 9001);
|
||||
|
@ -13,10 +13,10 @@ class GMController extends BaseAuthedController {
|
||||
public function _handlePre()
|
||||
{
|
||||
parent::_handlePre();
|
||||
if (SERVER_ENV == _ONLINE) {
|
||||
die("can't create GMController");
|
||||
return;
|
||||
}
|
||||
// if (SERVER_ENV == _ONLINE) {
|
||||
// die("can't create GMController");
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
public function execCmd()
|
||||
@ -35,9 +35,9 @@ class GMController extends BaseAuthedController {
|
||||
'.additem' => function () use($params) {
|
||||
$this->addItem($params);
|
||||
},
|
||||
// '.addnft' => function () use($params) {
|
||||
// $this->addNft($params);
|
||||
// },
|
||||
'.addnft' => function () use($params) {
|
||||
$this->addNft($params);
|
||||
},
|
||||
'.addtili' => function () use($params) {
|
||||
$this->addTili($params);
|
||||
},
|
||||
@ -92,44 +92,44 @@ END
|
||||
));
|
||||
}
|
||||
|
||||
// private function addNft($params)
|
||||
// {
|
||||
// $itemId = getXVal($params, 0, 0);
|
||||
// $propertyChgService = new services\PropertyChgService();
|
||||
// $awardService = new services\AwardService();
|
||||
//
|
||||
// $itemMeta = mt\Item::get($itemId);
|
||||
// if ($itemMeta) {
|
||||
// $tokenType = Nft::getTokenType($itemMeta);
|
||||
// if ($tokenType == Nft::NONE_TYPE) {
|
||||
// myself()->_rspErr(1, 'param item_id error');
|
||||
// return;
|
||||
// } else {
|
||||
// SqlHelper::insert(
|
||||
// myself()->_getMarketMysql(),
|
||||
// 't_nft',
|
||||
// array(
|
||||
// 'token_id' => Nft::genTempTokenId(),
|
||||
// 'token_type' => $tokenType,
|
||||
// 'game_id' => 2006,
|
||||
// 'item_id' => $itemId,
|
||||
// 'owner_address' => myself()->_getOpenId(),
|
||||
// 'createtime' => myself()->_getNowTime(),
|
||||
// 'modifytime' => myself()->_getNowTime(),
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
// } else {
|
||||
// myself()->_rspErr(1, 'param item_id error');
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// $this->_rspData(array(
|
||||
// 'text' => 'add nft success',
|
||||
// 'award' => $awardService->toDto(),
|
||||
// 'property_chg' => $propertyChgService->toDto(),
|
||||
// ));
|
||||
// }
|
||||
private function addNft($params)
|
||||
{
|
||||
$itemId = getXVal($params, 0, 0);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$awardService = new services\AwardService();
|
||||
|
||||
$itemMeta = mt\Item::get($itemId);
|
||||
if ($itemMeta) {
|
||||
$tokenType = Nft::getTokenType($itemMeta);
|
||||
if ($tokenType == Nft::NONE_TYPE) {
|
||||
myself()->_rspErr(1, 'param item_id error');
|
||||
return;
|
||||
} else {
|
||||
SqlHelper::insert(
|
||||
myself()->_getMarketMysql(),
|
||||
't_nft',
|
||||
array(
|
||||
'token_id' => Nft::genTempTokenId(),
|
||||
'token_type' => $tokenType,
|
||||
'game_id' => 2006,
|
||||
'item_id' => $itemId,
|
||||
'owner_address' => myself()->_getOpenId(),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
myself()->_rspErr(1, 'param item_id error');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_rspData(array(
|
||||
'text' => 'add nft success',
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
|
||||
private function addTili($params)
|
||||
{
|
||||
|
@ -131,14 +131,21 @@ class HeroController extends BaseAuthedController {
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $nextLevelMeta['gold']
|
||||
),
|
||||
// array(
|
||||
// 'item_id' => V_ITEM_DIAMOND,
|
||||
// 'item_num' => $nextLevelMeta['diamond']
|
||||
// )
|
||||
array(
|
||||
'item_id' => V_ITEM_HERO_META,
|
||||
'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);
|
||||
|
||||
$newHeroDto = $heroDto;
|
||||
$newHeroDto['hero_lv'] += 1;
|
||||
$attrs_min = Hero::LvUpAddAttr($heroDb,\mt\HeroLevelAttr::MIN_RAND_ATTR);
|
||||
@ -152,59 +159,54 @@ class HeroController extends BaseAuthedController {
|
||||
'cost' => $costItems
|
||||
));
|
||||
}
|
||||
public function test(){
|
||||
$levelAttrMeta= \mt\HeroLevelAttr::find(30100);
|
||||
$attr= \mt\HeroLevelAttr::addRandAttr($levelAttrMeta,2);
|
||||
print_r($attr);
|
||||
}
|
||||
|
||||
public function upgradeLv()
|
||||
{
|
||||
$heroUniId = getReqVal('hero_uniid', 0);
|
||||
$costHeroUniId = getReqVal('cost_hero_uniid', 0);
|
||||
// $costHeroUniId = getReqVal('cost_hero_uniid', 0);
|
||||
$heroDb = Hero::find($heroUniId);
|
||||
$oldHero = Hero::toDto($heroDb);
|
||||
$costHeroDb = Hero::findEx($costHeroUniId);
|
||||
// $costHeroDb = Hero::findEx($costHeroUniId);
|
||||
if (!$heroDb) {
|
||||
$this->_rspErr(100, 'param error or null');
|
||||
return;
|
||||
}
|
||||
if ($heroDb['hero_lv'] == Hero::LV_1 ||
|
||||
$heroDb['hero_lv'] == Hero::LV_2 ||
|
||||
$heroDb['hero_lv'] == Hero::LV_3 ){
|
||||
if (! $costHeroDb){
|
||||
$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');
|
||||
// if ($heroDb['hero_lv'] == Hero::LV_1 ||
|
||||
// $heroDb['hero_lv'] == Hero::LV_2 ||
|
||||
// $heroDb['hero_lv'] == Hero::LV_3 ){
|
||||
// if (! $costHeroDb){
|
||||
// $this->_rspErr(100, 'material param error or null');
|
||||
// return;
|
||||
// }
|
||||
switch ($heroDb['hero_lv']){
|
||||
case Hero::LV_1:{
|
||||
if ($heroDb['hero_lv'] < $costHeroDb['hero_lv']){
|
||||
$this->_rspErr(100, 'Grade discrepancy');
|
||||
return;
|
||||
}
|
||||
};break;
|
||||
case Hero::LV_2:{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
//// }
|
||||
// switch ($heroDb['hero_lv']){
|
||||
// case Hero::LV_1:{
|
||||
// if ($heroDb['hero_lv'] < $costHeroDb['hero_lv']){
|
||||
// $this->_rspErr(100, 'Grade discrepancy');
|
||||
// return;
|
||||
// }
|
||||
// };break;
|
||||
// case Hero::LV_2:{
|
||||
// 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']);
|
||||
if (!$heroMeta) {
|
||||
$this->_rspErr(100, 'server internal error');
|
||||
@ -215,7 +217,7 @@ class HeroController extends BaseAuthedController {
|
||||
$this->_rspErr(5, "It's already the highest level");
|
||||
return;
|
||||
}
|
||||
|
||||
die;
|
||||
//升级所需消耗
|
||||
$costItems = 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['account_id'] != myself()->_getAccountId()) {
|
||||
if (NftService::getChipBlance(myself()->_getOpenId(), $row['token_id']) <= 0) {
|
||||
if (NftService::getChipBlance(myself()->_getAddress(), $row['token_id']) <= 0) {
|
||||
$row = null;
|
||||
}
|
||||
}
|
||||
@ -67,7 +67,7 @@ class Chip extends BaseModel
|
||||
);
|
||||
if ($row) {
|
||||
$row['chip_uniid'] = $row['idx'];
|
||||
if (NftService::getChipBlance(myself()->_getOpenId(), $tokenId) <= 0) {
|
||||
if (NftService::getChipBlance(myself()->_getAddress(), $tokenId) <= 0) {
|
||||
$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";
|
||||
$whereKv =array(
|
||||
'owner_address' => myself()->_getOpenId(),
|
||||
'owner_address' => myself()->_getAddress(),
|
||||
);
|
||||
foreach (myself()->_getMarketMysql()->execQuery($sql,$whereKv) as $nftDb) {
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
|
@ -42,7 +42,7 @@ class Gun extends BaseModel {
|
||||
if ($row) {
|
||||
$row['gun_uniid'] = $row['idx'];
|
||||
if ($row['account_id'] != myself()->_getAccountId()) {
|
||||
if (!NftService::isEquipOwner(myself()->_getOpenId(), $row['token_id'])) {
|
||||
if (!NftService::isEquipOwner(myself()->_getAddress(), $row['token_id'])) {
|
||||
$row = null;
|
||||
}
|
||||
}
|
||||
@ -77,7 +77,7 @@ class Gun extends BaseModel {
|
||||
);
|
||||
if ($row) {
|
||||
$row['gun_uniid'] = $row['idx'];
|
||||
if (!NftService::isEquipOwner(myself()->_getOpenId(), $row['token_id'])) {
|
||||
if (!NftService::isEquipOwner(myself()->_getAddress(), $row['token_id'])) {
|
||||
$row = null;
|
||||
}
|
||||
}
|
||||
@ -161,7 +161,7 @@ class Gun extends BaseModel {
|
||||
$cb($row);
|
||||
}
|
||||
);
|
||||
foreach (NftService::getEquips(myself()->_getOpenId()) as $nftDb) {
|
||||
foreach (NftService::getEquips(myself()->_getAddress()) as $nftDb) {
|
||||
if (! $nftDb['deleted']){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
|
@ -76,7 +76,7 @@ class Hero extends BaseModel {
|
||||
);
|
||||
if ($row) {
|
||||
$row['hero_uniid'] = $row['idx'];
|
||||
if (!NftService::isHeroOwner(myself()->_getOpenId(), $row['token_id'])) {
|
||||
if (!NftService::isHeroOwner(myself()->_getAddress(), $row['token_id'])) {
|
||||
$row = null;
|
||||
}
|
||||
}
|
||||
@ -150,7 +150,7 @@ class Hero extends BaseModel {
|
||||
$cb($row);
|
||||
}
|
||||
);
|
||||
foreach (NftService::getHeros(myself()->_getOpenId()) as $nftDb) {
|
||||
foreach (NftService::getHeros(myself()->_getAddress()) as $nftDb) {
|
||||
if (! $nftDb['deleted']){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
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