Browse Source

商城宝石宝箱接口

cyzhao 1 year ago
parent
commit
0431251b09

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

@@ -400,6 +400,8 @@ class ErrCode {
      */
     const user_shop_activeExpire = 3403;
     
+    const user_shop_FreeNumLimit = 3404;
+    
 // </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 
- // 日期: 2024-04-10 14:40:02
+ // 日期: 2024-04-17 11:16:09
 ////////////////////
 
 namespace loyalsoft;
@@ -479,6 +479,22 @@ class GameConfig {
         return self::get_hash_item('plots', $itemid);
     }
     /**
+    * 商城宝箱表
+    * @return \shop_box
+    */
+    public static function shop_box()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'shop_box');
+    }
+    /**
+    * @return \sm_shop_box shop_box item数据 
+    */
+    public static function shop_box_getItem($itemid)
+    { 
+        return self::get_hash_item('shop_box', $itemid);
+    }
+    /**
     * 当前版本(时间戳)
     * @return \ver
     */

+ 17 - 1
Gameserver/App/model/Const/GameConfig.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-10 16:44:37
+ // 日期: 2024-04-17 11:16:09
 ////////////////////
 
 /**
@@ -477,6 +477,22 @@ class GameConfig {
         return self::get_hash_item('plots', $itemid);
     }
     /**
+    * 商城宝箱表
+    * @return \shop_box
+    */
+    public static function shop_box()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'shop_box');
+    }
+    /**
+    * @return \sm_shop_box shop_box item数据 
+    */
+    public static function shop_box_getItem($itemid)
+    { 
+        return self::get_hash_item('shop_box', $itemid);
+    }
+    /**
     * 当前版本(时间戳)
     * @return \ver
     */

+ 1 - 1
Gameserver/App/model/Const/sm_achieve_new.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-03-28 14:31:23
+ // 日期: 2024-04-15 13:59:34
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_active_day7_accumulate.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-02 15:31:10
+ // 日期: 2024-04-15 13:59:34
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_activity_day7.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-03-20 15:21:16
+ // 日期: 2024-04-15 13:59:34
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_clientVersionHistory.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-03-20 15:21:16
+ // 日期: 2024-04-15 13:59:34
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_equip.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-10 16:42:37
+ // 日期: 2024-04-15 13:59:34
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_equip_levelupgrade.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-10 16:36:02
+ // 日期: 2024-04-15 13:59:35
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_errmsg.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-03-20 15:21:16
+ // 日期: 2024-04-15 13:59:35
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_evolve.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-02 15:30:39
+ // 日期: 2024-04-15 13:59:35
 ////////////////////
 
 

+ 4 - 3
Gameserver/App/model/Const/sm_gate.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-08 15:03:38
+ // 日期: 2024-04-15 17:32:47
 ////////////////////
 
 
@@ -15,8 +15,9 @@ class sm_gate
 
     /**
     * @var Int32 关卡id: 
-    *  命名规律:关卡类型(1主线2主线挑战)+关卡序号(最大999)+关卡风格(编号待定)+关卡类型(0四方连续1上下连续2固定)+关卡难度(1普通2困难3噩梦)
-    *  例如:10010101,20010111  
+    *  命名规律:关卡类型(1主线2主线挑战)+ 地图资源类型(最大9999)+关卡难度(1普通2困难3噩梦)+ 关卡序号(最大999)
+    *  例如:10010101,20010111
+    *  备注: 地图资源类型(第一位: 1四方连续 2上下连续 3固定 4左右连续)  
     */
     public $gateId;
 

+ 1 - 1
Gameserver/App/model/Const/sm_gate_sbox.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-02 15:29:55
+ // 日期: 2024-04-15 13:59:35
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_gem.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-08 17:28:40
+ // 日期: 2024-04-15 13:59:35
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_globalsettings.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-10 16:05:28
+ // 日期: 2024-04-15 13:59:35
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_hero.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-08 17:02:46
+ // 日期: 2024-04-16 16:32:47
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_heroattr.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-02 15:30:55
+ // 日期: 2024-04-15 13:59:35
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_item.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-10 16:44:20
+ // 日期: 2024-04-15 13:59:35
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_plots.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-03-28 14:37:59
+ // 日期: 2024-04-15 13:59:36
 ////////////////////
 
 

+ 1 - 31
Gameserver/App/model/Const/sm_predicate.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-03-28 16:18:24
+ // 日期: 2024-04-16 09:59:45
 ////////////////////
 
 
@@ -78,36 +78,6 @@ class sm_predicate
     */
     public $uniqueKey;
 
-    /**
-    * @var String 词条前置条件类型:'none','attack', 'hpGreatThan', 'hpBelowThan', 其它待补充 default(none) 
-    */
-    public $preConditionType;
-
-    /**
-    * @var Single 词条前置条件参数: default(0) 
-    */
-    public $preConditionParam;
-
-    /**
-    * @var String 后置行为类型 default(none) 
-    */
-    public $postActionType;
-
-    /**
-    * @var Single 后置行为参数 default(0) 
-    */
-    public $postActionParam;
-
-    /**
-    * @var String 后置行为条件 default(none) 
-    */
-    public $postConditionType;
-
-    /**
-    * @var Single 后置行为条件参数 default(0) 
-    */
-    public $postConditionParam;
-
     /**
     * @var String 进化模块里的消息描述信息  
     */

