Browse Source

巡逻接口

cyzhao 1 year ago
parent
commit
82bc589892

+ 161 - 8
Gameserver/App/process/FightProc.php

@@ -51,24 +51,177 @@ class FightProc {
         $gateId = ctx()->gates->UnlockedGatesMaxId;
         $gateMo = GameConfig::gate_getItem($gateId);
         my_Assert($gateMo!=null, ErrCode::err_const_no);
-        
-        
-        
-        if($type == 1){//巡逻
+                      
+        if($type == 1){//巡逻                  
+            $curTs = now();
+            $startTs = ctx()->gates->xunluo_StartTs;
+            $ts = $curTs - $startTs;
+            $ts2 = intval($ts/60);//总的分钟数 
+
+            $fenzhong = intval($ts2/10);//有几个10分钟
+            $gold = 0;
+            $exp = 0;
+            $price = "";
+            if ($fenzhong > 0)
+            {
+                $gold = intval($gateMo->gold_xunluo / 6 * $fenzhong);
+                $exp = intval($gateMo->exp_xunluo / 6 * $fenzhong);    
+                $price = "1,".$gold.';'."4,".$exp;
+            }            
+            
+            $itemStr = explode(';', $gateMo->xunluo_item_ts);                     
+            $itemId = 0;
+            $itemNum = 0;
+             
+            $tempTs = 0;
+            foreach ($itemStr as $s) {
+                $arr = explode('-', $s);
+                $tsItemArr = explode(',', $arr[0]);
+                $sTs = $tsItemArr[0];//开始时间
+                $eTs = $tsItemArr[1]; //终止时间
+                $produceTs = $tsItemArr[2];//间隔
+                while (true)
+                {                       
+                        $tempTs += $produceTs;
+                        if ($tempTs <= $eTs && $tempTs <= $ts2)
+                        {
+                            $sList = explode(',', $arr[1]);
+                            $itemId = $sList[0];
+                            $itemNum += $sList[1];
+                        }
+
+                        if ($tempTs >= $ts2)
+                        {
+                            break;
+                        }
+
+                        if ($tempTs >= $eTs)
+                        {
+                            $tempTs = $eTs;
+                            break;
+                        }
+                }
+                
+                if ($tempTs >= $ts2)
+                {
+                    break;
+                }                
+            }
+            if($itemNum > 0){
+                $price = $price.";".$itemId.','.$itemNum;
+            }
+            
+            //---------------------------
+            $tuzhiStr = explode(';',$gateMo->xunluo_tuzhi_ts);                                          
+            $tuzhiId = 0;
+            $tuzhiNum = 0;
+
+            $tempTs2 = 0;
+            foreach ($tuzhiStr as $s)
+            {
+                $arr = explode('-', $s);
+                $tsItemArr = explode(',', $arr[0]);
+                $sTs = $tsItemArr[0];//开始时间
+                $eTs = $tsItemArr[1]; //终止时间
+                $produceTs = $tsItemArr[2];//间隔
+
+                    while (true)
+                    {
+                        $tempTs2 += $produceTs;
+                        if ($tempTs2 <= $eTs && $tempTs2 <= $ts2)
+                        {
+                            $sList = explode(',', $arr[1]);
+                            $tuzhiId = $sList[0];
+                            $tuzhiNum += $sList[1];
+                        }
+
+                        if ($tempTs2 >= $ts2)
+                        {
+                            break;
+                        }
+
+                        if ($tempTs2 >= $eTs)
+                        {
+                            $tempTs2 = $eTs;
+                            break;
+                        }
+                    }
+
+                    if ($tempTs2 >= $ts2)
+                    {
+                        break;
+                    }
+            }
+            if($tuzhiNum > 0){
+                $price = $price.";".$tuzhiId.','.$tuzhiNum;   
+            }
+            
+            //---------------------
+            $equipStr = explode(';', $gateMo->xunluo_equip_ts);                                     
+            $equipId = 0;
+            $equipNum = 0;
+
+            $tempTs3 = 0;
+                foreach ($equipStr as $s)
+                {
+                    $arr = explode('-', $s);
+                    $tsItemArr = explode(',', $arr[0]);
+                    $sTs = $tsItemArr[0];//开始时间
+                    $eTs = $tsItemArr[1]; //终止时间
+                    $produceTs = $tsItemArr[2];//间隔
+
+                    while (true)
+                    {
+                        $tempTs3 += $produceTs;
+                        if ($tempTs3 <= $eTs && $tempTs3 <= $ts2)
+                        {
+                            $sList = explode(',', $arr[1]);
+                            $equipId = $sList[0];
+                            $equipNum += $sList[1];
+                        }
+
+                        if ($tempTs3 >= $ts2)
+                        {
+                            break;
+                        }
+
+                        if ($tempTs3 >= $eTs)
+                        {
+                            $tempTs3 = $eTs;
+                            break;
+                        }
+                    }
+
+                    if ($tempTs3 >= $ts2)
+                    {
+                        break;
+                    }
+                }
+            if($equipNum > 0){
+                $price = $price.";".$equipId.','.$equipNum;
+            } 
+            StoreProc::AddMultiItemInStore($price);
             ctx()->gates->xunluo_StartTs = now();
-        } else {//快速巡逻
+            
+        } else {//快速巡逻            
+            my_Assert(ctx()->gates->xunluo_quick_buyRecord < $gateMo->xueluo_quick_num, ErrCode::err_const_no);
             ctx()->gates->xunluo_quick_buyRecord += 1;
-            ctx()->baseInfo->Consume_tili(15);           
+            ctx()->baseInfo->Consume_tili(15);        
+            StoreProc::AddMultiItemInStore($gateMo->xueluo_quick_reward);
         }    
         
         UserProc::updateUserInfo();
         $ret = array(                   
-            'ok' => 1,        
+            'gates' => ctx()->gates,        
             );
         return Resp::ok($ret);
     }
     
-    /**
+    public static function FightDailyClear() {
+        ctx()->gates->xunluo_quick_buyRecord = 0;
+    }
+
+        /**
      * 剧情回存
      * @return type
      */

+ 3 - 0
Gameserver/App/process/StoreProc.php

@@ -249,6 +249,9 @@ class StoreProc {
                     case 3:
                         ctx()->baseInfo->Add_tili($num);
                         break;
+                    case 4:
+                        ctx()->baseInfo->Add_Exp($num);
+                        break;
                     case 100:
                     case 101:
                     case 102:

+ 2 - 0
Gameserver/App/process/UserProc.php

@@ -265,6 +265,8 @@ class UserProc {
     static function OnNewDay($isnew) {
         ShopProc::DailyShopItemRand();
         ShopProc::ShopDailyClear();
+        //FightProc::FightDailyClear();
+        
     }
 
 // <editor-fold defaultstate="collapsed" desc="创建新用户">