From d0275cc9e8c59cfe663155146f9619e10f9b61f9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 8 Dec 2021 11:57:48 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 18 +++++++ .../controller/BaseAuthedController.class.php | 50 +++++++++++++++++-- 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 5397868..9378423 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -343,4 +343,22 @@ CREATE TABLE `t_used_name` ( ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `t_drop_log` +-- + +DROP TABLE IF EXISTS `t_drop_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_drop_log` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', + `drop_id` varchar(60) NOT NULL DEFAULT '' COMMENT '掉落id', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + KEY `account_id_drop_id` (`account_id`, `drop_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + -- Dump completed on 2015-08-19 18:51:22 diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 6e140e2..988941b 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -16,7 +16,7 @@ class BaseAuthedController extends BaseController { public function _handlePre() { - $this->accountId = $_REQUEST['account_id']; + $this->accountId = $_REQUEST['account_id']; $this->sessionId = $_REQUEST['session_id']; if (!phpcommon\isValidSessionId($this->accountId, $this->sessionId)) { @@ -202,7 +202,7 @@ class BaseAuthedController extends BaseController { } } - public function _addItems($items) + public function _addItems($items, $awardService, $propertyService) { foreach ($items as $item) { if ($this->_isVirtualItem($item['item_id'])) { @@ -269,7 +269,51 @@ class BaseAuthedController extends BaseController { public function _scatterDrop($dropMeta, $awardService, $propertyService) { - + $itemIds = explode('|', $dropMeta['item_id']); + $nums = explode('|', $dropMeta['num']); + $weights = explode('|', $dropMeta['weights']); + if (count($itemIds) != count($nums) || + count($itemIds) != count($weights)) { + return; + } + $totalWeight = 0; + foreach ($weights as $weight) { + $totalWeight += $weight; + } + $addItems = array(); + if ($dropMeta['type'] == 1) { + //N选N + for ($i = 0; $i < count($itemIds); ++$i) { + $itemId = $itemIds[$i]; + $num = $nums[$i]; + $weight = $weights[$i]; + if ((rand() % 10000) < $weight) { + array_push($addItems, array( + 'item_id' => $itemId, + 'item_num' => $num + )); + } + } + }else if ($dropMeta['type'] == 2 && $totalWeight > 0) { + //N选1 + $currWeight = 0; + $rnd = rand() % $totalWeight; + for ($i = 0; $i < count($itemIds); ++$i) { + $itemId = $itemIds[$i]; + $num = $nums[$i]; + $currWeight += $weights[$i]; + if ($currWeight > $rnd) { + array_push($addItems, array( + 'item_id' => $itemId, + 'item_num' => $num + )); + break; + } + } + } + if (count($addItems) > 0) { + $this->_addItems($addItems); + } } public function _getV($x, $y, $defVal = 0)