瀏覽代碼

商城的接口

cyzhao 1 年之前
父節點
當前提交
597b190e81

+ 4 - 1
Gameserver/App/base/ErrCode.php

@@ -355,7 +355,10 @@ class ErrCode {
     
     const user_shop_LimitNum = 3402;
     
-    
+    /**
+     * 活动过期
+     */
+    const user_shop_activeExpire = 3403;
     
 // </editor-fold>
 //

+ 17 - 1
Gameserver/App/configs/GameConfig.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2023-08-09 15:33:44
+ // 日期: 2023-08-18 09:41:56
 ////////////////////
 
 namespace loyalsoft;
@@ -431,6 +431,22 @@ class GameConfig {
         return self::get_hash_item('shop_supply', $itemid);
     }
     /**
+    * 商城军备
+    * @return \shop_junbei
+    */
+    public static function shop_junbei()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'shop_junbei');
+    }
+    /**
+    * @return \sm_shop_junbei shop_junbei item数据 
+    */
+    public static function shop_junbei_getItem($itemid)
+    { 
+        return self::get_hash_item('shop_junbei', $itemid);
+    }
+    /**
     * 当前版本(时间戳)
     * @return \ver
     */

+ 39 - 7
Gameserver/App/model/User/Info_PrivateState.php

@@ -48,20 +48,52 @@ class Info_PrivateState extends Object_ext {
     #[ArrayType]
     public $cashShopReceived = array();
 
-         
-    public $supplyShopNum_JunyongBox = 0;
-
-    public $supplyShopNum_BujiBox = 0;
     
+    public $supplyBichuDic = null;
+    
+//    public $supplyShopNum_JunyongBox = 0;
+//
+//    public $supplyShopNum_BujiBox = 0;
+//    /**
+//     * 军用物资箱 X次必出后重置
+//     * @var type
+//     */
+//    public $supplyShop_JunyongBoxBichuNum = 0;
+//
+//    /**
+//     * 补给箱 X次必出后重置
+//     * @var type
+//     */
+//    public $supplyShop_BujiBoxBichuNum = 0;
+    
+//    /**
+//     * 军用物资箱是否已经有必出了
+//     * @var type
+//     */
+//    public $supplyShop_JunyongBoxBichu = 0;
+//
+//    /**
+//     * 补给箱 是否已经有必出了
+//     * @var type
+//     */
+//    public $supplyShop_BujiBoxBichu = 0;
     
+    /**
+     * 每天买的数量,每日重置(S级军备和补给箱)
+     * @var type
+     */
     public $junbeiShopNumRecord = null;
     
+    /**
+     * 总的数量,每日不重置,必出后重置
+     * @var type
+     */
     public $junbeiShop_AllNumRecord = null;
 
 
     public $junbeiShop_XinYuan = null;
     
-    public function initialize() {
+    public function initialize() {              
         $this->junbeiShopNumRecord = new \stdClass();
         $this->junbeiShop_AllNumRecord = new \stdClass();
         $this->junbeiShop_XinYuan = new \stdClass();
@@ -73,9 +105,9 @@ class Info_PrivateState extends Object_ext {
                 $this->junbeiShopNumRecord = new \stdClass();
                 $this->junbeiShop_AllNumRecord = new \stdClass();
                 $this->junbeiShop_XinYuan = new \stdClass();
+                $this->supplyBichuDic = new \stdClass();
             }
-            
-            
+                       
         }else{			
             parent::__construct($arg);
         }

+ 2 - 2
Gameserver/App/model/User/Ins_JunBeiShop.php

@@ -21,11 +21,11 @@ class Ins_JunBeiShop {
      * 购买次数
      * @var type
      */
-    public $num_one;
+    public $num_bichu1;
 
     /**
      * 买10次的次数
      * @var type
      */
-    public $num_ten;
+    public $num_bichu2;
 }

+ 163 - 38
Gameserver/App/process/ShopProc.php

@@ -33,10 +33,10 @@ class ShopProc {
      * @return type
      */
     public static function ShopBuyGift() {
-        list($type,$typeId) = req()->paras;
+        list($type,$typeId,$buyNum) = req()->paras;
         $user = ctx();
 
-        $equipId = 0;
+        $equip = array();
         switch ($type) {
             case EnumShopGift::GateGift_Shop://章节礼包
                 my_Assert(!in_array($typeId, ctx()->privateState->gateGiftReceived), ErrCode::user_shop_NotRepeatBuy);       
@@ -74,68 +74,193 @@ class ShopProc {
                 
                 break;
                 
-            case EnumShopGift::SJunBeiBox_Shop://S级军备
-                
-                
-                break;
-            case EnumShopGift::BujiBox_Shop://补给箱
-                $mo = GameConfig::shop_supply_getItem($typeId);
+            case EnumShopGift::SJunBeiBox_Shop://S级军备                                             
+                $mo = GameConfig::shop_junbei_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); 
+                my_Assert(now()>=$mo->startTs && now() < $mo->endTs, ErrCode::user_shop_activeExpire); //活动过期
+                $numDic = $user->privateState->junbeiShopNumRecord;
+                if(!StlUtil::dictHasProperty($numDic, $typeId)){
+                    $numDic->$typeId = 0;
+                    $user->privateState->junbeiShopNumRecord =$numDic;
+                }         
                 
-                $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;
+                $allDic = $user->privateState->junbeiShop_AllNumRecord;
+                if(!StlUtil::dictHasProperty($allDic, $typeId)){
+                    $allDic->$typeId = new Ins_JunBeiShop();
+                    $user->privateState->junbeiShop_AllNumRecord =$allDic;
                 }
                 
-                $qual = null;
-                if($num%$bichu == 0){
-                    $qual = $mo->bichu_qual;
-                }               
+                my_Assert($numDic->$typeId + $buyNum <= $mo->limitNum, ErrCode::user_shop_LimitNum); 
+                $costArr = explode(',', $mo->cost_item); 
+                $costId = $costArr[0];
+                $costNum = $costArr[1];
+                                                                                                  
+                $cash = 0;
+                if($buyNum == 1){//买一次                                                                                                                                         
+                    $user->privateState->junbeiShopNumRecord->$typeId += 1;
+                    $cash = $mo->cost_one;
+                } else {//买10次                                      
+                    $user->privateState->junbeiShopNumRecord->$typeId += 10;
+                    $cash = $mo->cost_ten;
+                    $costNum *= 10;
+                }
                 
-                if($qual == null){
-                    $list = explode(';', $mo->percent);
+                if(StlUtil::dictHasProperty($user->store->items, $costId) && $user->store->items->$costId >= $costNum){
+                    $user->store->removeItem($costId, $costNum);
+                } else {
+                    //判断下钻石是否充足
+                    my_Assert($user->baseInfo->cash >= $cash, ErrCode::notenough_cash_msg); 
+                    $user->baseInfo->Consume_Cash($cash);
+                }                            
+                $bichu = explode(',', $mo->bichu_1);   
+                $bichu2 = explode(',', $mo->bichu_2);               
+                $dic = GameConfig::equip();                        
+                $list = explode(';', $mo->percent);
+                        
+                for ($i = 0; $i < $buyNum; $i++) {  
+                    $qual = 0;
+                    $xiyoudu = 0;
                     $randNum = rand(0,10000);
                     $start = 0;
-                    $end = 0;
-
-                    $result = 0;
+                    $end = 0;               
                     foreach ($list as $item) {
                         $arr = explode(',', $item); 
-
                         $per = $arr[2]*100;
                         $end += $per;
-                        if($randNum >= $start && $randNum <$end){
-                            $qual = $arr[0].','.$arr[1];
+                        if($randNum >= $start && $randNum <$end){                       
+                            $qual = $arr[0];
+                            $xiyoudu = $arr[1];
                             break;
                         }
                         $start = $end;
                     }
+                    
+                    $user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu1 += 1;
+                    $user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu2 += 1;
+                    
+                    $resultStr = $qual.",".$xiyoudu;
+                    $tag = false;
+                    if($qual == $bichu[1] && $xiyoudu == $bichu[2]){
+                        $resultStr = $bichu[1].",".$bichu[2];
+                        $user->privateState->junbeiShop_AllNumRecord->$typeId->num_buchu1 = 0;
+                        $tag = true;
+                    }
+                    
+                    if($qual == $bichu2[1] && $xiyoudu == $bichu2[2]){   
+                        $resultStr = $bichu2[1].",".$bichu2[2];
+                        $user->privateState->junbeiShop_AllNumRecord->$typeId->num_buchu2 = 0;
+                        $tag = true;
+                    }
+                    
+                    if(!$tag){//没有得到杰出或是S级杰出
+                        if($user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu1 == $bichu[0]){
+                            //得杰出
+                            $resultStr = $bichu[1].",".$bichu[2];
+                            $user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu1 = 0;
+                        }
+                        if($user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu2 == $bichu2[0]){
+                            //得S级杰出
+                            $resultStr = $bichu2[1].",".$bichu2[2];
+                            $user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu2 = 0;
+                        }
+                        
+                    }
+                    
+                    if($resultStr != null){
+                        $str = explode(',', $resultStr);
+                    
+                        $equipList = array();                
+                        foreach ($dic as $tid => $item) {
+                            if($str[0] == 1 || $str[0] == 2){//稀有度为1的装备
+                                if($item->qual == $str[0] && $item->rarity == $str[1]){
+                                    $equipList[] = $item->typeId;
+                                }
+                            }elseif ($str[0] == 3) {//特定装备的
+                               if($item->typeId == $str[0]){
+                                    $equipList[] = $item->typeId;
+                                }
+
+                            }
+                        }
+
+                        $rNum = rand(0, count($equipList));
+                        $equipId = $equipList[$rNum];
+                        StoreProc::PutEquipInStore($equipId, 1);
+                        $equip[] = $equipId;
+                    }
+                    
                 }
+                           
+                $user->baseInfo->Add_Gold($mo->gold*$buyNum);
+                
+                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_Gold($mo->gold);             
+                if(!StlUtil::dictHasProperty($user->privateState->junbeiShopNumRecord, $typeId)){                   
+                    $user->privateState->junbeiShopNumRecord->$typeId = 0;
+                }                
+                $num = $user->privateState->junbeiShopNumRecord->$typeId += 1;
+                
+                if(!StlUtil::dictHasProperty($user->privateState->supplyBichuDic, $typeId)){                   
+                    $user->privateState->supplyBichuDic->$typeId = 0;
+                } 
+                $user->privateState->supplyBichuDic->$typeId += 1;
+                
+                my_Assert($num <= $mo->limitNum, ErrCode::user_shop_LimitNum); 
+                $list = explode(';', $mo->percent);
+                $randNum = rand(0,10000);
+                $start = 0;
+                $end = 0;   
+                $qual = null;               
+                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;
+                }                         
+                //必出
+                $bichu = explode(',', $mo->bichu);
+                $qArr = explode(',', $qual);
+                if($qArr[0]==$bichu[1] && $qArr[1] == $bichu[2]){//得到必出,重置数量记录
+                    $user->privateState->supplyBichuDic->$typeId = 0;     
+                    $qual = $bichu[1].','.$bichu[2];
+                } else {
+                    if($user->privateState->supplyBichuDic->$typeId == $bichu[0]){
+                        $qual = $bichu[1].','.$bichu[2];
+                        $user->privateState->supplyBichuDic->$typeId = 0;
+                    }                                     
+                }
+                                         
                 if($qual != null){
-                    $str = explode(';', $qual);
+                    $str = explode(',', $qual);
                     
                     $equipList = array();
                     $dic = GameConfig::equip();
                     foreach ($dic as $tid => $item) {
-                        if($item->type == $str[0] && $item->rarity == $str[1]){
+                        if($item->qual == $str[0] && $item->rarity == $str[1]){
                             $equipList[] = $item->typeId;
                         }
                     }
                     
                     $rNum = rand(0, count($equipList));
                     $equipId = $equipList[$rNum];
+                    StoreProc::PutEquipInStore($equipId, 1);
+                    $equip[] = $equipId;
                 }
-                
-                StoreProc::PutEquipInStore($equipId, 1);
+                               
                 break;
             case EnumShopGift::Cash_Shop://商城-钻石
                 $mo = GameConfig::shop_cash_getItem($typeId);
@@ -180,7 +305,7 @@ class ShopProc {
               
         UserProc::updateUserInfo();
         return Resp::ok(array(         
-                    'equip'=>$equipId,
+                    'equip'=>$equip,
                     'base'=>$user->baseInfo,
                     'privateState' => $user->privateState,                   
                     'store' => $user->store,));
@@ -193,8 +318,8 @@ class ShopProc {
     public static function ShopDailyClear() {
         ctx()->privateState->dailyShopReceived = array();
         ctx()->privateState->goldShopReceived = array();
-        ctx()->privateState->supplyShopNum_BujiBox = 0;
-        ctx()->privateState->supplyShopNum_JunyongBox = 0;
+        ctx()->privateState->junbeiShopNumRecord = new \stdClass();
+        
     }
     
     /**

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

@@ -231,6 +231,9 @@ class StoreProc {
     }
     
     public static function PutEquipInStore($equipId,$num) {
+        if($equipId == 0){
+            return;
+        }
         $n = count((array)ctx()->store->equip)+1;
         
         for ($index = 0; $index < $num; $index++) {