diff --git a/webapp/controller/BaseController.class.php b/webapp/controller/BaseController.class.php index eb51257c..b7e4d8d0 100644 --- a/webapp/controller/BaseController.class.php +++ b/webapp/controller/BaseController.class.php @@ -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; + } } diff --git a/webapp/services/LootService.php b/webapp/services/LootService.php index 9c653bb2..0db1ead8 100644 --- a/webapp/services/LootService.php +++ b/webapp/services/LootService.php @@ -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){ diff --git a/webapp/services/RoomBattleDataService.php b/webapp/services/RoomBattleDataService.php index 572a3dd9..2696b695 100644 --- a/webapp/services/RoomBattleDataService.php +++ b/webapp/services/RoomBattleDataService.php @@ -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'],