From df90ff750bf544279a40e2bd1fd960b678f3a2ba Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 20 Oct 2022 17:12:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=9C=89ceg=E4=BA=A7?= =?UTF-8?q?=E5=87=BA=E7=9A=84nft?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/gamedb.sql | 4 +- webapp/bootstrap/constant.php | 1 + .../controller/BaseAuthedController.class.php | 9 +- webapp/models/Gun.php | 1 + webapp/models/NftActive.php | 40 +++++++++ webapp/models/User.php | 2 + webapp/services/BattleDataService.php | 82 ++++++++++++++++++- 7 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 webapp/models/NftActive.php diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 7f993221..8596ef9c 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -599,12 +599,14 @@ DROP TABLE IF EXISTS `t_nft_active`; CREATE TABLE `t_nft_active` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', + `uniid` varchar(255) NOT NULL DEFAULT '' COMMENT 'nft uniid', `token_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'token id', + `daytime` int(11) NOT NULL DEFAULT '0' COMMENT '今天0点时间', `token_type` int(11) NOT NULL DEFAULT '0' COMMENT 'nft类型 1:英雄 2:枪支 3:芯片 5:碎片箱子', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), - UNIQUE KEY `token_id` (`token_id`), + UNIQUE KEY `token_id_daytime` (`token_id`, `daytime`,`token_type`), KEY `account_id_token_type` (`account_id`,`token_type`) ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index b3463592..afbd8aae 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -8,6 +8,7 @@ define('V_ITEM_GOLD', 10001); //金币 define('V_ITEM_DIAMOND', 10002); //钻石 define('V_ITEM_EXP', 10003); //经验 define('V_ITEM_ACTIVE', 10004); //活跃度 +define('V_ITEM_BCEG', 10010); //BCEG define('TN_BEGIN', 8001); define('TN_ACTIVE', 8002); diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 8d267265..5995533f 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -193,7 +193,7 @@ class BaseAuthedController extends BaseController { public function _isVirtualItem($itemId) { - return in_array($itemId, array(V_ITEM_GOLD, V_ITEM_DIAMOND, V_ITEM_EXP, V_ITEM_ACTIVE)); + return in_array($itemId, array(V_ITEM_GOLD, V_ITEM_DIAMOND, V_ITEM_EXP, V_ITEM_ACTIVE,V_ITEM_BCEG)); } public function _addVirtualItem($itemId, $itemNum) @@ -220,8 +220,13 @@ class BaseAuthedController extends BaseController { )); } break; - case V_ITEM_EXP: + case V_ITEM_BCEG: { + $this->_updateUserInfo(array( + 'bceg' => function () use($itemNum) { + return "bceg + ${itemNum}"; + } + )); } break; case V_ITEM_ACTIVE: diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 77f6ac43..d479c054 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -179,6 +179,7 @@ class Gun extends BaseModel { $gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($row['quality']); $dto = array( 'idx' => $row['idx'], + 'token_id' => $row['token_id'], 'gun_uniid' => $row['idx'], 'gun_id' => $row['gun_id'], 'gun_lv' => $row['gun_lv'], diff --git a/webapp/models/NftActive.php b/webapp/models/NftActive.php new file mode 100644 index 00000000..3b0b5500 --- /dev/null +++ b/webapp/models/NftActive.php @@ -0,0 +1,40 @@ +$data['token_id'], + ); + }else{ + $where = array( + 'uniid' =>$data['uniid'], + ); + } + + SqlHelper::upsert + (myself()->_getSelfMysql(), + 't_nft_active', + $where, + array( + ), + array( + 'account_id' => myself()->_getAccountId(), + 'uniid' =>$data['uniid'], + 'token_id' =>$data['token_id']?$data['token_id']:'', + 'daytime' =>strtotime(date('Y-m-d',myself()->_getNowTime())), + 'token_type' =>$data['token_type'], + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + } + + +} \ No newline at end of file diff --git a/webapp/models/User.php b/webapp/models/User.php index f40a4c3f..8e4a3230 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -39,6 +39,7 @@ class User extends BaseModel { 'history_best_rank' => $row['history_best_rank'], 'score' => $row['score'], 'history_best_score' => $row['history_best_score'], + 'bceg' => cegFormat($row['bceg']), 'gold' => cegFormat($row['gold']), 'diamond' => cecFormat($row['diamond']), 'hero_id' => $row['hero_id'], @@ -71,6 +72,7 @@ class User extends BaseModel { 'history_best_rank' => $row['history_best_rank'], 'score' => $row['score'], 'history_best_score' => $row['history_best_score'], + 'bceg' => cegFormat($row['bceg']), 'gold' => cegFormat($row['gold']), 'diamond' => cecFormat($row['diamond']), 'hero_id' => $row['hero_id'], diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 3612afe7..39614ae4 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -21,9 +21,12 @@ require_once('models/Battle.php'); require_once('models/Bag.php'); require_once('models/Hero.php'); require_once('models/Gun.php'); +require_once('models/Chip.php'); +require_once('models/Nft.php'); require_once('models/FragmentPool.php'); require_once('models/RealtimeData.php'); require_once('models/BattleHistory.php'); +require_once('models/NftActive.php'); require_once('services/RankActivityService.php'); require_once('services/FormulaService.php'); @@ -32,6 +35,9 @@ require_once('services/PropertyChgService.php'); require_once('services/LogService.php'); +use models\Chip; +use models\Nft; +use models\NftActive; use mt; use services; use phpcommon\SqlHelper; @@ -140,8 +146,10 @@ class BattleDataService extends BaseService { $this->weapon2Dto['pve_ceg_uplimit'] : $this->weapon2Dto['pvp_ceg_uplimit']; } } + + //录入战斗记录 - $this->saveBattleHistory(); +// $this->saveBattleHistory(); switch ($matchMode) { case self::MATCH_MODE_PVP: @@ -839,12 +847,82 @@ class BattleDataService extends BaseService { 'new_weaponPvpCeg1' => $weaponPvpCeg1, 'new_weaponPvpCeg2' => $weaponPvpCeg2, ))); - $gold = $heroPvpCeg + $weaponPvpCeg1 + $weaponPvpCeg2; + $gold = $heroPvpCeg + $weaponPvpCeg1 + $weaponPvpCeg2;print_r($heroPvpCeg); + if ($heroPvpCeg>0){ + $this->_addNftActive($this->heroDto,1); + } + if ($weaponPvpCeg1>0){ + $this->_addNftActive($this->weapon1Dto,2); + } + if ($weaponPvpCeg2>0){ + + $this->_addNftActive($this->weapon2Dto,2); + } if ($gold > 0) { myself()->_addVirtualItem(V_ITEM_GOLD, $gold); } } + private function _addNftActive($nftDb,$type){ + if (!$nftDb){ + return ; + } + switch ($type){ + case Nft::HERO_TYPE: + { + $data = array( + 'uniid' => $nftDb['hero_uniid'], + 'token_id' => $nftDb['token_id'], + 'token_type' => Nft::HERO_TYPE, + ); + NftActive::upsert($data); + if ($nftDb['chip_ids']){ + $chip_ids = explode("|",$nftDb['chip_ids']); + if (count($chip_ids)>0){ + foreach ($chip_ids as $chip_id){ + $chipDb = Chip::getChipByIdx($chip_id); + self::_addNftActive($chipDb,Nft::CHIP_TYPE); + } + } + } + } + break; + case Nft::EQUIP_TYPE: + { + $data = array( + 'uniid' => $nftDb['gun_uniid'], + 'token_id' => $nftDb['token_id'], + 'token_type' => Nft::EQUIP_TYPE, + ); + NftActive::upsert($data); + if ($nftDb['chip_ids']){ + $chip_ids = explode("|",$nftDb['chip_ids']); + if (count($chip_ids)>0){ + foreach ($chip_ids as $chip_id){ + $chipDb = Chip::getChipByIdx($chip_id); + self::_addNftActive($chipDb,Nft::CHIP_TYPE); + } + } + } + } + break; + case Nft::CHIP_TYPE: + { + $data = array( + 'uniid' => $nftDb['idx'], + 'token_id' => $nftDb['token_id'], + 'token_type' => Nft::CHIP_TYPE, + ); + NftActive::upsert($data); + } + break; + default: + { + + } + } + } + private function rewardCegPve() { $log_param = [