瀏覽代碼

商城接口

cyzhao 1 年之前
父節點
當前提交
c6131feeca

+ 5 - 0
Gameserver/App/base/ErrCode.php

@@ -269,6 +269,11 @@ class ErrCode {
      * 资源点不足
      */
     const notenough_resPoint = 3048;
+    
+    /**
+     * 
+     */
+    const notenough_item = 3049;
 // </editor-fold>
 //
 // <editor-fold defaultstate="collapsed" desc="    user 31xx    ">

+ 18 - 8
Gameserver/App/model/User/Info_PrivateState.php

@@ -48,24 +48,34 @@ class Info_PrivateState extends Object_ext {
     #[ArrayType]
     public $cashShopReceived = array();
 
-    /**
-     * S级军备购买次数
-     * @var type
-     */
-    public $supplyShopNum_S = 0;
-
+         
     public $supplyShopNum_JunyongBox = 0;
 
     public $supplyShopNum_BujiBox = 0;
     
     
+    public $junbeiShopNumRecord = null;
+    
+    public $junbeiShop_AllNumRecord = null;
+
+
+    public $junbeiShop_XinYuan = null;
+    
     public function initialize() {
-        
+        $this->junbeiShopNumRecord = new \stdClass();
+        $this->junbeiShop_AllNumRecord = new \stdClass();
+        $this->junbeiShop_XinYuan = new \stdClass();
     }
     
     public function __construct($arg = null) {
         if($tag == null){
-           
+            if($this->junbeiShopNumRecord == null){
+                $this->junbeiShopNumRecord = new \stdClass();
+                $this->junbeiShop_AllNumRecord = new \stdClass();
+                $this->junbeiShop_XinYuan = new \stdClass();
+            }
+            
+            
         }else{			
             parent::__construct($arg);
         }

+ 95 - 10
Gameserver/App/process/ShopProc.php

@@ -36,6 +36,7 @@ class ShopProc {
         list($type,$typeId) = req()->paras;
         $user = ctx();
 
+        $equipId = 0;
         switch ($type) {
             case EnumShopGift::GateGift_Shop://章节礼包
                 my_Assert(!in_array($typeId, ctx()->privateState->gateGiftReceived), ErrCode::user_shop_NotRepeatBuy);       
@@ -57,11 +58,11 @@ class ShopProc {
                                                                                   
                 switch ($mo->costType) {                    
                     case EnumShopCost::Gold:
-                        my_Assert($user->baseInfo->gold>= $mo->costNum, ErrCode::err_const_no); 
+                        my_Assert($user->baseInfo->gold>= $mo->costNum, ErrCode::notenough_gold_msg); 
                         ctx()->baseInfo->Consume_Gold($mo->costNum);
                         break;
                     case EnumShopCost::Cash:
-                        my_Assert($user->baseInfo->cash>= $mo->costNum, ErrCode::err_const_no); 
+                        my_Assert($user->baseInfo->cash>= $mo->costNum, ErrCode::notenough_cash_msg); 
                         ctx()->baseInfo->Consume_Cash($mo->costNum);
                         break;
                     default:
@@ -78,27 +79,108 @@ class ShopProc {
                 
                 break;
             case EnumShopGift::BujiBox_Shop://补给箱
+                $mo = GameConfig::shop_supply_getItem($typeId);
+                my_Assert($mo != null, ErrCode::err_const_no); 
                 
+                $list = explode(',', $mo->cost);
+                my_Assert(StlUtil::dictHasProperty($user->store->items, $list[0]), ErrCode::notenough_item); 
                 
+                $user->store->removeItem($list[0], $list[1]);
+                $user->baseInfo->Add_Cash($mo->gold);
+                
+                //必出
+                $bichu = $mo->bichu;
+                if($mo->type == 1){
+                    $num = $user->privateState->supplyShopNum_JunyongBox;
+                } else {
+                    $num = $user->privateState->supplyShopNum_BujiBox;
+                }
+                
+                $qual = null;
+                if($num%$bichu == 0){
+                    $qual = $mo->bichu_qual;
+                }               
+                
+                if($qual == null){
+                    $list = explode(';', $mo->percent);
+                    $randNum = rand(0,10000);
+                    $start = 0;
+                    $end = 0;
+
+                    $result = 0;
+                    foreach ($list as $item) {
+                        $arr = explode(',', $item); 
+
+                        $per = $arr[2]*100;
+                        $end += $per;
+                        if($randNum >= $start && $randNum <$end){
+                            $qual = $arr[0].','.$arr[1];
+                            break;
+                        }
+                        $start = $end;
+                    }
+                }
+                if($qual != null){
+                    $str = explode(';', $qual);
+                    
+                    $equipList = array();
+                    $dic = GameConfig::equip();
+                    foreach ($dic as $tid => $item) {
+                        if($item->type == $str[0] && $item->rarity == $str[1]){
+                            $equipList[] = $item->typeId;
+                        }
+                    }
+                    
+                    $rNum = rand(0, count($equipList));
+                    $equipId = $equipList[$rNum];
+                }
+                
+                StoreProc::PutEquipInStore($equipId, 1);
                 break;
             case EnumShopGift::Cash_Shop://商城-钻石
+                $mo = GameConfig::shop_cash_getItem($typeId);
+                my_Assert($mo != null, ErrCode::err_const_no); 
                 
+                $tag = false;
+                if(StlUtil::dictHasProperty($user->privateState->cashShopReceived, $typeId)){
+                    $tag = true;            
+                }
                 
-                break;           
-            case EnumShopGift::Gold_Shop://商城-金币
+                $reward = $mo->reward;                
+                if(!$tag){
+                    $reward = $mo->reward.';'.$mo->reward;
+                }
+                
+                StoreProc::AddMultiItemInStore($reward);
+                $user->baseInfo->charge_amt += $mo->price;
                 
+                break;           
+            case EnumShopGift::Gold_Shop://商城-金币--可以多次购买
+                $mo = GameConfig::shop_gold_getItem($typeId);
+                my_Assert($mo != null, ErrCode::err_const_no); 
+                            
+                $tempNum = 0;
+                foreach ($user->privateState->goldShopReceived as $key) {
+                    if($key == $typeId){
+                        $tempNum += 1;
+                    }
+                }
+               
+                if($tempNum >= $mo->freeNum){
+                    my_Assert($user->baseInfo->cash>= $mo->costNum, ErrCode::notenough_cash_msg); 
+                    ctx()->baseInfo->Consume_Cash($mo->price);                    
+                }
                 
+                StoreProc::AddMultiItemInStore($mo->reward);
+                            
                 break;           
             default:
                 break;
         }
-        
-        
-        //my_Assert(StlUtil::dictHasProperty($user->store->equip, $uid), ErrCode::user_store_NoEquip);                  
-
-                      
+              
         UserProc::updateUserInfo();
-        return Resp::ok(array(                   
+        return Resp::ok(array(         
+                    'equip'=>$equipId,
                     'base'=>$user->baseInfo,
                     'privateState' => $user->privateState,                   
                     'store' => $user->store,));
@@ -110,6 +192,9 @@ class ShopProc {
      */
     public static function ShopDailyClear() {
         ctx()->privateState->dailyShopReceived = array();
+        ctx()->privateState->goldShopReceived = array();
+        ctx()->privateState->supplyShopNum_BujiBox = 0;
+        ctx()->privateState->supplyShopNum_JunyongBox = 0;
     }
     
     /**

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

@@ -231,11 +231,13 @@ class StoreProc {
     }
     
     public static function PutEquipInStore($equipId,$num) {
-        $n = count((array)ctx()->store->equip);
+        $n = count((array)ctx()->store->equip)+1;
         
         for ($index = 0; $index < $num; $index++) {
             $Equip = new Ins_Equip();
             ctx()->store->equip->$n = $Equip;
+            
+            $n += 1;
         }
     }
 }