This commit is contained in:
aozhiwei 2021-12-08 11:57:48 +08:00
parent 4b5eb1d239
commit d0275cc9e8
2 changed files with 65 additions and 3 deletions

View File

@ -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

View File

@ -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)