From 9b92608a7514db8c8304f36fb7c0ef6b81ba1691 Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 21 Dec 2022 14:50:08 +0800 Subject: [PATCH 01/65] ... --- doc/Market.py | 2 ++ webapp/controller/MarketController.class.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/doc/Market.py b/doc/Market.py index 0747c547..50d75881 100644 --- a/doc/Market.py +++ b/doc/Market.py @@ -9,6 +9,7 @@ class NftIntro(object): ['idx', 0, 'idx'], ['token_id', '', 'token_id'], ['token_type', 0, 'nft类型 1:英雄 2:枪支 3:芯片'], + ['amount', 0, '堆叠数量'], ['createtime', 0, '创建时间(上架时间)'], ['modifytime', 0, '修改时间(更新价格等)'], ['s_price', 0, '出售价格-暂定'], @@ -368,6 +369,7 @@ class Market(object): ['token', '', 'token'], ['nft_token', '', 'nft_token'], ['s_price', '', '出售价格USDT'], + ['amount', 0, '出售数量'], ['payment_token_address', '', 'payment_token_address'], ['nonce', '', 'nonce'], ['signature', '', '签名soliditySha3(type, payment_token_address, price, nonce), 签名的replace客户端做处理'], diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index a5585ea6..271f5393 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -884,6 +884,7 @@ class MarketController extends BaseController { $token = getReqVal('token', ''); $nft_token = getReqVal('nft_token', ''); $s_price = getReqVal('s_price', ''); + $amount = getReqVal('amount', 1); $payment_token_address = getReqVal('payment_token_address', ''); $nonce = getReqVal('nonce', ''); $signature = getReqVal('signature', ''); @@ -901,6 +902,7 @@ class MarketController extends BaseController { 'token_id' => $nft_token, 'owner_address' => $nftDetail['owner_address'], 'token_type' => $nftDetail['type'], + 'amount' => $amount, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), 's_price' => $s_price, From 2f5e42e7132bdb97c0532701aa7537e3270d1252 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 21 Dec 2022 16:18:06 +0800 Subject: [PATCH 02/65] =?UTF-8?q?=E9=99=8D=E8=90=BD=E4=BC=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/User.py | 1 + doc/_common.py | 2 ++ webapp/controller/UserController.class.php | 15 +++++++++++++++ webapp/models/Parachute.php | 13 ++++++++++++- webapp/models/User.php | 13 ++++++++++++- 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/doc/User.py b/doc/User.py index d257da97..e28a1f54 100644 --- a/doc/User.py +++ b/doc/User.py @@ -77,6 +77,7 @@ class User(object): ['guild_id', 0, '跟新工会id(可选参数,不传就不更新)'], ['guild_job', 0, '跟新工会职位(可选参数,不传就不更新)'], ['guild_name', 0, '跟新工会名称(可选参数,不传就不更新)'], + ['parachute', 0, '跟新降落伞(可选参数,不传就不更新)'], ], 'response': [ _common.RspHead(), diff --git a/doc/_common.py b/doc/_common.py index e38c0f55..7711c7f8 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -149,6 +149,8 @@ class UserInfo(object): ['guild_id', '', '工会id'], ['guild_job', 0, '工会职位'], ['guild_name', '', '工会名称'], + ['parachute', '', '当前使用的降落伞id'], + ['!parachute_list', [0], '拥有的降落伞列表'], ] class UserSimple(object): diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index f876b9d2..6b346dd5 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -486,6 +486,21 @@ class UserController extends BaseAuthedController { 'valid_func' => function ($val, &$errCode, &$errMsg) { return true; } + ), + 'parachute' => array( + 'field_name' => 'parachute', + 'val_func' => function ($val) { + return $val; + }, + 'valid_func' => function ($val, &$errCode, &$errMsg) { + if (User::isValidParachute($val)) { + return true; + } else { + $errCode = 1; + $errMsg = 'parachute parameter error'; + return false; + } + } ) ); $fieldsKv = array(); diff --git a/webapp/models/Parachute.php b/webapp/models/Parachute.php index 5c7a97fc..286dbfa2 100644 --- a/webapp/models/Parachute.php +++ b/webapp/models/Parachute.php @@ -8,14 +8,25 @@ use mt; use phpcommon\SqlHelper; class Parachute extends BaseModel { + public static $parachute = '170001'; //默认降落伞 + public static function getMyParachute(){ - return SqlHelper::ormSelect( + $list = array( + self::$parachute + ); + $rows = SqlHelper::ormSelect( myself()->_getSelfMysql(), 't_parachute', array( 'account_id' => myself()->_getAccountId(), ) ); + if ($rows){ + foreach ($rows as $row){ + array_push($list, $row['item_id']); + } + } + return $list; } public static function addParachute($itemMeta){ if ($itemMeta){ diff --git a/webapp/models/User.php b/webapp/models/User.php index 5b0c3729..0746e1c7 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -4,11 +4,13 @@ namespace models; require_once('mt/Item.php'); require_once('models/UserSeasonRing.php'); +require_once('models/Parachute.php'); use mt; use phpcommon; use phpcommon\SqlHelper; use models\UserSeasonRing; +use models\Parachute; class User extends BaseModel { @@ -69,6 +71,8 @@ class User extends BaseModel { 'guild_id' => $row['guild_id'], 'guild_job' => $row['guild_job'], 'guild_name' => $row['guild_name'], + 'parachute' => $row['parachute'] ? $row['parachute'] : Parachute::$parachute, + 'parachute_list' => Parachute::getMyParachute(), ); } @@ -106,7 +110,9 @@ class User extends BaseModel { 'guild_id' => $row['guild_id'], 'guild_job' => $row['guild_job'], 'guild_name' => $row['guild_name'], - 'ring_list' => UserSeasonRing::ringList($row['account_id']) + 'ring_list' => UserSeasonRing::ringList($row['account_id']), + 'parachute' => $row['parachute'] ? $row['parachute'] : Parachute::$parachute, + 'parachute_list' => Parachute::getMyParachute(), ); } @@ -150,6 +156,11 @@ class User extends BaseModel { return in_array($headFrame, $headFrameList); } + public static function isValidParachute($parachute){ + $parachuteList = Parachute::getMyParachute(); + return in_array($parachute, $parachuteList); + } + private static function getHeadList($userInfo) { $headList = emptyReplace(json_decode($userInfo['head_list'], true), array()); From 09036f72a50ab3ca3de77704e290288143f0b5fd Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 21 Dec 2022 16:20:44 +0800 Subject: [PATCH 03/65] 1 --- sql/gamedb.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index fd809c41..4c5563f5 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -65,6 +65,7 @@ CREATE TABLE `t_user` ( `guild_id` varchar(60) NOT NULL DEFAULT '' COMMENT '工会id', `guild_job` int(11) NOT NULL DEFAULT '0' COMMENT '工会职位', `guild_name` varchar(255) NOT NULL DEFAULT '' COMMENT '工会名称', + `parachute` int(11) NOT NULL DEFAULT '0' COMMENT '降落伞ID', PRIMARY KEY (`idx`), UNIQUE KEY `account_id` (`account_id`), KEY `channel` (`channel`) From c8a01d8cd3006447fd4b15fd027462dd8d14fcd0 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 21 Dec 2022 16:28:39 +0800 Subject: [PATCH 04/65] 1 --- webapp/controller/BattleController.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index bd4ba3ec..ec965086 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -7,6 +7,8 @@ require_once('models/Bag.php'); require_once('models/DynData.php'); require_once('models/BattleSettlement.php'); require_once('models/BattleHistory.php'); +require_once('models/User.php'); +require_once('models/Parachute.php'); require_once('services/BattleDataService.php'); require_once('services/FormulaService.php'); require_once('mt/RankSeason.php'); @@ -18,6 +20,8 @@ use models\Bag; use models\DynData; use models\BattleHistory; use models\BattleSettlement; +use models\User; +use models\Parachute; class BattleController extends BaseAuthedController { @@ -186,6 +190,7 @@ class BattleController extends BaseAuthedController { ); $currSeason = mt\RankSeason::getCurrentSeason(); foreach ($members as $member) { + $userDb = User::find($member['account_id']); $info = array( 'account_id' => $member['account_id'], 'session_id' => $member['session_id'], @@ -193,6 +198,7 @@ class BattleController extends BaseAuthedController { 'weapon_uuid1' => $member['weapon_uuid1'], 'weapon_uuid2' => $member['weapon_uuid2'], 'battle_uuid' => $member['battle_uuid'], + 'parachute' => $userDb['parachute']?$userDb['parachute']:Parachute::$parachute, 'hero_dto' => '', 'weapon_dto1' => '', 'weapon_dto2' => '', From 2e94814b363c91622c4b2b73e8cb76e81542eac8 Mon Sep 17 00:00:00 2001 From: songliang Date: Thu, 22 Dec 2022 16:50:16 +0800 Subject: [PATCH 05/65] ... --- doc/Market.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/doc/Market.py b/doc/Market.py index 50d75881..1f6589e7 100644 --- a/doc/Market.py +++ b/doc/Market.py @@ -19,6 +19,13 @@ class NftIntro(object): ['c_id', 0, '缓存-idx'], ['details', _common.NftDetail(), 'nft列表'], ] + +class CurrencyType(object): + def __init__(self): + self.fields = [ + ['name', '', '货币名称'], + ['address', '', '货币地址'], + ] class Market(object): def __init__(self): @@ -397,4 +404,17 @@ class Market(object): _common.RspHead() ] }, + { + 'name': 'getSupportedCurrencyTypes', + 'desc': '获取支持的货币类型', + 'group': 'Market', + 'url': 'webapp/index.php?c=Market&a=getSupportedCurrencyTypes', + 'params': [ + ['account', '', '账号id'], + ], + 'response': [ + _common.RspHead(), + ['!list', [CurrencyType()], '货币类型列表'], + ] + } ] From 40e545f030e57fafee620820e605b84faf074126 Mon Sep 17 00:00:00 2001 From: songliang Date: Thu, 22 Dec 2022 16:59:33 +0800 Subject: [PATCH 06/65] ... --- webapp/controller/MarketController.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 271f5393..30022331 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -936,6 +936,23 @@ class MarketController extends BaseController { $this->_rspOk(); } + public function getSupportedCurrencyTypes() { + $types = array(); + if (SERVER_ENV == _ONLINE) { + array_push($types, array( + 'name' => 'online', + 'address' => 'online', + )); + } else { + array_push($types, array( + 'name' => 'test', + 'address' => 'test', + )); + } + $this->_rspData(array( + 'list' => $types, + )); + } private function getNftGameData($nftRowInfo) { $t = $nftRowInfo['token_type']; From 1af2632812d44d31a2c5032757be521134755f28 Mon Sep 17 00:00:00 2001 From: songliang Date: Thu, 22 Dec 2022 17:13:57 +0800 Subject: [PATCH 07/65] ... --- webapp/controller/MarketController.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 30022331..d4ac152c 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -22,6 +22,7 @@ require_once('services/ActivateNftService.php'); require_once('phpcommon/bchelper.php'); +use phpcommon; use phpcommon\SqlHelper; use models\BoxOrder; use models\Nft; From ffd8dbccda8cc324d631bc364273c01c04458385 Mon Sep 17 00:00:00 2001 From: songliang Date: Thu, 22 Dec 2022 17:46:18 +0800 Subject: [PATCH 08/65] ... --- webapp/controller/MarketController.class.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index d4ac152c..c7dec445 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -941,13 +941,21 @@ class MarketController extends BaseController { $types = array(); if (SERVER_ENV == _ONLINE) { array_push($types, array( - 'name' => 'online', - 'address' => 'online', + 'name' => 'CEC', + 'address' => '0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7', + )); + array_push($types, array( + 'name' => 'CEG', + 'address' => '0x59d3631c86BbE35EF041872d502F218A39FBa150', )); } else { array_push($types, array( - 'name' => 'test', - 'address' => 'test', + 'name' => 'D CEC', + 'address' => '0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7', + )); + array_push($types, array( + 'name' => 'D CEG', + 'address' => '0x59d3631c86BbE35EF041872d502F218A39FBa150', )); } $this->_rspData(array( From 67152a0ec2108da3d45a20d722fd1753d3ccd192 Mon Sep 17 00:00:00 2001 From: songliang Date: Fri, 23 Dec 2022 10:50:19 +0800 Subject: [PATCH 09/65] ... --- webapp/controller/MarketController.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index c7dec445..454e67ee 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -940,6 +940,10 @@ class MarketController extends BaseController { public function getSupportedCurrencyTypes() { $types = array(); if (SERVER_ENV == _ONLINE) { + array_push($types, array( + 'name' => 'USDT', + 'address' => '0x514609B71340E149Cb81A80A953D07A7Fe41bd4F', + )); array_push($types, array( 'name' => 'CEC', 'address' => '0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7', @@ -949,6 +953,10 @@ class MarketController extends BaseController { 'address' => '0x59d3631c86BbE35EF041872d502F218A39FBa150', )); } else { + array_push($types, array( + 'name' => 'USDT', + 'address' => '0x514609B71340E149Cb81A80A953D07A7Fe41bd4F', + )); array_push($types, array( 'name' => 'D CEC', 'address' => '0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7', @@ -985,7 +993,6 @@ class MarketController extends BaseController { return array('unknown' => 'unknown game data type, cannot find data'); } - private function appendChipsInfo($detail) { $detail['chips_info'] = array(); if (!empty($detail['chip_ids'])) { From 9db86d6d35fd7381ec63fae8dd6902c777564a45 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 3 Jan 2023 15:44:56 +0800 Subject: [PATCH 10/65] ... --- uml/market.drawio | 149 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 uml/market.drawio diff --git a/uml/market.drawio b/uml/market.drawio new file mode 100644 index 00000000..e8009160 --- /dev/null +++ b/uml/market.drawio @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From acbfa7d61e1deaf216b47d10d52b0455de793d87 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 3 Jan 2023 16:39:31 +0800 Subject: [PATCH 11/65] ... --- doc/Market.py | 2 ++ webapp/controller/MarketController.class.php | 24 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/doc/Market.py b/doc/Market.py index 1f6589e7..041bef12 100644 --- a/doc/Market.py +++ b/doc/Market.py @@ -17,6 +17,8 @@ class NftIntro(object): ['c_job', 0, '缓存-职业'], ['c_lv', 0, '缓存-级别'], ['c_id', 0, '缓存-idx'], + ['selling', 0, '正在售卖的个数'], + ['o_link', '', '关联的售卖单号'], ['details', _common.NftDetail(), 'nft列表'], ] diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 454e67ee..a1a2d927 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -868,6 +868,7 @@ class MarketController extends BaseController { $nfts = array(); for ($x = $start; $x < $page_end; $x++) { $row = $rows[$x]; + $this->attach_market_selling($row); array_push($nfts, $row); } @@ -1007,4 +1008,27 @@ class MarketController extends BaseController { } return $detail; } + + private function attach_market_selling(&$row) { + $conn = myself()->_getMysql(''); + + $rows = $conn->execQuery( + 'SELECT * FROM t_market_store '. + 'WHERE token_id=:token_id AND owner_address=:owner_address', + array( + ':token_id' => $row['token_id'], + ':owner_address' => $row['owner_address'], + ) + ); + + $count = 0; + $link_array = array(); + foreach ($rows as $r) { + $count += $r['amount']; + array_push($link_array, $r['idx']); + } + + $row['o_link'] = implode('|', $link_array); + $row['selling'] = $count; + } } From b5c2a4868920834238188bc8a708d0f2bd4c7b8b Mon Sep 17 00:00:00 2001 From: songliang Date: Thu, 5 Jan 2023 14:54:43 +0800 Subject: [PATCH 12/65] update usdt address --- webapp/controller/MarketController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index a1a2d927..3cc60134 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -956,7 +956,7 @@ class MarketController extends BaseController { } else { array_push($types, array( 'name' => 'USDT', - 'address' => '0x514609B71340E149Cb81A80A953D07A7Fe41bd4F', + 'address' => '0xc6e7568D8552670f915914d6DD280AfD9a06f9AE', )); array_push($types, array( 'name' => 'D CEC', From 5d9c13ca7d09f493505128082b55a0fbd6d15ec0 Mon Sep 17 00:00:00 2001 From: songliang Date: Thu, 5 Jan 2023 14:58:10 +0800 Subject: [PATCH 13/65] ... --- webapp/controller/MarketController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 3cc60134..77f7ff35 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -956,7 +956,7 @@ class MarketController extends BaseController { } else { array_push($types, array( 'name' => 'USDT', - 'address' => '0xc6e7568D8552670f915914d6DD280AfD9a06f9AE', + 'address' => '0x8E7a8d3CAeEbbe9A92faC4db19424218aE6791a3', )); array_push($types, array( 'name' => 'D CEC', From 79150b62474c10647c07c31ea13f8e23400634f0 Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 9 Jan 2023 09:49:29 +0800 Subject: [PATCH 14/65] ... --- webapp/controller/MarketController.class.php | 217 ++++++++++++++++++- 1 file changed, 213 insertions(+), 4 deletions(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 77f7ff35..1e0b649b 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -22,7 +22,7 @@ require_once('services/ActivateNftService.php'); require_once('phpcommon/bchelper.php'); -use phpcommon; +// use phpcommon as phpcommon; use phpcommon\SqlHelper; use models\BoxOrder; use models\Nft; @@ -771,7 +771,7 @@ class MarketController extends BaseController { $counts = $conn->execQuery( 'SELECT count(*) as count FROM t_market_store '. - 'WHERE token_type=:token_type '. + 'WHERE token_type=:token_type AND status=0 '. $job_filter_fn($job_filter_array). $lv_filter_fn($lv_filter). $quality_filter_fn($quality_filter). @@ -795,7 +795,7 @@ class MarketController extends BaseController { $rows = $conn->execQuery( 'SELECT * FROM t_market_store '. - 'WHERE token_type=:token_type '. + 'WHERE token_type=:token_type AND status=0 '. $job_filter_fn($job_filter_array). $lv_filter_fn($lv_filter). $quality_filter_fn($quality_filter). @@ -972,6 +972,215 @@ class MarketController extends BaseController { )); } + public function eventSellOrder() { + $tokenId = getReqVal('tokenId', ''); + $owner = strtolower(getReqVal('owner', '')); + $nftToken = getReqVal('nftToken', ''); + $amount = getReqVal('amount', 0); + $orderId = getReqVal('orderId', ''); + $currency = getReqVal('currency', ''); + $price = getReqVal('price', ''); + + error_log("eventSellOrder:" . json_encode( + array( + 'tokenId' => $tokenId, + 'owner' => $owner, + 'nftToken' => $nftToken, + 'amount' => $amount, + 'orderId' => $orderId, + 'currency' => $currency, + 'price' => $price, + ), + JSON_PRETTY_PRINT + ) + ); + + $conn = myself()->_getMysql(''); + + // 1. check order status + $chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId)); + if (!empty($chk)) { + $this->_rspErr(1, 'repeat sell order, orderId='.$orderId); + return; + } + + // 2. insert sell order to t_market_store + $nftDb = Nft::findNftByOwner($owner, $tokenId); + $nftDetail = Nft::toDto($nftDb); + $detail = $this->getNftGameData($nftDb); + $r = SqlHelper::insert( + $conn, + 't_market_store', + array( + 'token_id' => $tokenId, + 'o_link' => $orderId, + 'nft_token' => $nftToken, + 'status' => 0, + 'owner_address' => $nftDetail['owner_address'], + 'token_type' => $nftDetail['type'], + 'amount' => $amount, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + 's_price' => $price, + 'c_name' => $nftDetail['info']['name'], + 'c_job' => isset($nftDetail['info']['job']) ? $nftDetail['info']['job'] + : (isset($detail['chip_type']) ? $detail['chip_type'] + : (isset($detail['type'])?$detail['type'] + :0)), + 'c_lv' => @$detail['gun_lv'] | @$detail['hero_lv'] | @$detail['chip_grade'], + 'c_quality' => isset($nftDetail['info']['quality']) ? $nftDetail['info']['quality'] : 0, + 'c_durability' => isset($nftDetail['info']['durability']) ? $nftDetail['info']['durability'] : (isset($detail['hero_tili']) ? $detail['hero_tili'] : 0), + 'c_type' => isset($detail['type']) ? $detail['type'] : 0, + 'c_id' => $nftDetail['item_id'], + ) + ); + if (!$r) { + $this->_rspErr(2, 'unknown error, orderId='.$orderId); + } + + $this->_rspOk(); + } + + public function eventBuyOrder() { + $tokenId = getReqVal('tokenId', ''); + $orderId = getReqVal('orderId', ''); + $nftToken = getReqVal('nftToken', ''); + $amount = getReqVal('amount', 0); + $seller = strtolower(getReqVal('seller', '')); + $buyer = strtolower(getReqVal('buyer', '')); + $erc20 = getReqVal('erc20', ''); + $price = getReqVal('price', ''); + + error_log("eventBuyOrder:" . json_encode( + array( + 'tokenId' => $tokenId, + 'orderId' => $orderId, + 'nftToken' => $nftToken, + 'amount' => $amount, + 'seller' => $seller, + 'buyer' => $buyer, + 'erc20' => $erc20, + 'price' => $price, + ), + JSON_PRETTY_PRINT + ) + ); + + $conn = myself()->_getMysql(''); + + // 1. check order status + $chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId)); + if (empty($chk)) { + $this->_rspErr(1, 'not found order, orderId='.$orderId); + return; + } + if ($chk['status']== '0') { + $r = SqlHelper::update( + $conn, + 't_market_store', + array( + 'o_link' => $orderId, + ), + array( + 'status' => 2, + ) + ); + if ($r) { + $this->_rspOk(); + return; + } + } + $this->_rspErr(1, 'order status error, order='.$orderId); + } + + public function eventCancelOrder() { + $orderId = getReqVal('orderId', ''); + $nftToken = getReqVal('nftToken', ''); + $tokenId = getReqVal('tokenId', ''); + error_log("eventCancelOrder:" . json_encode( + array( + 'orderId' => $orderId, + 'nftToken' => $nftToken, + 'tokenId' => $tokenId, + ), + JSON_PRETTY_PRINT + ) + ); + + $conn = myself()->_getMysql(''); + + // 1. check order status + $chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId)); + if (empty($chk)) { + $this->_rspErr(1, 'not found order, orderId='.$orderId); + return; + } + if ($chk['status']== '0') { + $r = SqlHelper::update( + $conn, + 't_market_store', + array( + 'o_link' => $orderId, + ), + array( + 'status' => 1, + ) + ); + if ($r) { + $this->_rspOk(); + return; + } + } + $this->_rspErr(1, 'order status error, order='.$orderId); + } + + public function eventPriceUpdateOrder() { + $orderId = getReqVal('orderId', '');; + $nftToken = getReqVal('nftToken', ''); + $tokenId = getReqVal('tokenId', ''); + $priceOld = getReqVal('priceOld', ''); + $price = getReqVal('price', ''); + error_log("eventPriceUpdateOrder:" . json_encode( + array( + 'orderId' => $orderId, + 'nftToken' => $nftToken, + 'tokenId' => $tokenId, + 'priceOld' => $priceOld, + 'price' => $price, + ), + JSON_PRETTY_PRINT + ) + ); + + $conn = myself()->_getMysql(''); + + // 1. check order status + $chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId)); + if (empty($chk)) { + $this->_rspErr(1, 'not found order, orderId='.$orderId); + return; + } + + if ($chk['status']== '0') { + $r = SqlHelper::update( + $conn, + 't_market_store', + array( + 'o_link' => $orderId, + ), + array( + 's_price' => $price, + ) + ); + if ($r) { + $this->_rspOk(); + return; + } + } + + $this->_rspErr(1, 'price update failed, orderId='.$orderId); + } + private function getNftGameData($nftRowInfo) { $t = $nftRowInfo['token_type']; $token_id = $nftRowInfo['token_id']; @@ -1025,7 +1234,7 @@ class MarketController extends BaseController { $link_array = array(); foreach ($rows as $r) { $count += $r['amount']; - array_push($link_array, $r['idx']); + array_push($link_array, $r['o_link']); } $row['o_link'] = implode('|', $link_array); From f76c917be340bd7b0ac54bf84d45486c4135e9ce Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 9 Jan 2023 11:43:02 +0800 Subject: [PATCH 15/65] ... --- webapp/controller/MarketController.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 1e0b649b..db445dfe 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -1223,10 +1223,11 @@ class MarketController extends BaseController { $rows = $conn->execQuery( 'SELECT * FROM t_market_store '. - 'WHERE token_id=:token_id AND owner_address=:owner_address', + 'WHERE token_id=:token_id AND owner_address=:owner_address AND status=:status', array( ':token_id' => $row['token_id'], ':owner_address' => $row['owner_address'], + ':status' => 0, ) ); From ebd9a237318ae36569ea833256cc56306c53cf87 Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 9 Jan 2023 14:15:32 +0800 Subject: [PATCH 16/65] ... --- webapp/controller/MarketController.class.php | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index db445dfe..2ca637c4 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -572,6 +572,7 @@ class MarketController extends BaseController { switch ($type) { case Nft::HERO_TYPE: { $rows = Nft::getNftListByType($account, $type); + $rows = array_merge($rows, $this->listMySelledNfts($account, $type)); foreach ($rows as &$row) { $nftDb = Nft::findNftByOwner($account, $row['token_id']); $row['info'] = Nft::toDto($nftDb); @@ -602,6 +603,7 @@ class MarketController extends BaseController { break; case Nft::EQUIP_TYPE: { $rows = Nft::getNftListByType($account, $type); + $rows = array_merge($rows, $this->listMySelledNfts($account, $type)); foreach ($rows as &$row) { $nftDb = Nft::findNftByOwner($account, $row['token_id']); $row['info'] = Nft::toDto($nftDb); @@ -631,6 +633,7 @@ class MarketController extends BaseController { break; case Nft::CHIP_TYPE: { $rows = Nft::getNft1155List($account, $type); + $rows = array_merge($rows, $this->listMySelledNfts($account, $type)); foreach ($rows as &$row) { $row['detail'] = Chip::toDto(Chip::getChipByTokenId($row['token_id'])); if (!in_array($row['detail']['chip_type'], $job)) @@ -654,6 +657,7 @@ class MarketController extends BaseController { break; case Nft::FRAGMENT_TYPE: { $rows = Nft::getNft1155List($account, $type); + $rows = array_merge($rows, $this->listMySelledNfts($account, $type)); foreach ($rows as &$row) { $nftDb = Nft::findNftByOwner($account, $row['token_id']); $row['detail'] = $this->getNftGameData($nftDb); @@ -868,7 +872,7 @@ class MarketController extends BaseController { $nfts = array(); for ($x = $start; $x < $page_end; $x++) { $row = $rows[$x]; - $this->attach_market_selling($row); + // $this->attach_market_selling($row); array_push($nfts, $row); } @@ -1241,4 +1245,20 @@ class MarketController extends BaseController { $row['o_link'] = implode('|', $link_array); $row['selling'] = $count; } + + private function listMySelledNfts($account, $type) + { + $conn = myself()->_getMysql(''); + + $rows = $conn->execQuery( + 'SELECT * FROM t_market_store '. + 'WHERE owner_address=:account AND token_type=:token_type AND status=0 ', + array( + ':account' => $account, + ':token_type' => $type, + ) + ); + + return $rows; + } } From 87aeb283cda7e316e456a080b545484c84014be6 Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 9 Jan 2023 14:38:08 +0800 Subject: [PATCH 17/65] ... --- webapp/controller/MarketController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 2ca637c4..ca981419 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -817,7 +817,7 @@ class MarketController extends BaseController { for ($x = $start; $x < $page_end; $x++) { $row = $rows[$x%$page_size]; - $nftDb = Nft::findNftByOwner($row['owner_address'], $row['token_id']); + $nftDb = Nft::getNft($row['token_id']); if (!$nftDb) { myself()->_rspErr(1, 'nft not exists'); return; From 535b31ccac839c9ad246ac4509015263cec62cf2 Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 9 Jan 2023 17:16:28 +0800 Subject: [PATCH 18/65] ... --- webapp/controller/MarketController.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index ca981419..21572f75 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -575,6 +575,9 @@ class MarketController extends BaseController { $rows = array_merge($rows, $this->listMySelledNfts($account, $type)); foreach ($rows as &$row) { $nftDb = Nft::findNftByOwner($account, $row['token_id']); + if (empty($nftDb)) { + $nftDb = Nft::getNft($row['token_id']); + } $row['info'] = Nft::toDto($nftDb); $row['detail'] = Hero::toDtoInfo(Hero::findByTokenId2($row['token_id'])); if (in_array($row['info']['info']['job'], $job)==false) continue; @@ -606,6 +609,9 @@ class MarketController extends BaseController { $rows = array_merge($rows, $this->listMySelledNfts($account, $type)); foreach ($rows as &$row) { $nftDb = Nft::findNftByOwner($account, $row['token_id']); + if (empty($nftDb)) { + $nftDb = Nft::getNft($row['token_id']); + } $row['info'] = Nft::toDto($nftDb); $row['detail'] = Gun::toDtoInfo(Gun::findByTokenId2($row['token_id'])); if ($row['detail']['gun_lv']<$lv) continue; @@ -660,6 +666,9 @@ class MarketController extends BaseController { $rows = array_merge($rows, $this->listMySelledNfts($account, $type)); foreach ($rows as &$row) { $nftDb = Nft::findNftByOwner($account, $row['token_id']); + if (empty($nftDb)) { + $nftDb = Nft::getNft($row['token_id']); + } $row['detail'] = $this->getNftGameData($nftDb); if (!in_array($row['detail']['type'], $job)) continue; From a05f062689974934b78079fdb53682f5ebae2574 Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 9 Jan 2023 17:46:42 +0800 Subject: [PATCH 19/65] ... --- webapp/controller/MarketController.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 21572f75..bf7fff39 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -828,8 +828,12 @@ class MarketController extends BaseController { $row = $rows[$x%$page_size]; $nftDb = Nft::getNft($row['token_id']); if (!$nftDb) { - myself()->_rspErr(1, 'nft not exists'); - return; + $nftDb = Nft::findNftByOwner($account, $row['token_id']); + // 0x768b5faed6dc69816f33377d214ffaf00dcdd0cf + if (!$nftDb) { + myself()->_rspErr(1, 'nft not exists'); + return; + } } $nft = Nft::toDto($nftDb); $row['info'] = $nft; From c410ae8981abf06bd1ac52a4e18e7fc2230f3d27 Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 9 Jan 2023 17:53:15 +0800 Subject: [PATCH 20/65] ... --- webapp/controller/MarketController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index bf7fff39..db72e722 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -690,7 +690,7 @@ class MarketController extends BaseController { public function listSellNfts() { - $account = getReqVal('account', ''); + $account = strtolower(getReqVal('account', '')); $token = getReqVal('token', ''); $start = getReqVal('start', 0); $page_size = getReqVal('page_size', 10); From fe8c3b7e2c9044de3a5cb19d28d1a8a06160e414 Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 9 Jan 2023 19:37:01 +0800 Subject: [PATCH 21/65] ... --- webapp/controller/MarketController.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index db72e722..2d4b040a 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -1038,6 +1038,7 @@ class MarketController extends BaseController { 'amount' => $amount, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), + 'currency' => $currency, 's_price' => $price, 'c_name' => $nftDetail['info']['name'], 'c_job' => isset($nftDetail['info']['job']) ? $nftDetail['info']['job'] From f06f599cb519a38cfc9f955437197eba3e0887e8 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 10 Jan 2023 10:17:30 +0800 Subject: [PATCH 22/65] ... --- webapp/controller/MarketController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 2d4b040a..9e572fe2 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -1038,7 +1038,7 @@ class MarketController extends BaseController { 'amount' => $amount, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), - 'currency' => $currency, + 's_currency' => $currency, 's_price' => $price, 'c_name' => $nftDetail['info']['name'], 'c_job' => isset($nftDetail['info']['job']) ? $nftDetail['info']['job'] From bf6292662ce21c9370f1a354a1ec911e6b8398aa Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 10 Jan 2023 10:31:41 +0800 Subject: [PATCH 23/65] ... --- webapp/controller/MarketController.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 9e572fe2..86ff4ea0 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -1023,6 +1023,9 @@ class MarketController extends BaseController { // 2. insert sell order to t_market_store $nftDb = Nft::findNftByOwner($owner, $tokenId); + if (empty($nftDb)) { + $nftDb = Nft::getNft($tokenId); + } $nftDetail = Nft::toDto($nftDb); $detail = $this->getNftGameData($nftDb); $r = SqlHelper::insert( @@ -1033,7 +1036,7 @@ class MarketController extends BaseController { 'o_link' => $orderId, 'nft_token' => $nftToken, 'status' => 0, - 'owner_address' => $nftDetail['owner_address'], + 'owner_address' => $owner, 'token_type' => $nftDetail['type'], 'amount' => $amount, 'createtime' => myself()->_getNowTime(), From 0aa328d8cad6311b0aac0c034e93cf94dc37bad4 Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 11 Jan 2023 13:04:17 +0800 Subject: [PATCH 24/65] ... --- webapp/controller/MarketController.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 86ff4ea0..efb2a366 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -960,7 +960,7 @@ class MarketController extends BaseController { if (SERVER_ENV == _ONLINE) { array_push($types, array( 'name' => 'USDT', - 'address' => '0x514609B71340E149Cb81A80A953D07A7Fe41bd4F', + 'address' => '0xc22Ffa318051d8aF4E5f2E2732d7049486fcE093', )); array_push($types, array( 'name' => 'CEC', @@ -968,7 +968,7 @@ class MarketController extends BaseController { )); array_push($types, array( 'name' => 'CEG', - 'address' => '0x59d3631c86BbE35EF041872d502F218A39FBa150', + 'address' => '0xc22Ffa318051d8aF4E5f2E2732d7049486fcE093', )); } else { array_push($types, array( From d04e8e2e7c542ab19991ddb966a64b1f1ad7dce9 Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 11 Jan 2023 13:29:37 +0800 Subject: [PATCH 25/65] ... --- webapp/controller/MarketController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index efb2a366..5c264e16 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -973,7 +973,7 @@ class MarketController extends BaseController { } else { array_push($types, array( 'name' => 'USDT', - 'address' => '0x8E7a8d3CAeEbbe9A92faC4db19424218aE6791a3', + 'address' => '0xc22Ffa318051d8aF4E5f2E2732d7049486fcE093', )); array_push($types, array( 'name' => 'D CEC', From 8593a751397e5a084a4fa83b2fd2b6a5036dc981 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 11 Jan 2023 13:30:48 +0800 Subject: [PATCH 26/65] 1 --- webapp/controller/UserController.class.php | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 6b346dd5..2346a138 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -125,24 +125,24 @@ class UserController extends BaseAuthedController { } private function _addFreeItem(){ -// foreach (mt\Parameter::getListValue('creator_hero_id') as $heroId) { -// $heroMeta = mt\Item::get($heroId); -// if ($heroMeta) { -// Hero::addHero($heroMeta); -// User::upsertHeadList($heroMeta); -// } -// } -// $addItems =array(); -// foreach (mt\Parameter::getListValue('creator_present_items') as $itemsStr) { -// list($itemId, $itemNum) = explode(':', $itemsStr); -// if ($itemNum > 0) { -// array_push($addItems, -// array( -// 'item_id' => $itemId, -// 'item_num' => $itemNum -// )); -// } -// } + foreach (mt\Parameter::getListValue('creator_hero_id') as $heroId) { + $heroMeta = mt\Item::get($heroId); + if ($heroMeta) { + Hero::addHero($heroMeta); + User::upsertHeadList($heroMeta); + } + } + $addItems =array(); + foreach (mt\Parameter::getListValue('creator_present_items') as $itemsStr) { + list($itemId, $itemNum) = explode(':', $itemsStr); + if ($itemNum > 0) { + array_push($addItems, + array( + 'item_id' => $itemId, + 'item_num' => $itemNum + )); + } + } $items = array( array( 'item_id' => V_ITEM_GOLD, From d54dab2ed55fb973d8010be42cdee14848c83053 Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 11 Jan 2023 16:34:19 +0800 Subject: [PATCH 27/65] ... --- webapp/controller/MarketController.class.php | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 5c264e16..34b46d18 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -962,27 +962,11 @@ class MarketController extends BaseController { 'name' => 'USDT', 'address' => '0xc22Ffa318051d8aF4E5f2E2732d7049486fcE093', )); - array_push($types, array( - 'name' => 'CEC', - 'address' => '0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7', - )); - array_push($types, array( - 'name' => 'CEG', - 'address' => '0xc22Ffa318051d8aF4E5f2E2732d7049486fcE093', - )); } else { array_push($types, array( 'name' => 'USDT', 'address' => '0xc22Ffa318051d8aF4E5f2E2732d7049486fcE093', )); - array_push($types, array( - 'name' => 'D CEC', - 'address' => '0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7', - )); - array_push($types, array( - 'name' => 'D CEG', - 'address' => '0x59d3631c86BbE35EF041872d502F218A39FBa150', - )); } $this->_rspData(array( 'list' => $types, From 4a702773fc9a8f51f28021d19456155e0a8dd776 Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 11 Jan 2023 18:54:56 +0800 Subject: [PATCH 28/65] ... --- webapp/controller/MarketController.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 34b46d18..f9c48250 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -831,8 +831,11 @@ class MarketController extends BaseController { $nftDb = Nft::findNftByOwner($account, $row['token_id']); // 0x768b5faed6dc69816f33377d214ffaf00dcdd0cf if (!$nftDb) { - myself()->_rspErr(1, 'nft not exists'); - return; + $nftDb = Nft::findNftByOwner('0xfc628dd79137395f3c9744e33b1c5de554d94882', $row['token_id']); + if (!$nftDb) { + myself()->_rspErr(1, 'nft not exists'); + return; + } } } $nft = Nft::toDto($nftDb); From d9809bf9d30c2e0295f279eb7944898ae6f7f286 Mon Sep 17 00:00:00 2001 From: songliang Date: Sat, 28 Jan 2023 11:20:26 +0800 Subject: [PATCH 29/65] ... --- doc/Market.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/doc/Market.py b/doc/Market.py index 041bef12..e1fe883d 100644 --- a/doc/Market.py +++ b/doc/Market.py @@ -28,6 +28,21 @@ class CurrencyType(object): ['name', '', '货币名称'], ['address', '', '货币地址'], ] + +class TransactionRecord(object): + def __init__(self): + self.fields = [ + ['idx', 0, 'idx'], + ['createtime', 0, '交易成功时间'], + ['orderid', 0, 'market订单id'], + ['o_link', '', '合约订单id'], + ['seller', '', '卖家'], + ['buyer', '', '买家'], + ['tokenid', '', 'tokenid'], + ['amount', 0, '商品数量'], + ['name', '', '商品名称'], + ['type', 0, '商品类型'], + ] class Market(object): def __init__(self): @@ -418,5 +433,24 @@ class Market(object): _common.RspHead(), ['!list', [CurrencyType()], '货币类型列表'], ] + }, + { + 'name': 'getTransactionRecord', + 'desc': '获取交易记录', + 'group': 'Market', + 'url': 'webapp/index.php?c=Market&a=getTransactionRecord', + 'params': [ + ['account', '', '账号id'], + ['start', 0, '分页开始偏移'], + ['page_size', 0, '分页大小'], + ], + 'response': [ + _common.RspHead(), + ['total', 0, '交易记录总数'], + ['start', 0, '有效的分页偏移'], + ['page_size', 0, '有效的分页大小'], + ['!list', [TransactionRecord()], '交易记录列表'], + ] } + ] From 1fb85e0bcabff4215be2d3e07eae03d903fb3091 Mon Sep 17 00:00:00 2001 From: songliang Date: Sat, 28 Jan 2023 12:04:24 +0800 Subject: [PATCH 30/65] ... --- doc/Market.py | 2 +- webapp/controller/MarketController.class.php | 69 +++++++++++++++++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/doc/Market.py b/doc/Market.py index e1fe883d..26141c6b 100644 --- a/doc/Market.py +++ b/doc/Market.py @@ -32,7 +32,7 @@ class CurrencyType(object): class TransactionRecord(object): def __init__(self): self.fields = [ - ['idx', 0, 'idx'], + ['idx', '', 'idx'], ['createtime', 0, '交易成功时间'], ['orderid', 0, 'market订单id'], ['o_link', '', '合约订单id'], diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index f9c48250..4042a593 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -976,6 +976,60 @@ class MarketController extends BaseController { )); } + public function getTransactionRecord() { + $account = strtolower(getReqVal('account', '')); + $start = getReqVal('start', 0); + $page_size = getReqVal('page_size', 10); + + $conn = myself()->_getMysql(''); + + $counts = $conn->execQuery( + 'SELECT count(*) as count FROM t_market_transaction_record '. + 'WHERE seller=:account OR buyer=:account ORDER BY createtime DESC', + array( + ':account' => $account, + ) + ); + + $total = $counts[0]['count']; + $page_end = $start + $page_size; + if ($page_end > $total) { + $page_end = $total; + $start = $total-1; + $start = intval($start / $page_size) * $page_size; + if ($start<0) $start = 0; + } + + $rows = $conn->execQuery( + 'SELECT * FROM t_market_transaction_record '. + 'WHERE seller=:account OR buyer=:account ORDER BY createtime DESC '. + 'LIMIT '.$start.','.$page_size, + array( + ':account' => $account, + ) + ); + + $this->_rspData(array( + "total" => $total, + "start" => $start, + "page_size" => $page_size, + 'nfts' => $rows, + )); + } + + private function addTransactionRecord($record) { + $conn = myself()->_getMysql(''); + + $r = SqlHelper::insert( + $conn, + 't_market_transaction_record', + $record + ); + if (!$r) { + $this->_rspErr(2, 'unknown error, orderId='.$record['orderid']); + } + } + public function eventSellOrder() { $tokenId = getReqVal('tokenId', ''); $owner = strtolower(getReqVal('owner', '')); @@ -1077,7 +1131,7 @@ class MarketController extends BaseController { $conn = myself()->_getMysql(''); // 1. check order status - $chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId)); + $chk = SqlHelper::selectOne($conn, 't_market_store', array('status','idx', 'c_name', 'c_type'), array('o_link' => $orderId)); if (empty($chk)) { $this->_rspErr(1, 'not found order, orderId='.$orderId); return; @@ -1094,6 +1148,19 @@ class MarketController extends BaseController { ) ); if ($r) { + // 增加交易记录 + $record = array( + 'createtime' => myself()->_getNowTime(), + 'orderid' => $chk['idx'], + 'o_link' => $orderId, + 'seller' => $seller, + 'buyer' => $buyer, + 'tokenid' => $tokenId, + 'amount' => $amount, + 'name' => $chk['c_name'], + 'type' => $chk['c_type'], + ); + $this->addTransactionRecord($record); $this->_rspOk(); return; } From ce9cf48da22358ba00d8b42899f22ba5c1e260e9 Mon Sep 17 00:00:00 2001 From: songliang Date: Sat, 28 Jan 2023 13:31:41 +0800 Subject: [PATCH 31/65] ... --- doc/Market.py | 1 + webapp/controller/MarketController.class.php | 22 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/doc/Market.py b/doc/Market.py index 26141c6b..c634f3d3 100644 --- a/doc/Market.py +++ b/doc/Market.py @@ -441,6 +441,7 @@ class Market(object): 'url': 'webapp/index.php?c=Market&a=getTransactionRecord', 'params': [ ['account', '', '账号id'], + ['type', 0, '物品类型 0:所有 1:英雄 2:武器 3:芯片 5:碎片'], ['start', 0, '分页开始偏移'], ['page_size', 0, '分页大小'], ], diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 4042a593..31d2a2db 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -978,14 +978,26 @@ class MarketController extends BaseController { public function getTransactionRecord() { $account = strtolower(getReqVal('account', '')); + $type = getReqVal('type', 0); $start = getReqVal('start', 0); $page_size = getReqVal('page_size', 10); $conn = myself()->_getMysql(''); + $type_filter_fn = function ($f) { + if ($f==0) { + return ''; + } + else { + return 'AND type=' . $f; + } + }; + $counts = $conn->execQuery( 'SELECT count(*) as count FROM t_market_transaction_record '. - 'WHERE seller=:account OR buyer=:account ORDER BY createtime DESC', + 'WHERE (seller=:account OR buyer=:account) '. + $type_filter_fn($type). + ' ORDER BY createtime DESC', array( ':account' => $account, ) @@ -1002,7 +1014,9 @@ class MarketController extends BaseController { $rows = $conn->execQuery( 'SELECT * FROM t_market_transaction_record '. - 'WHERE seller=:account OR buyer=:account ORDER BY createtime DESC '. + 'WHERE (seller=:account OR buyer=:account) '. + $type_filter_fn($type). + ' ORDER BY createtime DESC '. 'LIMIT '.$start.','.$page_size, array( ':account' => $account, @@ -1131,7 +1145,7 @@ class MarketController extends BaseController { $conn = myself()->_getMysql(''); // 1. check order status - $chk = SqlHelper::selectOne($conn, 't_market_store', array('status','idx', 'c_name', 'c_type'), array('o_link' => $orderId)); + $chk = SqlHelper::selectOne($conn, 't_market_store', array('status','idx', 'c_name', 'token_type'), array('o_link' => $orderId)); if (empty($chk)) { $this->_rspErr(1, 'not found order, orderId='.$orderId); return; @@ -1158,7 +1172,7 @@ class MarketController extends BaseController { 'tokenid' => $tokenId, 'amount' => $amount, 'name' => $chk['c_name'], - 'type' => $chk['c_type'], + 'type' => $chk['token_type'], ); $this->addTransactionRecord($record); $this->_rspOk(); From 2efd1415908c665e02f3166c7ca4bf441f63e365 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 9 Feb 2023 14:15:47 +0800 Subject: [PATCH 32/65] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=88=92=E5=AD=90?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/_common.py | 3 +++ sql/gamedb.sql | 1 + webapp/controller/UserController.class.php | 15 +++++++++++++++ webapp/models/User.php | 8 ++++++++ webapp/mt/LevelUp.php | 10 ++++++++++ 5 files changed, 37 insertions(+) create mode 100644 webapp/mt/LevelUp.php diff --git a/doc/_common.py b/doc/_common.py index 7711c7f8..fba7acb7 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -151,6 +151,8 @@ class UserInfo(object): ['guild_name', '', '工会名称'], ['parachute', '', '当前使用的降落伞id'], ['!parachute_list', [0], '拥有的降落伞列表'], + ['ring_id', 0, '勋章(戒指)ID'], + ['!ring_list', [0], '勋章(戒指)列表'], ] class UserSimple(object): @@ -940,6 +942,7 @@ class BattleReward(object): ['weapon1', BattleCegReward(), '武器1奖励'], ['weapon2', BattleCegReward(), '武器2奖励'], ['!items', [BattleItemReward()], '碎片奖励'], + ['lvInfo', [['oldLv',0,'老等级'],['newLv',0,'新等级']], '等级信息'], ] class BattleRankScore(object): diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 4c5563f5..cb3071fc 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -66,6 +66,7 @@ CREATE TABLE `t_user` ( `guild_job` int(11) NOT NULL DEFAULT '0' COMMENT '工会职位', `guild_name` varchar(255) NOT NULL DEFAULT '' COMMENT '工会名称', `parachute` int(11) NOT NULL DEFAULT '0' COMMENT '降落伞ID', + `ring_id` int(11) NOT NULL DEFAULT '0' COMMENT '戒指id', PRIMARY KEY (`idx`), UNIQUE KEY `account_id` (`account_id`), KEY `channel` (`channel`) diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 2346a138..d4cd34e6 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -501,6 +501,21 @@ class UserController extends BaseAuthedController { return false; } } + ), + 'ring_id' => array( + 'field_name' => 'ring_id', + 'val_func' => function ($val) { + return $val; + }, + 'valid_func' => function ($val, &$errCode, &$errMsg) { + if (User::isValidRing($val)) { + return true; + } else { + $errCode = 1; + $errMsg = 'ring_id parameter error'; + return false; + } + } ) ); $fieldsKv = array(); diff --git a/webapp/models/User.php b/webapp/models/User.php index 0746e1c7..ae9221a4 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -73,6 +73,8 @@ class User extends BaseModel { 'guild_name' => $row['guild_name'], 'parachute' => $row['parachute'] ? $row['parachute'] : Parachute::$parachute, 'parachute_list' => Parachute::getMyParachute(), + 'ring_id' => $row['ring_id'], + 'ring_list' => UserSeasonRing::ringList($row['account_id']), ); } @@ -110,6 +112,7 @@ class User extends BaseModel { 'guild_id' => $row['guild_id'], 'guild_job' => $row['guild_job'], 'guild_name' => $row['guild_name'], + 'ring_id' => $row['ring_id'], 'ring_list' => UserSeasonRing::ringList($row['account_id']), 'parachute' => $row['parachute'] ? $row['parachute'] : Parachute::$parachute, 'parachute_list' => Parachute::getMyParachute(), @@ -161,6 +164,11 @@ class User extends BaseModel { return in_array($parachute, $parachuteList); } + public static function isValidRing($parachute){ + $ringList = UserSeasonRing::ringList(myself()->_getAccountId()); + return in_array($parachute, $ringList); + } + private static function getHeadList($userInfo) { $headList = emptyReplace(json_decode($userInfo['head_list'], true), array()); diff --git a/webapp/mt/LevelUp.php b/webapp/mt/LevelUp.php new file mode 100644 index 00000000..684d8b1a --- /dev/null +++ b/webapp/mt/LevelUp.php @@ -0,0 +1,10 @@ + Date: Mon, 13 Feb 2023 14:22:45 +0800 Subject: [PATCH 33/65] =?UTF-8?q?=E8=A1=A8=E6=83=85=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Emoji.py | 44 ++++++++++++ doc/User.py | 1 + doc/_common.py | 8 +++ sql/gamedb.sql | 36 ++++++++++ webapp/controller/EmojiController.class.php | 76 +++++++++++++++++++++ webapp/models/Emoji.php | 52 ++++++++++++++ webapp/mt/LevelUp.php | 27 ++++++++ webapp/services/BattleDataService.php | 30 +++++++- 8 files changed, 273 insertions(+), 1 deletion(-) create mode 100644 doc/Emoji.py create mode 100644 webapp/controller/EmojiController.class.php create mode 100644 webapp/models/Emoji.php diff --git a/doc/Emoji.py b/doc/Emoji.py new file mode 100644 index 00000000..ff0bd6c6 --- /dev/null +++ b/doc/Emoji.py @@ -0,0 +1,44 @@ +import _common + +class Emoji(object): + + def __init__(self): + self.apis = [ + { + 'name': 'getEmojiList', + 'desc': '表情列表', + 'group': 'Emoji', + 'url': 'webapp/index.php?c=Emoji&a=getEmojiList', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['!data', [_common.Emoji()], '表情列表'] + ] + },{ + 'name': 'setEmoji', + 'desc': '设置表情', + 'group': 'Emoji', + 'url': 'webapp/index.php?c=Emoji&a=setEmoji', + 'params': [ + _common.ReqHead(), + ['item_id', '0', 'item_id'], + ], + 'response': [ + _common.RspHead(), + ] + },{ + 'name': 'cancel', + 'desc': '取消设置', + 'group': 'Emoji', + 'url': 'webapp/index.php?c=Emoji&a=cancel', + 'params': [ + _common.ReqHead(), + ['item_id', '0', 'item_id'], + ], + 'response': [ + _common.RspHead(), + ] + }, + ] \ No newline at end of file diff --git a/doc/User.py b/doc/User.py index e28a1f54..ac77f4cc 100644 --- a/doc/User.py +++ b/doc/User.py @@ -78,6 +78,7 @@ class User(object): ['guild_job', 0, '跟新工会职位(可选参数,不传就不更新)'], ['guild_name', 0, '跟新工会名称(可选参数,不传就不更新)'], ['parachute', 0, '跟新降落伞(可选参数,不传就不更新)'], + ['ring_id', 0, '跟新戒指(可选参数,不传就不更新)'], ], 'response': [ _common.RspHead(), diff --git a/doc/_common.py b/doc/_common.py index fba7acb7..3184d52a 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1017,4 +1017,12 @@ class Currency(object): ['symbol', '', '符号'], ['precision', 0, '精度'], ['type', 0, '1:ERC721 2:ERC1155 3:ERC20'], + ] + +class Emoji(object): + + def __init__(self): + self.fields = [ + ['item_id', 0, 'item_id'], + ['state', 0, '1:使用 0:未使用'], ] \ No newline at end of file diff --git a/sql/gamedb.sql b/sql/gamedb.sql index cb3071fc..40781bac 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -920,4 +920,40 @@ CREATE TABLE `t_user_currency` ( PRIMARY KEY (`idx`), UNIQUE KEY `account_net_address` (`account_id`, `net_id`, `address`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + + +-- +-- Table structure for table `t_emoji` +-- + +DROP TABLE IF EXISTS `t_emoji`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_emoji` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', + `item_id` int(11) NOT NULL DEFAULT '0' COMMENT 'itemID', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `account_item_id` (`account_id`, `item_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_user_use_emoji` +-- + +DROP TABLE IF EXISTS `t_user_use_emoji`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_user_use_emoji` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', + `value` varchar(255) NOT NULL DEFAULT '' COMMENT '选中表情itemID', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; \ No newline at end of file diff --git a/webapp/controller/EmojiController.class.php b/webapp/controller/EmojiController.class.php new file mode 100644 index 00000000..611a6d0e --- /dev/null +++ b/webapp/controller/EmojiController.class.php @@ -0,0 +1,76 @@ +$val, + 'state'=>1, + ) + ); + }else{ + array_push($data, + array( + 'item_id'=>$val, + 'state'=>0, + ) + ); + } + } + $this->_rspData(array( + 'data' => $data + )); + } + + public function setEmoji(){ + $itemId = getReqVal('item_id', ''); + if(! in_array($itemId,Emoji::emojiList())){ + $this->_rspErr(1, 'item_id parameter error'); + return; + } + $uses = Emoji::getUseEmoji(); + if(in_array($itemId,$uses)){ + $this->_rspErr(1, 'The emoji has been used'); + return; + } + if(count($uses) >= 6){ + $this->_rspErr(1, 'To maximize'); + return; + } + array_push($uses,$itemId); + Emoji::updateEmoji(array( + 'value' => implode('|',$uses) + )); + $this->_rspOk(); + } + + public function cancel(){ + $itemId = getReqVal('item_id', ''); + if(! in_array($itemId,Emoji::emojiList())){ + $this->_rspErr(1, 'item_id parameter error'); + return; + } + $uses = Emoji::getUseEmoji(); + if(! in_array($itemId,$uses)){ + $this->_rspErr(1, 'The emoji is not used'); + return; + } + foreach ($uses as $k=>$v){ + if ($itemId == $v){ + unset($uses[$k]); + } + } + Emoji::updateEmoji(array( + 'value' => implode('|',$uses) + )); + $this->_rspOk(); + } +} \ No newline at end of file diff --git a/webapp/models/Emoji.php b/webapp/models/Emoji.php new file mode 100644 index 00000000..68c06fe5 --- /dev/null +++ b/webapp/models/Emoji.php @@ -0,0 +1,52 @@ +_getSelfMysql(), + 't_user_use_emoji', + array( + 'account_id'=> myself()->_getAccountId() + ) + ); + $value = array(); + if ($row && $row['value']){ + $value = explode('|',$row['value']) ; + } + return $value; + } + + public static function updateEmoji($fieldsKv){ + SqlHelper::update + (myself()->_getSelfMysql(), + 't_user_use_emoji', + array( + 'account_id' => myself()->_getAccountId(), + ), + $fieldsKv + ); + } + +} \ No newline at end of file diff --git a/webapp/mt/LevelUp.php b/webapp/mt/LevelUp.php index 684d8b1a..2092597a 100644 --- a/webapp/mt/LevelUp.php +++ b/webapp/mt/LevelUp.php @@ -6,5 +6,32 @@ namespace mt; class LevelUp { + public static function getExpByLv(&$lv,&$exp){ + $meta = self::getMetaList(); + if ($exp > 0){ + for ($i=1;$i<=count($meta);$i++){ + if ($exp > $meta[count($meta)]['total_exp']){ + $exp = min($exp, $meta[count($meta)]['total_exp']); + $lv = $meta[count($meta)]['id']; + }else{ + if ($exp >= $meta[$i]['total_exp'] && + $exp < $meta[$i+1]['total_exp']) + { + $lv = $meta[$i]['id']; + } + } + } + } + } + + protected static function getMetaList() + { + if (!self::$metaList) { + self::$metaList = getMetaTable('levelup@levelup.php'); + } + return self::$metaList; + } + + protected static $metaList; } \ No newline at end of file diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 4f9019af..38f77b75 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -15,6 +15,7 @@ require_once('mt/AttrHelper.php'); require_once('mt/PveGemini.php'); require_once('mt/PveGeminiMode.php'); require_once('mt/RankSeason.php'); +require_once('mt/LevelUp.php'); require_once('models/Season.php'); require_once('models/Battle.php'); @@ -90,7 +91,8 @@ class BattleDataService extends BaseService { 'curr_ceg' => 0, ), 'total_ceg' => 0, - 'items' => array() + 'items' => array(), + 'lvInfo' => array() ); private $rankActivityService = null; private $pveGeminiMeta = null; @@ -191,6 +193,32 @@ class BattleDataService extends BaseService { } + public function rewardExpPvp(){ + $expNum = 222; + if ($expNum>0){ + array_push($this->reward['items'], + array( + 'item_id' => V_ITEM_EXP, + 'item_num' => $expNum + )); + $userInfo = myself()->_getOrmUserInfo(); + $newExp = $userInfo['exp']+$expNum; + $newLv = $userInfo['level']; + mt\LevelUp::getExpByLv($newLv,$newExp); + $this->reward['lvInfo'] = array( + 'oldLv' => $userInfo['level'], + 'newLv' => $newLv + ); + if ( $newExp != $userInfo['exp'] ) { + myself()->_updateUserInfo(array( + 'level' => $newLv, + 'exp' => $newExp, + )); + } + } + + } + private function saveBattleHistory(){ $user = myself()->_getOrmUserInfo(); $newRank = $user['rank']; From a6b67282f3238b954075894c11611ddaf0390144 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 14 Feb 2023 15:57:22 +0800 Subject: [PATCH 34/65] 1 --- doc/Emoji.py | 3 ++- webapp/bootstrap/constant.php | 1 + webapp/controller/EmojiController.class.php | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/Emoji.py b/doc/Emoji.py index ff0bd6c6..d120d16f 100644 --- a/doc/Emoji.py +++ b/doc/Emoji.py @@ -14,7 +14,8 @@ class Emoji(object): ], 'response': [ _common.RspHead(), - ['!data', [_common.Emoji()], '表情列表'] + ['!data', [_common.Emoji()], '表情列表'], + ['!use_emoji', [], '已选择的表情列表'], ] },{ 'name': 'setEmoji', diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index 3bdbd521..5fa3a7a3 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -95,3 +95,4 @@ const kWantedLockType = 3; const kMaxHeroUpLevelNum = 2; const kMaxHeroUpQualityNum = 2; +const kMaxEmojiNum = 6; diff --git a/webapp/controller/EmojiController.class.php b/webapp/controller/EmojiController.class.php index 611a6d0e..425a9f38 100644 --- a/webapp/controller/EmojiController.class.php +++ b/webapp/controller/EmojiController.class.php @@ -26,7 +26,8 @@ class EmojiController extends BaseAuthedController } } $this->_rspData(array( - 'data' => $data + 'data' => $data, + 'use_emoji' => $uses )); } @@ -41,7 +42,7 @@ class EmojiController extends BaseAuthedController $this->_rspErr(1, 'The emoji has been used'); return; } - if(count($uses) >= 6){ + if(count($uses) >= kMaxEmojiNum){ $this->_rspErr(1, 'To maximize'); return; } From edd20ab4e83e0a73b4320025e920abe7d53e74bd Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 14 Feb 2023 15:58:27 +0800 Subject: [PATCH 35/65] 1 --- doc/Emoji.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Emoji.py b/doc/Emoji.py index d120d16f..e18caec1 100644 --- a/doc/Emoji.py +++ b/doc/Emoji.py @@ -15,7 +15,7 @@ class Emoji(object): 'response': [ _common.RspHead(), ['!data', [_common.Emoji()], '表情列表'], - ['!use_emoji', [], '已选择的表情列表'], + ['use_emoji', [], '已选择的表情列表'], ] },{ 'name': 'setEmoji', From 3d6face169a5923cf206e43992a0f71450ee3d45 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 14 Feb 2023 16:35:57 +0800 Subject: [PATCH 36/65] 1 --- webapp/controller/EmojiController.class.php | 8 ++------ webapp/models/Emoji.php | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/webapp/controller/EmojiController.class.php b/webapp/controller/EmojiController.class.php index 425a9f38..9c333543 100644 --- a/webapp/controller/EmojiController.class.php +++ b/webapp/controller/EmojiController.class.php @@ -47,9 +47,7 @@ class EmojiController extends BaseAuthedController return; } array_push($uses,$itemId); - Emoji::updateEmoji(array( - 'value' => implode('|',$uses) - )); + Emoji::updateEmoji( implode('|',$uses) ); $this->_rspOk(); } @@ -69,9 +67,7 @@ class EmojiController extends BaseAuthedController unset($uses[$k]); } } - Emoji::updateEmoji(array( - 'value' => implode('|',$uses) - )); + Emoji::updateEmoji(implode('|',$uses)); $this->_rspOk(); } } \ No newline at end of file diff --git a/webapp/models/Emoji.php b/webapp/models/Emoji.php index 68c06fe5..4313f226 100644 --- a/webapp/models/Emoji.php +++ b/webapp/models/Emoji.php @@ -38,14 +38,23 @@ class Emoji extends BaseModel return $value; } - public static function updateEmoji($fieldsKv){ - SqlHelper::update + public static function updateEmoji($fields){ + SqlHelper::upsert (myself()->_getSelfMysql(), 't_user_use_emoji', array( 'account_id' => myself()->_getAccountId(), ), - $fieldsKv + array( + 'value' => $fields, + 'modifytime' => myself()->_getNowTime(), + ), + array( + 'account_id' => myself()->_getAccountId(), + 'value' => $fields, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) ); } From 0fcdfb2f2e7c39eda422b7e84a45be1b2a8b57bb Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 15 Feb 2023 16:17:19 +0800 Subject: [PATCH 37/65] =?UTF-8?q?=E6=AD=A6=E5=99=A8=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Gun.py | 17 +++++++ webapp/controller/GunController.class.php | 61 +++++++++++++++++++++++ webapp/models/Gun.php | 5 ++ 3 files changed, 83 insertions(+) diff --git a/doc/Gun.py b/doc/Gun.py index 1bd057d5..c29e42b7 100644 --- a/doc/Gun.py +++ b/doc/Gun.py @@ -197,4 +197,21 @@ class Gun(object): ['!infos', [_common.QualityingGun()], '升阶中的枪械列表'], ] }, + { + 'name': 'upgradeLv', + 'desc': '升等级', + 'group': 'Gun', + 'url': 'webapp/index.php?c=Gun&a=upgradeLv', + 'params': [ + _common.ReqHead(), + ['gun_uniid', 0, '枪械唯一id'], + ['cost_gun_uniid', 0, '材料武器id'], + ], + 'response': [ + _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], + ['old_gun', _common.Gun(), '枪械-老'], + ['new_gun', _common.Gun(), '枪械-新'], + ] + }, ] diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index a1b93908..d3ee9798 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -816,4 +816,65 @@ class GunController extends BaseAuthedController { )); } + public function upgradeLv(){ + $gunUniId = getReqVal('gun_uniid', 0); + $costGunUniId = getReqVal('cost_gun_uniid', 0); + $gunDb = Gun::find($gunUniId); + $oldGun = Gun::toDto($gunDb); + $costGunDb = Gun::findEx($costGunUniId); + if (!$gunDb || !$costGunDb) { + $this->_rspErr(100, 'param error or null'); + return; + } + if ($costGunDb['token_id']){ + $this->_rspErr(100, 'NFT cannot be a material'); + return; + } + if ($gunDb['gun_lv'] != $costGunDb['gun_lv']){ + $this->_rspErr(100, 'You need the same level to do it'); + return; + } + $itemMeta = mt\Item::get($gunDb['gun_id']); + if (!$itemMeta) { + $this->_rspErr(100, 'server internal error'); + return; + } + + $nextLevelMeta = mt\GunLevel::getByLevel($gunDb['gun_lv'] +1); + if (!$nextLevelMeta) { + $this->_rspErr(5, "It's already the highest level"); + return; + } + + //升级所需消耗 +// $costItems = array(); +// $lackItem = null; +// if (!$this->_hasEnoughItems($costItems, $lackItem)) { +// $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); +// return; +// } +// $this->_decItems($costItems); + + $attrs = mt\GunLevel::addRandAttrNew($gunDb,1); + Gun::update($gunUniId, + array( + 'gun_lv' => $gunDb['gun_lv'] + 1, + 'rand_attr' => json_encode($attrs), + )); + Gun::update($costGunUniId, + array( + 'account_id' => myself()->_getAccountId() . '!!!', + ) + ); + $newGun = Gun::toDto(Gun::find($gunUniId)); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addGunChg(); + $propertyChgService->addUserChg(); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + 'old_gun' => $oldGun, + 'new_gun' => $newGun, + )); + } + } diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 0290146a..8cd88b94 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -57,6 +57,11 @@ class Gun extends BaseModel { 'idx' => $gunUniId, ) ); + if ($row) { + if ($row['account_id'] != myself()->_getAccountId()) { + $row = null; + } + } return $row; } From f216a8b4455823ed44f7ff8103a6694b5dadc882 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 21 Feb 2023 16:01:25 +0800 Subject: [PATCH 38/65] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8A=AF=E7=89=87?= =?UTF-8?q?=E5=8F=8A=E6=96=B0=E5=A2=9E=E9=93=AD=E6=96=87=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Chip.py | 187 +--- doc/ChipPage.py | 87 ++ doc/_common.py | 82 +- sql/gamedb.sql | 20 + .../controller/CallbackController.class.php | 2 +- webapp/controller/ChipController.class.php | 882 +++--------------- .../controller/ChipPageController.class.php | 162 ++++ webapp/models/Chip.php | 371 ++++---- webapp/models/ChipPage.php | 182 ++++ webapp/models/Gun.php | 56 +- webapp/models/Hero.php | 59 +- webapp/mt/ChipAttr.php | 153 ++- webapp/services/ChipPageService.php | 57 ++ 13 files changed, 942 insertions(+), 1358 deletions(-) create mode 100644 doc/ChipPage.py create mode 100644 webapp/controller/ChipPageController.class.php create mode 100644 webapp/models/ChipPage.php create mode 100644 webapp/services/ChipPageService.php diff --git a/doc/Chip.py b/doc/Chip.py index 06f14617..01c6e3af 100644 --- a/doc/Chip.py +++ b/doc/Chip.py @@ -18,20 +18,6 @@ class Chip(object): _common.RspHead(), ['!data', [_common.Chip()], '芯片列表'] ] - },{ - 'name': 'chipOrder', - 'desc': '芯片列表排序', - 'group': 'Chip', - 'url': 'webapp/index.php?c=Chip&a=chipOrder', - 'params': [ - _common.ReqHead(), - ['type', '', '芯片类型:1 英雄;2 枪械'], - ['order', '', 'asc 升序;desc 降序'], - ], - 'response': [ - _common.RspHead(), - ['!data', [_common.Chip()], '芯片列表'] - ] },{ 'name': 'chipDetails', 'desc': '芯片详情', @@ -39,100 +25,24 @@ class Chip(object): 'url': 'webapp/index.php?c=Chip&a=chipDetails', 'params': [ _common.ReqHead(), - ['token_id', '', '芯片token id'], + ['unique_id', '', 'unique_id'], ], 'response': [ _common.RspHead(), ['!data', [_common.Chip()], '芯片信息'] ] },{ - 'name': 'beforeInlay', - 'desc': '芯片镶嵌前置,获取可镶嵌的芯片', + 'name': 'upgradeLevelPreview', + 'desc': '芯片升级前置操作', 'group': 'Chip', - 'url': 'webapp/index.php?c=Chip&a=beforeInlay', + 'url': 'webapp/index.php?c=Chip&a=upgradeLevelPreview', 'params': [ _common.ReqHead(), - ['type', '', '芯片类型:1 英雄;2 枪械'], + ['unique_id', '', 'unique_id'], ], 'response': [ _common.RspHead(), - ['!data', [_common.Chip()], '芯片列表'] - ] - },{ - 'name': 'inlayChip', - 'desc': '芯片镶嵌', - 'group': 'Chip', - 'url': 'webapp/index.php?c=Chip&a=inlayChip', - 'params': [ - _common.ReqHead(), - ['type', '', '1 英雄;2 枪械'], - ['unique_id', '', '英雄或枪械的唯一id'], - ['token_id', '', '芯片token id'], - ], - 'response': [ - _common.RspHead(), - ['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例'], - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - },{ - 'name': 'demountChip', - 'desc': '芯片卸下', - 'group': 'Chip', - 'url': 'webapp/index.php?c=Chip&a=demountChip', - 'params': [ - _common.ReqHead(), - ['type', '', '1 英雄;2 枪械'], - ['unique_id', '', '英雄或枪械的唯一id'], - ['token_id', '', '芯片token id'], - ], - 'response': [ - _common.RspHead(), - ['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例'], - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - },{ - 'name': 'replaceChip', - 'desc': '芯片替换', - 'group': 'Chip', - 'url': 'webapp/index.php?c=Chip&a=replaceChip', - 'params': [ - _common.ReqHead(), - ['type', '', '1 英雄;2 枪械'], - ['unique_id', '', '英雄或枪械的唯一id'], - ['token_id_new', '', '新芯片token id'], - ['token_id_old', '', '被替换的芯片token id'], - ], - 'response': [ - _common.RspHead(), - ['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例'], - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - },{ - 'name': 'aKeyInlayChip', - 'desc': '芯片一键镶嵌', - 'group': 'Chip', - 'url': 'webapp/index.php?c=Chip&a=aKeyInlayChip', - 'params': [ - _common.ReqHead(), - ['type', '', '1 英雄;2 枪械'], - ['unique_id', '', '英雄或枪械的唯一id'], - ], - 'response': [ - _common.RspHead(), - ['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例'] - ] - },{ - 'name': 'beforeSynthetic', - 'desc': '芯片合成前置操作', - 'group': 'Chip', - 'url': 'webapp/index.php?c=Chip&a=beforeSynthetic', - 'params': [ - _common.ReqHead(), - ['token_id', '', '新芯片token id'], - ], - 'response': [ - _common.RspHead(), - ['!data', [_common.ChipPro()], '芯片信息'] + ['!data', [_common.ChipPro()], '芯片信息'] ] },{ 'name': 'selectChip', @@ -141,21 +51,21 @@ class Chip(object): 'url': 'webapp/index.php?c=Chip&a=selectChip', 'params': [ _common.ReqHead(), - ['token_id', '', '芯片token id参数 例:参数1源芯片 参数2材料芯片'], + ['unique_id', '', '芯片unique_id参数 例:参数1源芯片 参数2材料芯片'], ], 'response': [ _common.RspHead(), - ['data', '', '材料芯片的累计价值'] + ['cost', '', '材料芯片的累计价值'] ] },{ - 'name': 'syntheticChip', - 'desc': '芯片合成', + 'name': 'upgradeLevel', + 'desc': '芯片升级', 'group': 'Chip', - 'url': 'webapp/index.php?c=Chip&a=syntheticChip', + 'url': 'webapp/index.php?c=Chip&a=upgradeLevel', 'params': [ _common.ReqHead(), - ['token_id_main', '', '源芯片token id'], - ['token_id_param', '', '材料芯片token id 例:参数1 参数2 参数3'], + ['unique_id_main', '', '源芯片token id'], + ['unique_id_param', '', '材料芯片token id 例:参数1 参数2 参数3'], ], 'response': [ _common.RspHead(), @@ -163,76 +73,5 @@ class Chip(object): ['state', 0, '1 成功,0 失败'], ['property_chg', _common.PropertyChg(), '属性变更'], ] - },{ - 'name': 'isNeedLucky', - 'desc': '选择需要幸运值', - 'group': 'Chip', - 'url': 'webapp/index.php?c=Chip&a=isNeedLucky', - 'params': [ - _common.ReqHead(), - ['token_id', '', '源芯片token id'], - ], - 'response': [ - _common.RspHead(), - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - },{ - 'name': 'isNotNeedLucky', - 'desc': '放弃幸运值', - 'group': 'Chip', - 'url': 'webapp/index.php?c=Chip&a=isNotNeedLucky', - 'params': [ - _common.ReqHead(), - ['token_id', '', '源芯片token id'], - ], - 'response': [ - _common.RspHead(), - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - },{ - 'name': 'waitingLucky', - 'desc': '幸运值未做选择-待定阶段', - 'group': 'Chip', - 'url': 'webapp/index.php?c=Chip&a=waitingLucky', - 'params': [ - _common.ReqHead(), - ['token_id', '', '源芯片token id'], - ], - 'response': [ - _common.RspHead(), - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - },{ - 'name': 'aKeySynthetic', - 'desc': '芯片合成一键添加', - 'group': 'Chip', - 'url': 'webapp/index.php?c=Chip&a=aKeySynthetic', - 'params': [ - _common.ReqHead(), - ['token_id', '', '源芯片token id'], - ], - 'response': [ - _common.RspHead(), - ['data', [ - ['cost', '', '所添加芯片的总累计价值'], - ['token_ids', '', '芯片token id 例如:token_id1 token_id2 token_id3'], - ], '芯片信息'] - ] - },{ - 'name': 'lockChip', - 'desc': '芯片加锁', - 'group': 'Chip', - 'url': 'webapp/index.php?c=Chip&a=lockChip', - 'params': [ - _common.ReqHead(), - ['token_id', '', '芯片token id'], - ['state', '', '1 加锁 ;0 释放锁'], - ], - 'response': [ - _common.RspHead(), - ['property_chg', _common.PropertyChg(), '属性变更'], - ] }, - - ] diff --git a/doc/ChipPage.py b/doc/ChipPage.py new file mode 100644 index 00000000..cc29d477 --- /dev/null +++ b/doc/ChipPage.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- + +import _common + +class ChipPage(object): + + def __init__(self): + self.apis = [ + { + 'name': 'chipPageList', + 'desc': '铭文页列表', + 'group': 'ChipPage', + 'url': 'webapp/index.php?c=ChipPage&a=chipPageList', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['!data', [_common.ChipPageList()], '页列表'] + ] + },{ + 'name': 'showPageInfo', + 'desc': '铭文页信息', + 'group': 'ChipPage', + 'url': 'webapp/index.php?c=ChipPage&a=showPageInfo', + 'params': [ + _common.ReqHead(), + ['page', '', '页id'], + ], + 'response': [ + _common.RspHead(), + ['!data', [_common.ChipPage()], '页信息'] + ] + },{ + 'name': 'addChipPage', + 'desc': '添加铭文页', + 'group': 'ChipPage', + 'url': 'webapp/index.php?c=ChipPage&a=addChipPage', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ] + },{ + 'name': 'rename', + 'desc': '修改页名', + 'group': 'ChipPage', + 'url': 'webapp/index.php?c=ChipPage&a=rename', + 'params': [ + _common.ReqHead(), + ['page', '', '页id'], + ], + 'response': [ + _common.RspHead(), + ['!data', [_common.ChipPage()], '页信息'] + ] + },{ + 'name': 'useChip', + 'desc': '使用芯片(镶嵌)', + 'group': 'ChipPage', + 'url': 'webapp/index.php?c=ChipPage&a=useChip', + 'params': [ + _common.ReqHead(), + ['page', '', '页id'], + ['slot_id', '', '卡槽id'], + ['unique_id', '', '芯片idx'], + ], + 'response': [ + _common.RspHead(), + ['!data', [_common.ChipPage()], '页信息'] + ] + },{ + 'name': 'removeChip', + 'desc': '芯片移除(一键移除)', + 'group': 'ChipPage', + 'url': 'webapp/index.php?c=ChipPage&a=removeChip', + 'params': [ + _common.ReqHead(), + ['page', '', '页id'], + ], + 'response': [ + _common.RspHead(), + ['!data', [_common.ChipPage()], '页信息'] + ] + }, + ] diff --git a/doc/_common.py b/doc/_common.py index 3184d52a..b1aedafb 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -86,7 +86,6 @@ class Gun(object): ['ceg_uplimit', 0, 'ceg今天获取上限'], ['!attr_base', [Attr()], '枪械基础属性'], ['!attr_pro', [Attr()], '枪械升级升阶加成属性'], - ['!attr_chip', [Attr()], '枪械芯片加成属性'], ['try_count', 0, '剩余体验次数 当state=1时才有意义'], ['lock_type', 0, '0:无锁 1:升级 2:升阶 3:派遣中'], ['unlock_time', 0, '使用解锁utc时间(升级或者升阶触发),锁定期间不可战斗和做其他操作,配合lock_type使用'], @@ -97,7 +96,7 @@ class Gun(object): ['last_pvp_get_ceg_time', 0, '最后一次获取pvp获取ceg时间'], ['last_pve_get_ceg_time', 0, '最后一次获取pve获取ceg时间'], ['chip_ids', '', '镶嵌的芯片主键id组'], - ['!chip_core', [ChipCore()], '芯片核心加成'], + ['pvp_ceg_uplimit', 0, 'pvp获取的ceg的上限'], ['pve_ceg_uplimit', 0, 'pve获取的ceg的上限'], ['offer_reward_state', 0, '是否悬赏中'], @@ -248,7 +247,6 @@ class Hero(object): ['!attr_base', [Attr()], '英雄基础属性'], ['!attr_pro', [Attr()], '英雄升级升阶提升属性'], ['!attr_skill', [Attr()], '英雄技能提升属性'], - ['!attr_chip', [Attr()], '英雄芯片提升属性'], ['try_count', 0, '剩余体验次数 当state=1时才有意义'], ['lock_type', 0, '0:无锁 1:升级 2:升阶 3:派遣中'], ['unlock_lefttime', 0, '解锁剩余时间(单位秒)'], @@ -262,7 +260,7 @@ class Hero(object): ['lukcy', 0, '幸运'], ['chip_ids', '', '镶嵌的芯片主键id组'], ['skill_points', '', '技能点'], - ['!chip_core', [ChipCore()], '芯片核心加成'], + ['!skill_common', [], '通用属性'], ['pvp_ceg_uplimit', 0, 'pvp获取的ceg的上限'], ['pve_ceg_uplimit', 0, 'pve获取的ceg的上限'], @@ -786,23 +784,7 @@ class ChipAttr(object): def __init__(self): self.fields = [ ['attr_id', 0, '属性id'], - ['type', 0, '1: 绝对值 2:百分比 ---弃用字段'], ['val', 0, '综合属性值'], - ['chip_type', 0, '1:英雄芯片 2:枪械芯片'], - ['attr_num', 0, '成长属性值'], - ['attr_pool_num', 0, '固定属性值'], - ] - -class ChipCore(object): - - def __init__(self): - self.fields = [ - ['chip_core_id', 0, '核心id'], - ['chip_core_type', 0, '1:英雄芯片核心 2:枪械芯片核心'], - ['chip_core_lv', 0, '核心等级'], - ['attr_id', 0, '芯片属性id'], - ['attr_number', 0, '属性加成'], - ['attr_add_type', 0, '加成类型:1 绝对值;2 百分比 ---弃用字段'], ] class Chip(object): @@ -815,39 +797,28 @@ class Chip(object): ['item_id', 0, '道具id'], ['item_num', 0, '道具数量'], ['chip_grade', 0, '芯片等级'], - ['chip_type', 0, '芯片类型:1 英雄;2 枪械'], - ['state', 0, '芯片添加状态:0 正常;1 选择;-1 锁定'], - ['supper_state', 0, '是否锁定:0 正常;1 锁住'], - ['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了'], + ['chip_type', 0, '芯片类型:1 攻击;2 防御;3 辅助'], + ['state', 0, '状态:0 免费;1 常规], + ['supper_state', 0, '是否锁定:0 正常;1 锁住 ---弃用字段'], + ['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了 ---弃用字段'], ['!rand_attr', [ChipAttr()], '属性'], - ['lucky_temporary', '', '升级成功后的幸运值'], - ['lucky_final', '', '最终幸运值'], - ['strength_max', '', '最大体力值'], - ['strength', '', '前一天体力值'], - ['strength_temporary', '', '升级成功所得出的总体力值'], - ['mint', '', '所需mint费'], - ['belong_to_item_id', '', '所镶嵌的英雄或枪械的item id'], - ] class ChipPro(object): def __init__(self): self.fields = [ - ['idx', 0, '主键id'], + ['idx', 0, '主键id'], ['token_id', '', 'token id'], ['account_id', '', '账号id'], ['item_id', 0, '道具id'], ['item_num', 0, '道具数量'], ['chip_grade', 0, '芯片等级'], - ['chip_type', 0, '芯片类型:1 英雄;2 枪械'], - ['state', 0, '芯片添加状态:0 正常;1 选择;-1 锁定'], - ['supper_state', 0, '是否锁定:0 正常;1 锁住'], - ['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了'], + ['chip_type', 0, '芯片类型:1 攻击;2 防御;3 辅助'], + ['state', 0, '状态:0 免费;1 常规], + ['supper_state', 0, '是否锁定:0 正常;1 锁住 ---弃用字段'], + ['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了 ---弃用字段'], ['!rand_attr', [ChipAttr()], '属性'], - ['lucky_temporary', '', '临时幸运值'], - ['lucky_final', '', '最终幸运值'], - ['strength', '', '体力值'], ['!rand_attr_after', [ChipAttr()], '芯片升级后的属性'], ['upgrade_cost', '', '芯片升级所需价值'], ] @@ -1025,4 +996,35 @@ class Emoji(object): self.fields = [ ['item_id', 0, 'item_id'], ['state', 0, '1:使用 0:未使用'], + ] + +class ChipPageList(object): + + def __init__(self): + self.fields = [ + ['idx', 0, 'idx'], + ['account_id', 0, 'account_id'], + ['page_id', 0, '页id'], + ['page_name', '', '页名'], + ['createtime', 0, '创建时间'], + ] + +class ChipPage(object): + + def __init__(self): + self.fields = [ + ['idx', 0, 'idx'], + ['page_id', 0, '页id'], + ['page_name', '', '页名'], + ['!data', [ChipPageSlot()], '卡槽信息'], + ['!attr', [Attr()], '属性信息'], + ] + +class ChipPageSlot(object): + + def __init__(self): + self.fields = [ + ['slot_id', 0, '卡槽id'], + ['state', 0, '0:未解锁 1:已解锁'], + ['chip_id', '', '芯片idx'], ] \ No newline at end of file diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 40781bac..54fd1c3e 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -956,4 +956,24 @@ CREATE TABLE `t_user_use_emoji` ( `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_chip_page` +-- + +DROP TABLE IF EXISTS `t_chip_page`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_chip_page` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', + `page_name` varchar(50) NOT NULL DEFAULT '' COMMENT '页名', + `page_id` int(11) NOT NULL DEFAULT '0' COMMENT '页id', + `data` mediumblob COMMENT 'data', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `account_page_id` (`account_id`, `page_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; \ No newline at end of file diff --git a/webapp/controller/CallbackController.class.php b/webapp/controller/CallbackController.class.php index cf39f53e..25cbfcc0 100644 --- a/webapp/controller/CallbackController.class.php +++ b/webapp/controller/CallbackController.class.php @@ -335,7 +335,7 @@ class CallbackController extends BaseController { myself()->_rspOk(); } - public function chipUpgradeGrade(){ + public function chipUpgradeGrade(){return; $transId = getReqVal('trans_id', '0'); $tokenId = getReqVal('token_id', '0'); if (!$transId || !$tokenId){ diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index ab05a5fa..2afc2561 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -14,6 +14,7 @@ require_once('services/LogService.php'); + use models\Chip; use models\Hero; use models\Gun; @@ -26,838 +27,173 @@ class ChipController extends BaseAuthedController { public function chipList() { -// $type = getReqVal('type',''); -// if (! $type){ -// $this->_rspErr(1,'Please enter instructions'); -// return ; -// } -// $chipList = Chip::all($type); -// $chipDtoList = array(); -// foreach ($chipList as $item) { -// array_push($chipDtoList, Chip::toDto($item)); -// } $chipList = array(); Chip::getChipList(function ($row) use(&$chipList){ - array_push($chipList, Chip::toDto($row)); + if ($row['inlay_state'] != 1){ + array_push($chipList, Chip::toDto($row)); + } }); $this->_rspData(array( 'data' => $chipList, )); } - public function chipOrder(){ - $type = getReqVal('type',''); - if (! $type){ - $this->_rspErr(1,'Please enter instructions'); - return ; - } - $order = getReqVal('order','asc'); - $chipList = Chip::all($type); - $chipDtoList = array(); - foreach ($chipList as $item) { - array_push($chipDtoList, Chip::toDto($item)); - } - $data = $this->_orderByChip($chipDtoList,$order); - $this->_rspData(array( - 'data' => $data, - )); - } - public function chipDetails(){ - $token_id = getReqVal('token_id',''); - if (! $token_id){ - $this->_rspErr(1,'Please enter instructions'); + $unique_id = trim(getReqVal('unique_id', 0)); + if (! $unique_id){ + $this->_rspErr(1, 'Please enter parameter unique_id'); return ; } - $chip = Chip::getChipByTokenId($token_id); - if ($chip['supper_state'] == 1){ - $chip['strength_temporary'] = \services\FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength($chip['chip_grade'],$chip['lucky_temporary']); - $chip['mint'] = strval(\services\FormulaService::Chip_Need_Mint_Cost($chip['chip_grade'])-$chip['upgrade_mint']); + $chipDb = Chip::find($unique_id); + if (! $chipDb){ + $this->_rspErr(1, "You don't have the chip yet"); + return; } -// if ($chip['inlay_state'] == 1){ - $tili = $chip['strength_max']-$chip['strength']; - $chip['mint'] = \services\FormulaService::Chip_Demount_Mint($tili); -// } - $chip = Chip::toDto($chip); + $chip = Chip::toDto($chipDb); $this->_rspData(array( 'data' => $chip, )); } - public function beforeInlay(){ - $type = getReqVal('type',''); - if (! $type){ - $this->_rspErr(1,'Please enter instructions'); - return ; - } - $chipList = Chip::all($type); - $chipDtoList = array(); - foreach ($chipList as $item) { - if ($item['supper_state']==0 && $item['inlay_state']==0){ - array_push($chipDtoList, Chip::toDto($item)); - } - } - $this->_rspData(array( - 'data' => $chipDtoList, - )); - } - - public function inlayChip(){ - $type = trim(getReqVal('type', 0)); + public function upgradeLevelPreview(){ $unique_id = trim(getReqVal('unique_id', 0)); - $token_id = trim(getReqVal('token_id', 0)); - if (!$type || ! $token_id || ! $unique_id) { - $this->_rspErr(1, 'Please enter instructions'); + if (! $unique_id) { + $this->_rspErr(1, 'Please enter parameter unique_id'); return; } - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addChip(); - if ($type == 1){ - if (! $this->_doInlayHero($unique_id,$token_id)){ - return; - } - $hero = Hero::toDto(Hero::find($unique_id)); - $propertyChgService->addHeroChg(); - $this->_rspData([ - 'data'=>$hero, - 'property_chg' => $propertyChgService->toDto(), - ]); - }else{ - if (! $this->_doInlayGun($unique_id,$token_id)){ - return; - } - $gun = Gun::toDto(Gun::find($unique_id)); - $propertyChgService->addGunChg(); - $this->_rspData([ - 'data'=>$gun, - 'property_chg' => $propertyChgService->toDto(), - ]); - } - - } - - public function demountChip(){ - $type = trim(getReqVal('type', 0)); - $unique_id = trim(getReqVal('unique_id', 0)); - $token_id = trim(getReqVal('token_id', 0)); - if (!$type || ! $token_id || ! $unique_id) { - $this->_rspErr(1, 'Please enter instructions'); + $chipDb = Chip::find($unique_id); + if (!$chipDb){ + $this->_rspErr(1,'unique_id parameter error'); return; } - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addChip(); - if ($type == 1){ - if (!$this->_doDemount($unique_id,$token_id)){ - return; - } - $hero = Hero::toDto(Hero::find($unique_id)); - $propertyChgService->addHeroChg(); - $this->_rspData([ - 'data'=>$hero, - 'property_chg' => $propertyChgService->toDto(), - ]); - }else{ - if (! $this->_doDemountGun($unique_id,$token_id)){ - return; - } - $gun = Gun::toDto(Gun::find($unique_id)); - $propertyChgService->addGunChg(); - $this->_rspData([ - 'data'=>$gun, - 'property_chg' => $propertyChgService->toDto(), - ]); - } - - } - - public function replaceChip(){ - $type = trim(getReqVal('type', 0)); - $unique_id = trim(getReqVal('unique_id', 0)); - $token_id_new = trim(getReqVal('token_id_new', 0)); - $token_id_old = trim(getReqVal('token_id_old', 0)); - if (! $token_id_new ||! $token_id_old || ! $unique_id || !$type) { - $this->_rspErr(1, 'Please enter instructions'); + if ($chipDb['chip_grade'] == Chip::CHIP_LV_MAX){ + $this->_rspErr(1,' Level upper limit'); return; } - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addChip(); - if ($type == 1){ - if (! $this->_doDemount($unique_id,$token_id_old)){ - return; - } - if (! $this->_doInlayHero($unique_id,$token_id_new)){ - return; - } - $hero = Hero::toDto(Hero::find($unique_id)); - $propertyChgService->addHeroChg(); - $this->_rspData([ - 'data'=>$hero, - 'property_chg' => $propertyChgService->toDto(), - ]); - }else{ - if (! $this->_doDemountGun($unique_id,$token_id_old)){ - return; - } - if (! $this->_doInlayGun($unique_id,$token_id_new)){ - return; - } - $gun = Gun::toDto(Gun::find($unique_id)); - $propertyChgService->addGunChg(); - $this->_rspData([ - 'data'=>$gun, - 'property_chg' => $propertyChgService->toDto(), - ]); - } - - } - - public function aKeyInlayChip(){ - $type = trim(getReqVal('type', 0)); - $unique_id = trim(getReqVal('unique_id', 0)); - if ( ! $type || ! $unique_id) { - $this->_rspErr(1, 'Please enter instructions'); - return; - } - if ($type == 1){ - $hero_or_gun = Hero::find($unique_id); - }else{ - $hero_or_gun = Gun::find($unique_id); - } - - if (! $hero_or_gun){ - $this->_rspErr(1, 'Not enough hero or gun'); - return; - } - $limit = 0; - if (! $hero_or_gun['chip_ids'] ){ - $limit = 4; - } - if ($hero_or_gun['chip_ids'] && !strpos($hero_or_gun['chip_ids'], '|')){ - $limit = 3; - } - if ($hero_or_gun['chip_ids'] && strpos($hero_or_gun['chip_ids'], '|')){ - $chipIdsArr = explode('|',$hero_or_gun['chip_ids']); - $limit = 4-count($chipIdsArr); - } - - $chipList = Chip::all($type); - if (! $chipList){ - $this->_rspErr(1, 'Not enough chip'); - return; - } - $usable = array(); - foreach ($chipList as $item) { - if ($item['supper_state']==0 && $item['inlay_state']==0){ - array_push($usable, $item); - } - } - - $res = $this->_getHignGradeLimit($usable,$limit); - if (! $res){ - $this->_rspErr(1, 'The chip slot is full'); - return; - } - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addChip(); - if ($type == 1){ - foreach ($res as $val){ - $this->_doInlayHero($unique_id,$val['token_id']); - } - $hero_new = Hero::toDto(Hero::find($unique_id)); - $propertyChgService->addHeroChg(); - $this->_rspData([ - 'data'=>$hero_new, - 'property_chg' => $propertyChgService->toDto(), - ]); - }else{ - foreach ($res as $val){ - $this->_doInlayGun($unique_id,$val['token_id']); - } - $gun_new = Gun::toDto(Gun::find($unique_id)); - $propertyChgService->addGunChg(); - $this->_rspData([ - 'data'=>$gun_new, - 'property_chg' => $propertyChgService->toDto(), - ]); - } - } - - public function beforeSynthetic(){ - $token_id = trim(getReqVal('token_id', 0)); - if (! $token_id) { - $this->_rspErr(1, 'Please enter instructions'); - return; - } - $chip = Chip::getChipByTokenId($token_id); - if ($chip['supper_state'] == 1 || $chip['inlay_state'] == 1 || $chip['state'] == -1){ - $this->_rspErr(1, "The chip can't synthetic"); - return; - } - if ($chip['chip_grade'] == 15){ - $this->_rspErr(1, "Chip Lv upper limit"); - return; - } - $chip = Chip::toDto($chip); - foreach ($chip['rand_attr'] as $k=>$val){ - $attr = \mt\ChipAttr::getAttrById($val['attr_id'],$val['chip_type']); - $chip['rand_attr_after'][$k] =[ - 'attr_id'=>$val['attr_id'], - 'type'=>$val['type'], - 'val'=>$attr['lv'.($chip['chip_grade']+1)]*$val['attr_pool_num'], - 'chip_type'=>$val['chip_type'] - ]; + $chip = Chip::toDto($chipDb); + $rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array()); + $chipMeta = mt\ChipAttr::getAttrByItemId($chipDb['item_id']); + if ($chipMeta){ + array_push($rand_attr,array( + 'attr_id'=>$chipMeta['attr_id'], + 'val' => $chipMeta['lv'.($chipDb['chip_grade']+1)] + )); } + $chip['rand_attr_after'] = $rand_attr; $chip['upgrade_cost']=\services\FormulaService::getChipUpgradeCost($chip['chip_grade']+1); $this->_rspData(['data'=>$chip]); } public function selectChip(){ - $token_id = trim(getReqVal('token_id', 0)); - $token_ids = explode(' ',$token_id); - if (count($token_ids)<0){ + $unique_id = trim(getReqVal('unique_id', 0)); + $idxArr = explode(' ',$unique_id); + if (count($idxArr)<0){ $this->_rspErr(1, 'Please enter instructions'); return; } - $chip_main = Chip::getChipByTokenId($token_ids[0]); - $chip_param = Chip::getChipByTokenId($token_ids[1]); - if ($chip_param['supper_state'] == 1 || $chip_param['inlay_state'] == 1 || $chip_param['state'] == -1){ - $this->_rspErr(1, "The chip can't select"); + $chipDbMain = Chip::find($idxArr[0]); + $chipDbParam = Chip::find($idxArr[1]); + if (!$chipDbMain || !$chipDbParam){ + $this->_rspErr(1,'unique_id parameter error'); return; } - if ($chip_param['chip_grade']>$chip_main['chip_grade']){ + if ($chipDbParam['token_id']) { + $this->_rspErr(1, "Unable to use nft chip"); + return; + } + if (!$chipDbParam['state']) { + $this->_rspErr(1, "Unable to use free chip"); + return; + } + if ($chipDbParam['chip_grade']>$chipDbMain['chip_grade']){ $this->_rspErr(1, "The selected material is too high grade"); return; } - $cost = \services\FormulaService::getChipCumulativeCost($chip_param['chip_grade']); - $this->_rspData(['data'=>$cost]); + $cost = \services\FormulaService::getChipCumulativeCost($chipDbParam['chip_grade']); + $this->_rspData(['cost'=>$cost]); } - public function syntheticChip(){ - $this->_rspOk();return; - $token_id_main = trim(getReqVal('token_id_main', 0)); - $token_id_param = array_filter(explode(' ',getReqVal('token_id_param', 0))); - if (! $token_id_main || count($token_id_param)<=0 ) { - $this->_rspErr(1, 'Please enter instructions token_id_param'); + public function upgradeLevel(){ + $idxMain = trim(getReqVal('unique_id_main', 0)); + $idxParam = array_filter(explode(' ',getReqVal('unique_id_param', 0))); + if (! $idxMain || count($idxParam)<=0 ) { + $this->_rspErr(1, 'Please enter parameter'); return; } - $chip_main = Chip::getChipByTokenId($token_id_main); - $upgrade_cost = \services\FormulaService::getChipUpgradeCost($chip_main['chip_grade']+1); - if ($upgrade_cost==0){ + $chipDbMain = Chip::find($idxMain); + if (!$chipDbMain){ + $this->_rspErr(1,'unique_id_main parameter error'); + return; + } + if ($chipDbMain['chip_grade'] == Chip::CHIP_LV_MAX){ + $this->_rspErr(1,' Level upper limit'); + return; + } + $upgrade_cost = \services\FormulaService::getChipUpgradeCost($chipDbMain['chip_grade']+1); + if ( $upgrade_cost == 0 ){ $this->_rspErr(1, 'Error in calculation formula'); return; } $cumulative_cost = 0; - $params = array(); - foreach ($token_id_param as $val){ - $chip_param = Chip::getChipByTokenId($val); - array_push($params,array( - 'unique_id'=>$chip_param['idx'], - 'token_id'=>$chip_param['token_id'], - )); - $cumulative_cost += \services\FormulaService::getChipCumulativeCost($chip_param['chip_grade']); -// Chip::deleteChip(['token_id'=>$val]); + + foreach ($idxParam as $val){ + $chipDbParam = Chip::find($val); + if (!$chipDbParam){ + $this->_rspErr(1,"unique_id_param:{$val} parameter error"); + return; + } + if ($chipDbParam['token_id']) { + $this->_rspErr(1, "Unable to use nft chip"); + return; + } + if (!$chipDbParam['state']) { + $this->_rspErr(1, "Unable to use free chip"); + return; + } + if ($chipDbParam['chip_grade']>$chipDbMain['chip_grade']){ + $this->_rspErr(1, "The selected material is too high grade"); + return; + } + $cumulative_cost += \services\FormulaService::getChipCumulativeCost($chipDbParam['chip_grade']); } - { - //埋点 - $event = [ - 'name' => LogService::CHIP_SYNTH_MATERIAL, - ]; - LogService::ConsumableMaterial($event,$params); + //清除材料芯片 + foreach ($idxParam as $idx){ + Chip::update2($idx, + array( + 'account_id' => myself()->_getAccountId() . '!!!', + ) + ); } - $num = round(round(($cumulative_cost/$upgrade_cost),5)*10000); $propertyChgService = new services\PropertyChgService(); $propertyChgService->addChip(); - if ($num ($cumulative_cost/$upgrade_cost)*100){ //合成失败 $this->_rspData([ 'state' => 0, 'property_chg' => $propertyChgService->toDto(), ]); - }else{ - //合成成功 - $this->_upgraded($chip_main); - $chip_new = Chip::toDto(Chip::getChipByTokenId($token_id_main)); - $chip_new['strength_temporary'] = \services\FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength($chip_new['chip_grade'],$chip_new['lucky_temporary']); - $chip_new['mint'] = \services\FormulaService::Chip_Need_Mint_Cost($chip_new['chip_grade'])-$chip_new['upgrade_mint']; - $this->_rspData([ - 'data'=>$chip_new, + return ; + } + + $rand_attr = emptyReplace(json_decode($chipDbMain['rand_attr'], true), array()); + $attrProMeta = \mt\ChipAttr::getAttrPool($chipDbMain); + array_push($rand_attr,array( + 'attr_id'=>$attrProMeta['attr_id'], + 'val'=>$attrProMeta['val'], + )); + Chip::update2($idxMain, + array( + 'chip_grade' => $chipDbMain['chip_grade']+1, 'state' => 1, - 'property_chg' => $propertyChgService->toDto(), - ]); - } - } - - public function isNeedLucky(){ - $token_id = trim(getReqVal('token_id', 0)); - if (! $token_id) { - $this->_rspErr(1, 'Please enter instructions'); - return; - } - $chip = Chip::getChipByTokenId($token_id); - $strength_max = \services\FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength($chip['chip_grade'],$chip['lucky_temporary']); - $mint_cost = \services\FormulaService::Chip_Need_Mint_Cost($chip['chip_grade'])-$chip['upgrade_mint']; - $fieldsKv = [ - 'supper_state' => 0, - 'lucky_final'=>$chip['lucky_temporary'], - 'lucky_temporary'=>0, - 'strength_max' => $strength_max, - 'strength' => $strength_max, - 'upgrade_mint' => $mint_cost, - 'labour' => 0 - ]; - $userObj = new User(); - $user=$userObj->find(myself()->_getAccountId()); - if ($mint_cost>$user['gold']){ - $this->_rspErr(2, 'Be short of gold coins'); - return; - } - User::update(['gold'=>$user['gold']-$mint_cost]); - Chip::update($chip['token_id'],$fieldsKv); - $old_chip = Chip::toDto($chip); - $new_chip = Chip::toDto(Chip::getChipByTokenId($token_id)); - { - //埋点 - $event = [ - 'name' => LogService::CHIP_LUCKY, - 'val' => $mint_cost - ]; - $old_chip['level'] = $old_chip['chip_grade']; - $new_chip['level'] = $new_chip['chip_grade']; - LogService::consumeCEG($event,$old_chip,$new_chip); - } - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addUserChg(); - $propertyChgService->addChip(); - $this->_rspData(array( - 'property_chg' => $propertyChgService->toDto(), - )); - } - - public function isNotNeedLucky(){ - $token_id = trim(getReqVal('token_id', 0)); - if (! $token_id) { - $this->_rspErr(1, 'Please enter instructions'); - return; - } - $chip = Chip::getChipByTokenId($token_id); - $fieldsKv = [ - 'supper_state' => 0, - 'lucky_temporary'=>0, - ]; - Chip::update($chip['token_id'],$fieldsKv); - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addChip(); - $this->_rspData(array( - 'property_chg' => $propertyChgService->toDto(), - )); - } - - public function waitingLucky(){ - $token_id = trim(getReqVal('token_id', 0)); - if (! $token_id) { - $this->_rspErr(1, 'Please enter instructions'); - return; - } - $chip = Chip::getChipByTokenId($token_id); - $fieldsKv = [ - 'supper_state'=>1, - ]; - Chip::update($chip['token_id'],$fieldsKv); - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addChip(); + 'rand_attr' => json_encode($rand_attr), + ) + ); + $chipDbNew = Chip::toDto(Chip::find($idxMain)); $this->_rspData([ + 'data'=>$chipDbNew, + 'state' => 1, 'property_chg' => $propertyChgService->toDto(), ]); } - public function aKeySynthetic(){ - $token_id = trim(getReqVal('token_id', 0)); - if (! $token_id) { - $this->_rspErr(1, 'Please enter instructions'); - return; - } - $chip = Chip::getChipByTokenId($token_id); - $upgrade_cost =\services\FormulaService::getChipUpgradeCost($chip['chip_grade']+1); //芯片升星价值 - - $chipList = Chip::all($chip['chip_type']); - $chipDtoList = array(); - foreach ($chipList as $item) { - if ($item['supper_state']==0 && $item['inlay_state']==0 && $item['state']!=-1 && $item['token_id'] != $token_id && $item['chip_grade'] <= $chip['chip_grade']){ - array_push($chipDtoList, $item); - } - }; - $data = $this->_orderByChip($chipDtoList,'asc'); - $chip_param = []; - $chip_param_out = []; - if (count($data) > 20) { - $cost = 0; - for ($i=0;$i$upgrade_cost){ - $diff_cost = $cost - $upgrade_cost; - foreach ($chip_param as $k=>$value){ - if ($diff_cost>$value['cost']){ - $diff_cost -= $value['cost']; - unset($chip_param[$k]); - } - } - }else{ - $chip_param = $this->_bestFun($upgrade_cost,$chip_param,$chip_param_out); - } - - }else{ - $cost = 0; - foreach ($data as $k=>$val){ - $data[$k]['cost'] = \services\FormulaService::getChipCumulativeCost($data[$k]['chip_grade']); - $cost += $data[$k]['cost']; - } - if ($cost > $upgrade_cost){ - $diff_cost = $cost - $upgrade_cost; - foreach ($data as $k=>$value){ - if ($diff_cost>$value['cost']){ - $diff_cost -= $value['cost']; - unset($data[$k]); - } - } - } - $chip_param = $data; - } - $cumulative_cost = []; - $token_id_arr = []; - foreach ($chip_param as $value){ - array_push($cumulative_cost,$value['cost']); - array_push($token_id_arr,$value['token_id']); - } - $this->_rspData(['data'=>['cost'=>$cumulative_cost,'token_ids'=>$token_id_arr]]); - } - - public function lockChip(){ - $token_id = trim(getReqVal('token_id', 0)); - $state = trim(getReqVal('state', 0)); - if (! $token_id){ - $this->_rspErr(1, 'Please enter instructions'); - return; - } - if ($state == 1){ - Chip::update($token_id,['state'=>-1]); - }else{ - Chip::update($token_id,['state'=>0]); - } - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addChip(); - $this->_rspData([ - 'property_chg' => $propertyChgService->toDto(), - ]); - } - - private function _doInlayHero($hero_id,$token_id){ - $chip = Chip::getChipByTokenId($token_id); - $hero = Hero::find($hero_id); - if (! $chip || ! $hero){ - $this->_rspErr(1, 'Not enough chip or hero'); - return false; - } - if (! $hero['chip_ids']){ - $fieldsKv = ['chip_ids'=>$chip['idx']]; - } - if ($hero['chip_ids'] && !strpos($hero['chip_ids'], '|')){ - $chipIdsArr = [$hero['chip_ids']]; - array_push($chipIdsArr,$chip['idx']); - $fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)]; - } - if ($hero['chip_ids'] && strpos($hero['chip_ids'], '|')){ - $chipIdsArr = explode('|',$hero['chip_ids']); - array_push($chipIdsArr,$chip['idx']); - $fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)]; - } - Hero::update($hero_id,$fieldsKv); - Chip::updateChipInlayState($token_id,1); - return true; - } - - private function _doInlayGun($gun_id,$token_id){ - $chip = Chip::getChipByTokenId($token_id); - $gun = Gun::find($gun_id); - if (! $chip || ! $gun){ - $this->_rspErr(1, 'Not enough chip or gun'); - return false; - } - if (! $gun['chip_ids']){ - $fieldsKv = ['chip_ids'=>$chip['idx']]; - } - if ($gun['chip_ids'] && !strpos($gun['chip_ids'], '|')){ - $chipIdsArr = [$gun['chip_ids']]; - array_push($chipIdsArr,$chip['idx']); - $fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)]; - } - if ($gun['chip_ids'] && strpos($gun['chip_ids'], '|')){ - $chipIdsArr = explode('|',$gun['chip_ids']); - array_push($chipIdsArr,$chip['idx']); - $fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)]; - } - Gun::update($gun_id,$fieldsKv); - Chip::updateChipInlayState($token_id,1); - return true; - } - - private function _doDemount($unique_id,$token_id){ - $chip = Chip::getChipByTokenId($token_id); - $hero = Hero::find($unique_id); - if (! $chip || ! $hero){ - $this->_rspErr(1, 'Not enough chip or hero'); - return false; - } - $chipIdsArr = explode('|',$hero['chip_ids']); - $k = array_search($chip['idx'],$chipIdsArr); - unset($chipIdsArr[$k]); - $fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)]; - $tili = $chip['strength_max']-$chip['strength']; - if ($tili){ - $mint = \services\FormulaService::Chip_Demount_Mint($tili); - $userObj = new User(); - $user=$userObj->find(myself()->_getAccountId()); - if ($mint>$user['gold']){ - $this->_rspErr(2, 'Be short of gold coins'); - return false; - } - User::update(['gold'=>$user['gold']-$mint]); - $chipDto = Chip::toDto($chip); - { - //埋点 - $event = [ - 'name' => LogService::CHIP_DEMOUNT, - 'val' => $mint - ]; - $chipDto['level'] = $chipDto['chip_grade']; - LogService::consumeCEG($event,$chipDto,$chipDto); - } - } - $where = ['inlay_state'=>0,'strength'=>$chip['strength_max']]; - Hero::update($unique_id,$fieldsKv); - Chip::update($token_id,$where); - return true; - } - - private function _doDemountGun($unique_id,$token_id){ - $chip = Chip::getChipByTokenId($token_id); - $gun = Gun::find($unique_id); - if (! $chip || ! $gun){ - $this->_rspErr(1, 'Not enough chip or gun'); - return false; - } - $chipIdsArr = explode('|',$gun['chip_ids']); - $k = array_search($chip['idx'],$chipIdsArr); - unset($chipIdsArr[$k]); - $fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)]; - - $tili = $chip['strength_max']-$chip['strength']; - if ($tili){ - $mint = \services\FormulaService::Chip_Demount_Mint($tili); - $userObj = new User(); - $user=$userObj->find(myself()->_getAccountId()); - if ($mint>$user['gold']){ - $this->_rspErr(2, 'Be short of gold coins'); - return false; - } - User::update(['gold'=>$user['gold']-$mint]); - $chipDto = Chip::toDto($chip); - { - //埋点 - $event = [ - 'name' => LogService::CHIP_DEMOUNT, - 'val' => $mint - ]; - $chipDto['level'] = $chipDto['chip_grade']; - LogService::consumeCEG($event,$chipDto,$chipDto); - } - } - $where = ['inlay_state'=>0,'strength'=>$chip['strength_max']]; - Gun::update($unique_id,$fieldsKv); - Chip::update($token_id,$where); - return true; - } - - private function _inLayNewAttr($hero_id){ - $heroDb = Hero::find($hero_id); - $hero = Hero::toDto($heroDb); - $chipAttr = []; - if (! $hero['chip_ids'] ){ - return $hero; - } - if ($hero['chip_ids'] && !strpos($hero['chip_ids'], '|')){ - $chip =Chip::toDto(Chip::getChipByIdx($hero['chip_ids'])); - foreach ($chip['rand_attr'] as $val){ - array_push($chipAttr,$val); - } - } - if ($hero['chip_ids'] && strpos($hero['chip_ids'], '|')){ - $chipIdsArr = explode('|',$hero['chip_ids']); - foreach ($chipIdsArr as $val){ - $chip = Chip::toDto(Chip::getChipByIdx($val)); - foreach ($chip['rand_attr'] as $v){ - array_push($chipAttr,$v); - } - } - } - $item = []; - foreach ($chipAttr as $k=>$v){ - if (!isset($item[$v['attr_id']])){ - $item[$v['attr_id']] = $v; - }else{ - $item[$v['attr_id']]['val']+= $v['val']; - } - } - $hero['attr_chip'] = $item;//芯片属性 - return $hero; - } - - private function _inLayNewAttrGun($gun_id){ - $gunDb = Gun::find($gun_id); - $gun = Gun::toDto($gunDb); - $chipAttr = []; - if (! $gun['chip_ids'] ){ - return $gun; - } - if ($gun['chip_ids'] && !strpos($gun['chip_ids'], '|')){ - $chip =Chip::toDto(Chip::getChipByIdx($gun['chip_ids'])); - foreach ($chip['rand_attr'] as $val){ - array_push($chipAttr,$val); - } - } - if ($gun['chip_ids'] && strpos($gun['chip_ids'], '|')){ - $chipIdsArr = explode('|',$gun['chip_ids']); - foreach ($chipIdsArr as $val){ - $chip = Chip::toDto(Chip::getChipByIdx($val)); - foreach ($chip['rand_attr'] as $v){ - array_push($chipAttr,$v); - } - } - } - $item = []; - foreach ($chipAttr as $k=>$v){ - if (!isset($item[$v['attr_id']])){ - $item[$v['attr_id']] = $v; - }else{ - $item[$v['attr_id']]['val']+= $v['val']; - } - } - $gun['attr_chip'] = $item;//芯片属性 - return $gun; - } - - private function _chipCore($unique_id,$type){ - $chipCore = []; - if ($type==1){ - $hero = Hero::find($unique_id); - }else{ - $hero = Gun::find($unique_id); - } - - if ($hero['chip_ids'] && strpos($hero['chip_ids'], '|')){ - $chipIdsArr = explode('|',$hero['chip_ids']); - if (count($chipIdsArr) == 4){ - $min = 15; - foreach ($chipIdsArr as $val){ - $chip = Chip::getChipByIdx($val); - if ($chip['chip_grade']<$min){ - $min = $chip['chip_grade']; - } - } - $chipCoreList = getMetaTable('chipCore@chipCore.php'); - foreach ($chipCoreList as $val){ - if ($val['chip_core_type']==$type && $val['chip_core_lv']<=$min){ - array_push($chipCore,$val); - } - } - return $chipCore; - }else{ - return []; - } - }else{ - return []; - } - } - - private function _getHignGradeLimit($data,$limit){ - $len = count($data); - if ($len<=1 || $len<=$limit){ - return $data; - } - for ($i = 0; $i < $len - 1; $i++) { - for ($j = $i + 1; $j < $len; $j++) { - if ($data[$i]['chip_grade'] < $data[$j]['chip_grade']) { - $tmp = $data[$i]; - $data[$i] = $data[$j]; - $data[$j] = $tmp; - } - } - } - return array_slice($data,0,$limit); - } - - private function _orderByChip($data,$order){ - $len = count($data); - if ($len<=1){ - return $data; - } - if ($order == 'desc'){ - for ($i = 0; $i < $len - 1; $i++) { - for ($j = $i + 1; $j < $len; $j++) { - if ($data[$i]['chip_grade'] < $data[$j]['chip_grade']) { - $tmp = $data[$i]; - $data[$i] = $data[$j]; - $data[$j] = $tmp; - } - } - } - }else{ - for ($i = 0; $i < $len - 1; $i++) { - for ($j = $i + 1; $j < $len; $j++) { - if ($data[$i]['chip_grade'] > $data[$j]['chip_grade']) { - $tmp = $data[$i]; - $data[$i] = $data[$j]; - $data[$j] = $tmp; - } - } - } - } - return $data; - } - - private function _upgraded($chip){ - $new_grade = $chip['chip_grade']+1; - if ($new_grade == 3 || $new_grade == 5){ - Chip::updateRandAttr(myself()->_getAccountId(),$chip); - } - - $lucky = ltrim(\services\FormulaService::getChipLuckyValue($new_grade),'-') ; - if ($new_grade>=5){ - $where = ['lucky_temporary'=>$lucky, 'chip_grade'=>$new_grade,'supper_state'=>1,'modifytime' => $this->_getNowTime()]; - }else{ - $where = ['lucky_temporary'=>$lucky, 'chip_grade'=>$new_grade,'modifytime' => $this->_getNowTime()]; - } - Chip::update($chip['token_id'],$where); - } - - private function _bestFun($upgrade_cost,$chip_param,$chip_param_out){ - $cost = 0; - foreach ($chip_param as $v){ - $cost += $v['cost']; - }; - if ($cost>$upgrade_cost){ - return $chip_param; - }else{ - array_shift($chip_param); - array_push($chip_param,array_shift($chip_param_out)); - return $this->_bestFun($upgrade_cost,$chip_param,$chip_param_out); - } - } - } \ No newline at end of file diff --git a/webapp/controller/ChipPageController.class.php b/webapp/controller/ChipPageController.class.php new file mode 100644 index 00000000..274e90c0 --- /dev/null +++ b/webapp/controller/ChipPageController.class.php @@ -0,0 +1,162 @@ +_rspData(array( + 'data' => $list, + )); + } + + public function showPageInfo(){ + $obj = new services\ChipPageService(); + $obj->initChipPage(); + + $page = getReqVal('page',1); + $chipPageDb = ChipPage::find($page); + if (!$chipPageDb){ + $this->_rspErr(1,'page parameter error'); + return ; + } + $chipPageDto = ChipPage::toDtoInfo($chipPageDb); + $this->_rspData(array( + 'data' => $chipPageDto, + )); + } + + public function addChipPage(){ + ChipPage::addChipPage(); + $this->_rspOk(); + } + + public function rename(){ + $page = getReqVal('page',0); + $chipPageDb = ChipPage::find($page); + if (! $chipPageDb ){ + $this->_rspErr(1,'page parameter error'); + return ; + } + $name = getReqVal('name',''); + if (mb_strlen($name) < 3) { + $this->_rspErr(1,'Parameter error name length must not be less than 3'); + return; + } + if (mb_strlen($name, 'utf8') > 12) { + $this->_rspErr(1,'Parameter error name length must not be greater than 12'); + return; + } + ChipPage::update($page,array( + 'page_name' => $name + )); + $chipPageDto = ChipPage::toDtoInfo($chipPageDb); + $this->_rspData(array( + 'data' => $chipPageDto, + )); + } + + public function useChip(){ + $page = getReqVal('page',0); + $slotId = getReqVal('slot_id',0); + $uniqueId = getReqVal('unique_id',0); + if (!$page || !$slotId || !$uniqueId){ + $this->_rspErr(1, 'Missing parameter'); + return ; + } + $chipPageDb = ChipPage::find($page); + if (!$chipPageDb){ + $this->_rspErr(1,'page parameter error'); + return ; + } + if ($slotId > ChipPageService::MAX_CHIP_SLOT_NUM || $slotId < 0 ){ + $this->_rspErr(1,'No card slot exists'); + return ; + } + $data = emptyReplace(json_decode($chipPageDb['data'], true), array()); +// $data[$slotId-1]['chip_id'] = $uniqueId; +// print_r($data);die; + if ( $data[$slotId-1]['state'] != 1){ + $this->_rspErr(1,'Unlocked state'); + return ; + } + $chipDb = Chip::find($uniqueId); + if (! $chipDb){ + $this->_rspErr(1, "You don't have the chip yet"); + return; + } + if ($chipDb['inlay_state'] == 1){ + $this->_rspErr(1, "The used chip"); + return; + } + switch ($slotId%3){ + case 1 : $type = 1;break; + case 2 : $type = 2;break; + case 0 : $type = 3;break; + default:$type = 0; + } + if ($chipDb['chip_type'] != $type){ + $this->_rspErr(1, "Type mismatch"); + return; + } + if ( $data[$slotId-1]['chip_id'] ){ + Chip::update2($data[$slotId-1]['chip_id'] , + array( + 'inlay_state' => 0, + ) + ); + } + $data[$slotId-1]['chip_id'] = $uniqueId; + Chip::update2($uniqueId , + array( + 'inlay_state' => 1, + ) + ); + ChipPage::update($page,array( + 'data' => json_encode($data) + )); + $newChipPageDb = ChipPage::find($page); + $chipPageDto = ChipPage::toDtoInfo($newChipPageDb); + $this->_rspData(array( + 'data' => $chipPageDto, + )); + } + + public function removeChip(){ + $page = getReqVal('page',0); + $chipPageDb = ChipPage::find($page); + if (!$chipPageDb){ + $this->_rspErr(1,'page parameter error'); + return ; + } + $data = emptyReplace(json_decode($chipPageDb['data'], true), array()); + foreach ($data as &$value){ + if ($value['chip_id']){ + Chip::update2($value['chip_id'] , + array( + 'inlay_state' => 0, + ) + ); + $value['chip_id'] = 0; + } + } + ChipPage::update($page,array( + 'data' => json_encode($data) + )); + $newChipPageDb = ChipPage::find($page); + $chipPageDto = ChipPage::toDtoInfo($newChipPageDb); + $this->_rspData(array( + 'data' => $chipPageDto, + )); + } +} \ No newline at end of file diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index 2374b3f4..6818e759 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -11,21 +11,46 @@ require_once('mt/ChipAttr.php'); use mt; +use mt\ChipAttr; use phpcommon\SqlHelper; use services\NftService; use services\FormulaService; class Chip extends BaseModel { - public static function all($type) + const CHIP_LV_MAX = 3; + + public static function find($chipUniId) { - $chipList = array(); - self::getChipList(function ($row) use(&$chipList,$type) { - if ($row['item_num'] > 0 && $row['chip_type'] == $type) { - array_push($chipList, $row); + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_chip', + array( + 'idx' => $chipUniId, + ) + ); + if ($row) { + if ($row['account_id'] != myself()->_getAccountId()) { + if (NftService::getChipBlance(myself()->_getOpenId(), $row['token_id']) <= 0) { + $row = null; + } } - }); - return $chipList; + } + return $row; + } + + public static function update2($chipUniId, $fieldsKv){ + if (self::find($chipUniId)) { + SqlHelper::update + (myself()->_getSelfMysql(), + 't_chip', + array( + 'idx' => $chipUniId, + ), + $fieldsKv + ); + } + } public static function findByTokenId($tokenId) @@ -48,6 +73,16 @@ class Chip extends BaseModel public static function getChipList($cb) { + SqlHelper::ormSelect( + myself()->_getSelfMysql(), + 't_chip', + array( + 'account_id' => myself()->_getAccountId() + ), + function ($row) use($cb) { + $cb($row); + } + ); $sql = "select * from t_nft1155 where owner_address=:owner_address and token_id>10000000 and balance>0"; $whereKv =array( 'owner_address' => myself()->_getOpenId(), @@ -60,6 +95,19 @@ class Chip extends BaseModel 'token_id' => $nftDb['token_id'], ) ); + if (!$row) { + $itemMeta = mt\Item::get($nftDb['item_id']); + if ($itemMeta) { + self::addNftChip($itemMeta, $nftDb['token_id']); + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_chip', + array( + 'token_id' => $nftDb['token_id'], + ) + ); + } + } if ($row){ if (! $row['activate']){ self::activateChip($row); @@ -78,201 +126,123 @@ class Chip extends BaseModel } private static function activateChip($row){ - if ($row['item_num'] <= 0) { - return; - } $itemMeta = mt\Item::get($row['item_id']); if (!$itemMeta) { return; } $randAttr = array(); - if (mt\Item::isRoleChipItem($itemMeta)) { - $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$row['chip_grade']); - } - if (mt\Item::isGunChipItem($itemMeta)) { - $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$row['chip_grade']); - } - if ($row['chip_grade'] >= 5){ - $lucky = ltrim(\services\FormulaService::getChipLuckyValue($row['chip_grade']),'-') ; - $fieldsKv = array( - 'supper_state'=>1, - 'lucky_temporary'=>$lucky, - 'chip_type' => $itemMeta['sub_type'], - 'rand_attr' => json_encode($randAttr), - 'activate' => 1, - 'modifytime' => myself()->_getNowTime() - ); - }else{ - $fieldsKv = array( - 'chip_type' => $itemMeta['sub_type'], - 'rand_attr' => json_encode($randAttr), - 'activate' => 1, - 'modifytime' => myself()->_getNowTime() - ); - } + $fieldsKv = array( + 'item_id' => $itemMeta['id'], + 'item_num' => 1, + 'rand_attr' => json_encode($randAttr), + 'chip_grade' => 1, + 'chip_type' => $itemMeta['sub_type'], + 'labour' => 0, + 'activate' => 1, + 'modifytime' => myself()->_getNowTime() + ); self::update($row['token_id'],$fieldsKv); } public static function toDto($row) { - $todayGetGold = $row['today_get_gold']; - $lastGetGoldTime = $row['last_get_gold_time']; - if (myself()->_getDaySeconds($lastGetGoldTime) > myself()->_getNowDaySeconds()) { - $todayGetGold = 0; +// $todayGetGold = $row['today_get_gold']; +// $lastGetGoldTime = $row['last_get_gold_time']; +// if (myself()->_getDaySeconds($lastGetGoldTime) > myself()->_getNowDaySeconds()) { +// $todayGetGold = 0; +// } + $rand_attr = emptyReplace(json_decode($row['rand_attr'], true), array()); + $chipMeta = mt\ChipAttr::getAttrByItemId($row['item_id']); + if ($chipMeta){ + array_unshift($rand_attr,array( + 'attr_id'=>$chipMeta['attr_id'], + 'val' => $chipMeta['lv'.$row['chip_grade']] + )); } - $attr_pool = emptyReplace(json_decode($row['rand_attr'], true), array()); - $attrs = array(); - foreach ($attr_pool as $key=>$val){ - if ($val){ - $attr = mt\ChipAttr::getAttrById($val['attr_id'],$val['attr_type']); - $newAttr = [ - - 'attr_id' => $attr['attr_id'], - 'type' => 2, - 'val' => strval($attr['lv'.$row['chip_grade']]*$val['attr_pool_number']), -// 'chip_name' => $attr['chip_name'], - 'chip_type' => $attr['chip_type'], - 'attr_num' => $attr['lv'.$row['chip_grade']], - 'attr_pool_num' => $val['attr_pool_number'], - ]; - array_push($attrs,$newAttr); - } - } - $row['rand_attr'] = $attrs; - $row['today_get_gold'] = $todayGetGold; - $row['last_get_gold_time'] = $lastGetGoldTime; - $row['chip_name'] = mt\Item::get($row['item_id'])?mt\Item::get($row['item_id'])['name']:'XXX'; -// $row['belong_to_item_id'] = self::belongsToWhereOld($row); + $dto = array( + 'idx'=> $row['idx'], + 'token_id'=> $row['token_id'], + 'item_id'=> $row['item_id'], + 'chip_grade'=> $row['chip_grade'], + 'chip_type'=> $row['chip_type'], + 'state'=> $row['state'], + 'supper_state'=> $row['supper_state'], + 'inlay_state'=> $row['inlay_state'], + 'rand_attr'=> $rand_attr, + ); + $dto['chip_name'] = mt\Item::get($row['item_id'])?mt\Item::get($row['item_id'])['name']:'XXX'; $nft_address = ''; - if ($row['token_id']){ + if ($dto['token_id']){ $nft_address = SERVER_ENV == _ONLINE ? '0x73482411443E87CAC124C12A10B34e9Aaa2De168' : '0x26b4AFb60d6C903165150C6F0AA14F8016bE4aec'; } - $row['nft_address'] = $nft_address; - return $row; + $dto['nft_address'] = $nft_address; + return $dto; } - public static function belongsToWhere($row){ - $tokenId = $row['token_id']; - $sql = "select * from t_chip_plugin where chip1=:tokenId or chip2=:tokenId or chip3=:tokenId or chip4=:tokenId limit 1"; - $whereKv =array( - 'tokenId' => $tokenId - ); - $ChipPluginDb = myself()->_getMarketMysql()->execQuery($sql,$whereKv); - if (!$ChipPluginDb){ - return 0; - } - switch ($row['chip_type']){ - case 1:{ - $heroDb = Hero::findByTokenId2($ChipPluginDb['token_id']); - if($heroDb){ - return $heroDb['hero_id']; - }else{ - return 0; - } - } - break; - case 2:{ - $gunDb = Gun::findByTokenId2($ChipPluginDb['token_id']); - if($gunDb){ - return $gunDb['gun_id']; - }else{ - return 0; - } - } - break; - default:{ - return 0; - } - } - } - public static function belongsToWhereOld($row){ - switch ($row['chip_type']){ - case 1:{ - $heroDb = array(); - Hero::getHeroList(function ($hero) use ($row,&$heroDb) { - if ($hero['chip_ids'] && strstr($hero['chip_ids']."|",strval($row['idx']."|")) ){ - $heroDb = $hero; - } - }); - if($heroDb){ - return $heroDb['hero_id']; - }else{ - return 0; - } - } - break; - case 2:{ - $gunDb = array(); - Gun::getGunList(function ($gun) use($row,&$gunDb) { - if ($gun['chip_ids'] && strstr($gun['chip_ids']."|",strval($row['idx']."|")) ){ - $gunDb = $gun; - } - }); - if($gunDb){ - return $gunDb['gun_id']; - }else{ - return 0; - } - } - break; - default:{ - return 0; - } - } - } - public static function addChip($itemId, $tokenId) + public static function addChip($itemMeta) { + + return self::internalAddItem( + myself()->_getSelfMysql(), + $itemMeta, + myself()->_getAccountId(), + null); + } + + public static function addNftChip($itemMeta,$tokenId) + { + return self::internalAddItem( myself()->_getMysql($tokenId), - $itemId, - 1, + $itemMeta, null, $tokenId); } - public static function internalAddItem($conn, $itemId, $itemNum, $accountId, $tokenId) + public static function internalAddItem($conn, $itemMeta, $accountId, $tokenId) { - $grade = rand(1,4);//随机一个等级 - if (myself()->_isVirtualItem($itemId)) { - return; - } - if ($itemNum <= 0) { - return; - } - $itemMeta = mt\Item::get($itemId); if (!$itemMeta) { return; } - $randAttr = array(); - if (mt\Item::isRoleChipItem($itemMeta)) { - $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$grade); - } - if (mt\Item::isGunChipItem($itemMeta)) { - $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$grade); - } - $fieldsKv = array( - 'item_id' => $itemId, - 'item_num' => 1, - 'rand_attr' => json_encode($randAttr), - 'chip_grade' => $grade, - 'chip_type' => $itemMeta['sub_type'], - 'labour' => 0, - 'createtime' => myself()->_getNowTime(), - 'modifytime' => myself()->_getNowTime() - ); - if ($accountId) { - $fieldsKv['account_id'] = $accountId; - } - if ($tokenId) { - $fieldsKv['token_id'] = $tokenId; - } + if (myself()->_isVirtualItem($itemMeta['id'])) { + return; + } + $chipMeta = ChipAttr::getAttrByItemId($itemMeta['id']); + if (!$chipMeta){ + return; + } +// $randAttr = array(); +// if (mt\Item::isRoleChipItem($itemMeta)) { +// $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$grade); +// } +// if (mt\Item::isGunChipItem($itemMeta)) { +// $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$grade); +// } + $randAttr = array(); + $fieldsKv = array( + 'item_id' => $itemMeta['id'], + 'item_num' => 1, + 'rand_attr' => json_encode($randAttr), + 'chip_grade' => 1, + 'chip_type' => $itemMeta['sub_type'], + 'labour' => 0, + 'activate' => 1, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ); + if ($accountId) { + $fieldsKv['account_id'] = $accountId; + } + if ($tokenId) { + $fieldsKv['token_id'] = $tokenId; + } - SqlHelper::insert - ($conn, - 't_chip', - $fieldsKv - ); + SqlHelper::insert + ($conn, + 't_chip', + $fieldsKv + ); } public static function getChipByTokenId($token_ids){ @@ -308,53 +278,24 @@ class Chip extends BaseModel ); } - public static function updateChipInlayState($token_id,$state){ - return SqlHelper::update( - myself()->_getSelfMysql(), - 't_chip', - ['token_id' => $token_id], - ['inlay_state'=>$state] - ); - } - public static function getChipInlay($type){ - return SqlHelper::ormSelect( - myself()->_getSelfMysql(), - 't_chip', - array( - 'chip_type' => $type, - 'supper_state' => 0, - 'inlay_state' => 0, - ) - ); - } - -// public static function deleteChip($whereKv){ +// public static function updateRandAttr($accountId,$chip){ +// $attr_pool = mt\ChipAttr::generateOneAttr($chip['chip_type']); +// $rand_attr = emptyReplace(json_decode($chip['rand_attr'], true), array()); +// array_push($rand_attr,$attr_pool); +// $fieldsKv = [ +// 'rand_attr'=>json_encode($rand_attr) +// ]; // SqlHelper::update( -// myself()->_getMarketMysql(), -// 't_nft', -// $whereKv, -// ['deleted'=>1] +// myself()->_getMysql($accountId), +// 't_chip', +// array( +// 'token_id' => $chip['token_id'], +// ), +// $fieldsKv // ); // } - public static function updateRandAttr($accountId,$chip){ - $attr_pool = mt\ChipAttr::generateOneAttr($chip['chip_type']); - $rand_attr = emptyReplace(json_decode($chip['rand_attr'], true), array()); - array_push($rand_attr,$attr_pool); - $fieldsKv = [ - 'rand_attr'=>json_encode($rand_attr) - ]; - SqlHelper::update( - myself()->_getMysql($accountId), - 't_chip', - array( - 'token_id' => $chip['token_id'], - ), - $fieldsKv - ); - } - public static function getChipAttr($chip_ids){ $data = ['attr_chip'=>[],'chip_core'=>[]]; if (! $chip_ids) { diff --git a/webapp/models/ChipPage.php b/webapp/models/ChipPage.php new file mode 100644 index 00000000..401bb5d5 --- /dev/null +++ b/webapp/models/ChipPage.php @@ -0,0 +1,182 @@ +_getSelfMysql(), + 't_chip_page', + array( + 'account_id'=> myself()->_getAccountId(), + 'page_id' => $page + ) + ); + if (!$row){ + return null; + } + return $row; + } + + public static function getList($cb){ + SqlHelper::ormSelect( + myself()->_getSelfMysql(), + 't_chip_page', + array( + 'account_id'=> myself()->_getAccountId(), + ), + function ($row) use($cb) { + $cb($row); + } + ); + } + + public static function toDto($row){ + return array( + 'idx' => $row['idx'], + 'account_id' => $row['account_id'], + 'page_name' => $row['page_name'], + 'page_id' => $row['page_id'], + 'createtime' => $row['createtime'], + ); + } + + public static function toDtoInfo($row){ + $data = emptyReplace(json_decode($row['data'], true), array()); + foreach ($data as &$value){ + $chipDb = Chip::find($value['chip_id']); + if ( !$chipDb ) { + $value['chip_id'] = 0; + } + } + self::update($row['page_id'],array( + 'data' => json_encode($data) + )); + $newRow = self::find($row['page_id']); + $newData = emptyReplace(json_decode($newRow['data'], true), array()); + $attrs = array(); + foreach ($newData as $value){ + if ($value['chip_id']){ + $chipDb = Chip::find($value['chip_id']); + $chipAttrMeta = ChipAttr::getAttrByItemId($chipDb['item_id']); + $rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array()); + array_push($attrs,array( + 'attr_id'=>$chipAttrMeta['attr_id'], + 'val'=>$chipAttrMeta['lv'.$chipDb['chip_grade']], + )); + foreach ($rand_attr as $val){ + array_push($attrs,$val); + } + } + } + $item = []; + foreach ($attrs as $k=>$v){ + if (!isset($item[$v['attr_id']])){ + $item[$v['attr_id']] = $v; + }else{ + $item[$v['attr_id']]['val']+= $v['val']; + } + } + $info = array( + 'idx' => $newRow['idx'], + 'page_id' => $newRow['page_id'], + 'page_name' => $newRow['page_name'], + 'data' => $newData, + 'attr' => $item + ); + return $info; + } + + public static function updatePage($page,$slot_id,$chip_id){ + $row = self::find($page); + $data = emptyReplace(json_decode($row['data'], true), array()); + foreach ($data as &$value){ + if ($value['slot_id'] == $slot_id){ + $value['chip_id'] = $chip_id; + } + } + SqlHelper::update + (myself()->_getSelfMysql(), + 't_chip_page', + array( + 'account_id'=> myself()->_getAccountId(), + 'page_id' => $page + ), + array( + 'data'=> json_encode($data) + ) + ); + } + + public static function update($page,$fieldsKv){ + SqlHelper::update + (myself()->_getSelfMysql(), + 't_chip_page', + array( + 'account_id'=> myself()->_getAccountId(), + 'page_id' => $page + ), + $fieldsKv + ); + } + + public static function addChipPage(){ + $data = array(); + $userInfo = myself()->_getOrmUserInfo(); + for ($i=1;$i <= ChipPageService::MAX_CHIP_SLOT_NUM;$i++){ + if ($i <= $userInfo['level']){ + array_push( + $data, + array( + 'slot_id'=>$i, + 'state'=>1, + 'chip_id'=>0, + ) + ); + }else{ + array_push( + $data, + array( + 'slot_id'=>$i, + 'state'=>0, + 'chip_id'=>0, + ) + ); + } + } + $rows = SqlHelper::ormSelect( + myself()->_getSelfMysql(), + 't_chip_page', + array( + 'account_id'=> myself()->_getAccountId() + ) + ); + $page_id = 1; + if ($rows){ + $page_id = count($rows)+1; + } + $info = array( + 'account_id' => myself()->_getAccountId(), + 'page_name' => '芯片页'.$page_id, + 'page_id' => $page_id, + 'data' => json_encode($data), + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ); + SqlHelper::insert( + myself()->_getSelfMysql(), + 't_chip_page', + $info + ); + } +} \ No newline at end of file diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 8cd88b94..0907d789 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -168,6 +168,22 @@ class Gun extends BaseModel { 'token_id' => $nftDb['token_id'], ) ); + + //将NFT表的数据同步到中心化英雄表 (以后可能删除) + if (!$row) { + $itemMeta = mt\Item::get($nftDb['item_id']); + if ($itemMeta) { + self::addNftGun($itemMeta, $nftDb['token_id']); + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_gun', + array( + 'token_id' => $nftDb['token_id'], + ) + ); + } + } + if ($row){ if ( ! $row['activate']){ self::activateGun($row); @@ -271,8 +287,6 @@ class Gun extends BaseModel { 'raw_pve_ceg_uplimit' => 0, 'attr_base' => $baseAttr, 'attr_pro' => $attrPro, - 'attr_chip' => Chip::getChipAttr($chipIds)['attr_chip'], - 'chip_core' => Chip::getChipAttr($chipIds)['chip_core'], 'try_count' => $row['try_count'], 'current_pvp_get_ceg' => $todayGetGold / 100, 'last_pvp_get_ceg_time' => $lastGetGoldTime, @@ -312,14 +326,14 @@ class Gun extends BaseModel { null); } -// public static function addNftGun($gunMeta, $tokenId) -// { -// return self::internalAddGun( -// myself()->_getMysql($tokenId), -// $gunMeta, -// null, -// $tokenId); -// } + public static function addNftGun($gunMeta, $tokenId) + { + return self::internalAddGun( + myself()->_getMysql($tokenId), + $gunMeta, + null, + $tokenId); + } private static function internalAddGun($conn, $gunMeta, $accountId, $tokenId) { @@ -672,9 +686,7 @@ class Gun extends BaseModel { $todayPveGetCeg = 0; } $gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($row['quality']); - $chipIds = ChipPlugin::getInlayChip($row['token_id']); - $attr_chip= Chip::getChipAttr($chipIds)['attr_chip']; - $chip_core= Chip::getChipAttr($chipIds)['chip_core']; + $rand_attr = $baseAttr; if ($attrPro){ @@ -686,20 +698,7 @@ class Gun extends BaseModel { } } } - if ($attr_chip){ - $rand_attr = self::_mergeArr(array_merge($rand_attr,$attr_chip)); - } - if ($chip_core){ - $coreAttr = array(); - foreach ($chip_core as $value){ - array_push($coreAttr,array( - 'attr_id'=>$value['attr_id'], - 'type'=>$value['attr_add_type'], - 'val'=>$value['attr_number'], - )); - } - $rand_attr = self::_mergeArr(array_merge($rand_attr,$coreAttr)); - } + $info = array( 'idx' => $row['idx'], 'token_id' => $row['token_id'], @@ -712,10 +711,9 @@ class Gun extends BaseModel { 'lucky' => strval($gunLucky), 'durability' => $row['durability'], 'rand_attr' => array_values($rand_attr), - 'chip_core' => $chip_core ? $coreAttr : $chip_core, 'current_pvp_get_ceg' => $todayGetGold / 100, 'current_pve_get_ceg' => $todayPveGetCeg / 100, - 'chip_ids' => $chipIds, + 'chip_ids' => $row['chip_ids'], 'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],2)), //计算ceg上限所需参数 'labour' => $row['labour'], ); diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index f0d2a24c..d85b0fac 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -149,6 +149,22 @@ class Hero extends BaseModel { 'token_id' => $nftDb['token_id'], ) ); + + //将NFT表的数据同步到中心化英雄表 (以后可能删除) + if (!$row) { + $itemMeta = mt\Item::get($nftDb['item_id']); + if ($itemMeta) { + self::addNftHero($itemMeta, $nftDb['token_id']); + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_hero', + array( + 'token_id' => $nftDb['token_id'], + ) + ); + } + } + if ($row) { if (!$row['activate']) { self::activateHero($row); @@ -264,8 +280,6 @@ class Hero extends BaseModel { 'attr_base' => $baseAttr, 'attr_pro' => $attrPro, 'attr_skill' => $attr_skill, - 'attr_chip' => Chip::getChipAttr($chipIds)['attr_chip'], - 'chip_core' => Chip::getChipAttr($chipIds)['chip_core'], 'try_count' => $row['try_count'], 'lock_type' => $lockType, 'unlock_time' => $unlockTime, @@ -309,14 +323,14 @@ class Hero extends BaseModel { null); } -// public static function addNftHero($heroMeta, $tokenId) -// { -// return self::internalAddHero( -// myself()->_getMysql($tokenId), -// $heroMeta, -// null, -// $tokenId); -// } + public static function addNftHero($heroMeta, $tokenId) + { + return self::internalAddHero( + myself()->_getMysql($tokenId), + $heroMeta, + null, + $tokenId); + } public static function internalAddHero($conn, $heroMeta, $accountId, $tokenId) { @@ -711,9 +725,6 @@ class Hero extends BaseModel { array_push($attr_skill,$item); } } - $chipIds = ChipPlugin::getInlayChip($row['token_id']); - $attr_chip= Chip::getChipAttr($chipIds)['attr_chip']; - $chip_core= Chip::getChipAttr($chipIds)['chip_core']; $rand_attr = $baseAttr; if ($attrPro){ @@ -728,20 +739,7 @@ class Hero extends BaseModel { if ($attr_skill){ $rand_attr = self::_mergeArr(array_merge($rand_attr,$attr_skill)); } - if ($attr_chip){ - $rand_attr = self::_mergeArr(array_merge($rand_attr,$attr_chip)); - } - if ($chip_core){ - $coreAttr = array(); - foreach ($chip_core as $value){ - array_push($coreAttr,array( - 'attr_id'=>$value['attr_id'], - 'type'=>$value['attr_add_type'], - 'val'=>$value['attr_number'], - )); - } - $rand_attr = self::_mergeArr(array_merge($rand_attr,$coreAttr)); - } + $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($row['quality']); $info = array( 'idx' => $row['idx'], @@ -753,18 +751,15 @@ class Hero extends BaseModel { 'hero_tili' => $row['hero_tili'], 'quality' => $row['quality'], 'rand_attr' => array_values($rand_attr), - 'chip_core' => $chip_core ? $coreAttr : $chip_core, // 'attr_base' => $baseAttr, // 'attr_pro' => $attrPro, // 'attr_skill' => $attr_skill, -// 'attr_chip' => Chip::getChipAttr($chipIds)['attr_chip'], -// 'chip_core' => Chip::getChipAttr($chipIds)['chip_core'], 'current_pvp_get_ceg' => $todayGetGold / 100, 'current_pve_get_ceg' => $todayPveGetCeg / 100, 'advanced_count' => $row['advanced_count'], 'lucky' => strval($heroLucky), - 'chip_ids' => $chipIds, - 'chip_strength_sum' => strval(Chip::getChipMaxStrength($chipIds,1)), //计算ceg上限所需参数 + 'chip_ids' => $row['chip_ids'], + 'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],1)), //计算ceg上限所需参数 'skill_points' => $row['skill_points'], 'labour' => $row['labour'], ); diff --git a/webapp/mt/ChipAttr.php b/webapp/mt/ChipAttr.php index 7674b4c1..fcef3d37 100644 --- a/webapp/mt/ChipAttr.php +++ b/webapp/mt/ChipAttr.php @@ -30,120 +30,85 @@ class ChipAttr { return self::$attrPoolList; } - public static function getAttrPool($attr){ - $attr_pool = array(); + public static function getAttrPool($chip){ + $temp = array(); + $attrWeight = 0; foreach (self::getAttrPoolList() as $item){ - if ($item['attr_id'] == $attr['attr_id'] && $item['attr_type'] == $attr['chip_type'] ){ - $attr_pool = $item; + if ($item['chip_type'] == $chip['chip_type']){ + $attrWeight += $item['attr_weight']; + for ($i = 0; $i < $item['attr_weight']; $i++) { + $temp[] = $item; + } } } + $attr_pool = $temp[rand(0, $attrWeight -1)]; if ($attr_pool){ - $attr_pool['weight'] = explode('|',$attr_pool['weight']); - foreach ($attr_pool['weight'] as $key =>$item){ - $attr_pool['weight'][$key] = explode(':',$item); + $attr_pool['num_weight'] = explode('|',$attr_pool['num_weight']); + foreach ($attr_pool['num_weight'] as $key =>$item){ + $attr_pool['num_weight'][$key] = explode(':',$item); } - $weight = 0; $tempData = array (); - foreach ($attr_pool['weight'] as $one) { + foreach ($attr_pool['num_weight'] as $one) { $weight += $one[1]; for ($i = 0; $i < $one[1]; $i++) { $tempData[] = $one; + } } $k = rand(0, $weight -1); - $attr_pool['attr_pool_number'] = $tempData[$k][0]; - unset($attr_pool['weight']); + $attr_pool['val'] = $tempData[$k][0]; + unset($attr_pool['num_weight']); } return $attr_pool; } - public static function generateAttrRandom($itemMeta,$chip_grade){ - if ($itemMeta['sub_type'] == self::ROLE_CHIP_SUBTYPE){ - $chip = self::getNodeChip(); - return self::_randomNum($itemMeta,$chip_grade,$chip); - } - if ($itemMeta['sub_type'] == self::GUN_CHIP_SUBTYPE){ - $chip = self::getGunChip(); - return self::_randomNum($itemMeta,$chip_grade,$chip); - } - return array(); - } - public static function getAttrById($attr_id,$attr_type){ - if($attr_type == self::ROLE_CHIP_SUBTYPE){ - $chip = self::getNodeChip(); - } - if($attr_type == self::GUN_CHIP_SUBTYPE){ - $chip = self::getGunChip(); - } - foreach ($chip as $item) { - if ($item['attr_id'] == $attr_id && $item['chip_type'] == $attr_type){ - return $item; - } - } - } - public static function generateOneAttr($type){ -// $itemMeta = Item::get($item_id); -// return self::getAttrPool(self::getAttrByItemId($itemMeta['id'])); +// public static function generateOneAttr($type){ +//// $itemMeta = Item::get($item_id); +//// return self::getAttrPool(self::getAttrByItemId($itemMeta['id'])); +// +//// $attr_pool = self::getAttrPool(self::getAttrByItemId($itemMeta['id'])); +//// $attr = emptyReplace(json_decode($chip['rand_attr'], true), array()); +//// array_push($attr,$attr_pool); +//// return $attr; +// if ($type == self::ROLE_CHIP_SUBTYPE){ +// $chip = self::getNodeChip(); +// $attr = $chip[ array_rand($chip)]; +// return self::getAttrPool($attr); +// } +// if ($type == self::GUN_CHIP_SUBTYPE){ +// $chip = self::getGunChip(); +// $attr = $chip[ array_rand($chip)]; +// return self::getAttrPool($attr); +// } +// return array(); +// } +// +// +// +// private static function getNodeChip(){ +// $node_chip = array(); +// foreach (self::getMetaList() as $item){ +// if ($item['chip_type'] == self::ROLE_CHIP_SUBTYPE){ +// array_push($node_chip,$item); +// } +// } +// return $node_chip; +// } +// +// private static function getGunChip(){ +// $gun_chip = array(); +// foreach (self::getMetaList() as $item){ +// if ($item['chip_type'] == self::GUN_CHIP_SUBTYPE){ +// array_push($gun_chip,$item); +// } +// } +// return $gun_chip; +// } -// $attr_pool = self::getAttrPool(self::getAttrByItemId($itemMeta['id'])); -// $attr = emptyReplace(json_decode($chip['rand_attr'], true), array()); -// array_push($attr,$attr_pool); -// return $attr; - if ($type == self::ROLE_CHIP_SUBTYPE){ - $chip = self::getNodeChip(); - $attr = $chip[ array_rand($chip)]; - return self::getAttrPool($attr); - } - if ($type == self::GUN_CHIP_SUBTYPE){ - $chip = self::getGunChip(); - $attr = $chip[ array_rand($chip)]; - return self::getAttrPool($attr); - } - return array(); - } - - private static function _randomNum($itemMeta,$chip_grade,$chipList){ - $attr_pool = array(); - array_push($attr_pool,self::getAttrPool(self::getAttrByItemId($itemMeta['id']))); - if ($chip_grade>=3){ - if ($chip_grade<5){ - $num = 1; - } - if ($chip_grade>=5){ - $num = 2; - } - for ($i=1;$i<=$num;$i++){ - $attr = $chipList[ array_rand($chipList)]; - array_push($attr_pool,self::getAttrPool($attr)); - } - } - return $attr_pool ; - } - - private static function getNodeChip(){ - $node_chip = array(); - foreach (self::getMetaList() as $item){ - if ($item['chip_type'] == self::ROLE_CHIP_SUBTYPE){ - array_push($node_chip,$item); - } - } - return $node_chip; - } - - private static function getGunChip(){ - $gun_chip = array(); - foreach (self::getMetaList() as $item){ - if ($item['chip_type'] == self::GUN_CHIP_SUBTYPE){ - array_push($gun_chip,$item); - } - } - return $gun_chip; - } - - private static function getAttrByItemId($item_id){ + public static function getAttrByItemId($item_id){ foreach (self::getMetaList() as $item){ if ($item['item_id'] == $item_id){ return $item; diff --git a/webapp/services/ChipPageService.php b/webapp/services/ChipPageService.php new file mode 100644 index 00000000..b308b82b --- /dev/null +++ b/webapp/services/ChipPageService.php @@ -0,0 +1,57 @@ +_getSelfMysql(), + 't_chip_page', + array( + 'account_id'=> myself()->_getAccountId() + ) + ); + if (!$rows){ + for ($i=0;$irefreshSlotState($row); + } + } + } + + private function refreshSlotState($row){ + $data = emptyReplace(json_decode($row['data'], true), array()); + $userInfo = myself()->_getOrmUserInfo(); + foreach ($data as &$val){ + if ($userInfo['level'] < $val['slot_id'] && $val['state'] == 0){ + $val['state'] = 0; + }else{ + $val['state'] = 1; + } + } + + SqlHelper::update( + myself()->_getSelfMysql(), + 't_chip_page', + array( + 'idx' => $row['idx'] + ), + array( + 'data' => json_encode($data), + ) + ); + } + +} \ No newline at end of file From ab1a340f11c417966cf0c9545bfafcbeeaae50e4 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 21 Feb 2023 16:04:25 +0800 Subject: [PATCH 39/65] 1 --- doc/_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/_common.py b/doc/_common.py index b1aedafb..0a38eb55 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -798,7 +798,7 @@ class Chip(object): ['item_num', 0, '道具数量'], ['chip_grade', 0, '芯片等级'], ['chip_type', 0, '芯片类型:1 攻击;2 防御;3 辅助'], - ['state', 0, '状态:0 免费;1 常规], + ['state', 0, '状态:0 免费;1 常规'], ['supper_state', 0, '是否锁定:0 正常;1 锁住 ---弃用字段'], ['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了 ---弃用字段'], ['!rand_attr', [ChipAttr()], '属性'], From 829d6ab3c4d2f628d0e2ac4ab231666b55a8151c Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 21 Feb 2023 16:05:05 +0800 Subject: [PATCH 40/65] 1 --- doc/_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/_common.py b/doc/_common.py index 0a38eb55..22329419 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -815,7 +815,7 @@ class ChipPro(object): ['item_num', 0, '道具数量'], ['chip_grade', 0, '芯片等级'], ['chip_type', 0, '芯片类型:1 攻击;2 防御;3 辅助'], - ['state', 0, '状态:0 免费;1 常规], + ['state', 0, '状态:0 免费;1 常规'], ['supper_state', 0, '是否锁定:0 正常;1 锁住 ---弃用字段'], ['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了 ---弃用字段'], ['!rand_attr', [ChipAttr()], '属性'], From 400627a4edcfcde6ffee0ccb8af122be09028ab3 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 21 Feb 2023 16:12:52 +0800 Subject: [PATCH 41/65] 1 --- webapp/controller/BaseAuthedController.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 69dfe18e..b60cda98 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -12,6 +12,7 @@ require_once('models/User.php'); require_once('models/Nft.php'); require_once('models/UserSeasonRing.php'); require_once('models/Parachute.php'); +require_once('models/Chip.php'); require_once('mt/Parameter.php'); require_once('mt/RankSeason.php'); @@ -26,6 +27,7 @@ use models\User; use models\Nft; use models\Parachute; use models\UserSeasonRing; +use models\Chip; class BaseAuthedController extends BaseController { @@ -375,6 +377,12 @@ class BaseAuthedController extends BaseController { $propertyService->addUserChg(); } break; + case mt\Item::CHIP_TYPE: + { + Chip::addChip($itemMeta); + $propertyService->addChip(); + } + break; default: { $this->_addLog('additems', 'invalid_item', array( From efed668b2fa2bd10f5f7ebcae525ba81f2048db6 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 23 Feb 2023 15:07:02 +0800 Subject: [PATCH 42/65] =?UTF-8?q?hero=E5=8D=87=E7=BA=A7&&GIFT=E6=A0=87?= =?UTF-8?q?=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Gun.py | 2 +- doc/Hero.py | 16 +++++ doc/_common.py | 6 +- webapp/controller/ChipController.class.php | 4 +- webapp/controller/GunController.class.php | 5 ++ webapp/controller/HeroController.class.php | 77 ++++++++++++++++++++++ webapp/controller/UserController.class.php | 4 +- webapp/models/Chip.php | 23 ++++++- webapp/models/Gun.php | 24 +++++-- webapp/models/Hero.php | 33 ++++++++-- 10 files changed, 171 insertions(+), 23 deletions(-) diff --git a/doc/Gun.py b/doc/Gun.py index c29e42b7..ddaf6573 100644 --- a/doc/Gun.py +++ b/doc/Gun.py @@ -187,7 +187,7 @@ class Gun(object): { 'name': 'getUpgradeQualityList', 'desc': '获取升阶中的枪械列表', - 'group': 'Hero', + 'group': 'Gun', 'url': 'webapp/index.php?c=Hero&a=getUpgradeQualityList', 'params': [ _common.ReqHead(), diff --git a/doc/Hero.py b/doc/Hero.py index 05d6cc02..94613077 100644 --- a/doc/Hero.py +++ b/doc/Hero.py @@ -227,6 +227,22 @@ class Hero(object): _common.RspHead(), ['property_chg', _common.PropertyChg(), '属性变更'], ] + },{ + 'name': 'upgradeLv', + 'desc': '升级', + 'group': 'Hero', + 'url': 'webapp/index.php?c=Hero&a=upgradeLv', + 'params': [ + _common.ReqHead(), + ['hero_uniid', 0, '英雄唯一id'], + ['cost_hero_uniid', 0, '材料英雄id(非必选参数--4|9|14等级必选)'], + ], + 'response': [ + _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], + ['old_hero', _common.Hero(), '英雄-老'], + ['new_hero', _common.Hero(), '英雄-新'], + ] }, ] diff --git a/doc/_common.py b/doc/_common.py index 22329419..c85902af 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -78,7 +78,7 @@ class Gun(object): ['token_id', '', 'token id'], ['gun_uniid', 0, '枪唯一id'], ['gun_id', 0, '枪id'], - ['state', 0, '0:已购买 1:体验中'], + ['state', 0, '0:已购买 1:免费(GIFT标签)'], ['gun_lv', 0, '枪等级'], ['quality', 0, '品阶'], ['durability', 0, '耐久'], @@ -239,7 +239,7 @@ class Hero(object): ['hero_lv', 0, '英雄等级'], ['hero_tili', 0, '英雄体力'], ['hero_tili_max', 0, '英雄最大体力'], - ['state', 0, '0:已购买 1:体验中'], + ['state', 0, '0:已购买 1:免费(GIFT标签)'], ['skin_id', 0, '英雄皮肤id'], ['quality', 0, '品阶'], ['skill_lv1', 0, '主动技能等级'], @@ -798,7 +798,7 @@ class Chip(object): ['item_num', 0, '道具数量'], ['chip_grade', 0, '芯片等级'], ['chip_type', 0, '芯片类型:1 攻击;2 防御;3 辅助'], - ['state', 0, '状态:0 免费;1 常规'], + ['state', 0, '0:已购买 1:免费(GIFT标签)'], ['supper_state', 0, '是否锁定:0 正常;1 锁住 ---弃用字段'], ['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了 ---弃用字段'], ['!rand_attr', [ChipAttr()], '属性'], diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index 2afc2561..a54768c5 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -146,7 +146,7 @@ class ChipController extends BaseAuthedController $this->_rspErr(1, "Unable to use nft chip"); return; } - if (!$chipDbParam['state']) { + if ($chipDbParam['state'] == Chip::FREE_STATE) { $this->_rspErr(1, "Unable to use free chip"); return; } @@ -184,7 +184,7 @@ class ChipController extends BaseAuthedController Chip::update2($idxMain, array( 'chip_grade' => $chipDbMain['chip_grade']+1, - 'state' => 1, + 'state' => Chip::GETED_STATE, 'rand_attr' => json_encode($rand_attr), ) ); diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index d3ee9798..8058a0d5 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -830,6 +830,10 @@ class GunController extends BaseAuthedController { $this->_rspErr(100, 'NFT cannot be a material'); return; } + if ($costGunDb['state'] == Gun::FREE_STATE){ + $this->_rspErr(100, 'Unable to use free gun'); + return; + } if ($gunDb['gun_lv'] != $costGunDb['gun_lv']){ $this->_rspErr(100, 'You need the same level to do it'); return; @@ -859,6 +863,7 @@ class GunController extends BaseAuthedController { Gun::update($gunUniId, array( 'gun_lv' => $gunDb['gun_lv'] + 1, + 'state' => 1, 'rand_attr' => json_encode($attrs), )); Gun::update($costGunUniId, diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 3d27d598..65cec0e5 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -952,4 +952,81 @@ class HeroController extends BaseAuthedController { 'old_hero'=>Hero::toDto($oldHeroDb) )); } + + public function upgradeLv() + { + $heroUniId = getReqVal('hero_uniid', 0); + $costHeroUniId = getReqVal('cost_hero_uniid', 0); + $heroDb = Hero::find($heroUniId); + $oldHero = Hero::toDto($heroDb); + $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'); + return; + } + if ($heroDb['hero_lv'] != $costHeroDb['hero_lv']){ + $this->_rspErr(100, 'You need the same level to do it'); + return; + } + } + $heroMeta = mt\Hero::get($heroDb['hero_id']); + if (!$heroMeta) { + $this->_rspErr(100, 'server internal error'); + return; + } + $nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1); + if (!$nextLevelMeta) { + $this->_rspErr(5, "It's already the highest level"); + return; + } + + //升级所需消耗 +// $costItems = array(); +// $lackItem = null; +// if (!$this->_hasEnoughItems($costItems, $lackItem)) { +// $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); +// return; +// } +// $this->_decItems($costItems); + + $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,1); + Hero::update($heroUniId, array( + 'hero_lv' => $heroDb['hero_lv'] + 1, + 'rand_attr' => json_encode($attrs), + 'state' => Hero::GETED_STATE, + 'skill_points' => $heroDb['skill_points']+$nextLevelMeta['skill_point'] + )); + if ($costHeroDb){ + Hero::update($costHeroUniId, array( + 'account_id' => myself()->_getAccountId() . '!!!', + )); + } + if ($heroDb['hero_lv'] + 1 > myself()->_getV(TN_HERO_MAX_LEVEL, 0)) { + myself()->_setV(TN_HERO_MAX_LEVEL, 0, $heroDb['hero_lv'] + 1); + } + $newHero = Hero::toDto(Hero::find($heroUniId)); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addHeroChg(); + $propertyChgService->addUserChg(); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + 'old_hero' => $oldHero, + 'new_hero' => $newHero, + )); + } } diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index d4cd34e6..e6e2ea1e 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -729,8 +729,8 @@ class UserController extends BaseAuthedController { if ($heroMeta['normal_gift'] && !in_array($heroMeta['normal_gift'],$headList)){ array_push($headList,$heroMeta['normal_gift']); } - Hero::addHero($heroMeta); - Gun::addGun($gunMeta); + Hero::addFreeHero($heroMeta); + Gun::addFreeGun($gunMeta); $fields = array( 'hero_id' => $temp ? $temp[1] : 0, 'head_id' => $temp ? $temp[0] : 0, diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index 6818e759..7edb744a 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -18,6 +18,9 @@ use services\FormulaService; class Chip extends BaseModel { + const GETED_STATE = 0; + const FREE_STATE = 1; + const CHIP_LV_MAX = 3; public static function find($chipUniId) @@ -134,6 +137,7 @@ class Chip extends BaseModel $fieldsKv = array( 'item_id' => $itemMeta['id'], 'item_num' => 1, + 'state' => self::GETED_STATE, 'rand_attr' => json_encode($randAttr), 'chip_grade' => 1, 'chip_type' => $itemMeta['sub_type'], @@ -179,6 +183,16 @@ class Chip extends BaseModel return $dto; } + public static function addFreeChip($itemMeta) + { + + return self::internalAddItem( + myself()->_getSelfMysql(), + $itemMeta, + myself()->_getAccountId(), + null, + self::FREE_STATE); + } public static function addChip($itemMeta) { @@ -187,7 +201,8 @@ class Chip extends BaseModel myself()->_getSelfMysql(), $itemMeta, myself()->_getAccountId(), - null); + null, + self::GETED_STATE); } public static function addNftChip($itemMeta,$tokenId) @@ -197,10 +212,11 @@ class Chip extends BaseModel myself()->_getMysql($tokenId), $itemMeta, null, - $tokenId); + $tokenId, + self::GETED_STATE); } - public static function internalAddItem($conn, $itemMeta, $accountId, $tokenId) + public static function internalAddItem($conn, $itemMeta, $accountId, $tokenId,$state) { if (!$itemMeta) { return; @@ -223,6 +239,7 @@ class Chip extends BaseModel $fieldsKv = array( 'item_id' => $itemMeta['id'], 'item_num' => 1, + 'state' => $state, 'rand_attr' => json_encode($randAttr), 'chip_grade' => 1, 'chip_type' => $itemMeta['sub_type'], diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 0907d789..1da5e03d 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -20,7 +20,7 @@ use models\ChipPlugin; class Gun extends BaseModel { const GETED_STATE = 0; - const TRY_STATE = 1; + const FREE_STATE = 1; const NO_LOCK = 0; const LEVEL_LOCK = 1; @@ -317,13 +317,24 @@ class Gun extends BaseModel { return $dto; } + public static function addFreeGun($gunMeta) + { + return self::internalAddGun( + myself()->_getSelfMysql(), + $gunMeta, + myself()->_getAccountId(), + null, + self::FREE_STATE); + } + public static function addGun($gunMeta) { return self::internalAddGun( myself()->_getSelfMysql(), $gunMeta, myself()->_getAccountId(), - null); + null, + self::GETED_STATE); } public static function addNftGun($gunMeta, $tokenId) @@ -332,10 +343,11 @@ class Gun extends BaseModel { myself()->_getMysql($tokenId), $gunMeta, null, - $tokenId); + $tokenId, + self::GETED_STATE); } - private static function internalAddGun($conn, $gunMeta, $accountId, $tokenId) + private static function internalAddGun($conn, $gunMeta, $accountId, $tokenId,$state) { $randAttr = array(); { @@ -348,7 +360,7 @@ class Gun extends BaseModel { 'gun_id' => $gunMeta['id'], 'gun_lv' => 1, 'quality' => 1, - 'state' => self::GETED_STATE, + 'state' => $state, 'durability' => FormulaService::Weapon_NFT_Maximum_Durability(1,FormulaService::Weapon_Advanced_Lucky_Value(1)), 'rand_attr' => json_encode($randAttr), 'lock_type' => self::NO_LOCK, @@ -396,7 +408,7 @@ class Gun extends BaseModel { 'gun_id' => $gunMeta['id'], 'gun_lv' => 1, 'quality' => 1, - 'state' => self::TRY_STATE, + 'state' => self::FREE_STATE, 'try_count' => $tryCount, 'durability' => $gunMeta['init_durability'], 'rand_attr' => json_encode($randAttr), diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index d85b0fac..0912e944 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -27,13 +27,17 @@ use models\ChipPlugin; class Hero extends BaseModel { const GETED_STATE = 0; - const TRY_STATE = 1; + const FREE_STATE = 1; const NO_LOCK = 0; const LEVEL_LOCK = 1; const QUALITY_LOCK = 2; const SEND_LOCK = 3; const COST_LOCK = 4; + //需要材料所需等级 + const LV_1 = 4; + const LV_2 = 9; + const LV_3 = 14; public static function find($heroUniId) { @@ -48,6 +52,11 @@ class Hero extends BaseModel { 'idx' => $heroUniId, ) ); + if ($row) { + if ($row['account_id'] != myself()->_getAccountId()) { + $row = null; + } + } return $row; } @@ -314,13 +323,24 @@ class Hero extends BaseModel { return $dto; } + public static function addFreeHero($heroMeta) + { + return self::internalAddHero( + myself()->_getSelfMysql(), + $heroMeta, + myself()->_getAccountId(), + null, + self::FREE_STATE); + } + public static function addHero($heroMeta) { return self::internalAddHero( myself()->_getSelfMysql(), $heroMeta, myself()->_getAccountId(), - null); + null, + self::GETED_STATE); } public static function addNftHero($heroMeta, $tokenId) @@ -329,10 +349,11 @@ class Hero extends BaseModel { myself()->_getMysql($tokenId), $heroMeta, null, - $tokenId); + $tokenId, + self::GETED_STATE); } - public static function internalAddHero($conn, $heroMeta, $accountId, $tokenId) + public static function internalAddHero($conn, $heroMeta, $accountId, $tokenId,$state) { $realHeroMeta = mt\Hero::get($heroMeta['id']); $randAttr = array(); @@ -341,7 +362,7 @@ class Hero extends BaseModel { 'hero_lv' => 1, 'quality' => 1, 'hero_tili' => FormulaService::Hero_NFT_Maximum_Physical_Strength(1,FormulaService::Hero_Advanced_Lucky_Value(1)), - 'state' => self::GETED_STATE, + 'state' => $state, 'skill_lv1' => 1, 'skill_lv2' => 1, 'rand_attr' => json_encode($randAttr), @@ -393,7 +414,7 @@ class Hero extends BaseModel { 'hero_lv' => 1, 'quality' => 1, 'hero_tili' => $realHeroMeta ? $realHeroMeta['tili'] : 0, - 'state' => self::TRY_STATE, + 'state' => self::FREE_STATE, 'try_count' => $tryCount, 'skill_lv1' => 1, 'skill_lv2' => 1, From 0f3a63a7796c5d19adce4af893757e84ab823a66 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 23 Feb 2023 15:31:15 +0800 Subject: [PATCH 43/65] 1 --- doc/_common.py | 3 +++ webapp/controller/GunController.class.php | 7 +++++++ webapp/controller/HeroController.class.php | 7 +++++++ webapp/models/Chip.php | 1 + webapp/models/Gun.php | 3 +++ webapp/models/Hero.php | 3 +++ 6 files changed, 24 insertions(+) diff --git a/doc/_common.py b/doc/_common.py index c85902af..fc7d9fe5 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -100,6 +100,7 @@ class Gun(object): ['pvp_ceg_uplimit', 0, 'pvp获取的ceg的上限'], ['pve_ceg_uplimit', 0, 'pve获取的ceg的上限'], ['offer_reward_state', 0, '是否悬赏中'], + ['tags', '', '1:Gen状态'], ] class GunSkin(object): @@ -265,6 +266,7 @@ class Hero(object): ['pvp_ceg_uplimit', 0, 'pvp获取的ceg的上限'], ['pve_ceg_uplimit', 0, 'pve获取的ceg的上限'], ['offer_reward_state', 0, '是否悬赏中'], + ['tags', '', '1:Gen状态'], ] @@ -802,6 +804,7 @@ class Chip(object): ['supper_state', 0, '是否锁定:0 正常;1 锁住 ---弃用字段'], ['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了 ---弃用字段'], ['!rand_attr', [ChipAttr()], '属性'], + ['tags', '', '1:Gen状态'], ] class ChipPro(object): diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index 8058a0d5..dba9c355 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -11,6 +11,7 @@ require_once('models/User.php'); require_once('models/Gun.php'); require_once('models/Bag.php'); require_once('models/Chip.php'); +require_once('models/Nft.php'); require_once('models/NftUpReceive.php'); require_once('models/Transaction.php'); @@ -26,6 +27,7 @@ use models\User; use models\Gun; use models\Bag; use models\Chip; +use models\Nft; use models\NftUpReceive; use models\Transaction; use services\LogService; @@ -61,6 +63,11 @@ class GunController extends BaseAuthedController { $this->_rspErr(1, "You don't have the gun yet"); return; } + $gunDb['tags'] = ''; + if ($gunDb['token_id']){ + $nftDb = Nft::getNft($gunDb['token_id']); + $gunDb['tags'] = $nftDb['tags']; + } $gun = Gun::toDto($gunDb); $this->_rspData(array( diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 65cec0e5..95947538 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -15,6 +15,7 @@ require_once('models/Hero.php'); require_once('models/Bag.php'); require_once('models/HeroSkin.php'); require_once('models/Chip.php'); +require_once('models/Nft.php'); require_once('models/NftUpReceive.php'); require_once('models/Transaction.php'); @@ -30,6 +31,7 @@ use models\Hero; use models\Bag; use models\HeroSkin; use models\Chip; +use models\Nft; use models\NftUpReceive; use models\Transaction; use services\LogService; @@ -59,6 +61,11 @@ class HeroController extends BaseAuthedController { $this->_rspErr(1, "You don't have the hero yet"); return; } + $heroDb['tags'] = ''; + if ($heroDb['token_id']){ + $nftDb = Nft::getNft($heroDb['token_id']); + $heroDb['tags'] = $nftDb['tags']; + } $hero = Hero::toDto($heroDb); $this->_rspData(array( diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index 7edb744a..38c1e38c 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -180,6 +180,7 @@ class Chip extends BaseModel $nft_address = SERVER_ENV == _ONLINE ? '0x73482411443E87CAC124C12A10B34e9Aaa2De168' : '0x26b4AFb60d6C903165150C6F0AA14F8016bE4aec'; } $dto['nft_address'] = $nft_address; + $dto['tags'] = ''; return $dto; } diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 1da5e03d..9c2d4d25 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -156,6 +156,7 @@ class Gun extends BaseModel { 'account_id' => myself()->_getAccountId() ), function ($row) use($cb) { + $row['tags'] = ''; $cb($row); } ); @@ -195,6 +196,7 @@ class Gun extends BaseModel { ) ); } + $row['tags'] = $nftDb['tags']; $cb($row); } } @@ -303,6 +305,7 @@ class Gun extends BaseModel { 'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],2)), //计算ceg上限所需参数 'offer_reward_state' => 0, 'labour' => $row['labour'], + 'tags' => $row['tags'], ); $dto['durability_max'] = strval(round(FormulaService::Weapon_NFT_Maximum_Durability($dto['quality'],$dto['lucky']),3)); $dto['pvp_ceg_uplimit'] = strval( round(FormulaService::getWeaponPvpDailyCegUpLimit($dto),2) ); diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index 0912e944..fce7fd33 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -146,6 +146,7 @@ class Hero extends BaseModel { 'account_id' => myself()->_getAccountId() ), function ($row) use($cb) { + $row['tags'] = ''; $cb($row); } ); @@ -185,6 +186,7 @@ class Hero extends BaseModel { ) ); } + $row['tags'] = $nftDb['tags']; $cb($row); } } @@ -309,6 +311,7 @@ class Hero extends BaseModel { 'skill_points' => $row['skill_points'], 'offer_reward_state' => 0, 'labour' => $row['labour'], + 'tags' => $row['tags'], ); $dto['hero_tili_max'] = strval(round(FormulaService::Hero_NFT_Maximum_Physical_Strength($dto['quality'],$dto['lucky']),3)); $dto['pvp_ceg_uplimit'] =strval( round(FormulaService::getHeroPvpDailyCegUpLimit($dto),2) ); From 833e187541f99f5020a4bfaf6f379e5d32a3b2c4 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Mon, 27 Feb 2023 15:08:25 +0800 Subject: [PATCH 44/65] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E6=8A=80=E8=83=BD?= =?UTF-8?q?=E5=A4=87=E6=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Chip.py | 14 --- doc/HeroSkill.py | 48 +++++++ doc/_common.py | 2 +- sql/gamedb.sql | 19 +++ webapp/controller/ChipController.class.php | 117 +++++++++++------- .../controller/HeroSkillController.class.php | 111 +++++++++++++++++ webapp/models/ChipPage.php | 4 +- webapp/models/Hero.php | 10 ++ webapp/mt/Skill.php | 11 ++ 9 files changed, 272 insertions(+), 64 deletions(-) create mode 100644 doc/HeroSkill.py create mode 100644 webapp/controller/HeroSkillController.class.php diff --git a/doc/Chip.py b/doc/Chip.py index 01c6e3af..73582c88 100644 --- a/doc/Chip.py +++ b/doc/Chip.py @@ -44,19 +44,6 @@ class Chip(object): _common.RspHead(), ['!data', [_common.ChipPro()], '芯片信息'] ] - },{ - 'name': 'selectChip', - 'desc': '选择合成材料', - 'group': 'Chip', - 'url': 'webapp/index.php?c=Chip&a=selectChip', - 'params': [ - _common.ReqHead(), - ['unique_id', '', '芯片unique_id参数 例:参数1源芯片 参数2材料芯片'], - ], - 'response': [ - _common.RspHead(), - ['cost', '', '材料芯片的累计价值'] - ] },{ 'name': 'upgradeLevel', 'desc': '芯片升级', @@ -70,7 +57,6 @@ class Chip(object): 'response': [ _common.RspHead(), ['!data', [_common.Chip()], '芯片信息'], - ['state', 0, '1 成功,0 失败'], ['property_chg', _common.PropertyChg(), '属性变更'], ] }, diff --git a/doc/HeroSkill.py b/doc/HeroSkill.py new file mode 100644 index 00000000..9112e61c --- /dev/null +++ b/doc/HeroSkill.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +import _common + +class HeroSkill(object): + + def __init__(self): + self.apis = [ + { + 'name': 'getSkillList', + 'desc': '技能列表', + 'group': 'HeroSkill', + 'url': 'webapp/index.php?c=HeroSkill&a=getSkillList', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['data', [], '技能itemId'] + ] + },{ + 'name': 'presetHero', + 'desc': '技能预设', + 'group': 'HeroSkill', + 'url': 'webapp/index.php?c=HeroSkill&a=presetHero', + 'params': [ + _common.ReqHead(), + ['skill_id', '0', '技能id'], + ], + 'response': [ + _common.RspHead(), + ['!data', [['item_id',0,'英雄itemId'],['state',0,'1:设置 0:未设置']], '技能itemId'] + ] + },{ + 'name': 'applyHero', + 'desc': '技能应用', + 'group': 'HeroSkill', + 'url': 'webapp/index.php?c=HeroSkill&a=applyHero', + 'params': [ + _common.ReqHead(), + ['skill_id', '0', '技能itemId'], + ['hero_ids', '0', '英雄itemId'], + ], + 'response': [ + _common.RspHead(), + ] + }, + ] diff --git a/doc/_common.py b/doc/_common.py index fc7d9fe5..14d97927 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -823,7 +823,7 @@ class ChipPro(object): ['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了 ---弃用字段'], ['!rand_attr', [ChipAttr()], '属性'], ['!rand_attr_after', [ChipAttr()], '芯片升级后的属性'], - ['upgrade_cost', '', '芯片升级所需价值'], + ['cost',[],'升级所需gold消耗'] ] class BattleMember(object): diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 54fd1c3e..b6df5415 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -976,4 +976,23 @@ CREATE TABLE `t_chip_page` ( PRIMARY KEY (`idx`), UNIQUE KEY `account_page_id` (`account_id`, `page_id`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_hero_skill` +-- + +DROP TABLE IF EXISTS `t_hero_skill`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_hero_skill` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', + `hero_uid` int(11) NOT NULL DEFAULT '0' COMMENT 'hero uniid', + `skill_id` int(11) NOT NULL DEFAULT '0' COMMENT '技能 item_id', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `account_hero_skill` (`account_id`, `hero_uid`, `skill_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; \ No newline at end of file diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index a54768c5..d1440c68 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -29,9 +29,9 @@ class ChipController extends BaseAuthedController { $chipList = array(); Chip::getChipList(function ($row) use(&$chipList){ - if ($row['inlay_state'] != 1){ +// if ($row['inlay_state'] != 1){ array_push($chipList, Chip::toDto($row)); - } +// } }); $this->_rspData(array( 'data' => $chipList, @@ -80,8 +80,26 @@ class ChipController extends BaseAuthedController )); } $chip['rand_attr_after'] = $rand_attr; - $chip['upgrade_cost']=\services\FormulaService::getChipUpgradeCost($chip['chip_grade']+1); - $this->_rspData(['data'=>$chip]); + $paramMeta = mt\Parameter::getByName('chip_upgrade_cost'); + $gold = 0; + if ($paramMeta){ + $paramValue = explode('|',$paramMeta['param_value']); + switch ($chipDb['chip_grade']){ + case 1: { + $gold = $paramValue[0]; + };break; + case 2: { + $gold = $paramValue[1]; + };break; + } + } + $chip['cost'] = array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $gold + ); + $this->_rspData(array( + 'data' => $chip + )); } public function selectChip(){ @@ -115,8 +133,8 @@ class ChipController extends BaseAuthedController public function upgradeLevel(){ $idxMain = trim(getReqVal('unique_id_main', 0)); - $idxParam = array_filter(explode(' ',getReqVal('unique_id_param', 0))); - if (! $idxMain || count($idxParam)<=0 ) { + $idxParam = trim(getReqVal('unique_id_param', 0)); + if (!$idxMain || !$idxParam) { $this->_rspErr(1, 'Please enter parameter'); return; } @@ -129,52 +147,56 @@ class ChipController extends BaseAuthedController $this->_rspErr(1,' Level upper limit'); return; } - $upgrade_cost = \services\FormulaService::getChipUpgradeCost($chipDbMain['chip_grade']+1); - if ( $upgrade_cost == 0 ){ - $this->_rspErr(1, 'Error in calculation formula'); + $chipDbParam = Chip::find($idxParam); + if (!$chipDbParam){ + $this->_rspErr(1,"unique_id_param parameter error"); + return; + } + if ($chipDbParam['token_id']) { + $this->_rspErr(1, "Unable to use nft chip"); + return; + } + if ($chipDbParam['state'] == Chip::FREE_STATE) { + $this->_rspErr(1, "Unable to use free chip"); + return; + } + if ($chipDbParam['chip_grade'] != $chipDbMain['chip_grade']){ + $this->_rspErr(1, "Material chip grade does not meet"); + return; + } + $paramMeta = mt\Parameter::getByName('chip_upgrade_cost'); + $gold = 0; + if ($paramMeta){ + $paramValue = explode('|',$paramMeta['param_value']); + switch ($chipDbMain['chip_grade']){ + case 1: { + $gold = $paramValue[0]; + };break; + case 2: { + $gold = $paramValue[1]; + };break; + } + } + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $gold + ), + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); return; } - $cumulative_cost = 0; - foreach ($idxParam as $val){ - $chipDbParam = Chip::find($val); - if (!$chipDbParam){ - $this->_rspErr(1,"unique_id_param:{$val} parameter error"); - return; - } - if ($chipDbParam['token_id']) { - $this->_rspErr(1, "Unable to use nft chip"); - return; - } - if ($chipDbParam['state'] == Chip::FREE_STATE) { - $this->_rspErr(1, "Unable to use free chip"); - return; - } - if ($chipDbParam['chip_grade']>$chipDbMain['chip_grade']){ - $this->_rspErr(1, "The selected material is too high grade"); - return; - } - $cumulative_cost += \services\FormulaService::getChipCumulativeCost($chipDbParam['chip_grade']); - } - //清除材料芯片 - foreach ($idxParam as $idx){ - Chip::update2($idx, - array( - 'account_id' => myself()->_getAccountId() . '!!!', - ) - ); - } + $this->_decItems($costItems); + Chip::update2($idxParam, + array( + 'account_id' => myself()->_getAccountId() . '!!!', + ) + ); $propertyChgService = new services\PropertyChgService(); $propertyChgService->addChip(); - if (round(1,100) > ($cumulative_cost/$upgrade_cost)*100){ - //合成失败 - $this->_rspData([ - 'state' => 0, - 'property_chg' => $propertyChgService->toDto(), - ]); - return ; - } - $rand_attr = emptyReplace(json_decode($chipDbMain['rand_attr'], true), array()); $attrProMeta = \mt\ChipAttr::getAttrPool($chipDbMain); array_push($rand_attr,array( @@ -191,7 +213,6 @@ class ChipController extends BaseAuthedController $chipDbNew = Chip::toDto(Chip::find($idxMain)); $this->_rspData([ 'data'=>$chipDbNew, - 'state' => 1, 'property_chg' => $propertyChgService->toDto(), ]); } diff --git a/webapp/controller/HeroSkillController.class.php b/webapp/controller/HeroSkillController.class.php new file mode 100644 index 00000000..fb70e076 --- /dev/null +++ b/webapp/controller/HeroSkillController.class.php @@ -0,0 +1,111 @@ +_rspData(array( + 'data' => $list, + )); + } + + public function presetHero(){ + $skillId = getReqVal('skill_id',0); + $skillMeta = \mt\Skill::get($skillId); + if (! $skillMeta){ + $this->_rspErr(1,'skill_id parameter error'); + return ; + } + $heroList = array(); + Hero::getHeroList(function ($row) use(&$heroList) { + array_push($heroList, $row); + }); + $list = array_unique(array_column($heroList,'hero_id')); + $data = array(); + if (count($list) > 0){ + foreach ($list as $value){ + $data[$value] = array( + 'item_id' => $value, + 'state' => 0 + ); + } + } + + $rows = SqlHelper::ormSelect( + $this->_getSelfMysql(), + 't_hero_skill', + array( + 'account_id' => $this->_getAccountId(), + 'skill_id' => $skillId, + ) + ); + if ($rows){ + foreach ($rows as $row){ + $heroDb = Hero::find($row['hero_uid']); + $data[$heroDb['hero_id']]['state'] = 1; + } + } + $this->_rspData(array( + 'data' => $data, + )); + } + + public function applyHero(){ + $skillId = getReqVal('skill_id',0); + $heroIds = getReqVal('hero_ids',''); + $heroIdArr = explode('|',$heroIds); + if (!$skillId || count($heroIdArr)<0){ + $this->_rspErr(1,' parameter error'); + return ; + } + $skillMeta = \mt\Skill::get($skillId); + if (! $skillMeta){ + $this->_rspErr(1,'skill_id parameter error'); + return ; + } + foreach ($heroIdArr as $heroId){ + $heroMeta = \mt\Hero::get($heroId); + if (! $heroMeta){ + $this->_rspErr(1,'hero_id parameter error'); + return ; + } + } + foreach ($heroIdArr as $heroId){ + $heroList = Hero::getHeroByItemId($heroId); + if ($heroList){ + foreach ($heroList as $hero){ + SqlHelper::upsert + ($this->_getSelfMysql(), + 't_hero_skill', + array( + 'account_id' => $this->_getAccountId(), + 'hero_uid' => $hero['idx'], + ), + array( + 'skill_id' => $skillId, + 'modifytime' => $this->_getNowTime(), + ), + array( + 'account_id' => $this->_getAccountId(), + 'hero_uid' => $hero['idx'], + 'skill_id' => $skillId, + 'createtime' => $this->_getNowTime(), + 'modifytime' => $this->_getNowTime(), + + ) + ); + } + } + } + $this->_rspOk(); + } +} \ No newline at end of file diff --git a/webapp/models/ChipPage.php b/webapp/models/ChipPage.php index 401bb5d5..731e72d3 100644 --- a/webapp/models/ChipPage.php +++ b/webapp/models/ChipPage.php @@ -65,9 +65,11 @@ class ChipPage extends BaseModel $newRow = self::find($row['page_id']); $newData = emptyReplace(json_decode($newRow['data'], true), array()); $attrs = array(); - foreach ($newData as $value){ + foreach ($newData as $key=>$value){ + $newData[$key]['item_id'] = 0; if ($value['chip_id']){ $chipDb = Chip::find($value['chip_id']); + $newData[$key]['item_id'] = $chipDb['item_id']; $chipAttrMeta = ChipAttr::getAttrByItemId($chipDb['item_id']); $rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array()); array_push($attrs,array( diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index fce7fd33..1fac48ca 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -812,4 +812,14 @@ class Hero extends BaseModel { } } + public static function getHeroByItemId($itemId){ + $hero = array(); + self::getHeroList(function ($row) use (&$hero,$itemId) { + if ($row['hero_id'] == $itemId) { + array_push($hero,$row); + } + }); + return $hero; + } + } diff --git a/webapp/mt/Skill.php b/webapp/mt/Skill.php index 30fe2a37..3a77df1f 100644 --- a/webapp/mt/Skill.php +++ b/webapp/mt/Skill.php @@ -11,6 +11,17 @@ class Skill { return getXVal(self::getMetaList(), $id); } + public static function getPresetSkill() + { + $list = array(); + foreach (self::getMetaList() as $value){ + if ($value['skill_id'] < 20000){ + array_push($list,$value); + } + } + return $list; + } + protected static function getMetaList() { if (!self::$metaList) { From 0e6ae3983d199f3dd0ec992107abfca1757fd1ca Mon Sep 17 00:00:00 2001 From: hujiabin Date: Mon, 27 Feb 2023 15:11:48 +0800 Subject: [PATCH 45/65] 1 --- doc/HeroSkill.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/HeroSkill.py b/doc/HeroSkill.py index 9112e61c..147b5074 100644 --- a/doc/HeroSkill.py +++ b/doc/HeroSkill.py @@ -29,7 +29,7 @@ class HeroSkill(object): ], 'response': [ _common.RspHead(), - ['!data', [['item_id',0,'英雄itemId'],['state',0,'1:设置 0:未设置']], '技能itemId'] + ['!data', [['item_id',0,'英雄itemId'],['state',0,'1:设置 0:未设置']], '预设英雄信息'] ] },{ 'name': 'applyHero', From 084b2bd9aa91cbd4df0f8c200db715c796aa72f0 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Mon, 27 Feb 2023 15:19:43 +0800 Subject: [PATCH 46/65] 1 --- doc/HeroSkill.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/HeroSkill.py b/doc/HeroSkill.py index 147b5074..767c6d7b 100644 --- a/doc/HeroSkill.py +++ b/doc/HeroSkill.py @@ -39,7 +39,7 @@ class HeroSkill(object): 'params': [ _common.ReqHead(), ['skill_id', '0', '技能itemId'], - ['hero_ids', '0', '英雄itemId'], + ['hero_ids', '0', '英雄itemId 用|分割 例如 xxx|xxx'], ], 'response': [ _common.RspHead(), From 3475b9260c24b86c78e62f492b55db1788061a8e Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 28 Feb 2023 14:58:21 +0800 Subject: [PATCH 47/65] 1 --- doc/ChipPage.py | 18 +++++- sql/gamedb.sql | 21 +------ webapp/controller/ChipController.class.php | 4 ++ .../controller/ChipPageController.class.php | 61 +++++++++++++------ webapp/models/Chip.php | 16 +++++ 5 files changed, 80 insertions(+), 40 deletions(-) diff --git a/doc/ChipPage.py b/doc/ChipPage.py index cc29d477..6871c4e8 100644 --- a/doc/ChipPage.py +++ b/doc/ChipPage.py @@ -71,10 +71,24 @@ class ChipPage(object): ['!data', [_common.ChipPage()], '页信息'] ] },{ - 'name': 'removeChip', + 'name': 'removeChipOne', + 'desc': '芯片移除', + 'group': 'ChipPage', + 'url': 'webapp/index.php?c=ChipPage&a=removeChipOne', + 'params': [ + _common.ReqHead(), + ['page', '', '页id'], + ['slot_id', '', '卡槽id'], + ], + 'response': [ + _common.RspHead(), + ['!data', [_common.ChipPage()], '页信息'] + ] + },{ + 'name': 'removeChipAll', 'desc': '芯片移除(一键移除)', 'group': 'ChipPage', - 'url': 'webapp/index.php?c=ChipPage&a=removeChip', + 'url': 'webapp/index.php?c=ChipPage&a=removeChipAll', 'params': [ _common.ReqHead(), ['page', '', '页id'], diff --git a/sql/gamedb.sql b/sql/gamedb.sql index b6df5415..639a0421 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -164,10 +164,6 @@ CREATE TABLE `t_hero` ( `last_mission_get_ceg_time` bigint NOT NULL DEFAULT '0' COMMENT '最后悬赏任务获取金币的时间', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', - `chip_ids` varchar(100) NOT NULL DEFAULT '' COMMENT '已镶嵌的芯片idx组', - `skill_common` varchar(255) NOT NULL DEFAULT '100100|100120|100140|100160|100180|100200|100220|100240|100260|100280' COMMENT '通用技能', - `skill_points` int(11) NOT NULL DEFAULT '0' COMMENT '技能点', - `labour` int(11) NOT NULL DEFAULT '0' COMMENT '劳力值', `active_token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'active_token_id', `active_count` int(11) NOT NULL DEFAULT '0' COMMENT 'active_count', `activate` int(11) NOT NULL DEFAULT '0' COMMENT '是否激活 1:已初始激活', @@ -242,22 +238,13 @@ CREATE TABLE `t_chip` ( `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', `item_num` int(11) NOT NULL DEFAULT '1' COMMENT '数量', `chip_grade` int(11) NOT NULL DEFAULT '1' COMMENT '芯片等级', - `chip_type` int(11) NOT NULL DEFAULT '1' COMMENT '1:角色芯片 2:武器芯片', - `state` int(11) NOT NULL DEFAULT '0' COMMENT '芯片添加状态:0 正常;1 选择;-1 锁定', - `supper_state` int(11) NOT NULL DEFAULT '0' COMMENT '是否锁定:0 正常;1 锁住', - `inlay_state` int(11) NOT NULL DEFAULT '0' COMMENT '镶嵌状态:0 未镶嵌;1 镶嵌了', + `chip_type` int(11) NOT NULL DEFAULT '1' COMMENT '1 攻击;2 防御;3 辅助', + `state` int(11) NOT NULL DEFAULT '0' COMMENT '0:已购买 1:免费(GIFT标签)', + `inlay_state` varchar(60) COMMENT '所镶嵌的芯片页id:1|2|3', `rand_attr` mediumblob COMMENT '随机属性', - `today_get_gold` bigint NOT NULL DEFAULT '0' COMMENT '金币', - `last_get_gold_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后获取金币的时间', - `lucky_temporary` varchar(10) NOT NULL DEFAULT '0' COMMENT '临时幸运值', - `lucky_final` varchar(10) NOT NULL DEFAULT '0' COMMENT '最终幸运值', - `strength_max` varchar(10) NOT NULL DEFAULT '0' COMMENT '最大体力值', - `strength` varchar(10) NOT NULL DEFAULT '0' COMMENT '前一天体力值', - `upgrade_mint` double NOT NULL DEFAULT '0' COMMENT 'mint费用', `activate` int(11) NOT NULL DEFAULT '0' COMMENT '是否激活 1:已初始激活', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', - `labour` int(11) NOT NULL DEFAULT '0' COMMENT '劳力值', PRIMARY KEY (`idx`), UNIQUE KEY `token_id` (`token_id`), KEY `item_id` (`item_id`), @@ -294,8 +281,6 @@ CREATE TABLE `t_gun` ( `last_mission_get_ceg_time` bigint NOT NULL DEFAULT '0' COMMENT '最后悬赏任务获取金币的时间', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', - `chip_ids` varchar(100) NOT NULL DEFAULT '' COMMENT '已镶嵌的芯片idx组', - `labour` int(11) NOT NULL DEFAULT '0' COMMENT '劳力值', `active_token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'active_token_id', `active_count` int(11) NOT NULL DEFAULT '0' COMMENT 'active_count', `activate` int(11) NOT NULL DEFAULT '0' COMMENT '是否激活 1:已初始激活', diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index d1440c68..dfa04c5d 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -160,6 +160,10 @@ class ChipController extends BaseAuthedController $this->_rspErr(1, "Unable to use free chip"); return; } + if (count(array_filter(explode("|",$chipDbParam['inlay_state']))) > 0){ + $this->_rspErr(1, "The used chip"); + return; + } if ($chipDbParam['chip_grade'] != $chipDbMain['chip_grade']){ $this->_rspErr(1, "Material chip grade does not meet"); return; diff --git a/webapp/controller/ChipPageController.class.php b/webapp/controller/ChipPageController.class.php index 274e90c0..b482565e 100644 --- a/webapp/controller/ChipPageController.class.php +++ b/webapp/controller/ChipPageController.class.php @@ -84,8 +84,6 @@ class ChipPageController extends BaseAuthedController return ; } $data = emptyReplace(json_decode($chipPageDb['data'], true), array()); -// $data[$slotId-1]['chip_id'] = $uniqueId; -// print_r($data);die; if ( $data[$slotId-1]['state'] != 1){ $this->_rspErr(1,'Unlocked state'); return ; @@ -95,7 +93,8 @@ class ChipPageController extends BaseAuthedController $this->_rspErr(1, "You don't have the chip yet"); return; } - if ($chipDb['inlay_state'] == 1){ + + if (in_array($page,array_filter(explode("|",$chipDb['inlay_state'])))){ $this->_rspErr(1, "The used chip"); return; } @@ -105,23 +104,18 @@ class ChipPageController extends BaseAuthedController case 0 : $type = 3;break; default:$type = 0; } + if ($chipDb['chip_type'] != $type){ $this->_rspErr(1, "Type mismatch"); return; } if ( $data[$slotId-1]['chip_id'] ){ - Chip::update2($data[$slotId-1]['chip_id'] , - array( - 'inlay_state' => 0, - ) - ); + + Chip::updateInlayState($data[$slotId-1]['chip_id'],$page); } $data[$slotId-1]['chip_id'] = $uniqueId; - Chip::update2($uniqueId , - array( - 'inlay_state' => 1, - ) - ); + + Chip::updateInlayState($uniqueId,$page); ChipPage::update($page,array( 'data' => json_encode($data) )); @@ -132,8 +126,13 @@ class ChipPageController extends BaseAuthedController )); } - public function removeChip(){ + public function removeChipOne(){ $page = getReqVal('page',0); + $slotId = getReqVal('slot_id',0); + if (!$page || !$slotId){ + $this->_rspErr(1, 'Missing parameter'); + return ; + } $chipPageDb = ChipPage::find($page); if (!$chipPageDb){ $this->_rspErr(1,'page parameter error'); @@ -141,12 +140,8 @@ class ChipPageController extends BaseAuthedController } $data = emptyReplace(json_decode($chipPageDb['data'], true), array()); foreach ($data as &$value){ - if ($value['chip_id']){ - Chip::update2($value['chip_id'] , - array( - 'inlay_state' => 0, - ) - ); + if ($value['slot_id'] == $slotId){ + Chip::updateInlayState($value['chip_id'],$page); $value['chip_id'] = 0; } } @@ -159,4 +154,30 @@ class ChipPageController extends BaseAuthedController 'data' => $chipPageDto, )); } + + public function removeChipAll(){ + $page = getReqVal('page',0); + $chipPageDb = ChipPage::find($page); + if (!$chipPageDb){ + $this->_rspErr(1,'page parameter error'); + return ; + } + $data = emptyReplace(json_decode($chipPageDb['data'], true), array()); + foreach ($data as &$value){ + if ($value['chip_id']){ + Chip::updateInlayState($value['chip_id'],$page); + $value['chip_id'] = 0; + } + } + ChipPage::update($page,array( + 'data' => json_encode($data) + )); + $newChipPageDb = ChipPage::find($page); + $chipPageDto = ChipPage::toDtoInfo($newChipPageDb); + $this->_rspData(array( + 'data' => $chipPageDto, + )); + } + + } \ No newline at end of file diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index 38c1e38c..80f4275f 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -296,6 +296,22 @@ class Chip extends BaseModel ); } + public static function updateInlayState($idx,$page){ + $row = self::find($idx); + if ($row){ + $inlayState = array_filter (explode("|",$row['inlay_state']) ); + if (in_array($page,$inlayState)){ + unset($inlayState[array_search($page,$inlayState)]); + }else{ + array_push($inlayState,$page); + } + self::update2($idx,array( + 'inlay_state' => implode('|',$inlayState) + )); + } + + } + // public static function updateRandAttr($accountId,$chip){ // $attr_pool = mt\ChipAttr::generateOneAttr($chip['chip_type']); From bcf3462c1450973b28995469b63b8606a5854bfc Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 28 Feb 2023 15:12:49 +0800 Subject: [PATCH 48/65] 1 --- webapp/models/Chip.php | 2 -- webapp/models/Gun.php | 14 ++++---------- webapp/models/Hero.php | 28 +++++----------------------- 3 files changed, 9 insertions(+), 35 deletions(-) diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index 80f4275f..8b121f10 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -141,7 +141,6 @@ class Chip extends BaseModel 'rand_attr' => json_encode($randAttr), 'chip_grade' => 1, 'chip_type' => $itemMeta['sub_type'], - 'labour' => 0, 'activate' => 1, 'modifytime' => myself()->_getNowTime() ); @@ -244,7 +243,6 @@ class Chip extends BaseModel 'rand_attr' => json_encode($randAttr), 'chip_grade' => 1, 'chip_type' => $itemMeta['sub_type'], - 'labour' => 0, 'activate' => 1, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime() diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 9c2d4d25..d77afb50 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -224,7 +224,6 @@ class Gun extends BaseModel { 'lock_type' => self::NO_LOCK, 'unlock_time' => 0, 'unlock_trade_time' => 0, - 'labour' => 0, 'activate' => 1, 'modifytime' => myself()->_getNowTime() ); @@ -273,7 +272,6 @@ class Gun extends BaseModel { $todayMissionGetCeg = 0; } $gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($row['quality']); - $chipIds = ChipPlugin::getInlayChip($row['token_id']); $dto = array( 'idx' => $row['idx'], 'token_id' => $row['token_id'], @@ -301,16 +299,13 @@ class Gun extends BaseModel { 'unlock_lefttime' => max(0, $unlockTime - myself()->_getNowTime()), 'unlock_trade_time' => $row['unlock_trade_time'], - 'chip_ids' => $chipIds, - 'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],2)), //计算ceg上限所需参数 'offer_reward_state' => 0, - 'labour' => $row['labour'], 'tags' => $row['tags'], ); - $dto['durability_max'] = strval(round(FormulaService::Weapon_NFT_Maximum_Durability($dto['quality'],$dto['lucky']),3)); - $dto['pvp_ceg_uplimit'] = strval( round(FormulaService::getWeaponPvpDailyCegUpLimit($dto),2) ); - $dto['pve_ceg_uplimit'] = strval( round(FormulaService::getWeaponPveDailyCegUpLimit($dto),2) ); - $dto['mission_ceg_uplimit'] = strval( round(FormulaService::getWeaponMissionDailyCegUpLimit($dto),2) ); +// $dto['durability_max'] = strval(round(FormulaService::Weapon_NFT_Maximum_Durability($dto['quality'],$dto['lucky']),3)); +// $dto['pvp_ceg_uplimit'] = strval( round(FormulaService::getWeaponPvpDailyCegUpLimit($dto),2) ); +// $dto['pve_ceg_uplimit'] = strval( round(FormulaService::getWeaponPveDailyCegUpLimit($dto),2) ); +// $dto['mission_ceg_uplimit'] = strval( round(FormulaService::getWeaponMissionDailyCegUpLimit($dto),2) ); $nft_address = ''; if ($row['token_id']){ @@ -369,7 +364,6 @@ class Gun extends BaseModel { 'lock_type' => self::NO_LOCK, 'unlock_time' => 0, 'unlock_trade_time' => 0, - 'labour' => 0, 'activate' => 1, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime() diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index 1fac48ca..dfc99aaf 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -210,8 +210,6 @@ class Hero extends BaseModel { 'lock_type' => self::NO_LOCK, 'unlock_time' => 0, 'unlock_trade_time' => 0, - 'skill_points' => 0, - 'labour' => 0, 'activate' => 1, 'modifytime' => myself()->_getNowTime() ); @@ -266,15 +264,6 @@ class Hero extends BaseModel { } $attrPro = self::mergeAttrPro($baseAttr,$attrPro1,$attrPro2); } - $skill_common = explode("|",$row['skill_common']); - $attr_skill = []; - foreach ($skill_common as $val){ - $item = mt\SkillCommon::getAttrBySkillCommon($val); - if ($item){ - array_push($attr_skill,$item); - } - } - $chipIds = ChipPlugin::getInlayChip($row['token_id']); $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($row['quality']); $dto = array( 'idx' => $row['idx'], @@ -290,7 +279,7 @@ class Hero extends BaseModel { 'skill_lv2' => $row['skill_lv2'], 'attr_base' => $baseAttr, 'attr_pro' => $attrPro, - 'attr_skill' => $attr_skill, + 'try_count' => $row['try_count'], 'lock_type' => $lockType, 'unlock_time' => $unlockTime, @@ -305,18 +294,13 @@ class Hero extends BaseModel { 'unlock_trade_time' => $row['unlock_trade_time'], 'advanced_count' => $row['advanced_count'], 'lucky' => $heroLucky, - 'chip_ids' => $chipIds, - 'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],1)), //计算ceg上限所需参数 - 'skill_common' => $skill_common, - 'skill_points' => $row['skill_points'], 'offer_reward_state' => 0, - 'labour' => $row['labour'], 'tags' => $row['tags'], ); - $dto['hero_tili_max'] = strval(round(FormulaService::Hero_NFT_Maximum_Physical_Strength($dto['quality'],$dto['lucky']),3)); - $dto['pvp_ceg_uplimit'] =strval( round(FormulaService::getHeroPvpDailyCegUpLimit($dto),2) ); - $dto['pve_ceg_uplimit'] = strval( round(FormulaService::getHeroPveDailyCegUpLimit($dto),2) ); - $dto['mission_ceg_uplimit'] = strval( round(FormulaService::getHeroMissionDailyCegUpLimit($dto),2) ); +// $dto['hero_tili_max'] = strval(round(FormulaService::Hero_NFT_Maximum_Physical_Strength($dto['quality'],$dto['lucky']),3)); +// $dto['pvp_ceg_uplimit'] =strval( round(FormulaService::getHeroPvpDailyCegUpLimit($dto),2) ); +// $dto['pve_ceg_uplimit'] = strval( round(FormulaService::getHeroPveDailyCegUpLimit($dto),2) ); +// $dto['mission_ceg_uplimit'] = strval( round(FormulaService::getHeroMissionDailyCegUpLimit($dto),2) ); $nft_address = ''; if ($row['token_id']){ @@ -372,8 +356,6 @@ class Hero extends BaseModel { 'lock_type' => self::NO_LOCK, 'unlock_time' => 0, 'unlock_trade_time' => 0, - 'skill_points' => 0, - 'labour' => 0, 'activate' => 1, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime() From 8fb2aa81a4b76746938d07c936593b5da3c8fa1c Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 28 Feb 2023 15:21:36 +0800 Subject: [PATCH 49/65] 1 --- doc/_common.py | 14 -------------- webapp/models/Gun.php | 4 ++-- webapp/models/Hero.php | 4 ++-- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/doc/_common.py b/doc/_common.py index 14d97927..a7c5bfe4 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -82,7 +82,6 @@ class Gun(object): ['gun_lv', 0, '枪等级'], ['quality', 0, '品阶'], ['durability', 0, '耐久'], - ['durability_max', 0, '最大耐久'], ['ceg_uplimit', 0, 'ceg今天获取上限'], ['!attr_base', [Attr()], '枪械基础属性'], ['!attr_pro', [Attr()], '枪械升级升阶加成属性'], @@ -95,10 +94,6 @@ class Gun(object): ['current_pve_get_ceg', 0, '当前pve获取的ceg数量'], ['last_pvp_get_ceg_time', 0, '最后一次获取pvp获取ceg时间'], ['last_pve_get_ceg_time', 0, '最后一次获取pve获取ceg时间'], - ['chip_ids', '', '镶嵌的芯片主键id组'], - - ['pvp_ceg_uplimit', 0, 'pvp获取的ceg的上限'], - ['pve_ceg_uplimit', 0, 'pve获取的ceg的上限'], ['offer_reward_state', 0, '是否悬赏中'], ['tags', '', '1:Gen状态'], ] @@ -239,7 +234,6 @@ class Hero(object): ['hero_id', 0, '英雄id'], ['hero_lv', 0, '英雄等级'], ['hero_tili', 0, '英雄体力'], - ['hero_tili_max', 0, '英雄最大体力'], ['state', 0, '0:已购买 1:免费(GIFT标签)'], ['skin_id', 0, '英雄皮肤id'], ['quality', 0, '品阶'], @@ -247,7 +241,6 @@ class Hero(object): ['skill_lv2', 0, '被动技能等级'], ['!attr_base', [Attr()], '英雄基础属性'], ['!attr_pro', [Attr()], '英雄升级升阶提升属性'], - ['!attr_skill', [Attr()], '英雄技能提升属性'], ['try_count', 0, '剩余体验次数 当state=1时才有意义'], ['lock_type', 0, '0:无锁 1:升级 2:升阶 3:派遣中'], ['unlock_lefttime', 0, '解锁剩余时间(单位秒)'], @@ -258,13 +251,6 @@ class Hero(object): ['last_pve_get_ceg_time', 0, '最后一次获取pve获取ceg时间'], ['unlock_trade_time', 0, '出售解锁utc时间(升级或者升阶完成后触发),只锁交易,其他的操作仍可进行,和lock_type无关是独立的锁!!!'], ['advanced_count', 0, '进阶次数'], - ['lukcy', 0, '幸运'], - ['chip_ids', '', '镶嵌的芯片主键id组'], - ['skill_points', '', '技能点'], - - ['!skill_common', [], '通用属性'], - ['pvp_ceg_uplimit', 0, 'pvp获取的ceg的上限'], - ['pve_ceg_uplimit', 0, 'pve获取的ceg的上限'], ['offer_reward_state', 0, '是否悬赏中'], ['tags', '', '1:Gen状态'], diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index d77afb50..1fefab2b 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -271,7 +271,7 @@ class Gun extends BaseModel { if (myself()->_getDaySeconds($lastMissionGetCegTime) < myself()->_getNowDaySeconds()) { $todayMissionGetCeg = 0; } - $gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($row['quality']); +// $gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($row['quality']); $dto = array( 'idx' => $row['idx'], 'token_id' => $row['token_id'], @@ -280,7 +280,7 @@ class Gun extends BaseModel { 'gun_lv' => $row['gun_lv'], 'state' => $row['state'], 'quality' => $row['quality'], - 'lucky' => strval($gunLucky), +// 'lucky' => strval($gunLucky), 'durability' => $row['durability'], 'ceg_uplimit' => 0, 'pve_ceg_uplimit' => 0, diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index dfc99aaf..f0b67a93 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -264,7 +264,7 @@ class Hero extends BaseModel { } $attrPro = self::mergeAttrPro($baseAttr,$attrPro1,$attrPro2); } - $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($row['quality']); +// $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($row['quality']); $dto = array( 'idx' => $row['idx'], 'token_id' => $row['token_id'], @@ -293,7 +293,7 @@ class Hero extends BaseModel { 'last_mission_get_ceg_time' => $lastMissionGetCegTime, 'unlock_trade_time' => $row['unlock_trade_time'], 'advanced_count' => $row['advanced_count'], - 'lucky' => $heroLucky, +// 'lucky' => $heroLucky, 'offer_reward_state' => 0, 'tags' => $row['tags'], ); From 7f55d4e5522379cbf22e34fc9563727684c1a514 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 1 Mar 2023 15:34:47 +0800 Subject: [PATCH 50/65] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E9=A2=84=E8=AE=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Gun.py | 2 +- doc/Hero.py | 29 ++ doc/HeroSkill.py | 28 +- doc/_common.py | 10 + sql/gamedb.sql | 20 +- webapp/controller/GunController.class.php | 41 +- webapp/controller/HeroController.class.php | 546 +++++++++++++-------- webapp/mt/Skill.php | 1 + 8 files changed, 417 insertions(+), 260 deletions(-) diff --git a/doc/Gun.py b/doc/Gun.py index ddaf6573..c87184b3 100644 --- a/doc/Gun.py +++ b/doc/Gun.py @@ -87,7 +87,7 @@ class Gun(object): _common.RspHead(), ['old_gun', _common.Gun(), '枪械-老'], ['new_gun', _common.Gun(), '枪械-新'], - ['cost', _common.Cost(), '所需费用'], + ['!cost', [_common.AwardItem()], '所需费用'], ] }, { diff --git a/doc/Hero.py b/doc/Hero.py index 94613077..780f3811 100644 --- a/doc/Hero.py +++ b/doc/Hero.py @@ -243,6 +243,35 @@ class Hero(object): ['old_hero', _common.Hero(), '英雄-老'], ['new_hero', _common.Hero(), '英雄-新'], ] + },{ + 'name': 'presetHero', + 'desc': '英雄预设', + 'group': 'Hero', + 'url': 'webapp/index.php?c=Hero&a=presetHero', + 'params': [ + _common.ReqHead(), + ['hero_uid', 0, '英雄唯一id'], + ], + 'response': [ + _common.RspHead(), + ['data', _common.HeroPreset(), '预设信息'] + ] + },{ + 'name': 'applyHero', + 'desc': '应用', + 'group': 'Hero', + 'url': 'webapp/index.php?c=Hero&a=applyHero', + 'params': [ + _common.ReqHead(), + ['hero_uid', 0, '英雄唯一id'], + ['skill_id', 0, '技能itemId'], + ['weapon_uid1', 0, '武器1唯一id'], + ['weapon_uid2', 0, '武器2唯一id'], + ['chip_page', 0, '芯片页id'], + ], + 'response': [ + _common.RspHead(), + ] }, ] diff --git a/doc/HeroSkill.py b/doc/HeroSkill.py index 767c6d7b..add8505b 100644 --- a/doc/HeroSkill.py +++ b/doc/HeroSkill.py @@ -18,31 +18,5 @@ class HeroSkill(object): _common.RspHead(), ['data', [], '技能itemId'] ] - },{ - 'name': 'presetHero', - 'desc': '技能预设', - 'group': 'HeroSkill', - 'url': 'webapp/index.php?c=HeroSkill&a=presetHero', - 'params': [ - _common.ReqHead(), - ['skill_id', '0', '技能id'], - ], - 'response': [ - _common.RspHead(), - ['!data', [['item_id',0,'英雄itemId'],['state',0,'1:设置 0:未设置']], '预设英雄信息'] - ] - },{ - 'name': 'applyHero', - 'desc': '技能应用', - 'group': 'HeroSkill', - 'url': 'webapp/index.php?c=HeroSkill&a=applyHero', - 'params': [ - _common.ReqHead(), - ['skill_id', '0', '技能itemId'], - ['hero_ids', '0', '英雄itemId 用|分割 例如 xxx|xxx'], - ], - 'response': [ - _common.RspHead(), - ] - }, + } ] diff --git a/doc/_common.py b/doc/_common.py index a7c5bfe4..d66c5a3f 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1016,4 +1016,14 @@ class ChipPageSlot(object): ['slot_id', 0, '卡槽id'], ['state', 0, '0:未解锁 1:已解锁'], ['chip_id', '', '芯片idx'], + ] + +class HeroPreset(object): + + def __init__(self): + self.fields = [ + ['skill_id', 0, '技能item id'], + ['weapon_uid1', 0, '武器1唯一id'], + ['weapon_uid2', 0, '武器2唯一id'], + ['chip_page', 0, '芯片页id'], ] \ No newline at end of file diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 639a0421..1a4fe4dd 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -964,20 +964,22 @@ CREATE TABLE `t_chip_page` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `t_hero_skill` +-- Table structure for table `t_hero_preset` -- -DROP TABLE IF EXISTS `t_hero_skill`; +DROP TABLE IF EXISTS `t_hero_preset`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `t_hero_skill` ( +CREATE TABLE `t_hero_preset` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', - `hero_uid` int(11) NOT NULL DEFAULT '0' COMMENT 'hero uniid', - `skill_id` int(11) NOT NULL DEFAULT '0' COMMENT '技能 item_id', - `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', - PRIMARY KEY (`idx`), - UNIQUE KEY `account_hero_skill` (`account_id`, `hero_uid`, `skill_id`) + `hero_uid` int(11) NOT NULL DEFAULT 0 COMMENT 'hero uniid', + `skill_id` int(11) NOT NULL DEFAULT 0 COMMENT '技能 item_id', + `weapon_uid1` int(11) NOT NULL DEFAULT 0 COMMENT 'gun uniid1', + `weapon_uid2` int(11) NOT NULL DEFAULT 0 COMMENT 'gun uniid2', + `chip_page` int(11) NOT NULL DEFAULT 0 COMMENT '芯片页id', + `createtime` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间', + PRIMARY KEY (`idx`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; \ No newline at end of file diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index dba9c355..03544e25 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -262,19 +262,29 @@ class GunController extends BaseAuthedController { return; } + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $nextLevelMeta['gold'] + ), + array( + 'item_id' => V_ITEM_DIAMOND, + 'item_num' => $nextLevelMeta['diamond'] + ), + ); + $newGunDb = $gunDb; $newGunDb['gun_lv'] += 1; $attrs = mt\GunLevel::addRandAttrNew($gunDb,0); $newGunDb['rand_attr'] = json_encode($attrs); - $cost['CEG'] = \services\FormulaService::Weapon_Upgrade_CEG_Expend( $newGunDb['gun_lv']); - $cost['CEC'] = \services\FormulaService::Weapon_Upgrade_CEC_Expend( $newGunDb['gun_lv']); + $gunDto = Gun::toDto($gunDb); $newGunDto = Gun::toDto($newGunDb); $this->_rspData(array( 'old_gun' => $gunDto, 'new_gun' => $newGunDto, - 'cost' => $cost + 'cost' => $costItems )); } @@ -858,19 +868,28 @@ class GunController extends BaseAuthedController { } //升级所需消耗 -// $costItems = array(); -// $lackItem = null; -// if (!$this->_hasEnoughItems($costItems, $lackItem)) { -// $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); -// return; -// } -// $this->_decItems($costItems); + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $nextLevelMeta['gold'] + ), + array( + 'item_id' => V_ITEM_DIAMOND, + 'item_num' => $nextLevelMeta['diamond'] + ), + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $this->_decItems($costItems); $attrs = mt\GunLevel::addRandAttrNew($gunDb,1); Gun::update($gunUniId, array( 'gun_lv' => $gunDb['gun_lv'] + 1, - 'state' => 1, + 'state' => Gun::GETED_STATE, 'rand_attr' => json_encode($attrs), )); Gun::update($costGunUniId, diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 95947538..e681506e 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -14,10 +14,11 @@ require_once('mt/Skill.php'); require_once('models/Hero.php'); require_once('models/Bag.php'); require_once('models/HeroSkin.php'); -require_once('models/Chip.php'); require_once('models/Nft.php'); require_once('models/NftUpReceive.php'); require_once('models/Transaction.php'); +require_once('models/ChipPage.php'); +require_once('models/Gun.php'); require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); @@ -30,7 +31,8 @@ use phpcommon\SqlHelper; use models\Hero; use models\Bag; use models\HeroSkin; -use models\Chip; +use models\ChipPage; +use models\Gun; use models\Nft; use models\NftUpReceive; use models\Transaction; @@ -235,9 +237,9 @@ class HeroController extends BaseAuthedController { // $this->_rspData(array( // 'infos' => $infos // )); - $list = NftUpReceive::all(myself()->_getAccountId(),1); - $infos = array(); - foreach ($list as $value){ + $list = NftUpReceive::all(myself()->_getAccountId(),1); + $infos = array(); + foreach ($list as $value){ if ($this->_getNowTime() - $value['createtime'] < 24*3600 && !$value['from_data'] || $value['from_data'] ){ $hero = Hero::findByTokenId2($value['token_id1']); $costHero = Hero::findByTokenId2($value['token_id2']); @@ -261,7 +263,7 @@ class HeroController extends BaseAuthedController { ); array_push($infos,$info); } - } + } $this->_rspData(array( 'infos' => $infos )); @@ -286,40 +288,40 @@ class HeroController extends BaseAuthedController { $oldHero = $heroDto; $newHero = $heroDto; switch ($type) { - case 1: - { - $idx = 0; - $found = false; - for ($i = 0; $i < kMaxHeroUpLevelNum; ++$i) { - $upHeroUniId = $this->_getV(TN_HERO_LEVEL_UP, $i); - if ($upHeroUniId == $heroUniId) { - $idx = $i; - $found = true; - break; - } - } + case 1: + { + $idx = 0; + $found = false; + for ($i = 0; $i < kMaxHeroUpLevelNum; ++$i) { + $upHeroUniId = $this->_getV(TN_HERO_LEVEL_UP, $i); + if ($upHeroUniId == $heroUniId) { + $idx = $i; + $found = true; + break; + } + } - if (!$found) { - $this->_rspErr(1, 'hero does not exist2'); - return; - } - $this->_setV(TN_HERO_LEVEL_UP, $idx, 0); - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addHeroChg(); - $propertyChgService->addBagChg(); - $propertyChgService->addUserChg(); - $nextLevelMeta = null; - $nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1); - if ($nextLevelMeta) { - $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,1); - $where = array( - 'hero_lv' => $heroDb['hero_lv'] + 1, - 'rand_attr' => json_encode($attrs), - 'lock_type' => 0, - 'unlock_time' => 0, - 'skill_points' => $heroDb['skill_points']+$nextLevelMeta['skill_point'] - ); - //免费英雄到底15级后生成NFT + if (!$found) { + $this->_rspErr(1, 'hero does not exist2'); + return; + } + $this->_setV(TN_HERO_LEVEL_UP, $idx, 0); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addHeroChg(); + $propertyChgService->addBagChg(); + $propertyChgService->addUserChg(); + $nextLevelMeta = null; + $nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1); + if ($nextLevelMeta) { + $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,1); + $where = array( + 'hero_lv' => $heroDb['hero_lv'] + 1, + 'rand_attr' => json_encode($attrs), + 'lock_type' => 0, + 'unlock_time' => 0, + 'skill_points' => $heroDb['skill_points']+$nextLevelMeta['skill_point'] + ); + //免费英雄到底15级后生成NFT // if ($heroDb['hero_lv'] + 1 == 15 && !$heroDb['token_id']){ // $token_id = myself()->_getNowTime(); // if(!\services\NftService::addNft($heroDb['hero_id'],$token_id)){ @@ -334,181 +336,181 @@ class HeroController extends BaseAuthedController { // 'skill_points' => $heroDb['skill_points']+$nextLevelMeta['skill_point'] // ); // } - Hero::update($heroUniId, $where); - if ($heroDb['hero_lv'] + 1 > myself()->_getV(TN_HERO_MAX_LEVEL, 0)) { - myself()->_setV(TN_HERO_MAX_LEVEL, 0, $heroDb['hero_lv'] + 1); + Hero::update($heroUniId, $where); + if ($heroDb['hero_lv'] + 1 > myself()->_getV(TN_HERO_MAX_LEVEL, 0)) { + myself()->_setV(TN_HERO_MAX_LEVEL, 0, $heroDb['hero_lv'] + 1); + } + $newHeroDb = Hero::find($heroUniId); + $newHero = Hero::toDto($newHeroDb); } - $newHeroDb = Hero::find($heroUniId); - $newHero = Hero::toDto($newHeroDb); + { + //埋点 + $event = [ + 'name' => LogService::HERO_LEVEL_UP, + ]; + $oldHero['level'] = $oldHero['hero_lv']; + $oldHero['item_id'] = $oldHero['hero_id']; + $newHero['level'] = $newHero['hero_lv']; + $newHero['item_id'] = $newHero['hero_id']; + LogService::LevelUpOrQualityUp($event,$oldHero,$newHero); + } + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + 'old_hero' => $oldHero, + 'new_hero' => $newHero, + )); } - { - //埋点 - $event = [ - 'name' => LogService::HERO_LEVEL_UP, - ]; - $oldHero['level'] = $oldHero['hero_lv']; - $oldHero['item_id'] = $oldHero['hero_id']; - $newHero['level'] = $newHero['hero_lv']; - $newHero['item_id'] = $newHero['hero_id']; - LogService::LevelUpOrQualityUp($event,$oldHero,$newHero); - } - $this->_rspData(array( - 'property_chg' => $propertyChgService->toDto(), - 'old_hero' => $oldHero, - 'new_hero' => $newHero, - )); - } - break; - case 2: - { - $this->_rspOk();return; - $idx = 0; - $found = false; - for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) { - $upHeroUniId = $this->_getV(TN_HERO_QUALITY_UP, $i); - if ($upHeroUniId == $heroUniId) { - $idx = $i; - $found = true; - break; - } - } - if (!$found) { - $this->_rspErr(1, 'hero does not exist'); - return; - } - $costHeroUniId = $this->_getV(TN_HERO_QUALITY_UP, (int)$idx + 1000); - $this->_setV(TN_HERO_QUALITY_UP, $idx, 0); - $this->_setV(TN_HERO_QUALITY_UP, (int)$idx + 1000, 0); - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addHeroChg(); - $propertyChgService->addBagChg(); - $propertyChgService->addUserChg(); - $nextQualityMeta = mt\HeroQuality::getByQuality($heroDb['quality'] + 1); - if ($nextQualityMeta) { - $costHeroDb = Hero::find($costHeroUniId); - if ($costHeroDb['token_id']){ + break; + case 2: + { + $this->_rspOk();return; + $idx = 0; + $found = false; + for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) { + $upHeroUniId = $this->_getV(TN_HERO_QUALITY_UP, $i); + if ($upHeroUniId == $heroUniId) { + $idx = $i; + $found = true; + break; + } + } + if (!$found) { + $this->_rspErr(1, 'hero does not exist'); + return; + } + $costHeroUniId = $this->_getV(TN_HERO_QUALITY_UP, (int)$idx + 1000); + $this->_setV(TN_HERO_QUALITY_UP, $idx, 0); + $this->_setV(TN_HERO_QUALITY_UP, (int)$idx + 1000, 0); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addHeroChg(); + $propertyChgService->addBagChg(); + $propertyChgService->addUserChg(); + $nextQualityMeta = mt\HeroQuality::getByQuality($heroDb['quality'] + 1); + if ($nextQualityMeta) { + $costHeroDb = Hero::find($costHeroUniId); + if ($costHeroDb['token_id']){ // SqlHelper::update( // myself()->_getMarketMysql(), // 't_nft', // ['token_id'=>$costHeroDb['token_id']], // ['deleted'=>1] // ); - }else{ + }else{ + Hero::update($costHeroUniId, + array( + 'account_id' => myself()->_getAccountId() . '!!!', + ) + ); + } Hero::update($costHeroUniId, array( - 'account_id' => myself()->_getAccountId() . '!!!', + 'lock_type' => 0, + 'unlock_time' => 0, ) ); - } - Hero::update($costHeroUniId, - array( - 'lock_type' => 0, - 'unlock_time' => 0, - ) - ); - { - //埋点 - $event = [ - 'name' => LogService::HERO_QUALITY_UP_MATERIAL, - ]; - $params = array( - array( - 'unique_id'=>$costHeroDb['idx'], - 'token_id'=>$costHeroDb['token_id'], - ) - ); - LogService::ConsumableMaterial($event,$params); - } - $rnd = rand(1, 100); - $probability = \services\FormulaService::Hero_Advanced_Probability($heroDb['quality'] + 1)*100; - if ($rnd > $probability) { - Hero::update($heroUniId, - array( - 'advanced_count' => $heroDb['advanced_count'] + 1, - 'lock_type' => 0, - 'unlock_time' => 0, - ) - ); - $oldHero['advanced_count'] += 1; - $newHero['advanced_count'] += 1; { //埋点 $event = [ - 'name' => LogService::HERO_QUALITY_UP, + 'name' => LogService::HERO_QUALITY_UP_MATERIAL, ]; - $oldHero['level'] = $oldHero['hero_lv']; - $oldHero['item_id'] = $oldHero['hero_id']; - $newHero['level'] = $newHero['hero_lv']; - $newHero['item_id'] = $newHero['hero_id']; - LogService::LevelUpOrQualityUp($event,$oldHero,$newHero); + $params = array( + array( + 'unique_id'=>$costHeroDb['idx'], + 'token_id'=>$costHeroDb['token_id'], + ) + ); + LogService::ConsumableMaterial($event,$params); } - $this->_rspRawData(array( - 'errcode' => 0, - 'errmsg' => '', - 'state' => 0, - 'old_hero' => $oldHero, - 'new_hero' => $newHero, - //'errmsg' => 'advance failed', - 'property_chg' => $propertyChgService->toDto(), - )); + $rnd = rand(1, 100); + $probability = \services\FormulaService::Hero_Advanced_Probability($heroDb['quality'] + 1)*100; + if ($rnd > $probability) { + Hero::update($heroUniId, + array( + 'advanced_count' => $heroDb['advanced_count'] + 1, + 'lock_type' => 0, + 'unlock_time' => 0, + ) + ); + $oldHero['advanced_count'] += 1; + $newHero['advanced_count'] += 1; + { + //埋点 + $event = [ + 'name' => LogService::HERO_QUALITY_UP, + ]; + $oldHero['level'] = $oldHero['hero_lv']; + $oldHero['item_id'] = $oldHero['hero_id']; + $newHero['level'] = $newHero['hero_lv']; + $newHero['item_id'] = $newHero['hero_id']; + LogService::LevelUpOrQualityUp($event,$oldHero,$newHero); + } + $this->_rspRawData(array( + 'errcode' => 0, + 'errmsg' => '', + 'state' => 0, + 'old_hero' => $oldHero, + 'new_hero' => $newHero, + //'errmsg' => 'advance failed', + 'property_chg' => $propertyChgService->toDto(), + )); + return; + } + $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($heroDb['quality']); + $nextHeroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($heroDb['quality'] + 1); + $heroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'],$heroLucky); + $nextHeroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'] + 1,$nextHeroLucky); + Hero::update($heroUniId, + array( + 'hero_tili' => $heroDb['hero_tili']+($nextHeroTili-$heroTili), + 'skill_points' => $heroDb['skill_points'] + $nextQualityMeta['skill_point'], + 'quality' => $heroDb['quality'] + 1, + 'advanced_count' => $heroDb['advanced_count'] + 1, + 'lock_type' => 0, + 'unlock_time' => 0, + 'labour' => 0, + ) + ); + if ($heroDb['quality'] + 1 > myself()->_getV(TN_HERO_MAX_QUALITY, 0)) { + myself()->_setV(TN_HERO_MAX_QUALITY, 0, $heroDb['quality'] + 1); + } + $newHeroDb = Hero::find($heroUniId); + $newHero = Hero::toDto($newHeroDb); + error_log(json_encode(array( + 'costHeroUniId' => $costHeroUniId, + 'heroUniId' => $heroUniId + ))); + $rankActivityService = new services\RankActivityService(); + $rankActivityService->heroUpgradeQuality($heroDb['quality'] + 1); + } + if (!$nextQualityMeta) { + $this->_rspErr(1, 'quality is full'); return; } - $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($heroDb['quality']); - $nextHeroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($heroDb['quality'] + 1); - $heroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'],$heroLucky); - $nextHeroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'] + 1,$nextHeroLucky); - Hero::update($heroUniId, - array( - 'hero_tili' => $heroDb['hero_tili']+($nextHeroTili-$heroTili), - 'skill_points' => $heroDb['skill_points'] + $nextQualityMeta['skill_point'], - 'quality' => $heroDb['quality'] + 1, - 'advanced_count' => $heroDb['advanced_count'] + 1, - 'lock_type' => 0, - 'unlock_time' => 0, - 'labour' => 0, - ) - ); - if ($heroDb['quality'] + 1 > myself()->_getV(TN_HERO_MAX_QUALITY, 0)) { - myself()->_setV(TN_HERO_MAX_QUALITY, 0, $heroDb['quality'] + 1); + { + //埋点 + $event = [ + 'name' => LogService::HERO_QUALITY_UP, + ]; + $oldHero['level'] = $oldHero['hero_lv']; + $oldHero['item_id'] = $oldHero['hero_id']; + $newHero['level'] = $newHero['hero_lv']; + $newHero['item_id'] = $newHero['hero_id']; + LogService::LevelUpOrQualityUp($event,$oldHero,$newHero); } - $newHeroDb = Hero::find($heroUniId); - $newHero = Hero::toDto($newHeroDb); - error_log(json_encode(array( - 'costHeroUniId' => $costHeroUniId, - 'heroUniId' => $heroUniId - ))); - $rankActivityService = new services\RankActivityService(); - $rankActivityService->heroUpgradeQuality($heroDb['quality'] + 1); + $this->_rspData(array( + 'state' => 1, + 'property_chg' => $propertyChgService->toDto(), + 'old_hero' => $oldHero, + 'new_hero' => $newHero, + )); } - if (!$nextQualityMeta) { - $this->_rspErr(1, 'quality is full'); - return; - } - { - //埋点 - $event = [ - 'name' => LogService::HERO_QUALITY_UP, - ]; - $oldHero['level'] = $oldHero['hero_lv']; - $oldHero['item_id'] = $oldHero['hero_id']; - $newHero['level'] = $newHero['hero_lv']; - $newHero['item_id'] = $newHero['hero_id']; - LogService::LevelUpOrQualityUp($event,$oldHero,$newHero); - } - $this->_rspData(array( - 'state' => 1, - 'property_chg' => $propertyChgService->toDto(), - 'old_hero' => $oldHero, - 'new_hero' => $newHero, - )); - } - break; - default: - { - $this->_rspErr(1, 'type parameter error'); - return; - } - break; + break; + default: + { + $this->_rspErr(1, 'type parameter error'); + return; + } + break; } } @@ -640,19 +642,31 @@ class HeroController extends BaseAuthedController { $this->_rspErr(5, "It's already the highest level"); return; } + + $meta = mt\HeroLevel::get($heroDb['hero_lv'] + 1); + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $meta['gold'] + ), + array( + 'item_id' => V_ITEM_DIAMOND, + 'item_num' => $meta['diamond'] + ) + ); + $newHeroDb = $heroDb; $newHeroDb['hero_lv'] += 1; $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,0); $newHeroDb['rand_attr'] = json_encode($attrs); - $cost['CEG'] = \services\FormulaService::Hero_Upgrade_CEG_Expend($newHeroDb['hero_lv']); - $cost['CEC'] = \services\FormulaService::Hero_Upgrade_CEC_Expend($newHeroDb['hero_lv']); + $heroDto = Hero::toDto($heroDb); $newHeroDto = Hero::toDto($newHeroDb); $this->_rspData(array( 'old_hero' => $heroDto, 'new_hero' => $newHeroDto, - 'cost' => $cost + 'cost' => $costItems )); } @@ -765,16 +779,16 @@ class HeroController extends BaseAuthedController { $this->_decItems($costItems); Hero::update($heroUniId, - array( - 'lock_type' => Hero::QUALITY_LOCK, - 'unlock_time' => $this->_getNowTime() + $nextQualityMeta['time'], - ) + array( + 'lock_type' => Hero::QUALITY_LOCK, + 'unlock_time' => $this->_getNowTime() + $nextQualityMeta['time'], + ) ); Hero::update($costHeroUniId, - array( - 'lock_type' => Hero::COST_LOCK, - 'unlock_time' => $this->_getNowTime() + $nextQualityMeta['time'], - ) + array( + 'lock_type' => Hero::COST_LOCK, + 'unlock_time' => $this->_getNowTime() + $nextQualityMeta['time'], + ) ); $this->_setV(TN_HERO_QUALITY_UP, (int)$slotId, (int)$heroDb['idx']); $this->_setV(TN_HERO_QUALITY_UP, (int)$slotId + 1000, (int)$costHeroDb['idx']); @@ -1003,20 +1017,29 @@ class HeroController extends BaseAuthedController { } //升级所需消耗 -// $costItems = array(); -// $lackItem = null; -// if (!$this->_hasEnoughItems($costItems, $lackItem)) { -// $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); -// return; -// } -// $this->_decItems($costItems); + $meta = mt\HeroLevel::get($heroDb['hero_lv'] + 1); + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $meta['gold'] + ), + array( + 'item_id' => V_ITEM_DIAMOND, + 'item_num' => $meta['diamond'] + ) + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $this->_decItems($costItems); $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,1); Hero::update($heroUniId, array( 'hero_lv' => $heroDb['hero_lv'] + 1, 'rand_attr' => json_encode($attrs), 'state' => Hero::GETED_STATE, - 'skill_points' => $heroDb['skill_points']+$nextLevelMeta['skill_point'] )); if ($costHeroDb){ Hero::update($costHeroUniId, array( @@ -1036,4 +1059,103 @@ class HeroController extends BaseAuthedController { 'new_hero' => $newHero, )); } + + public function presetHero(){ + $heroId = getReqVal('hero_uid',0); + $heroDb = Hero::find($heroId); + if (! $heroDb){ + $this->_rspErr(1, "You don't have the hero yet"); + return; + } + $row = SqlHelper::ormSelectOne( + $this->_getSelfMysql(), + 't_hero_preset', + array( + 'account_id' => $this->_getAccountId(), + 'hero_uid' => $heroId, + ) + ); + if ($row){ + $data = array( + 'skill_id' => $row['skill_id'], + 'weapon_uid1' => $row['weapon_uid1'], + 'weapon_uid2' => $row['weapon_uid2'], + 'chip_page' => $row['chip_page'], + ); + }else{ + $data = array( + 'skill_id' => \mt\Skill::DEFAULT_SKILL, + 'weapon_uid1' => 0, + 'weapon_uid2' => 0, + 'chip_page' => 1, + ); + } + $this->_rspData(array( + 'data' => $data, + )); + } + + public function applyHero(){ + $heroId = getReqVal('hero_uid',0); + $chipPageId = getReqVal('chip_page',0); + $weaponUid1 = getReqVal('weapon_uid1',0); + $weaponUid2 = getReqVal('weapon_uid2',0); + $skillId = getReqVal('skill_id',0); + $heroDb = Hero::find($heroId); + if (! $heroDb){ + $this->_rspErr(1, "You don't have the hero yet"); + return; + } + $chipPageDb = ChipPage::find($chipPageId); + if (! $chipPageDb){ + $this->_rspErr(1, "You don't have the chip page"); + return; + } + if ($weaponUid1){ + $gunDb1 = Gun::find($weaponUid1); + if (!$gunDb1){ + $this->_rspErr(1, "You don't have the gun1 yet"); + return; + } + } + if ($weaponUid2){ + $gunDb2 = Gun::find($weaponUid2); + if (!$gunDb2){ + $this->_rspErr(1, "You don't have the gun2 yet"); + return; + } + } + $skillMeta = \mt\Skill::get($skillId); + if (! $skillMeta){ + $this->_rspErr(1,'skill_id parameter error'); + return ; + } + SqlHelper::upsert + ($this->_getSelfMysql(), + 't_hero_preset', + array( + 'account_id' => $this->_getAccountId(), + 'hero_uid' => $heroId, + ), + array( + 'skill_id' => $skillId, + 'weapon_uid1' => $weaponUid1, + 'weapon_uid2' => $weaponUid2, + 'chip_page' => $chipPageId, + 'modifytime' => $this->_getNowTime(), + ), + array( + 'account_id' => $this->_getAccountId(), + 'hero_uid' => $heroId, + 'skill_id' => $skillId, + 'weapon_uid1' => $weaponUid1, + 'weapon_uid2' => $weaponUid2, + 'chip_page' => $chipPageId, + 'createtime' => $this->_getNowTime(), + 'modifytime' => $this->_getNowTime(), + + ) + ); + $this->_rspOk(); + } } diff --git a/webapp/mt/Skill.php b/webapp/mt/Skill.php index 3a77df1f..e047f198 100644 --- a/webapp/mt/Skill.php +++ b/webapp/mt/Skill.php @@ -6,6 +6,7 @@ use phpcommon; class Skill { + const DEFAULT_SKILL = 10101; public static function get($id) { return getXVal(self::getMetaList(), $id); From b8e082a83f4c9c2bdf2fdf593a6a1f2771a8e8c8 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 2 Mar 2023 14:22:04 +0800 Subject: [PATCH 51/65] 1 --- webapp/controller/ChipController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index dfa04c5d..feef0d66 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -74,7 +74,7 @@ class ChipController extends BaseAuthedController $rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array()); $chipMeta = mt\ChipAttr::getAttrByItemId($chipDb['item_id']); if ($chipMeta){ - array_push($rand_attr,array( + array_unshift($rand_attr,array( 'attr_id'=>$chipMeta['attr_id'], 'val' => $chipMeta['lv'.($chipDb['chip_grade']+1)] )); From 59ec4c358a051e8f2297717492968ea8380b747e Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 7 Mar 2023 11:34:53 +0800 Subject: [PATCH 52/65] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E7=9A=AE=E8=82=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Hero.py | 1 + doc/_common.py | 11 +- sql/gamedb.sql | 1 + webapp/controller/HeroController.class.php | 559 +++++++++++---------- webapp/models/Hero.php | 46 +- webapp/models/HeroSkin.php | 72 ++- 6 files changed, 391 insertions(+), 299 deletions(-) diff --git a/doc/Hero.py b/doc/Hero.py index 780f3811..62ca56df 100644 --- a/doc/Hero.py +++ b/doc/Hero.py @@ -26,6 +26,7 @@ class Hero(object): 'url': 'webapp/index.php?c=Hero&a=skinList', 'params': [ _common.ReqHead(), + ['hero_id', 0, '英雄itemId'], ], 'response': [ _common.RspHead(), diff --git a/doc/_common.py b/doc/_common.py index d66c5a3f..fd68a533 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -245,10 +245,9 @@ class Hero(object): ['lock_type', 0, '0:无锁 1:升级 2:升阶 3:派遣中'], ['unlock_lefttime', 0, '解锁剩余时间(单位秒)'], ['unlock_time', 0, '使用解锁utc时间(升级或者升阶触发),锁定期间不可战斗和做其他操作,配合lock_type使用'], - ['current_pvp_get_ceg', 0, '当前pvp获取的ceg数量'], - ['current_pve_get_ceg', 0, '当前pve获取的ceg数量'], - ['last_pvp_get_ceg_time', 0, '最后一次获取pvp获取ceg时间'], - ['last_pve_get_ceg_time', 0, '最后一次获取pve获取ceg时间'], + ['current_get_gold', 0, '当前获取的gold数量'], + ['last_get_gold_time', 0, '最后一次获取gold时间'], + ['gold_uplimit', 0, '每天gold上限'], ['unlock_trade_time', 0, '出售解锁utc时间(升级或者升阶完成后触发),只锁交易,其他的操作仍可进行,和lock_type无关是独立的锁!!!'], ['advanced_count', 0, '进阶次数'], ['offer_reward_state', 0, '是否悬赏中'], @@ -289,8 +288,8 @@ class HeroSkin(object): def __init__(self): self.fields = [ ['skin_id', 0, '英雄皮肤id'], - ['skin_state', 0, '英雄皮肤状态 0=已经购,1 = 试用状态'], - ['try_expire_at', 0, '试用到期时间(utc时间)'], + ['is_have', 0, '是否拥有 1:拥有 0:未拥有'], + ['use_state', 0, '选中状态 1:选中 0:未选中'], ] class Item(object): diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 1a4fe4dd..e8712281 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -184,6 +184,7 @@ CREATE TABLE `t_hero_skin` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id', `skin_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤id', + `hero_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄id', `skin_state` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤状态 0=已经购,1 = 试用状态', `get_from` int(11) NOT NULL DEFAULT '0' COMMENT '获得方式 0 = 系统赠送 1 = 金币购买', `consume_num` int(11) NOT NULL DEFAULT '0' COMMENT '消耗货币的具体数量', diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index e681506e..dc1c8ea7 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -75,6 +75,299 @@ class HeroController extends BaseAuthedController { )); } + public function skinList() + { + $heroId = getReqVal('hero_id',0); + if (!$heroId){ + $this->_rspErr(1, "param null"); + return; + } + $itemMeta = \mt\Item::get($heroId); + if (!$itemMeta || $itemMeta['type']!=\mt\Item::HERO_TYPE){ + $this->_rspErr(1, "param error"); + return; + } + $skinList = array(); + $skinMeta = \mt\Item::getMetaListByType(\mt\Item::HERO_SKIN_TYPE); + if ($skinMeta){ + foreach ($skinMeta as $value){ + if ($value['playerid'] == $heroId){ + array_push($skinList,HeroSkin::toDto($value)); + } + } + } + $this->_rspData(array( + 'skin_list' => $skinList + )); + } + + public function takeonSkin() + { + $heroUniId = getReqVal('hero_uniid', 0); + $skinId = getReqVal('skin_id', 0); + $heroDb = Hero::find($heroUniId); + $heroSkinDb = HeroSkin::find($skinId); + if (!$heroDb) { + $this->_rspErr(1, "You don't have the hero yet"); + return; + } + if (!$heroSkinDb) { + $this->_rspErr(2, "You don't have the skin yet"); + return; + } + HeroSkin::takeonSkin( $skinId,$heroDb['hero_id']); + $this->_rspOk(); + } + + public function upgradeLevelPreview(){ + $heroUniId = getReqVal('hero_uniid', 0); + $heroDb = Hero::find($heroUniId); + if (!$heroDb) { + $this->_rspErr(1, 'hero does not exist'); + return; + } + $heroMeta = mt\Hero::get($heroDb['hero_id']); + if (!$heroMeta) { + $this->_rspErr(100, 'server internal error'); + return; + } + $nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1); + if (!$nextLevelMeta) { + $this->_rspErr(5, "It's already the highest level"); + return; + } + + $meta = mt\HeroLevel::get($heroDb['hero_lv'] + 1); + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $meta['gold'] + ), + array( + 'item_id' => V_ITEM_DIAMOND, + 'item_num' => $meta['diamond'] + ) + ); + + $newHeroDb = $heroDb; + $newHeroDb['hero_lv'] += 1; + $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,0); + $newHeroDb['rand_attr'] = json_encode($attrs); + + $heroDto = Hero::toDto($heroDb); + $newHeroDto = Hero::toDto($newHeroDb); + $this->_rspData(array( + + 'old_hero' => $heroDto, + 'new_hero' => $newHeroDto, + 'cost' => $costItems + )); + } + + public function upgradeLv() + { + $heroUniId = getReqVal('hero_uniid', 0); + $costHeroUniId = getReqVal('cost_hero_uniid', 0); + $heroDb = Hero::find($heroUniId); + $oldHero = Hero::toDto($heroDb); + $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'); + 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'); + return; + } + $nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1); + if (!$nextLevelMeta) { + $this->_rspErr(5, "It's already the highest level"); + return; + } + + //升级所需消耗 + $meta = mt\HeroLevel::get($heroDb['hero_lv'] + 1); + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $meta['gold'] + ), + array( + 'item_id' => V_ITEM_DIAMOND, + 'item_num' => $meta['diamond'] + ) + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $this->_decItems($costItems); + + $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,1); + Hero::update($heroUniId, array( + 'hero_lv' => $heroDb['hero_lv'] + 1, + 'rand_attr' => json_encode($attrs), + 'state' => Hero::GETED_STATE, + )); + if ($costHeroDb){ + Hero::update($costHeroUniId, array( + 'account_id' => myself()->_getAccountId() . '!!!', + )); + } + if ($heroDb['hero_lv'] + 1 > myself()->_getV(TN_HERO_MAX_LEVEL, 0)) { + myself()->_setV(TN_HERO_MAX_LEVEL, 0, $heroDb['hero_lv'] + 1); + } + $newHero = Hero::toDto(Hero::find($heroUniId)); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addHeroChg(); + $propertyChgService->addUserChg(); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + 'old_hero' => $oldHero, + 'new_hero' => $newHero, + )); + } + + public function presetHero(){ + $heroId = getReqVal('hero_uid',0); + $heroDb = Hero::find($heroId); + if (! $heroDb){ + $this->_rspErr(1, "You don't have the hero yet"); + return; + } + $row = SqlHelper::ormSelectOne( + $this->_getSelfMysql(), + 't_hero_preset', + array( + 'account_id' => $this->_getAccountId(), + 'hero_uid' => $heroId, + ) + ); + if ($row){ + $data = array( + 'skill_id' => $row['skill_id'], + 'weapon_uid1' => $row['weapon_uid1'], + 'weapon_uid2' => $row['weapon_uid2'], + 'chip_page' => $row['chip_page'], + ); + }else{ + $data = array( + 'skill_id' => \mt\Skill::DEFAULT_SKILL, + 'weapon_uid1' => 0, + 'weapon_uid2' => 0, + 'chip_page' => 1, + ); + } + $this->_rspData(array( + 'data' => $data, + )); + } + + public function applyHero(){ + $heroId = getReqVal('hero_uid',0); + $chipPageId = getReqVal('chip_page',0); + $weaponUid1 = getReqVal('weapon_uid1',0); + $weaponUid2 = getReqVal('weapon_uid2',0); + $skillId = getReqVal('skill_id',0); + $heroDb = Hero::find($heroId); + if (! $heroDb){ + $this->_rspErr(1, "You don't have the hero yet"); + return; + } + $chipPageDb = ChipPage::find($chipPageId); + if (! $chipPageDb){ + $this->_rspErr(1, "You don't have the chip page"); + return; + } + if ($weaponUid1){ + $gunDb1 = Gun::find($weaponUid1); + if (!$gunDb1){ + $this->_rspErr(1, "You don't have the gun1 yet"); + return; + } + } + if ($weaponUid2){ + $gunDb2 = Gun::find($weaponUid2); + if (!$gunDb2){ + $this->_rspErr(1, "You don't have the gun2 yet"); + return; + } + } + $skillMeta = \mt\Skill::get($skillId); + if (! $skillMeta){ + $this->_rspErr(1,'skill_id parameter error'); + return ; + } + SqlHelper::upsert + ($this->_getSelfMysql(), + 't_hero_preset', + array( + 'account_id' => $this->_getAccountId(), + 'hero_uid' => $heroId, + ), + array( + 'skill_id' => $skillId, + 'weapon_uid1' => $weaponUid1, + 'weapon_uid2' => $weaponUid2, + 'chip_page' => $chipPageId, + 'modifytime' => $this->_getNowTime(), + ), + array( + 'account_id' => $this->_getAccountId(), + 'hero_uid' => $heroId, + 'skill_id' => $skillId, + 'weapon_uid1' => $weaponUid1, + 'weapon_uid2' => $weaponUid2, + 'chip_page' => $chipPageId, + 'createtime' => $this->_getNowTime(), + 'modifytime' => $this->_getNowTime(), + + ) + ); + $this->_rspOk(); + } + + + + public function upgradeSkillCommon(){ $heroUniId = getReqVal('hero_uniid', 0); $skillIndex = getReqVal('skill_index', 0); @@ -157,42 +450,6 @@ class HeroController extends BaseAuthedController { )); } - public function skinList() - { - $skinList = array(); - SqlHelper::ormSelect( - $this->_getSelfMysql(), - 't_hero_skin', - array( - 'account_id' => $this->_getAccountId() - ), - function ($row) use(&$skinList) { - array_push($skinList, HeroSkin::toDto($row)); - } - ); - $this->_rspData(array( - 'skin_list' => $skinList - )); - } - - public function takeonSkin() - { - $heroUniId = getReqVal('hero_uniid', 0); - $skinId = getReqVal('skin_id', 0); - $heroDb = Hero::find($heroUniId); - $heroSkinDb = HeroSkin::find($skinId); - if (!$heroDb) { - $this->_rspErr(1, "You don't have the hero yet"); - return; - } - if (!$heroSkinDb) { - $this->_rspErr(2, "You don't have the skin yet"); - return; - } - Hero::takeonSkin($heroUniId, $skinId); - $this->_rspOk(); - } - public function getUpgradeLevelList() { $infos = array(); @@ -625,51 +882,6 @@ class HeroController extends BaseAuthedController { )); } - public function upgradeLevelPreview(){ - $heroUniId = getReqVal('hero_uniid', 0); - $heroDb = Hero::find($heroUniId); - if (!$heroDb) { - $this->_rspErr(1, 'hero does not exist'); - return; - } - $heroMeta = mt\Hero::get($heroDb['hero_id']); - if (!$heroMeta) { - $this->_rspErr(100, 'server internal error'); - return; - } - $nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1); - if (!$nextLevelMeta) { - $this->_rspErr(5, "It's already the highest level"); - return; - } - - $meta = mt\HeroLevel::get($heroDb['hero_lv'] + 1); - $costItems = array( - array( - 'item_id' => V_ITEM_GOLD, - 'item_num' => $meta['gold'] - ), - array( - 'item_id' => V_ITEM_DIAMOND, - 'item_num' => $meta['diamond'] - ) - ); - - $newHeroDb = $heroDb; - $newHeroDb['hero_lv'] += 1; - $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,0); - $newHeroDb['rand_attr'] = json_encode($attrs); - - $heroDto = Hero::toDto($heroDb); - $newHeroDto = Hero::toDto($newHeroDb); - $this->_rspData(array( - - 'old_hero' => $heroDto, - 'new_hero' => $newHeroDto, - 'cost' => $costItems - )); - } - public function upgradeQualityOld() { $costHeroUniId = getReqVal('cost_hero_uniid', 0); @@ -973,189 +1185,4 @@ class HeroController extends BaseAuthedController { 'old_hero'=>Hero::toDto($oldHeroDb) )); } - - public function upgradeLv() - { - $heroUniId = getReqVal('hero_uniid', 0); - $costHeroUniId = getReqVal('cost_hero_uniid', 0); - $heroDb = Hero::find($heroUniId); - $oldHero = Hero::toDto($heroDb); - $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'); - return; - } - if ($heroDb['hero_lv'] != $costHeroDb['hero_lv']){ - $this->_rspErr(100, 'You need the same level to do it'); - return; - } - } - $heroMeta = mt\Hero::get($heroDb['hero_id']); - if (!$heroMeta) { - $this->_rspErr(100, 'server internal error'); - return; - } - $nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1); - if (!$nextLevelMeta) { - $this->_rspErr(5, "It's already the highest level"); - return; - } - - //升级所需消耗 - $meta = mt\HeroLevel::get($heroDb['hero_lv'] + 1); - $costItems = array( - array( - 'item_id' => V_ITEM_GOLD, - 'item_num' => $meta['gold'] - ), - array( - 'item_id' => V_ITEM_DIAMOND, - 'item_num' => $meta['diamond'] - ) - ); - $lackItem = null; - if (!$this->_hasEnoughItems($costItems, $lackItem)) { - $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); - return; - } - $this->_decItems($costItems); - - $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,1); - Hero::update($heroUniId, array( - 'hero_lv' => $heroDb['hero_lv'] + 1, - 'rand_attr' => json_encode($attrs), - 'state' => Hero::GETED_STATE, - )); - if ($costHeroDb){ - Hero::update($costHeroUniId, array( - 'account_id' => myself()->_getAccountId() . '!!!', - )); - } - if ($heroDb['hero_lv'] + 1 > myself()->_getV(TN_HERO_MAX_LEVEL, 0)) { - myself()->_setV(TN_HERO_MAX_LEVEL, 0, $heroDb['hero_lv'] + 1); - } - $newHero = Hero::toDto(Hero::find($heroUniId)); - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addHeroChg(); - $propertyChgService->addUserChg(); - $this->_rspData(array( - 'property_chg' => $propertyChgService->toDto(), - 'old_hero' => $oldHero, - 'new_hero' => $newHero, - )); - } - - public function presetHero(){ - $heroId = getReqVal('hero_uid',0); - $heroDb = Hero::find($heroId); - if (! $heroDb){ - $this->_rspErr(1, "You don't have the hero yet"); - return; - } - $row = SqlHelper::ormSelectOne( - $this->_getSelfMysql(), - 't_hero_preset', - array( - 'account_id' => $this->_getAccountId(), - 'hero_uid' => $heroId, - ) - ); - if ($row){ - $data = array( - 'skill_id' => $row['skill_id'], - 'weapon_uid1' => $row['weapon_uid1'], - 'weapon_uid2' => $row['weapon_uid2'], - 'chip_page' => $row['chip_page'], - ); - }else{ - $data = array( - 'skill_id' => \mt\Skill::DEFAULT_SKILL, - 'weapon_uid1' => 0, - 'weapon_uid2' => 0, - 'chip_page' => 1, - ); - } - $this->_rspData(array( - 'data' => $data, - )); - } - - public function applyHero(){ - $heroId = getReqVal('hero_uid',0); - $chipPageId = getReqVal('chip_page',0); - $weaponUid1 = getReqVal('weapon_uid1',0); - $weaponUid2 = getReqVal('weapon_uid2',0); - $skillId = getReqVal('skill_id',0); - $heroDb = Hero::find($heroId); - if (! $heroDb){ - $this->_rspErr(1, "You don't have the hero yet"); - return; - } - $chipPageDb = ChipPage::find($chipPageId); - if (! $chipPageDb){ - $this->_rspErr(1, "You don't have the chip page"); - return; - } - if ($weaponUid1){ - $gunDb1 = Gun::find($weaponUid1); - if (!$gunDb1){ - $this->_rspErr(1, "You don't have the gun1 yet"); - return; - } - } - if ($weaponUid2){ - $gunDb2 = Gun::find($weaponUid2); - if (!$gunDb2){ - $this->_rspErr(1, "You don't have the gun2 yet"); - return; - } - } - $skillMeta = \mt\Skill::get($skillId); - if (! $skillMeta){ - $this->_rspErr(1,'skill_id parameter error'); - return ; - } - SqlHelper::upsert - ($this->_getSelfMysql(), - 't_hero_preset', - array( - 'account_id' => $this->_getAccountId(), - 'hero_uid' => $heroId, - ), - array( - 'skill_id' => $skillId, - 'weapon_uid1' => $weaponUid1, - 'weapon_uid2' => $weaponUid2, - 'chip_page' => $chipPageId, - 'modifytime' => $this->_getNowTime(), - ), - array( - 'account_id' => $this->_getAccountId(), - 'hero_uid' => $heroId, - 'skill_id' => $skillId, - 'weapon_uid1' => $weaponUid1, - 'weapon_uid2' => $weaponUid2, - 'chip_page' => $chipPageId, - 'createtime' => $this->_getNowTime(), - 'modifytime' => $this->_getNowTime(), - - ) - ); - $this->_rspOk(); - } } diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index f0b67a93..6d599fda 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -5,6 +5,7 @@ namespace models; require_once('mt/Hero.php'); require_once('mt/HeroLevelAttr.php'); require_once('mt/HeroQuality.php'); +require_once('mt/HeroLevel.php'); require_once('mt/AttrHelper.php'); require_once('mt/Item.php'); require_once('mt/SkillCommon.php'); @@ -231,24 +232,24 @@ class Hero extends BaseModel { $unlockTime = $row['unlock_time']; } - $qualityMeta = mt\HeroQuality::getByQuality($row['quality']); + $levelMeta = mt\HeroLevel::getByLevel($row['hero_lv']); $todayGetGold = $row['today_get_gold']; $lastGetGoldTime = $row['last_get_gold_time']; if (myself()->_getDaySeconds($lastGetGoldTime) < myself()->_getNowDaySeconds()) { $todayGetGold = 0; } - $todayPveGetCeg = $row['today_pve_get_ceg']; - $lastPveGetCegTime = $row['last_pve_get_ceg_time']; - if (myself()->_getDaySeconds($lastPveGetCegTime) < - myself()->_getNowDaySeconds()) { - $todayPveGetCeg = 0; - } - $todayMissionGetCeg = $row['today_mission_get_ceg']; - $lastMissionGetCegTime = $row['last_mission_get_ceg_time']; - if (myself()->_getDaySeconds($lastMissionGetCegTime) < myself()->_getNowDaySeconds()) { - $todayMissionGetCeg = 0; - } +// $todayPveGetCeg = $row['today_pve_get_ceg']; +// $lastPveGetCegTime = $row['last_pve_get_ceg_time']; +// if (myself()->_getDaySeconds($lastPveGetCegTime) < +// myself()->_getNowDaySeconds()) { +// $todayPveGetCeg = 0; +// } +// $todayMissionGetCeg = $row['today_mission_get_ceg']; +// $lastMissionGetCegTime = $row['last_mission_get_ceg_time']; +// if (myself()->_getDaySeconds($lastMissionGetCegTime) < myself()->_getNowDaySeconds()) { +// $todayMissionGetCeg = 0; +// } $baseAttr=[]; $attrPro=[]; $heroMeta = mt\Hero::get($row['hero_id']); @@ -285,12 +286,13 @@ class Hero extends BaseModel { 'unlock_time' => $unlockTime, 'unlock_lefttime' => max(0, $unlockTime - myself()->_getNowTime()), - 'current_pvp_get_ceg' => $todayGetGold / 100, - 'last_pvp_get_ceg_time' => $lastGetGoldTime, - 'current_pve_get_ceg' => $todayPveGetCeg / 100, - 'last_pve_get_ceg_time' => $lastPveGetCegTime, - 'current_mission_get_ceg' => $todayMissionGetCeg / 100, - 'last_mission_get_ceg_time' => $lastMissionGetCegTime, + 'current_get_gold' => $todayGetGold / 100, + 'last_get_gold_time' => $lastGetGoldTime, + 'gold_uplimit' => $levelMeta['gold_limit'], +// 'current_pve_get_ceg' => $todayPveGetCeg / 100, +// 'last_pve_get_ceg_time' => $lastPveGetCegTime, +// 'current_mission_get_ceg' => $todayMissionGetCeg / 100, +// 'last_mission_get_ceg_time' => $lastMissionGetCegTime, 'unlock_trade_time' => $row['unlock_trade_time'], 'advanced_count' => $row['advanced_count'], // 'lucky' => $heroLucky, @@ -342,6 +344,14 @@ class Hero extends BaseModel { public static function internalAddHero($conn, $heroMeta, $accountId, $tokenId,$state) { + $skinItemMeta = \mt\Item::getMetaListByType(\mt\Item::HERO_SKIN_TYPE); + if ($skinItemMeta){ + foreach ($skinItemMeta as $value){ + if ($value['playerid'] == $heroMeta['id'] && $value['isdefaultskin'] ==1){ + HeroSkin::addSkin($value); + } + } + } $realHeroMeta = mt\Hero::get($heroMeta['id']); $randAttr = array(); $fieldsKv = array( diff --git a/webapp/models/HeroSkin.php b/webapp/models/HeroSkin.php index b6db2bd9..9fc0db9e 100644 --- a/webapp/models/HeroSkin.php +++ b/webapp/models/HeroSkin.php @@ -25,13 +25,69 @@ class HeroSkin extends BaseModel { return $row; } - public static function toDto($row) + public static function findBx($heroId) { - return array( - 'skin_id' => $row['skin_id'], - 'skin_state' => $row['skin_state'], - 'try_expire_at' => $row['try_expire_at'], + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_hero_skin', + array( + 'account_id' => myself()->_getAccountId(), + 'hero_id' => $heroId + ) ); + return $row; + } + + public static function takeonSkin($skinId,$heroId){ + $row = self::findBx($heroId); + SqlHelper::update( + myself()->_getSelfMysql(), + 't_hero_skin', + array( + 'account_id' => myself()->_getAccountId(), + 'skin_id' => $row['skin_id'] + ), + array( + 'hero_id'=>0 + ) + ); + SqlHelper::update( + myself()->_getSelfMysql(), + 't_hero_skin', + array( + 'account_id' => myself()->_getAccountId(), + 'skin_id' => $skinId + ), + array( + 'hero_id'=>$heroId + ) + ); + } + + + public static function getSkinList($cb){ + SqlHelper::ormSelect( + myself()->_getSelfMysql(), + 't_hero_skin', + array( + 'account_id' => myself()->_getAccountId() + ), + function ($row) use($cb) { + $cb($row); + } + ); + } + + + public static function toDto($meta) + { + $row = self::find($meta['id']); + $array = array( + 'skin_id'=>$meta['id'], + 'is_have' => $row?1:0, + 'use_state' => $row['hero_id']?1:0, + ); + return $array; } public static function addSkin($itemMeta) @@ -43,10 +99,7 @@ class HeroSkin extends BaseModel { 'account_id' => myself()->_getAccountId(), 'skin_id' => $itemMeta['id'] ), - array( - 'skin_state' => 3, - 'modifytime' => myself()->_getNowTime() - ), + array(), array( 'account_id' => myself()->_getAccountId(), 'skin_id' => $itemMeta['id'], @@ -54,6 +107,7 @@ class HeroSkin extends BaseModel { 'get_from' => 0, 'consume_num' => 0, 'try_expire_at' => 0, + 'hero_id' => $itemMeta['isdefaultskin']?$itemMeta['playerid']:0, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime() ) From 9ad9ff6455e17939b5aa835ca8bcbce5c4720fdb Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 7 Mar 2023 11:38:53 +0800 Subject: [PATCH 53/65] 1 --- doc/Gun.py | 109 +------------------------------------ doc/Hero.py | 151 ---------------------------------------------------- 2 files changed, 1 insertion(+), 259 deletions(-) diff --git a/doc/Gun.py b/doc/Gun.py index c87184b3..68413646 100644 --- a/doc/Gun.py +++ b/doc/Gun.py @@ -59,21 +59,7 @@ class Gun(object): ['!gun_list', [_common.Gun()], '枪械列表'] ] }, - { - 'name': 'upgradeLevel', - 'desc': '升等级', - 'group': 'Gun', - 'url': 'webapp/index.php?c=Gun&a=upgradeLevel', - 'params': [ - _common.ReqHead(), - ['gun_uniid', 0, '枪械唯一id'], - ['slot_id', 0, '槽id(0-1)'], - ], - 'response': [ - _common.RspHead(), - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - }, + { 'name': 'upgradeLevelPreview', 'desc': '升等级', @@ -90,86 +76,6 @@ class Gun(object): ['!cost', [_common.AwardItem()], '所需费用'], ] }, - { - 'name': 'upgradeQualityOld', - 'desc': '升阶', - 'group': 'Gun', - 'url': 'webapp/index.php?c=Gun&a=upgradeQualityOld', - 'params': [ - _common.ReqHead(), - ['gun_uniid', 0, '枪械唯一id'], - ['cost_hero_uniid', 0, '耗材英雄唯一id'], - ['slot_id', 0, '槽id(0-1)'], - ], - 'response': [ - _common.RspHead(), - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - }, - { - 'name': 'upgradeQuality', - 'desc': '升阶', - 'group': 'Gun', - 'url': 'webapp/index.php?c=Gun&a=upgradeQuality', - 'params': [ - _common.ReqHead(), - ['trans_id', 0, 'transId'], - ['token_id1', 0, '枪械token'], - ['token_id2', 0, '耗材枪械token'], - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'name': 'upgradeQualityPreview', - 'desc': '升阶', - 'group': 'Gun', - 'url': 'webapp/index.php?c=Gun&a=upgradeQualityPreview', - 'params': [ - _common.ReqHead(), - ['gun_uniid', 0, '枪械唯一id'], - ['cost_gun_uniid', 0, '耗材枪械唯一id'], - ], - 'response': [ - _common.RspHead(), - ['old_gun', _common.Gun(), '枪械-老'], - ['new_gun', _common.Gun(), '枪械-新'], - ['cost', _common.Cost(), '所需费用'], - ] - }, - { - 'name': 'receiveUpgradeQuality', - 'desc': '获取升阶后的武器', - 'group': 'Gun', - 'url': 'webapp/index.php?c=Gun&a=receiveUpgradeQuality', - 'params': [ - _common.ReqHead(), - ['trans_id', 0, 'transId'], - ['token_id', 0, '枪械token'], - ], - 'response': [ - _common.RspHead(), - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - }, - { - 'name': 'receive', - 'desc': '获取升级、升阶后的武器', - 'group': 'Gun', - 'url': 'webapp/index.php?c=Gun&a=receive', - 'params': [ - _common.ReqHead(), - ['type', 0, '1:领取升级 2:领取升阶'], - ['gun_uniid', 0, '枪械唯一id'], - ], - 'response': [ - _common.RspHead(), - ['state', 0, '0:失败 1:成功'], - ['old_hero', _common.Gun(), '枪械-老'], - ['new_hero', _common.Gun(), '枪械-新'], - ] - }, { 'name': 'gunDetails', 'desc': '武器详情', @@ -184,19 +90,6 @@ class Gun(object): ['!data', [_common.Gun()], '枪械信息'] ] }, - { - 'name': 'getUpgradeQualityList', - 'desc': '获取升阶中的枪械列表', - 'group': 'Gun', - 'url': 'webapp/index.php?c=Hero&a=getUpgradeQualityList', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ['!infos', [_common.QualityingGun()], '升阶中的枪械列表'], - ] - }, { 'name': 'upgradeLv', 'desc': '升等级', diff --git a/doc/Hero.py b/doc/Hero.py index 62ca56df..3223aa2f 100644 --- a/doc/Hero.py +++ b/doc/Hero.py @@ -47,37 +47,6 @@ class Hero(object): _common.RspHead(), ] }, - { - 'name': 'upgradeSkill', - 'desc': '升技能', - 'group': 'Hero', - 'url': 'webapp/index.php?c=Hero&a=upgradeSkill', - 'params': [ - _common.ReqHead(), - ['hero_uniid', 0, '英雄唯一id'], - ['skill_uniid', 0, '技能唯一id'], - ['skill_idx', 0, '技能idx 0:主动技能;1:被动技能'], - ], - 'response': [ - _common.RspHead(), - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - }, - { - 'name': 'upgradeLevel', - 'desc': '升等级', - 'group': 'Hero', - 'url': 'webapp/index.php?c=Hero&a=upgradeLevel', - 'params': [ - _common.ReqHead(), - ['hero_uniid', 0, '英雄唯一id'], - ['slot_id', 0, '槽id(0-1)'], - ], - 'response': [ - _common.RspHead(), - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - }, { 'name': 'upgradeLevelPreview', 'desc': '升等级', @@ -94,112 +63,6 @@ class Hero(object): ['cost', _common.Cost(), '所需费用'], ] }, - { - 'name': 'getUpgradeLevelList', - 'desc': '获取升级中的英雄列表', - 'group': 'Hero', - 'url': 'webapp/index.php?c=Hero&a=getUpgradeLevelList', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ['!infos', [_common.LevelingHero()], '升级中的英雄列表'], - ] - }, - { - 'name': 'upgradeQuality', - 'desc': '升阶', - 'group': 'Hero', - 'url': 'webapp/index.php?c=Hero&a=upgradeQuality', - 'params': [ - _common.ReqHead(), - ['trans_id', 0, 'transId'], - ['token_id1', 0, '英雄token'], - ['token_id2', 0, '耗材英雄token'], - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'name': 'receiveUpgradeQuality', - 'desc': '领取升阶', - 'group': 'Hero', - 'url': 'webapp/index.php?c=Hero&a=receiveUpgradeQuality', - 'params': [ - _common.ReqHead(), - ['trans_id', 0, 'transId'], - ['token_id', 0, '英雄token'], - ], - 'response': [ - _common.RspHead(), - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - }, - { - 'name': 'upgradeQualityOld', - 'desc': '升阶', - 'group': 'Hero', - 'url': 'webapp/index.php?c=Hero&a=upgradeQualityOld', - 'params': [ - _common.ReqHead(), - ['hero_uniid', 0, '英雄唯一id'], - ['slot_id', 0, '槽id(0-1)'], - ['cost_hero_uniid', 0, '耗材英雄唯一id'], - ], - 'response': [ - _common.RspHead(), - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - }, - { - 'name': 'upgradeQualityPreview', - 'desc': '升阶', - 'group': 'Hero', - 'url': 'webapp/index.php?c=Hero&a=upgradeQualityPreview', - 'params': [ - _common.ReqHead(), - ['hero_uniid', 0, '英雄唯一id'], - ['cost_hero_uniid', 0, '耗材英雄唯一id'], - ], - 'response': [ - _common.RspHead(), - ['old_hero', _common.Hero(), '英雄-老'], - ['new_hero', _common.Hero(), '英雄-新'], - ['cost', _common.Cost(), '所需费用'], - ] - }, - { - 'name': 'getUpgradeQualityList', - 'desc': '获取升阶中的英雄列表', - 'group': 'Hero', - 'url': 'webapp/index.php?c=Hero&a=getUpgradeQualityList', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ['!infos', [_common.QualityingHero()], '升阶中的英雄列表'], - ] - }, - { - 'name': 'receive', - 'desc': '领取升级/升阶英雄', - 'group': 'Hero', - 'url': 'webapp/index.php?c=Hero&a=receive', - 'params': [ - _common.ReqHead(), - ['type', 0, '1:领取升级 2:领取升阶'], - ['hero_uniid', 0, '英雄唯一id'], - ], - 'response': [ - _common.RspHead(), - ['state', 0, '0:失败 1:成功'], - ['old_hero', _common.Hero(), '英雄-老'], - ['new_hero', _common.Hero(), '英雄-新'], - ] - }, { 'name': 'heroDetails', 'desc': '英雄详情', @@ -215,20 +78,6 @@ class Hero(object): ] }, { - 'name': 'upgradeSkillCommon', - 'desc': '通用技能升级', - 'group': 'Hero', - 'url': 'webapp/index.php?c=Hero&a=upgradeSkillCommon', - 'params': [ - _common.ReqHead(), - ['hero_uniid', 0, '英雄唯一id'], - ['skill_index', 0, '通用技能下标'], - ], - 'response': [ - _common.RspHead(), - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - },{ 'name': 'upgradeLv', 'desc': '升级', 'group': 'Hero', From 1bc8f8e2f01d0ebdf70ee4edd390658c359709ca Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 7 Mar 2023 13:35:35 +0800 Subject: [PATCH 54/65] 1 --- webapp/controller/ChipPageController.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webapp/controller/ChipPageController.class.php b/webapp/controller/ChipPageController.class.php index b482565e..f070b215 100644 --- a/webapp/controller/ChipPageController.class.php +++ b/webapp/controller/ChipPageController.class.php @@ -11,6 +11,9 @@ use phpcommon\SqlHelper; class ChipPageController extends BaseAuthedController { public function chipPageList(){ + $obj = new services\ChipPageService(); + $obj->initChipPage(); + $list =array(); ChipPage::getList(function ($row) use(&$list){ array_push($list, ChipPage::toDto($row)); @@ -21,9 +24,6 @@ class ChipPageController extends BaseAuthedController } public function showPageInfo(){ - $obj = new services\ChipPageService(); - $obj->initChipPage(); - $page = getReqVal('page',1); $chipPageDb = ChipPage::find($page); if (!$chipPageDb){ From 73bcb52c175d8d2eb04b45bf39479885aac67d56 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 7 Mar 2023 15:02:15 +0800 Subject: [PATCH 55/65] 1 --- webapp/controller/HeroController.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index dc1c8ea7..f28a17c7 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -282,17 +282,30 @@ class HeroController extends BaseAuthedController { ) ); if ($row){ + $data = array( 'skill_id' => $row['skill_id'], 'weapon_uid1' => $row['weapon_uid1'], 'weapon_uid2' => $row['weapon_uid2'], 'chip_page' => $row['chip_page'], + 'gun_id1'=>0, + 'gun_id2'=>0, ); + $gunDb1 = Gun::find($row['weapon_uid1']); + $gunDb2 = Gun::find($row['weapon_uid2']); + if ($gunDb1){ + $data['gun_id1'] = $gunDb1['gun_id']; + } + if ($gunDb1){ + $data['gun_id2'] = $gunDb2['gun_id']; + } }else{ $data = array( 'skill_id' => \mt\Skill::DEFAULT_SKILL, 'weapon_uid1' => 0, 'weapon_uid2' => 0, + 'gun_id1'=>0, + 'gun_id2'=>0, 'chip_page' => 1, ); } From 345aa7408a233ce3c57f43d2acf6d6190fae1ac9 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 7 Mar 2023 15:39:18 +0800 Subject: [PATCH 56/65] 1 --- webapp/controller/HeroSkillController.class.php | 5 ++++- webapp/models/Gun.php | 2 +- webapp/models/Hero.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/webapp/controller/HeroSkillController.class.php b/webapp/controller/HeroSkillController.class.php index fb70e076..c9cee0b5 100644 --- a/webapp/controller/HeroSkillController.class.php +++ b/webapp/controller/HeroSkillController.class.php @@ -12,7 +12,10 @@ class HeroSkillController extends BaseAuthedController { public function getSkillList(){ $skillList = \mt\Skill::getPresetSkill(); - $list = array_column($skillList,'skill_id'); + $list = array(); + foreach ($skillList as $skill){ + $list[] = $skill['skill_id']; + } $this->_rspData(array( 'data' => $list, )); diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 1fefab2b..c3ca498b 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -300,7 +300,7 @@ class Gun extends BaseModel { $unlockTime - myself()->_getNowTime()), 'unlock_trade_time' => $row['unlock_trade_time'], 'offer_reward_state' => 0, - 'tags' => $row['tags'], + 'tags' => $row['tags']?:'', ); // $dto['durability_max'] = strval(round(FormulaService::Weapon_NFT_Maximum_Durability($dto['quality'],$dto['lucky']),3)); // $dto['pvp_ceg_uplimit'] = strval( round(FormulaService::getWeaponPvpDailyCegUpLimit($dto),2) ); diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index 6d599fda..6e1fb446 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -297,7 +297,7 @@ class Hero extends BaseModel { 'advanced_count' => $row['advanced_count'], // 'lucky' => $heroLucky, 'offer_reward_state' => 0, - 'tags' => $row['tags'], + 'tags' => $row['tags']?:'', ); // $dto['hero_tili_max'] = strval(round(FormulaService::Hero_NFT_Maximum_Physical_Strength($dto['quality'],$dto['lucky']),3)); // $dto['pvp_ceg_uplimit'] =strval( round(FormulaService::getHeroPvpDailyCegUpLimit($dto),2) ); From ae51e55d42f3d57385623b0109413237b13aa994 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Tue, 7 Mar 2023 17:05:48 +0800 Subject: [PATCH 57/65] 1 --- webapp/models/ChipPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/models/ChipPage.php b/webapp/models/ChipPage.php index 731e72d3..c053fa2c 100644 --- a/webapp/models/ChipPage.php +++ b/webapp/models/ChipPage.php @@ -169,7 +169,7 @@ class ChipPage extends BaseModel } $info = array( 'account_id' => myself()->_getAccountId(), - 'page_name' => '芯片页'.$page_id, + 'page_name' => 'page'.$page_id, 'page_id' => $page_id, 'data' => json_encode($data), 'createtime' => myself()->_getNowTime(), From 947fd83ca6d2d6ec591f27520c84423d0a3c9264 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 8 Mar 2023 17:12:06 +0800 Subject: [PATCH 58/65] =?UTF-8?q?pve=E7=A2=8E=E7=89=87=E4=BA=A7=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/_common.py | 2 + sql/gamedb.sql | 19 ++ webapp/bootstrap/constant.php | 2 + webapp/models/FragmentRecord.php | 53 +++++ webapp/services/BattleDataService.php | 282 +++++++++++++------------- webapp/services/FormulaService.php | 9 +- 6 files changed, 229 insertions(+), 138 deletions(-) create mode 100644 webapp/models/FragmentRecord.php diff --git a/doc/_common.py b/doc/_common.py index fd68a533..8cdef054 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1024,5 +1024,7 @@ class HeroPreset(object): ['skill_id', 0, '技能item id'], ['weapon_uid1', 0, '武器1唯一id'], ['weapon_uid2', 0, '武器2唯一id'], + ['gun_id1', 0, '武器1 item id'], + ['gun_id2', 0, '武器2 item id'], ['chip_page', 0, '芯片页id'], ] \ No newline at end of file diff --git a/sql/gamedb.sql b/sql/gamedb.sql index e8712281..9f657746 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -622,6 +622,25 @@ CREATE TABLE `t_fragment_pool` ( ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `t_fragment_record` +-- + +DROP TABLE IF EXISTS `t_fragment_record`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_fragment_record` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', + `param` int(11) NOT NULL DEFAULT '0' COMMENT 'param', + `value` int(11) NOT NULL DEFAULT '0' COMMENT '有效场次', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + KEY `account_param` (`account_id`, `param`) +) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `t_realtime_data` -- diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index 5fa3a7a3..26cf74e5 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -41,6 +41,8 @@ define('TN_DAILY_PVP_GET_FRAGMENT_NUM', 9009); define('TN_DAILY_PVE_LAST_GET_FRAGMENT_BATTLE', 9010); define('TN_DAILY_RANK_BATTLE_TIMES', 9011); define('TN_DAILY_END', 9011); +define('TN_DAILY_PVE_GET_HERO_FRAGMENT_NUM', 9012); +define('TN_DAILY_PVE_GET_GUN_FRAGMENT_NUM', 9013); define('TN_WEEKLY_BEGIN', 10001); define('TN_WEEKLY_ACTIVE', 10002); diff --git a/webapp/models/FragmentRecord.php b/webapp/models/FragmentRecord.php new file mode 100644 index 00000000..6875a4a9 --- /dev/null +++ b/webapp/models/FragmentRecord.php @@ -0,0 +1,53 @@ +_getSelfMysql(), + 't_fragment_record', + array( + 'account_id' => myself()->_getAccountId(), + 'param' => $param, + ) + ); + $num = 0; + if ($row) { + $num = $row['value']; + } + return $num; + } + + public static function upsertGamesNum($param,$value){ + SqlHelper::upsert + (myself()->_getSelfMysql(), + 't_fragment_record', + array( + 'account_id' => myself()->_getAccountId(), + 'param' => $param + ), + array( + 'value' => $value, + 'modifytime' => myself()->_getNowDaySeconds() + ), + array( + 'account_id' => myself()->_getAccountId(), + 'param' => $param, + 'value' => 1, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowDaySeconds() + ) + ); + } + +} \ No newline at end of file diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 38f77b75..2e358814 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -28,6 +28,7 @@ require_once('models/FragmentPool.php'); require_once('models/RealtimeData.php'); require_once('models/BattleHistory.php'); require_once('models/NftActive.php'); +require_once('models/FragmentRecord.php'); require_once('services/RankActivityService.php'); require_once('services/FormulaService.php'); @@ -37,6 +38,7 @@ require_once('services/LogService.php'); use models\Chip; +use models\FragmentRecord; use models\Nft; use models\NftActive; use models\User; @@ -79,17 +81,6 @@ class BattleDataService extends BaseService { 'obtain_ceg' => 0, 'curr_ceg' => 0, ), - 'weapon1' => array( - 'gun_uniid' => '', - 'ceg_uplimit' => 0, - 'obtain_ceg' => 0, - ), - 'weapon2' => array( - 'gun_uniid' => '', - 'ceg_uplimit' => 0, - 'obtain_ceg' => 0, - 'curr_ceg' => 0, - ), 'total_ceg' => 0, 'items' => array(), 'lvInfo' => array() @@ -126,32 +117,7 @@ class BattleDataService extends BaseService { $this->reward['hero']['ceg_uplimit'] = $matchMode == self::MATCH_MODE_PVE ? $this->heroDto['pve_ceg_uplimit'] : $this->heroDto['pvp_ceg_uplimit']; } - { - $weaponUuid1 = getReqVal('weapon_uuid1', ''); - if ($weaponUuid1) { - $weaponDb = Gun::find($weaponUuid1); - if (!$weaponDb) { - return false; - } - $this->weapon1Dto = Gun::toDto($weaponDb); - $this->reward['weapon1']['gun_uniid'] = $this->weapon1Dto['gun_uniid']; - $this->reward['weapon1']['ceg_uplimit'] = $matchMode == self::MATCH_MODE_PVE ? - $this->weapon1Dto['pve_ceg_uplimit'] : $this->weapon1Dto['pvp_ceg_uplimit']; - } - } - { - $weaponUuid2 = getReqVal('weapon_uuid2', ''); - if ($weaponUuid2) { - $weaponDb = Gun::find($weaponUuid2); - if (!$weaponDb) { - return false; - } - $this->weapon2Dto = Gun::toDto($weaponDb); - $this->reward['weapon2']['gun_uniid'] = $this->weapon2Dto['gun_uniid']; - $this->reward['weapon2']['ceg_uplimit'] = $matchMode == self::MATCH_MODE_PVE ? - $this->weapon2Dto['pve_ceg_uplimit'] : $this->weapon2Dto['pvp_ceg_uplimit']; - } - } + //录入战斗记录 $this->saveBattleHistory(); @@ -162,7 +128,6 @@ class BattleDataService extends BaseService { //匹配赛模式 $this->updatePvpData(); $this->rewardCegPvp(); - $this->rewardFragmentPvp(); myself()->_incDailyV(TN_DAILY_PVP_BATTLE_TIMES, 0, 1); } break; @@ -179,7 +144,6 @@ class BattleDataService extends BaseService { $this->updatePveData(); if ($this->pveGeminiMeta && $this->pveGeminiModeMeta) { - $this->rewardCegPve(); $this->rewardFragmentPve(); } myself()->_incDailyV(TN_DAILY_PVE_BATTLE_TIMES, 0, 1); @@ -809,54 +773,151 @@ class BattleDataService extends BaseService { private function rewardFragmentPve() { - if ($this->instanceRank < 1) { + $bossReward = getReqVal('pve_kill_boss', 0) ? 1 : 0; + if ($this->instanceRank < 1 || !$bossReward) { return; } - $todayPveBattleTimes = myself()->_getDailyV(TN_DAILY_PVE_BATTLE_TIMES, 0); - $todayPveLastGetFragmentBattle = myself()->_getDailyV(TN_DAILY_PVE_LAST_GET_FRAGMENT_BATTLE, 0); - $todayPveGetFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_FRAGMENT_NUM, 0); - $todayPvpGetFragmentNum = myself()->_getDailyV(TN_DAILY_PVP_GET_FRAGMENT_NUM, 0); + $dropRate = $this->pveGeminiMeta['drop_rate']; + $todayPveGetHeroFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_HERO_FRAGMENT_NUM, 0); + $todayPveGetGunFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_GUN_FRAGMENT_NUM, 0); + if ($todayPveGetHeroFragmentNum < self::MAX_DROP_NUM) { + $gamesNum = FragmentRecord::getGamesNum(FragmentRecord::HERO_FRAGMENT); + $rate = $dropRate*($gamesNum+1); + if (rand(1,100) < $rate*100){ + $dropHeroFragmentId = $this->randWeight2(1); + $this->drop($dropHeroFragmentId,1); + FragmentRecord::upsertGamesNum(FragmentRecord::HERO_FRAGMENT,0); + }else{ + FragmentRecord::upsertGamesNum(FragmentRecord::HERO_FRAGMENT,$gamesNum+1); + } - if ($todayPveGetFragmentNum + $todayPvpGetFragmentNum < self::MAX_DROP_NUM) { - $onlineNum = RealtimeData::getOnline(); - $heroFragmentNum = FragmentPool::getHeroNum(1); - $gunFragmentNum = FragmentPool::getGunNum(1); - - $instanceLevel = $this->pveGeminiMeta['gemini_lv']; - $instanceRank = $this->instanceRank; - $instanceRankRate = $this->getInstanceRankRate(); - $bossReward = getReqVal('pve_kill_boss', 0) ? 1 : 0; - $heroQuality = $this->heroDto['quality']; - - $heroProbability = FormulaService::calcHeroFragmentProbabilityPve - ( - $heroQuality, - $onlineNum, - $heroFragmentNum, - $todayPveBattleTimes, - $instanceLevel, - $instanceRank, - $instanceRankRate, - $bossReward, - $todayPveLastGetFragmentBattle - ); - $gunProbability = FormulaService::calcWeaponFragmentProbabilityPve - ( - $heroQuality, - $onlineNum, - $gunFragmentNum, - $todayPveBattleTimes, - $instanceLevel, - $instanceRank, - $instanceRankRate, - $bossReward, - $todayPveLastGetFragmentBattle - ); - $emptyProbability = max(1 - $heroProbability - $gunProbability, 0); - - $dropIdx = $this->randWeight(array($heroProbability, $gunProbability, $emptyProbability)); - $this->procDrop($dropIdx); } + if ($todayPveGetGunFragmentNum < self::MAX_DROP_NUM) { + $gamesNum = FragmentRecord::getGamesNum(FragmentRecord::GUN_FRAGMENT); + $rate = $dropRate*($gamesNum+1); + if (rand(1,100) < $rate*100){ + $dropGunFragmentId = $this->randWeight2(2); + $this->drop($dropGunFragmentId,2); + FragmentRecord::upsertGamesNum(FragmentRecord::GUN_FRAGMENT,0); + }else{ + FragmentRecord::upsertGamesNum(FragmentRecord::GUN_FRAGMENT,$gamesNum+1); + } + + } + +// $todayPveBattleTimes = myself()->_getDailyV(TN_DAILY_PVE_BATTLE_TIMES, 0); +// $todayPveLastGetFragmentBattle = myself()->_getDailyV(TN_DAILY_PVE_LAST_GET_FRAGMENT_BATTLE, 0); +// $todayPveGetFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_FRAGMENT_NUM, 0); +// $todayPvpGetFragmentNum = myself()->_getDailyV(TN_DAILY_PVP_GET_FRAGMENT_NUM, 0); +// +// if ($todayPveGetFragmentNum + $todayPvpGetFragmentNum < self::MAX_DROP_NUM) { +// $onlineNum = RealtimeData::getOnline(); +// $heroFragmentNum = FragmentPool::getHeroNum(1); +// $gunFragmentNum = FragmentPool::getGunNum(1); +// +// $instanceLevel = $this->pveGeminiMeta['gemini_lv']; +// $instanceRank = $this->instanceRank; +// $instanceRankRate = $this->getInstanceRankRate(); +// $bossReward = getReqVal('pve_kill_boss', 0) ? 1 : 0; +// $heroQuality = $this->heroDto['quality']; +// +// $heroProbability = FormulaService::calcHeroFragmentProbabilityPve +// ( +// $heroQuality, +// $onlineNum, +// $heroFragmentNum, +// $todayPveBattleTimes, +// $instanceLevel, +// $instanceRank, +// $instanceRankRate, +// $bossReward, +// $todayPveLastGetFragmentBattle +// ); +// $gunProbability = FormulaService::calcWeaponFragmentProbabilityPve +// ( +// $heroQuality, +// $onlineNum, +// $gunFragmentNum, +// $todayPveBattleTimes, +// $instanceLevel, +// $instanceRank, +// $instanceRankRate, +// $bossReward, +// $todayPveLastGetFragmentBattle +// ); +// $emptyProbability = max(1 - $heroProbability - $gunProbability, 0); +// +// $dropIdx = $this->randWeight(array($heroProbability, $gunProbability, $emptyProbability)); +// $this->procDrop($dropIdx); +// } + } + + private function randWeight2($type){ + $itemMeta = mt\Item::getMetaListByType(mt\Item::FRAGMENT_TYPE); + $heroFragment = array(); + $gunFragment = array(); + foreach ($itemMeta as $meta){ + if ($meta['sub_type'] == 3 || $meta['sub_type'] == 1){ + array_push($heroFragment,$meta['id']); + } + if ($meta['sub_type'] == 4 || $meta['sub_type'] == 2){ + array_push($gunFragment,$meta['id']); + } + } + $weightRate = array( + array(0,4), + array(1,12), + array(2,12), + array(3,12), + array(4,12), + array(5,12), + array(6,12), + array(7,12), + array(8,12), + ); + $weight = 0; + $tempData = array (); + foreach ($weightRate as $one) { + $weight += $one[1]; + for ($i = 0; $i < $one[1]; $i++) { + $tempData[] = $one; + + } + } + $key = $tempData[rand(0, $weight -1)][0]; + switch ($type){ + case 1:return $heroFragment[$key]; + case 2:return $gunFragment[$key]; + default:return null; + } + } + + private function drop($itemId,$type){ + $itemMeta = mt\Item::get($itemId); + if ($itemMeta){ + $propertyChgService = new services\PropertyChgService(); + $awardService = new services\AwardService(); + array_push($this->reward['items'], + array( + 'item_id' => $itemId, + 'item_num' => 1 + )); + myself()->_addItems( + array( + array( + 'item_id' => $itemId, + 'item_num' => 1 + )), + $awardService, + $propertyChgService + ); + switch ($type){ + case 1:myself()->_incDailyV(TN_DAILY_PVE_GET_HERO_FRAGMENT_NUM, 0, 1);break; + case 2:myself()->_incDailyV(TN_DAILY_PVE_GET_GUN_FRAGMENT_NUM, 0, 1);break; + } + + } + } private function rewardCegPvp() @@ -878,22 +939,11 @@ class BattleDataService extends BaseService { } } $heroPvpCeg = FormulaService::calcHeroPvpCeg($this->heroDto, $_REQUEST); - $weaponPvpCeg1 = 0; - $weaponPvpCeg2 = 0; - if ($this->weapon1Dto) { - $weaponPvpCeg1 = FormulaService::calcWeaponPvpCeg($this->weapon1Dto, $_REQUEST); - } - if ($this->weapon2Dto) { - $weaponPvpCeg2 = FormulaService::calcWeaponPvpCeg($this->weapon2Dto, $_REQUEST); - } error_log(json_encode(array( 'heroPvpCeg' => $heroPvpCeg, - 'weaponPvpCeg1' => $weaponPvpCeg1, - 'weaponPvpCeg2' => $weaponPvpCeg2, ))); if ($heroPvpCeg > 0) { $heroPvpCeg = Hero::gainGoldPvp($this->heroDto, $heroPvpCeg); - { //埋点 $event = [ @@ -907,56 +957,14 @@ class BattleDataService extends BaseService { $this->reward['hero']['obtain_ceg'] = '' . ($this->heroDto['current_pvp_get_ceg'] + $heroPvpCeg); $this->reward['total_ceg'] += $heroPvpCeg; } - if ($weaponPvpCeg1 > 0) { - $weaponPvpCeg1 = Gun::gainGoldPvp($this->weapon1Dto, $weaponPvpCeg1); - { - //埋点 - $event = [ - 'name' => LogService::BATTLE_AWARD_PVP, - 'val' => $weaponPvpCeg1 - ]; - LogService::productCEG($event,$this->weapon1Dto,$log_param); - } - - $this->reward['weapon1']['curr_ceg'] = '' . ($this->weapon1Dto['current_pvp_get_ceg'] + $weaponPvpCeg1); - $this->reward['weapon1']['obtain_ceg'] = '' . ($this->weapon1Dto['current_pvp_get_ceg'] + $weaponPvpCeg1); - $this->reward['total_ceg'] += $weaponPvpCeg1; - } - if ($weaponPvpCeg2 > 0) { - $weaponPvpCeg2 = Gun::gainGoldPvp($this->weapon2Dto, $weaponPvpCeg2); - - { - //埋点 - $event = [ - 'name' => LogService::BATTLE_AWARD_PVP, - 'val' => $weaponPvpCeg2 - ]; - LogService::productCEG($event,$this->weapon2Dto,$log_param); - } - - $this->reward['weapon2']['curr_ceg'] = '' . ($this->weapon2Dto['current_pvp_get_ceg'] + $weaponPvpCeg2); - $this->reward['weapon2']['obtain_ceg'] = '' . ($this->weapon2Dto['current_pvp_get_ceg'] + $weaponPvpCeg2); - $this->reward['total_ceg'] += $weaponPvpCeg2; - } $this->reward['total_ceg'] .= ''; error_log(json_encode(array( 'new_heroPvpCeg' => $heroPvpCeg, - 'new_weaponPvpCeg1' => $weaponPvpCeg1, - 'new_weaponPvpCeg2' => $weaponPvpCeg2, ))); - $gold = $heroPvpCeg + $weaponPvpCeg1 + $weaponPvpCeg2; + $gold = $heroPvpCeg; error_log('updateBattleData1'); $this->rankActivityService->updateBattleData($gold); - if ($heroPvpCeg>0){ - NftService::addNftActive($this->heroDto,1); - } - if ($weaponPvpCeg1>0){ - NftService::addNftActive($this->weapon1Dto,2); - } - if ($weaponPvpCeg2>0){ - NftService::addNftActive($this->weapon2Dto,2); - } if ($gold > 0) { myself()->_addVirtualItem(V_ITEM_GOLD, $gold); } diff --git a/webapp/services/FormulaService.php b/webapp/services/FormulaService.php index 0dbfb5d4..fc25f7d3 100644 --- a/webapp/services/FormulaService.php +++ b/webapp/services/FormulaService.php @@ -17,10 +17,17 @@ use mt; class FormulaService extends BaseService { + public static function calcHeroPvpGold($heroDto, $params) + { +// GOLD = Min(英雄每天gold上限*10%,标准值) * (f(队伍排名) + g(队伍击杀数)) +// f(队伍排名) = round(1-(队伍排名-1)/10 ,1) +// g(队伍击杀数)= Min(队伍击杀数*0.1 ,2) + } + public static function calcHeroPvpCeg($heroDto, $params) { //每局实际收益=10%PVP收益*5*(50%*[每局排名TopX%对应比例]+25%*[每局PK人数排名TopX%对应比例]+15%*[每局英雄属性排名TopX%对应比例]+5%*[每局武器属性排名TopX%对应比例]+5%*[每局存活时间排名TopX%对应比例]) - $upLimit = $heroDto['pvp_ceg_uplimit']; + $upLimit = $heroDto['gold_uplimit']; $ranked = getXVal($params, 'ranked'); $kills = getXVal($params, 'kills'); $aliveTime = getXVal($params, 'alive_time'); From bf824378ef05b7b8d3e0621b8f08785d06033eb3 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 9 Mar 2023 11:08:31 +0800 Subject: [PATCH 59/65] 1 --- webapp/controller/BaseAuthedController.class.php | 9 +++++++++ webapp/models/User.php | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index b60cda98..76d206c5 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -254,6 +254,15 @@ class BaseAuthedController extends BaseController { )); } break; + case V_ITEM_EXP: + { + $this->_updateUserInfo(array( + 'exp' => function () use($itemNum) { + return "exp + ${itemNum}"; + } + )); + } + break; case V_ITEM_ACTIVE: { return; diff --git a/webapp/models/User.php b/webapp/models/User.php index ae9221a4..03607a56 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -3,6 +3,7 @@ namespace models; require_once('mt/Item.php'); +require_once('mt/LevelUp.php'); require_once('models/UserSeasonRing.php'); require_once('models/Parachute.php'); @@ -40,6 +41,7 @@ class User extends BaseModel { public static function show($row) { + mt\LevelUp::getExpByLv($row['level'],$row['exp']); return array( 'activated' => $row['activated'], 'rename_count' => $row['rename_count'], @@ -50,7 +52,6 @@ class User extends BaseModel { 'head_frame' => $row['head_frame'], 'level' => $row['level'], 'exp' => $row['exp'], - 'max_exp' => $row['exp'] + 1000, 'rank' => $row['rank'], 'history_best_rank' => $row['history_best_rank'], 'score' => $row['score'], @@ -80,6 +81,7 @@ class User extends BaseModel { public static function info($row) { + mt\LevelUp::getExpByLv($row['level'],$row['exp']); return array( 'activated' => $row['activated'], 'rename_count' => $row['rename_count'], @@ -90,7 +92,6 @@ class User extends BaseModel { 'head_frame' => $row['head_frame'], 'level' => $row['level'], 'exp' => $row['exp'], - 'max_exp' => $row['exp'] + 1000, 'rank' => $row['rank'], 'history_best_rank' => $row['history_best_rank'], 'score' => $row['score'], From 61021776403bf23842b1b8dbe64d1386ba131e5a Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 9 Mar 2023 16:07:50 +0800 Subject: [PATCH 60/65] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=88=98=E6=96=97?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/controller/BattleController.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index ec965086..ea38c468 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -1,6 +1,7 @@ $member['account_id'], 'session_id' => $member['session_id'], @@ -144,6 +147,7 @@ class BattleController extends BaseAuthedController { 'hero_dto' => '', 'weapon_dto1' => '', 'weapon_dto2' => '', + 'level' =>$user['level'], 'is_valid_battle' => 0, 'payload' => json_encode($member['cmjoin']), @@ -160,6 +164,12 @@ class BattleController extends BaseAuthedController { if ($heroDb) { $info['is_valid_battle'] = 1; $info['hero_dto'] = Hero::toDto($heroDb); + {//选用皮肤id + $skinDb = HeroSkin::findBx($heroDb['hero_id']); + if ($skinDb){ + $info['hero_dto']['skin_id'] = $skinDb['skin_id']; + } + } } else { $info['errcode'] = 51; $info['errmsg'] = 'paramater error'; From 219897fb6cc3d21388bdde65b3dc7f71c07e93f1 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 9 Mar 2023 16:56:08 +0800 Subject: [PATCH 61/65] 1 --- webapp/models/Chip.php | 1 - 1 file changed, 1 deletion(-) diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index 8b121f10..d691c8c6 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -169,7 +169,6 @@ class Chip extends BaseModel 'chip_grade'=> $row['chip_grade'], 'chip_type'=> $row['chip_type'], 'state'=> $row['state'], - 'supper_state'=> $row['supper_state'], 'inlay_state'=> $row['inlay_state'], 'rand_attr'=> $rand_attr, ); From 3e66d3b7874e2479721949f1f7650694a514e9fe Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 9 Mar 2023 17:07:43 +0800 Subject: [PATCH 62/65] 1 --- webapp/models/Gun.php | 13 ++-- webapp/models/Hero.php | 138 ++++++++++------------------------------- 2 files changed, 39 insertions(+), 112 deletions(-) diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index c3ca498b..55901bc1 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -271,7 +271,7 @@ class Gun extends BaseModel { if (myself()->_getDaySeconds($lastMissionGetCegTime) < myself()->_getNowDaySeconds()) { $todayMissionGetCeg = 0; } -// $gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($row['quality']); + $gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($row['quality']); $dto = array( 'idx' => $row['idx'], 'token_id' => $row['token_id'], @@ -280,7 +280,6 @@ class Gun extends BaseModel { 'gun_lv' => $row['gun_lv'], 'state' => $row['state'], 'quality' => $row['quality'], -// 'lucky' => strval($gunLucky), 'durability' => $row['durability'], 'ceg_uplimit' => 0, 'pve_ceg_uplimit' => 0, @@ -301,11 +300,13 @@ class Gun extends BaseModel { 'unlock_trade_time' => $row['unlock_trade_time'], 'offer_reward_state' => 0, 'tags' => $row['tags']?:'', + + 'lucky' => strval($gunLucky), ); -// $dto['durability_max'] = strval(round(FormulaService::Weapon_NFT_Maximum_Durability($dto['quality'],$dto['lucky']),3)); -// $dto['pvp_ceg_uplimit'] = strval( round(FormulaService::getWeaponPvpDailyCegUpLimit($dto),2) ); -// $dto['pve_ceg_uplimit'] = strval( round(FormulaService::getWeaponPveDailyCegUpLimit($dto),2) ); -// $dto['mission_ceg_uplimit'] = strval( round(FormulaService::getWeaponMissionDailyCegUpLimit($dto),2) ); + $dto['durability_max'] = strval(round(FormulaService::Weapon_NFT_Maximum_Durability($dto['quality'],$dto['lucky']),3)); + $dto['pvp_ceg_uplimit'] = strval( round(FormulaService::getWeaponPvpDailyCegUpLimit($dto),2) ); + $dto['pve_ceg_uplimit'] = strval( round(FormulaService::getWeaponPveDailyCegUpLimit($dto),2) ); + $dto['mission_ceg_uplimit'] = strval( round(FormulaService::getWeaponMissionDailyCegUpLimit($dto),2) ); $nft_address = ''; if ($row['token_id']){ diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index 6e1fb446..7b9dee0f 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -239,17 +239,23 @@ class Hero extends BaseModel { myself()->_getNowDaySeconds()) { $todayGetGold = 0; } -// $todayPveGetCeg = $row['today_pve_get_ceg']; -// $lastPveGetCegTime = $row['last_pve_get_ceg_time']; -// if (myself()->_getDaySeconds($lastPveGetCegTime) < -// myself()->_getNowDaySeconds()) { -// $todayPveGetCeg = 0; -// } -// $todayMissionGetCeg = $row['today_mission_get_ceg']; -// $lastMissionGetCegTime = $row['last_mission_get_ceg_time']; -// if (myself()->_getDaySeconds($lastMissionGetCegTime) < myself()->_getNowDaySeconds()) { -// $todayMissionGetCeg = 0; -// } + + { + $todayPveGetCeg = $row['today_pve_get_ceg']; + $lastPveGetCegTime = $row['last_pve_get_ceg_time']; + if (myself()->_getDaySeconds($lastPveGetCegTime) < + myself()->_getNowDaySeconds()) { + $todayPveGetCeg = 0; + } + $todayMissionGetCeg = $row['today_mission_get_ceg']; + $lastMissionGetCegTime = $row['last_mission_get_ceg_time']; + if (myself()->_getDaySeconds($lastMissionGetCegTime) < myself()->_getNowDaySeconds()) { + $todayMissionGetCeg = 0; + } + } + + + $baseAttr=[]; $attrPro=[]; $heroMeta = mt\Hero::get($row['hero_id']); @@ -265,7 +271,7 @@ class Hero extends BaseModel { } $attrPro = self::mergeAttrPro($baseAttr,$attrPro1,$attrPro2); } -// $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($row['quality']); + $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($row['quality']); $dto = array( 'idx' => $row['idx'], 'token_id' => $row['token_id'], @@ -280,7 +286,6 @@ class Hero extends BaseModel { 'skill_lv2' => $row['skill_lv2'], 'attr_base' => $baseAttr, 'attr_pro' => $attrPro, - 'try_count' => $row['try_count'], 'lock_type' => $lockType, 'unlock_time' => $unlockTime, @@ -289,20 +294,25 @@ class Hero extends BaseModel { 'current_get_gold' => $todayGetGold / 100, 'last_get_gold_time' => $lastGetGoldTime, 'gold_uplimit' => $levelMeta['gold_limit'], -// 'current_pve_get_ceg' => $todayPveGetCeg / 100, -// 'last_pve_get_ceg_time' => $lastPveGetCegTime, -// 'current_mission_get_ceg' => $todayMissionGetCeg / 100, -// 'last_mission_get_ceg_time' => $lastMissionGetCegTime, 'unlock_trade_time' => $row['unlock_trade_time'], 'advanced_count' => $row['advanced_count'], -// 'lucky' => $heroLucky, 'offer_reward_state' => 0, 'tags' => $row['tags']?:'', + + //暂留(以下弃用字段) + 'current_pvp_get_ceg' => $todayGetGold / 100, + 'last_pvp_get_ceg_time' => $lastGetGoldTime, + 'current_pve_get_ceg' => $todayPveGetCeg / 100, + 'last_pve_get_ceg_time' => $lastPveGetCegTime, + 'current_mission_get_ceg' => $todayMissionGetCeg / 100, + 'last_mission_get_ceg_time' => $lastMissionGetCegTime, + 'lucky' => $heroLucky, + ); -// $dto['hero_tili_max'] = strval(round(FormulaService::Hero_NFT_Maximum_Physical_Strength($dto['quality'],$dto['lucky']),3)); -// $dto['pvp_ceg_uplimit'] =strval( round(FormulaService::getHeroPvpDailyCegUpLimit($dto),2) ); -// $dto['pve_ceg_uplimit'] = strval( round(FormulaService::getHeroPveDailyCegUpLimit($dto),2) ); -// $dto['mission_ceg_uplimit'] = strval( round(FormulaService::getHeroMissionDailyCegUpLimit($dto),2) ); + $dto['hero_tili_max'] = strval(round(FormulaService::Hero_NFT_Maximum_Physical_Strength($dto['quality'],$dto['lucky']),3)); + $dto['pvp_ceg_uplimit'] =strval( round(FormulaService::getHeroPvpDailyCegUpLimit($dto),2) ); + $dto['pve_ceg_uplimit'] = strval( round(FormulaService::getHeroPveDailyCegUpLimit($dto),2) ); + $dto['mission_ceg_uplimit'] = strval( round(FormulaService::getHeroMissionDailyCegUpLimit($dto),2) ); $nft_address = ''; if ($row['token_id']){ @@ -384,69 +394,6 @@ class Hero extends BaseModel { ); } - public static function addTryHero($heroMeta, $tryCount) - { - $realHeroMeta = mt\Hero::get($heroMeta['id']); - $randAttr = array(); - { - $initQualityMeta = mt\HeroQuality::getByQuality(1); - if ($initQualityMeta) { - $randAttr = mt\HeroQuality::getRandAttr($initQualityMeta); - } - } - SqlHelper::upsert( - myself()->_getSelfMysql(), - 't_hero', - array( - 'account_id' => myself()->_getAccountId(), - 'hero_id' => $heroMeta['id'] - ), - array( - ), - array( - 'account_id' => myself()->_getAccountId(), - 'hero_id' => $heroMeta['id'], - 'hero_lv' => 1, - 'quality' => 1, - 'hero_tili' => $realHeroMeta ? $realHeroMeta['tili'] : 0, - 'state' => self::FREE_STATE, - 'try_count' => $tryCount, - 'skill_lv1' => 1, - 'skill_lv2' => 1, - 'rand_attr' => json_encode($randAttr), - 'lock_type' => self::NO_LOCK, - 'unlock_time' => 0, - 'unlock_trade_time' => 0, - 'createtime' => myself()->_getNowTime(), - 'modifytime' => myself()->_getNowTime() - ) - ); - } - - public static function takeonSkin($heroUniId, $skinId) - { - self::update($heroUniId, array( - 'skin_id' => $skinId, - 'modifytime' => myself()->_getNowTime() - )); - } - - public static function upgradeSkill($heroUniId, $skillIdx,$skill_points) - { - if (!in_array($skillIdx, array(0, 1))) { - return; - } - $fieldName = 'skill_lv' . ($skillIdx + 1); - self::update($heroUniId, array( - $fieldName => function () use($fieldName) { - return "${fieldName} + 1"; - }, - 'skill_points' => function() use ($skill_points){ - return "GREATEST(0, skill_points - ${skill_points})"; - }, - 'modifytime' => myself()->_getNowTime() - )); - } public static function update($heroUniId, $fieldsKv) { @@ -641,13 +588,6 @@ class Hero extends BaseModel { foreach ($baseAttr as $val){ foreach ($attr as $v){ $coef_level = mt\HeroLevelAttr::getByCoefficient($coefficient_level,$val['attr_id']); -// if ($val['attr_id'] == $v['attr_id'] && $val['attr_id'] == kHAT_Atk){ //18 //18.941564456287 //20.847692307692 -// array_push($attrPro1,[ -// 'attr_id' => $val['attr_id'], -// 'type'=> $val['type'], -// 'val' => strval($val['val']*$v['val']+$v['val']/$coef_level['val']*100-100/$coef_level['val']), -// ]); -// } //&& $val['attr_id'] != kHAT_Atk if ( $val['attr_id'] == $v['attr_id'] ){ array_push($attrPro1,[ @@ -668,20 +608,6 @@ class Hero extends BaseModel { foreach ($baseAttr as $val){ $coef_quality = mt\HeroQuality::getByCoefficient($coefficient_quality,$val['attr_id']); if ($coef_quality){ -// if ($val['attr_id'] == kHAT_Atk){ -// array_push($attrPro2,[ -// 'attr_id' => $val['attr_id'], -// 'type'=> $val['type'], -// 'val' => strval($val['val']*$qualityMeta['promote_val']+$qualityMeta['promote_val']/$coef_quality['val']*100-100/$coef_quality['val']), -// ]); -// } -// if ($val['attr_id'] != kHAT_Atk) { -// array_push($attrPro2, [ -// 'attr_id' => $val['attr_id'], -// 'type' => $val['type'], -// 'val' => strval($val['val'] * pow($qualityMeta['promote_val'], $coef_quality['val'])), -// ]); -// } array_push($attrPro2, [ 'attr_id' => $val['attr_id'], 'type' => $val['type'], From 8de5a84b84709a1c2509fde38968dcecad1512fe Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 9 Mar 2023 17:13:49 +0800 Subject: [PATCH 63/65] 1 --- webapp/models/Gun.php | 2 ++ webapp/models/Hero.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 55901bc1..03549c93 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -302,6 +302,8 @@ class Gun extends BaseModel { 'tags' => $row['tags']?:'', 'lucky' => strval($gunLucky), + 'chip_strength_sum' => 0, + 'labour' => 0, ); $dto['durability_max'] = strval(round(FormulaService::Weapon_NFT_Maximum_Durability($dto['quality'],$dto['lucky']),3)); $dto['pvp_ceg_uplimit'] = strval( round(FormulaService::getWeaponPvpDailyCegUpLimit($dto),2) ); diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index 7b9dee0f..b3bbc525 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -307,6 +307,8 @@ class Hero extends BaseModel { 'current_mission_get_ceg' => $todayMissionGetCeg / 100, 'last_mission_get_ceg_time' => $lastMissionGetCegTime, 'lucky' => $heroLucky, + 'chip_strength_sum' => 0, + 'labour' => 0, ); $dto['hero_tili_max'] = strval(round(FormulaService::Hero_NFT_Maximum_Physical_Strength($dto['quality'],$dto['lucky']),3)); From 42107b1a115c0a6c0f3176c3e048fcd11a3b94f3 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 9 Mar 2023 17:16:25 +0800 Subject: [PATCH 64/65] 1 --- webapp/models/Gun.php | 2 +- webapp/models/Hero.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 03549c93..eba64702 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -299,7 +299,7 @@ class Gun extends BaseModel { $unlockTime - myself()->_getNowTime()), 'unlock_trade_time' => $row['unlock_trade_time'], 'offer_reward_state' => 0, - 'tags' => $row['tags']?:'', + 'tags' => isset($row['tags'])?$row['tags']:'', 'lucky' => strval($gunLucky), 'chip_strength_sum' => 0, diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index b3bbc525..fefcf3c5 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -297,7 +297,7 @@ class Hero extends BaseModel { 'unlock_trade_time' => $row['unlock_trade_time'], 'advanced_count' => $row['advanced_count'], 'offer_reward_state' => 0, - 'tags' => $row['tags']?:'', + 'tags' => isset($row['tags'])?$row['tags']:'', //暂留(以下弃用字段) 'current_pvp_get_ceg' => $todayGetGold / 100, From 19674015c45530b7d62df242b92df7b4db5ae10a Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 9 Mar 2023 17:22:46 +0800 Subject: [PATCH 65/65] 1 --- webapp/models/HeroSkin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/models/HeroSkin.php b/webapp/models/HeroSkin.php index 9fc0db9e..dedd5be6 100644 --- a/webapp/models/HeroSkin.php +++ b/webapp/models/HeroSkin.php @@ -107,7 +107,7 @@ class HeroSkin extends BaseModel { 'get_from' => 0, 'consume_num' => 0, 'try_expire_at' => 0, - 'hero_id' => $itemMeta['isdefaultskin']?$itemMeta['playerid']:0, + 'hero_id' => 0, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime() )