cyzhao il y a 4 ans
Parent
commit
307c75d0ad

+ 4 - 0
Gameserver/Amfphp/model/User/Info_ShenMiao.php

@@ -49,6 +49,10 @@ class Info_ShenMiao extends Object_ext {
     public function initActiveItem() { 
     public function initActiveItem() { 
         $nowTs = time();
         $nowTs = time();
    
    
+        if($this->activeDic == null){
+            $this->activeDic = new \stdClass();
+        }
+        
         $aDic = new \stdClass();
         $aDic = new \stdClass();
         $enum = new Enum_Active();
         $enum = new Enum_Active();
         $list = array_values($enum->getConstList());            
         $list = array_values($enum->getConstList());            

+ 17 - 2
Gameserver/Amfphp/model/User/Ins_active.php

@@ -28,17 +28,32 @@ class Ins_active extends Object_ext{
     public $num=0;
     public $num=0;
 
 
     /**
     /**
-     * 累计次数,90次保底一次ur
+     * 10连抽的次数 90次保底一次ur
      * @var type
      * @var type
      */
      */
     public $totalNum=0;
     public $totalNum=0;
 
 
     /**
     /**
-     * 每90次内是否已经出过ur了。0:否 1:是
+     * 每90次内是否已经出过ur了。0:否 1:是---废弃
      * @var type
      * @var type
      */
      */
     public $isUr = 0;
     public $isUr = 0;
     
     
+    /**
+     * 只要出的是ur,第一次是普通ur;下一次就upUr
+     * @var type
+     */
+    public $isUpUr = 0;
+    /**
+     * 只要出的是Ssr,第一次是普通ssr;下一次就upssr
+     * @var type
+     */
+    public $isUpSsr = 0;
+    
+    /**
+     * 10次或是10连抽是否
+     * @var type
+     */
     public $isSsr = 0;
     public $isSsr = 0;
 
 
     public function __construct($args = null) {
     public function __construct($args = null) {

+ 150 - 160
Gameserver/Amfphp/process/ActiveProc.php

@@ -63,9 +63,9 @@ class ActiveProc {
      */
      */
     static function GetShenmiaoData() {
     static function GetShenmiaoData() {
         $req = req();          
         $req = req();          
-        $shenmiaoInfo = $req->userInfo->game->shenmiao;
+        //$shenmiaoInfo = $req->userInfo->game->shenmiao;
         
         
-        //$shenmiaoInfo = new Info_ShenMiao();
+        $shenmiaoInfo = new Info_ShenMiao($req->userInfo->game->shenmiao);
         $shenmiaoInfo->initActiveItem();
         $shenmiaoInfo->initActiveItem();
         $req->userInfo->game->shenmiao = $shenmiaoInfo;
         $req->userInfo->game->shenmiao = $shenmiaoInfo;
         
         
@@ -94,8 +94,8 @@ class ActiveProc {
             $shenmo = GameConfig::shenmiao_getItem($shenmiaoInfo->activeDic->$type->id);
             $shenmo = GameConfig::shenmiao_getItem($shenmiaoInfo->activeDic->$type->id);
             if($shenmo->discount != 0){
             if($shenmo->discount != 0){
                 $sList = explode(',', $shenmo->cost);
                 $sList = explode(',', $shenmo->cost);
-                //$costVal = $sList[1] - $sList[1]*$shenmo->discount/100;
-                //$costStr = $sList[0].','.$costVal*$num;
+                $costVal = $sList[1] - $sList[1]*$shenmo->discount/100;
+                $costStr = $sList[0].','.$costVal*$num;
                 StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$costVal*$num);
                 StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$costVal*$num);
             }      
             }      
             
             
@@ -120,55 +120,28 @@ class ActiveProc {
                 
                 
             if($shenmiaoInfo->activeDic->$type->totalNum >= 20){
             if($shenmiaoInfo->activeDic->$type->totalNum >= 20){
                 StlUtil::dictRemove($shenmiaoInfo->activeDic, $type);
                 StlUtil::dictRemove($shenmiaoInfo->activeDic, $type);
-            }
-                                                       
-        } else if(Enum_Active::OpenWish == $type){            
-            $old = intval($shenmiaoInfo->activeDic->$type->totalNum/90);            
-            $shenmiaoInfo->activeDic->$type->totalNum += $num;
-            $new = intval($shenmiaoInfo->activeDic->$type->totalNum/90);        
-            $shenmo = GameConfig::shenmiao_getItem($shenmiaoInfo->activeDic->$type->id);            
+            }                                                     
+        } else if(Enum_Active::OpenWish == $type){                             
+            $shenmo = GameConfig::shenmiao_getItem($shenmiaoInfo->activeDic->$type->id);                
             if($num == 1){
             if($num == 1){
                 $shenmiaoInfo->activeDic->$type->num += $num; 
                 $shenmiaoInfo->activeDic->$type->num += $num; 
                 $sList = explode(',', $shenmo->cost);
                 $sList = explode(',', $shenmo->cost);
                 StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$sList[1]);
                 StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$sList[1]);
                   
                   
-                $itemType = self::activeRandom($shenmo->per, $shenmo);
-               
-                $aid =self::getActiveRandomItem($itemType, $shenmo);    
-                if($shenmiaoInfo->activeDic->$type->num%10 == 0){
-                    if($shenmiaoInfo->activeDic->$type->num%90 == 0){
-                        if($shenmiaoInfo->activeDic->$type->Ur == 0){
-                            $aid =self::getActiveRandomItem(Enum_ActiveItemType::Ur, $shenmo);
-                            $list[] = $aid;
-                        } else {                         
-                            $list[] = $aid;
-                            $shenmiaoInfo->activeDic->$type->Ur = 0;
-                        }                                             
-                    } else {
-                        if($shenmiaoInfo->activeDic->$type->Ssr == 0){
-                            $aid =self::getActiveRandomItem(Enum_ActiveItemType::Ssr, $shenmo);
-                            $list[] = $aid;
-                        } else {                         
-                            $list[] = $aid;
-                            $shenmiaoInfo->activeDic->$type->Ssr = 0;
-                        }                      
-                    }                                                                                                     
-                } else {                              
-                    if($itemType == Enum_ActiveItemType::Ssr){
-                        $shenmiaoInfo->activeDic->$type->Ssr = 1;
-                    }
+                $itemType = self::activeRandom($shenmo->per, $shenmo);              
+                $aid =self::getActiveRandomItem($itemType, $shenmo);
                 
                 
-                    if($itemType == Enum_ActiveItemType::Ur){
-                        $shenmiaoInfo->activeDic->$type->Ssr = 1;
-                        $shenmiaoInfo->activeDic->$type->Ur = 1;
-                    }
-                     $list[] = $aid;
-                }             
+                if($shenmiaoInfo->activeDic->$type->num % glc()->Active_UR_Num == 0 && $itemType != Enum_ActiveItemType::Ur){
+                    $aid =self::getActiveRandomItem(Enum_ActiveItemType::Ur, $shenmo);
+                    $list[] = $aid;
+                } else {
+                    $list[] = $aid;
+                }                  
             } else {//10连抽
             } else {//10连抽
-                $sList = explode(',', $shenmo->cost);
-                //$costStr = $sList[0].','.$sList[1]*$num;
-                StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$sList[1]*$num);              
+                $sList = explode(',', $shenmo->cost);             
+                StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$sList[1]*$num);
                 
                 
+                $shenmiaoInfo->activeDic->$type->totalNum += $num;                              
                 $tag = false;
                 $tag = false;
                 $n = 0;
                 $n = 0;
                 for ($index1 = 0; $index1 < $num; $index1++) {
                 for ($index1 = 0; $index1 < $num; $index1++) {
@@ -180,67 +153,35 @@ class ActiveProc {
                     if($n==10 && $tag == false){
                     if($n==10 && $tag == false){
                         $list[] =self::getActiveRandomItem(Enum_ActiveItemType::Ssr, $shenmo);
                         $list[] =self::getActiveRandomItem(Enum_ActiveItemType::Ssr, $shenmo);
                     } else {
                     } else {
-                        $list[] =self::getActiveRandomItem($itemType, $shenmo);
-                        if($itemType == Enum_ActiveItemType::Ur){
-                            $shenmiaoInfo->activeDic->$type->Ur = 1;
-                        }                      
+                        $list[] =self::getActiveRandomItem($itemType, $shenmo);                                           
                     }  
                     }  
-                }
-                
-                if($old != $new){//说明过了一个90次的抽奖
-                    if($shenmiaoInfo->activeDic->$type->Ur == 0){
-                        $aid =self::getActiveRandomItem(Enum_ActiveItemType::Ur, $shenmo); 
-                        $list[0] = $aid;
-                    } else {
-                        $shenmiaoInfo->activeDic->$type->Ur = 0;
-                    }
-                }                                             
-            }
-            
-        } else {//不定期活动
-            $old = intval($shenmiaoInfo->activeDic->$type->totalNum/90);        
-            $shenmiaoInfo->activeDic->$type->totalNum += $num;
-            $new = intval($shenmiaoInfo->activeDic->$type->totalNum/90);            
-            $shenmo = GameConfig::shenmiao_getItem($shenmiaoInfo->activeDic->$type->id);  
-            
+                }               
+                if($shenmiaoInfo->activeDic->$type->totalNum >= glc()->Active_UR_Num){//第90次必得
+                    $aid =self::getActiveRandomItem(Enum_ActiveItemType::Ur, $shenmo); 
+                    $list[0] = $aid;
+                    $shenmiaoInfo->activeDic->$type->totalNum = 0;
+                }                                                                           
+            }          
+        } else {//不定期活动                                  
+            $shenmo = GameConfig::shenmiao_getItem($shenmiaoInfo->activeDic->$type->id);            
             if($num == 1){
             if($num == 1){
                 $shenmiaoInfo->activeDic->$type->num += $num; 
                 $shenmiaoInfo->activeDic->$type->num += $num; 
                 $sList = explode(',', $shenmo->cost);
                 $sList = explode(',', $shenmo->cost);
                 StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$sList[1]);
                 StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$sList[1]);
                   
                   
                 $itemType = self::activeRandom($shenmo->per, $shenmo);
                 $itemType = self::activeRandom($shenmo->per, $shenmo);
-                $aid =self::getActiveRandomItem_2($itemType, $shenmo);//随机出的id                              
-                if($shenmiaoInfo->activeDic->$type->num%10 == 0){
-                    if($shenmiaoInfo->activeDic->$type->num%90 == 0){
-                        if($shenmiaoInfo->activeDic->$type->Ur == 0){
-                            $aid =self::getActiveRandomItem_2(Enum_ActiveItemType::Ur, $shenmo);
-                            $list[] = $aid;
-                        } else {
-                            $list[] = $aid;
-                            $shenmiaoInfo->activeDic->$type->Ur = 0;
-                        }                                             
-                    } else {
-                        if($shenmiaoInfo->activeDic->$type->Ssr == 0){
-                            $aid =self::getActiveRandomItem_2(Enum_ActiveItemType::Ssr, $shenmo);
-                            $list[] = $aid;
-                        } else {
-                            $list[] = $aid;
-                            $shenmiaoInfo->activeDic->$type->Ssr = 0;
-                        }                      
-                    }                                                                                                     
-                } else {                                 
-                    if($itemType == Enum_ActiveItemType::Ssr){
-                        $shenmiaoInfo->activeDic->$type->Ssr = 1;
-                    }               
-                    if($itemType == Enum_ActiveItemType::Ur){
-                        $shenmiaoInfo->activeDic->$type->Ssr = 1;
-                        $shenmiaoInfo->activeDic->$type->Ur = 1;
-                    }
+                $aid =self::getActiveRandomItem_3($itemType, $shenmo);//随机出的id                                  
+                if($shenmiaoInfo->activeDic->$type->num% glc()->Active_UR_Num == 0){
+                    $aid =self::getActiveRandomItem_3(Enum_ActiveItemType::Ur, $shenmo);
                     $list[] = $aid;
                     $list[] = $aid;
-                }
+                } else {
+                    $list[] = $aid;
+                }           
             } else {
             } else {
                 $sList = explode(',', $shenmo->cost);
                 $sList = explode(',', $shenmo->cost);
-                StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$sList[1]);             
+                StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$sList[1]*$num);             
+                
+                $shenmiaoInfo->activeDic->$type->totalNum += $num;
                 
                 
                 $tag = false;
                 $tag = false;
                 $n = 0;
                 $n = 0;
@@ -251,23 +192,17 @@ class ActiveProc {
                         $tag = true;
                         $tag = true;
                     }
                     }
                     if($n==10 && $tag == false){
                     if($n==10 && $tag == false){
-                        $list[] =self::getActiveRandomItem_2(Enum_ActiveItemType::Ssr, $shenmo);
+                        $list[] =self::getActiveRandomItem_3(Enum_ActiveItemType::Ssr, $shenmo);
                     } else {
                     } else {
-                        $list[] =self::getActiveRandomItem_2($itemType, $shenmo);
-                        if($itemType == Enum_ActiveItemType::Ur){
-                            $shenmiaoInfo->activeDic->$type->Ur = 1;
-                        }                      
+                        $list[] =self::getActiveRandomItem_3($itemType, $shenmo);                                         
                     }  
                     }  
                 }
                 }
                 
                 
-                if($old != $new){//说明过了一个90次的抽奖
-                    if($shenmiaoInfo->activeDic->$type->Ur == 0){
-                        $aid =self::getActiveRandomItem_2(Enum_ActiveItemType::Ur, $shenmo); 
-                        $list[0] = $aid;
-                    } else {
-                        $shenmiaoInfo->activeDic->$type->Ur = 0;
-                    }
-                }
+                if($shenmiaoInfo->activeDic->$type->totalNum >= glc()->Active_UR_Num){//第90次必得
+                    $aid =self::getActiveRandomItem_3(Enum_ActiveItemType::Ur, $shenmo); 
+                    $list[0] = $aid;
+                    $shenmiaoInfo->activeDic->$type->totalNum = 0;
+                }                               
             }          
             }          
         }  
         }  
         
         
