This commit is contained in:
hujiabin 2024-04-18 14:25:35 +08:00
parent 2b483e0da4
commit 1686e136ba

View File

@ -3,6 +3,7 @@
require_once('phpcommon/tglog.php');
require_once('mt/Item.php');
require_once('mt/Parameter.php');
require_once('services/AwardService.php');
require_once('services/PropertyChgService.php');
require_once('services/LootService.php');
@ -217,12 +218,48 @@ END
}
private function lootTest($params){
$dropIndex = getXVal($params, 0, 0);
$dropNum = getXVal($params, 1, 0);
for ($i=0; $i<$dropNum; $i++){
$items = \services\LootService::dropOutItem($dropIndex);
$lucky = getXVal($params, 0, 0);
$itemId = getXVal($params, 1, 0);
$itemNum = getXVal($params, 2, 0);
$itemMeta = mt\Item::get($itemId);
if (!$itemMeta || $itemMeta['type'] != mt\Item::BATTLE_REWARD_BOX) {
$this->_rspErr(2, 'config error');
return;
}
$luckyParam = \mt\Parameter::getVal('economy_account_luck_K',0);
$luckyMaxPro = \mt\Parameter::getVal('economy_account_luck_E',0);
$prob = $luckyMaxPro * ($lucky / ($lucky+$luckyParam));
for ($i=0; $i<$itemNum; $i++){
$times = $this->proEffect($prob,1);
$temp = array(
"prob" => $prob,
"times" => $times
);
$items = \services\LootService::dropOutItem($itemMeta['loot']);
if ($times > 0){
foreach ($items as &$item){
$item['item_num'] += $item['item_num']*$times;
}
}
array_unshift($items,$temp);
TGLog::writeToLog("game_2006_api","loot",$items);
}
}
private function proEffect($p,$b){
if ($p * $b > -1 && $b != 0) {
$x = floor($p) * $b;
$y = max($x+$b,-1);
$q = ($p * $b - $y) / ($x - $y);
$rnd = rand(1,100);
return $rnd < $q*100 ? $x : $y;
}else{
return 0;
}
}
}