+ 1 - 1
Gameserver/App/model/Const/sm_service_schedule.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-03-20 15:21:22
+ // 日期: 2024-04-15 13:59:36
 ////////////////////
 
 

+ 77 - 0
Gameserver/App/model/Const/sm_shop_box.php

@@ -0,0 +1,77 @@
+<?php
+////////////////////
+ // 由CodeGenerator创建。
+ // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
+ // author: gwang 
+ // 日期: 2024-04-17 10:49:26
+////////////////////
+
+
+/**
+ * Static Model shop_box 商城宝箱表
+ */
+class sm_shop_box
+{
+
+    /**
+    * @var Int32 用途未知!!请到数据库中添加字段注释。  
+    */
+    public $id;
+
+    /**
+    * @var Int32 宝石id  
+    */
+    public $typeId;
+
+    /**
+    * @var String 用途未知!!请到数据库中添加字段注释。  
+    */
+    public $name;
+
+    /**
+    * @var Int32 1;普通宝箱  2 璀璨宝箱    
+    */
+    public $type;
+
+    /**
+    * @var String 10次内必出蓝色宝石  
+    */
+    public $desc;
+
+    /**
+    * @var String 用途未知!!请到数据库中添加字段注释。  
+    */
+    public $icon;
+
+    /**
+    * @var Int32 购买一个花费的钻石 default(0) 
+    */
+    public $cost_one;
+
+    /**
+    * @var Int32 购买十个花费的钻石 default(0) 
+    */
+    public $cost_ten;
+
+    /**
+    * @var String X次必出某品阶宝石 例子:次数,必出的宝石品阶  
+    */
+    public $bichu1;
+
+    /**
+    * @var String X次必出某品阶宝石 例子:次数,必出的宝石品阶  
+    */
+    public $bichu2;
+
+    /**
+    * @var Int32 免费次数倒计时时间(天为单位)  
+    */
+    public $freeDownTs;
+
+    /**
+    * @var String 不同品阶宝石的随机概率  
+    */
+    public $percent;
+
+}
+

+ 1 - 1
Gameserver/App/model/Const/sm_shop_cash.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-07 10:22:49
+ // 日期: 2024-04-15 13:59:36
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/Const/sm_sysmail.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-03-20 15:21:24
+ // 日期: 2024-04-15 13:59:37
 ////////////////////
 
 

+ 2 - 0
Gameserver/App/model/User/EnumShopGift.php

@@ -26,6 +26,8 @@ class EnumShopGift extends Enum{
     const Cash_Shop = 5;
 
     const Gold_Shop = 6;
+    
+    const GemBox_Shop = 7;
 
 }
 

+ 25 - 0
Gameserver/App/model/User/Info_PrivateState.php

