1
This commit is contained in:
parent
384d677a6a
commit
42dc915959
@ -377,4 +377,20 @@ class BaseController {
|
||||
error_log('waring unsafe call---------------' . json_encode($_REQUEST));
|
||||
}
|
||||
}
|
||||
|
||||
public function _mergeAlikeItemKey($items){
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
@ -26,19 +26,20 @@ class LootService
|
||||
$items = array();
|
||||
$depth = 0;
|
||||
self::disposeLootIndex($dropIndex,$depth,$items);
|
||||
$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;
|
||||
// $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;
|
||||
return myself()->_mergeAlikeItemKey($items);
|
||||
}
|
||||
|
||||
private static function disposeLootIndex($dropIndex,&$depth,&$items){
|
||||
|
@ -262,6 +262,7 @@ class RoomBattleDataService extends BaseService {
|
||||
$rate = isset($chestLootProbArr[$teamRank-1]) ? $chestLootProbArr[$teamRank-1] : 0;
|
||||
//error_log(json_encode($member));
|
||||
if ($rate > 0 && !empty($member['box_num'])){
|
||||
$rewardBox = array();
|
||||
for ($i = 0; $i < $member['box_num']; ++$i) {
|
||||
$rand = $rate * 100;
|
||||
$rnd = rand(1,100);
|
||||
@ -283,10 +284,17 @@ class RoomBattleDataService extends BaseService {
|
||||
}
|
||||
|
||||
foreach ($chestItems as $item){
|
||||
array_push($reward,$item);
|
||||
array_push($rewardBox,$item);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($rewardBox) > 0){
|
||||
$rewardBoxResult = myself()->_mergeAlikeItemKey($rewardBox);
|
||||
foreach ($rewardBoxResult as $item){
|
||||
array_push($reward,$item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
TGLog::writeToLog("game_2006_api","battleReport",array(
|
||||
'account_id' => $userDb['account_id'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user