@@ -281,10 +216,10 @@ class ActiveProc {
         
         
         return Resp::ok(array(#                                                 # 返回值
         return Resp::ok(array(#                                                 # 返回值
                     'shenmiaoInfo' => $shenmiaoInfo,
                     'shenmiaoInfo' => $shenmiaoInfo,
-                    'list'=>$list,            
+                    'list'=>$list,
+                    'store'=>$req->userInfo->game->store,
         ));
         ));
-        
-    }
+    }   
     /**
     /**
      * 
      * 
      * @param type $randCtx
      * @param type $randCtx
@@ -306,31 +241,24 @@ class ActiveProc {
             $type += 1;
             $type += 1;
             $start = $end;
             $start = $end;
         }
         }
-        return $type;
-        
-//        $id = 0;
-//        switch ($type) {
-//            case Enum_ActiveItemType::Sr:
-//                $id = array_rand($mo->srList);
-//                break;
-//            case Enum_ActiveItemType::Ssr:
-//                $id = array_rand($mo->ssrList);
-//
-//                break;
-//            case Enum_ActiveItemType::Ur:
-//                $id = array_rand($mo->urList);
-//                break;
-//            default:
-//                break;
-//        }      
-//        return $id;
+        return $type;     
     }
     }
-    
+    /**
+     * 
+     * @param type $arr
+     * @return type
+     */
     public static function randList($arr) {
     public static function randList($arr) {
         $rand = rand(0, count($arr)-1);    
         $rand = rand(0, count($arr)-1);    
         return $arr[$rand];
         return $arr[$rand];
     }
     }
     
     