@@ -114,6 +114,31 @@ class Info_PrivateState extends Object_ext {
     #[ArrayType]
     public $day7_accumulateDrawed = array();
 
+    /**
+     * 普通宝石免费领取时间记录
+     * @var long
+     */
+    public $lastFreeGetTs_ShopBoxCommon = 0;
+
+    /**
+     * 璀璨宝石免费领取时间记录
+     * @var type
+     */
+    public $lastFreeGetTs_ShopBoxBright = 0;
+
+    /**
+     * 普通宝石购买次数记录
+     * @var type
+     */
+    public $buyNum_ShopBoxCommon = 0;
+
+    /**
+     * 璀璨宝石购买次数记录
+     * @var type
+     */
+    public $buyNum_ShopBoxBright = 0;
+    
+    
     public function initialize() {
         $this->junbeiShopNumRecord = new \stdClass();
         $this->junbeiShop_AllNumRecord = new \stdClass();

+ 61 - 108
Gameserver/App/process/ShopProc.php

@@ -36,6 +36,8 @@ class ShopProc {
         list($type,$typeId,$buyNum) = req()->paras;
         $user = ctx();
 
+        $resultArr = array();
+        
         $equip = array();
         $gateGift = array();
         switch ($type) {
@@ -99,129 +101,79 @@ class ShopProc {
                 
                 break;
                 
-            case EnumShopGift::SJunBeiBox_Shop://S级军备                                             
-                $mo = GameConfig::shop_junbei_getItem($typeId);
+            case EnumShopGift::GemBox_Shop ://宝石宝箱
+                $mo = GameConfig::shop_box_getItem($typeId);
                 my_Assert($mo != null, ErrCode::err_const_no); 
+                              
+                if($buyNum > 0){
+                    $cost = $mo->cost_ten;
+                    if($buyNum == 1){
+                        $cost = $mo->cost_one;    
+                    }
+                    my_Assert( $user->baseInfo->cash >= $cost, ErrCode::notenough_cash_msg);    
+                    $user->baseInfo->Consume_Cash($cost);        
+                }
                 
-                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;
-                }         
+                if($mo->type == 1){
+                    if($buyNum == 0){
+                        $buyNum = 1;
+                        my_Assert(now()-$user->privateState->lastFreeGetTs_ShopBoxCommon >= $mo->freeDownTs*24*60*60, ErrCode::user_shop_FreeNumLimit);
+                    }
+                    $user->privateState->buyNum_ShopBoxCommon += $buyNum;        
+                } else if($mo->type == 2){
+                    if($buyNum == 0){
+                        $buyNum = 1;
+                        my_Assert(now()-$user->privateState->lastFreeGetTs_ShopBoxBright >= $mo->freeDownTs*24*60*60, ErrCode::user_shop_FreeNumLimit);
+                    }
+                    $user->privateState->buyNum_ShopBoxBright += $buyNum;        
+                }
                 
-                $allDic = $user->privateState->junbeiShop_AllNumRecord;
-                if(!StlUtil::dictHasProperty($allDic, $typeId)){
-                    $junbei = new Ins_JunBeiShop();
-                    $junbei->typeId = $typeId;
-                    $allDic->$typeId = $junbei;
-                    $user->privateState->junbeiShop_AllNumRecord =$allDic;
+                $arr = array();
+                $arr[] = 1;
+                $arr[] = 10;
+                if(!in_array($buyNum, $arr)){
+                    $buyNum = 1;
                 }
                 
-                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;
+                $perList = explode(';',$mo->percent); 
+                $allNum = 0;
+                foreach ($perList as $key => $value) {
+                    $str = explode(',', $value);
+                    $allNum += $str[1];
                 }
                 
-                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);
+                $allNum *= 1000;                    
+                for ($i = 0; $i < $buyNum; $i++) {
                     $start = 0;
-                    $end = 0;               
-                    foreach ($list as $item) {
-                        $arr = explode(',', $item); 
-                        $per = $arr[2]*100;
-                        $end += $per;
-                        if($randNum >= $start && $randNum <$end){                       
-                            $qual = $arr[0];
-                            $xiyoudu = $arr[1];
+                    $end = 0;
+                    $qual = 0;
+                    $randNum = rand (1,$allNum);                       
+                    foreach ($perList as $k => $val) {
+                        $str = explode(',', $value);
+                        $end += $str[1]*1000;
+                        if($randNum > $start && $randNum <= $end){
+                            $qual = $str[0];
                             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_bichu1 = 0;                                             
-                        //$tag = true;
-                    }
-                    
-                    if($qual == $bichu2[1] && $xiyoudu == $bichu2[2]){   
-                        $resultStr = $bichu2[1].",".$bichu2[2];
-                        $user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu2 = 0;
-                        if($user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu1 == $bichu[0]){                                                   
-                            $user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu1 = 0;
-                        }                                               
-                        //$tag = true;
-                    }
-                    
-//                    if($tag){                                              
-//                    }
-                    
-                    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]){                            
-                            $resultStr = $bichu2[1].",".$bichu2[2];//得S级杰出
-                            $user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu2 = 0;
-                    }
-                                                                                             
-                    if($resultStr != null){
-                        $str = explode(',', $resultStr);
-                    
-                        $equipList = array();                
-                        foreach ($dic as $tid => $item) {
-                            if($str[1] == 1 || $str[1] == 2){//稀有度为1的装备
-                                if($item->qual == $str[0] && $item->rarity == $str[1]){
-                                    $equipList[] = $item->typeId;
-                                }
-                            }elseif ($str[1] == 3) {//特定装备的
-                               if($item->typeId == $str[0]){
-                                    $equipList[] = $item->typeId;
+                        
+                    if($qual >0){
+                            $gemDic = GameConfig::gem();
+                            $gemList = array();
+                            foreach ($gemDic as $key => $value) {
+                                if($value->qual == $qual){
+                                    $gemList[] = $value;
                                 }
-
                             }
-                        }
-
-                        $rNum = rand(0, count($equipList)-1);
-                        $equipId = $equipList[$rNum];
-                        StoreProc::PutEquipInStore($equipId, 1);
-                        $equip[] = $equipId;
-                    }
-                    
+                            
+                            $n = rand(0, count($gemList)-1);                  
+                            $gem = StoreProc::initGem($gateGift[$n]->typeId);
+                            $resultArr[] = $gem;
+                            StoreProc::PutGemInStore2($gem);
+                    }                                                                                       
                 }
-                           
-                $user->baseInfo->Add_Gold($mo->gold*$buyNum);
+                
                 
                 break;
             case EnumShopGift::BujiBox_Shop://补给箱
@@ -344,6 +296,7 @@ class ShopProc {
         ctx($user);
         UserProc::updateUserInfo();
         return Resp::ok(array(         
+                    'resultArr' => $resultArr,
                     'gateGift'=>$gateGift,
                     'equip'=>$equip,
                     'cash'=>$user->baseInfo->cash,