_getV(TN_TOTAL_LOOT_TIMES,0); $recycleTimes = myself()->_getV(TN_TOTAL_LOOT_TIMES,1); $contentArr = explode("|",$lootMeta['content']); $initTimes = $contentArr[0]; $po = $contentArr[1]; $pd = $contentArr[2]; $pm = $contentArr[3]; $index1 = $contentArr[4]; $index2 = $contentArr[5]; if ($totalTimes == 0){ $recycleTimes = $initTimes; } $p = min($po + ($recycleTimes-1) * $pd,$pm) * 100 ; $rnd = rand(1,100); myself()->_incV(TN_TOTAL_LOOT_TIMES,0,1); if ($rnd <= $p){ myself()->_setV(TN_TOTAL_LOOT_TIMES,1,1); return self::dropOutReward($index1); }else{ myself()->_incV(TN_TOTAL_LOOT_TIMES,1,1); return self::dropOutReward($index2); } } private static function disposeDropContent3($lootMeta) { $numPara = explode("|",$lootMeta['numPara']); $items = array(); $times = $numPara[0]; $number = $numPara[1]; $contentArr = explode("|",$lootMeta['content']); for ($i=0;$i<$times;$i++){ for ($j=0;$j<$number;$j++){ self::randWeight2($contentArr,$items); } } return $items; } private static function randWeight2(&$contentArr,&$items){ $totalWeight = 0; foreach ($contentArr as $value){ $contentArrEx = explode(":",$value); $totalWeight += $contentArrEx[3]; } $rnd = rand() % $totalWeight; $currWeight = 0; foreach ($contentArr as $key=>$value){ $contentArrEx = explode(":",$value); $currWeight += $contentArrEx[3]; if ($currWeight > $rnd){ switch ($contentArrEx[0]){ case 1: { array_push($items,array( "item_id" => $contentArrEx[1], "item_num" => $contentArrEx[2], )); } break; case 2: { $rewards = self::dropOutReward($contentArrEx[1]); $items = array_merge($items,$rewards); } break; } unset($contentArr[$key]); break; } } } private static function disposeDropContent2($lootMeta) { $numPara = explode("|",$lootMeta['numPara']); $items = array(); $times = $numPara[0]; $number = $numPara[1]; for ($i=0;$i<$times;$i++){ for ($j=0;$j<$number;$j++){ $result = self::randWeight($lootMeta['content']); // array_push($items,$result); $items = array_merge($items,$result); } } $hashItems = array(); foreach ($items as $item){ if (isset($hashItems[$item['item_id']])){ $hashItems[$item['item_id']]['item_num'] += $item['item_num']; }else{ $hashItems[$item['item_id']] = $item; } } $finalItems = array(); foreach ($hashItems as $hashItem){ array_push($finalItems,$hashItem); } return $finalItems; } private static function randWeight($content){ $contentArr = explode("|",$content); $totalWeight = 0; foreach ($contentArr as $value){ $contentArrEx = explode(":",$value); $totalWeight += $contentArrEx[3]; } $rnd = rand() % $totalWeight; $currWeight = 0; $items = array(); foreach ($contentArr as $value){ $contentArrEx = explode(":",$value); $currWeight += $contentArrEx[3]; if ($currWeight > $rnd){ switch ($contentArrEx[0]){ case 1: { array_push($items,array( "item_id" => $contentArrEx[1], "item_num" => $contentArrEx[2], )); } break; case 2: { $items = self::dropOutReward($contentArrEx[1]); } break; } break; } } return $items; } private static function disposeDropContent1($lootMeta){ $contentArr = explode("|",$lootMeta['content']); $items = array(); if (count($contentArr) > 0){ foreach ($contentArr as $value){ $contentArrEx = explode(":",$value); switch ($contentArrEx[0]){ case 1: { array_push($items,array( "item_id" => $contentArrEx[1], "item_num" => $contentArrEx[2], )); } break; case 2: { $rewards = self::dropOutReward($contentArrEx[1]); $items = array_merge($items,$rewards); } break; } } } return $items; } }