Browse Source

商城宝箱bug修复

cyzhao 1 năm trước cách đây
mục cha
commit
15efd9921a
1 tập tin đã thay đổi với 27 bổ sung4 xóa
  1. 27 4
      Gameserver/App/process/ShopProc.php

+ 27 - 4
Gameserver/App/process/ShopProc.php

@@ -80,6 +80,12 @@ class ShopProc {
                 $mo = GameConfig::shop_daily_getItem($typeId);
                 my_Assert($mo != null, ErrCode::err_const_no);   
                 
+                if($mo->freeNum > 0){
+                    
+                    
+                    
+                }
+                
                 my_Assert(in_array($typeId, $user->privateState->dailyShopRandItems), ErrCode::err_const_no);                                            
                 my_Assert(!in_array($typeId, $user->privateState->dailyShopReceived), ErrCode::user_shop_NotRepeatBuy);   
                                                                                   
@@ -190,7 +196,7 @@ class ShopProc {
                             }
                             
                             $n = rand(0, count($gemList)-1);                  
-                            $gem = StoreProc::initGem($gateGift[$n]->typeId);
+                            $gem = StoreProc::initGem($gemList[$n]->typeId);
                             $resultArr[] = $gem->uid;
                             StoreProc::PutGemInStore2($gem);
                     }                                                                                       
@@ -366,9 +372,26 @@ class ShopProc {
         foreach ($arrType as $k) {            
             if(StlUtil::dictHasProperty($dataDic,$k) && count($dataDic->$k) > 0){
                 $arr2 = $dataDic->$k;            
-                $num = rand(0, count($arr2)-1);
-                $result[] = $arr2[$num];
-                unset($arr2[$num]);
+                $allNum = 0;
+                foreach ($arr2 as $giftTypeId) {
+                    $allNum += GameConfig::shop_daily_getItem($giftTypeId)->per;                   
+                }
+                
+                $randNum = rand(1,$allNum);
+                $start = 0;
+                $end = 0;
+                $index = 0;
+                foreach ($arr2 as $itemId) {
+                    $per = GameConfig::shop_daily_getItem($itemId)->per;
+                    $end += $per;
+                    if($randNum >= $start && $randNum < $end){
+                        $result[] = $itemId;
+                        break;
+                    }
+                    $start = $end;
+                    $index += 1;
+                }                            
+                unset($arr2[$index]);
                 
                 $dataDic->$k = array_values($arr2);             
             }