+    /**
+     * 
+     * @param type $type
+     * @param type $mo
+     * @return type
+     */
     public static function getActiveRandomItem($type,$mo) {            
     public static function getActiveRandomItem($type,$mo) {            
         $id = 0;
         $id = 0;
         switch ($type) {
         switch ($type) {
@@ -355,7 +283,9 @@ class ActiveProc {
      * @param sm_shenmiao $mo
      * @param sm_shenmiao $mo
      * @return type
      * @return type
      */
      */
-    public static function getActiveRandomItem_2($type,$mo) {            
+    public static function getActiveRandomItem_3($type,$mo) {    
+        $shenmiaoInfo = req()->userInfo->game->shenmiao;
+       
         $id = 0;
         $id = 0;
         switch ($type) {
         switch ($type) {
             case Enum_ActiveItemType::Sr:
             case Enum_ActiveItemType::Sr:
@@ -365,25 +295,43 @@ class ActiveProc {
                 if($mo->ssrUp != null){
                 if($mo->ssrUp != null){
                     $dic = new \stdClass();
                     $dic = new \stdClass();
                     $ssrList = explode(';', $mo->ssrUp);
                     $ssrList = explode(';', $mo->ssrUp);
+                    
+                    $tNum = 0;
                     foreach ($ssrList as $val) {
                     foreach ($ssrList as $val) {
                         $sList = explode(',', $val); 
                         $sList = explode(',', $val); 
                         $sid = $sList[0];
                         $sid = $sList[0];
                         $dic->$sid = $sList[1];
                         $dic->$sid = $sList[1];
-                    }                                  
-                    $rand = rand(1,100);      
-                    $start = 0;
-                    foreach ($dic as $k=>$val) {
-                        $end = $val + $start;
-                        if($rand > $start && $rand <= $end){
-                            $id = $k;
-                            break;
-                        } else {
-                            $id = array_rand($mo->ssrList);                           
-                            break;
-                        }
-                        $start = $end;
-                    }
+                        $tNum += $sList[1];
+                    } 
                     
                     
+                    if($shenmiaoInfo->activeDic->$type->isUpSsr == 1){
+                        $rand = rand(1,$tNum);      
+                        $start = 0;                                                         
+                        foreach ($dic as $k=>$val) {
+                            $end = $val + $start;
+                            if($rand > $start && $rand <= $end){//随机到Up得id
+                                $id = $k;                             
+                                break;
+                            }
+                            $start = $end;
+                        }                       
+                        $shenmiaoInfo->activeDic->$type->isUpSsr = 0;
+                    } else {
+                        $rand = rand(1,10000);      
+                        $start = 0;                                                         
+                        foreach ($dic as $k=>$val) {
+                            $end = $val + $start;
+                            if($rand > $start && $rand <= $end){//随机到Up得id
+                                $id = $k;                           
+                                break;
+                            } else {//随机到普通的id
+                                $shenmiaoInfo->activeDic->$type->isUpSsr = 1;
+                                $id = self::randList(explode(',', $mo->ssrList));                           
+                                break;
+                            }
+                            $start = $end;
+                        }
+                    }                                                           
                 } else {
                 } else {
                     $id = self::randList(explode(',', $mo->ssrList));               
                     $id = self::randList(explode(',', $mo->ssrList));               
                 }                                                             
                 }                                                             
@@ -392,25 +340,42 @@ class ActiveProc {
                 if($mo->ssrUp != null){
                 if($mo->ssrUp != null){
                     $dic = new \stdClass();
                     $dic = new \stdClass();
                     $urList = explode(';', $mo->urUp);
                     $urList = explode(';', $mo->urUp);
+                    $tNum = 0;
                     foreach ($urList as $val) {
                     foreach ($urList as $val) {
                         $sList = explode(',', $val); 
                         $sList = explode(',', $val); 
                         $sid = $sList[0];
                         $sid = $sList[0];
                         $dic->$sid = $sList[1];
                         $dic->$sid = $sList[1];
-                    }                                  
-                    $rand = rand(1,100);      
-                    $start = 0;
-                    foreach ($dic as $k=>$val) {
-                        $end = $val + $start;
-                        if($rand > $start && $rand <= $end){
-                            $id = $k;
-                            break;
-                        } else {
-                            $id = array_rand($mo->urList);                           
-                            break;
-                        }
-                        $start = $end;
-                    }
+                        $tNum += $sList[1];
+                    }      
                     
                     
+                    if($shenmiaoInfo->activeDic->$type->isUpUr == 1){
+                        $rand = rand(1,$tNum);      
+                        $start = 0;                                                         
+                        foreach ($dic as $k=>$val) {
+                            $end = $val + $start;
+                            if($rand > $start && $rand <= $end){//随机到Up得id
+                                $id = $k;                             
+                                break;
+                            }
+                            $start = $end;
+                        }                       
+                        $shenmiaoInfo->activeDic->$type->$isUpUr = 0;
+                    } else {
+                        $rand = rand(1,10000);      
+                        $start = 0;
+                        foreach ($dic as $k=>$val) {
+                            $end = $val + $start;
+                            if($rand > $start && $rand <= $end){
+                                $id = $k;
+                                break;
+                            } else { 
+                                $shenmiaoInfo->activeDic->$type->isUpUr = 1;
+                                $id = self::randList(explode(',', $mo->urList));         
+                                break;
+                            }
+                            $start = $end;
+                        }
+                    }                                                                                               
                 } else {         
                 } else {         
                     $id = self::randList(explode(',', $mo->urList));      
                     $id = self::randList(explode(',', $mo->urList));      
                 }                                                                     
                 }                                                                     
@@ -420,6 +385,31 @@ class ActiveProc {
         }      
         }      
         return $id;
         return $id;
     }
     }
+      
+    /**
+     * 从SSr 和  uR中得一个
+     * @param type $param
+     */
+    public function functionName($per) {
+        $list = explode(',', $randCtx);
+        $n = 0;
+        foreach ($list as $value) {
+            if($n == 0){
+                contains($value);
+            }
+            $n+= 1;
+        }
+        $start = 0;
+        foreach ($list as $val) {
+            $end = $val + $start;
+            if($rand > $start && $rand <= $end){
+                break;
+            }
+            $type += 1;
+            $start = $end;
+        }
+        
+    }
     
     
     /**
     /**
      * 
      *