1
This commit is contained in:
parent
4b5eb1d239
commit
d0275cc9e8
@ -343,4 +343,22 @@ CREATE TABLE `t_used_name` (
|
|||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!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
|
-- Dump completed on 2015-08-19 18:51:22
|
||||||
|
@ -202,7 +202,7 @@ class BaseAuthedController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _addItems($items)
|
public function _addItems($items, $awardService, $propertyService)
|
||||||
{
|
{
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
if ($this->_isVirtualItem($item['item_id'])) {
|
if ($this->_isVirtualItem($item['item_id'])) {
|
||||||
@ -269,7 +269,51 @@ class BaseAuthedController extends BaseController {
|
|||||||
|
|
||||||
public function _scatterDrop($dropMeta, $awardService, $propertyService)
|
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)
|
public function _getV($x, $y, $defVal = 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user