Browse Source

元宝商城

cyzhao 4 tháng trước cách đây
mục cha
commit
ae2c9fd88e

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

@@ -197,6 +197,11 @@ class CmdCode {
      * 6111 领取在线(时长)礼包
      */
     const cmd_active_draw_onlinegift = 6112;
+    
+    /**
+     * 元宝商城购买
+     */
+    const cmd_active_YanBaoBuyItemActive_drawReward = 6113;
 // </editor-fold>
 // <editor-fold defaultstate="collapsed" desc="任务操作码 - 62xx">
 

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2025-01-20 16:09:05
+ // 日期: 2025-01-23 09:25:06
 ////////////////////
 
 namespace loyalsoft;
@@ -1096,6 +1096,22 @@ class GameConfig {
         return self::get_hash_item('activity_onlinegift', $itemid);
     }
     /**
+    * 元宝购买道具活动
+    * @return \activity_cashmall
+    */
+    public static function activity_cashmall()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'activity_cashmall');
+    }
+    /**
+    * @return \sm_activity_cashmall activity_cashmall item数据 
+    */
+    public static function activity_cashmall_getItem($itemid)
+    { 
+        return self::get_hash_item('activity_cashmall', $itemid);
+    }
+    /**
     * 当前版本(时间戳)
     * @return \ver
     */

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

@@ -476,6 +476,19 @@ class Info_PrivateState extends Object_ext {
      */
     #[ArrayType]
     public $onlineGiftIDs = array();
+    
+    /**
+     * 元宝购买
+     * @var type
+     */
+    #[ArrayType]
+    public $YuanbaoBuy_RewardRecord = array();
+    
+    /**
+     * 刷新时间
+     * @var type
+     */
+    public $YuanbaoBuy_RefershTs = 0;
 
     public function initialize() {      
         $this->onlineGiftts = 1;

+ 41 - 2
Gameserver/App/process/ActiveProc.php

@@ -48,19 +48,51 @@ class ActiveProc {
                 return self::GetTodayOnlineInfos();
             case CmdCode::cmd_active_draw_onlinegift:                           # 6112 领取在线(时长)礼包
                 return self::DrawOnlineGift();    
-                
+            case CmdCode::cmd_active_YanBaoBuyItemActive_drawReward:
+                return self::YanBaoBuyItemActive_drawReward();
             default:
                 Err(ErrCode::cmd_err);
         }
     }
     
+    /**
+     * [6112] 领取连续在线礼包
+     */
+    static function YanBaoBuyItemActive_drawReward() {
+        list($typeId) = req()->paras;                                           # 提取参数: 礼包的编号
+                                                  
+        $Mo = GameConfig::activity_cashmall_getItem($typeId);                   # 常量数据
+        my_Assert(null != $Mo, ErrCode::err_const_no);                          # 防御找不到配置数据
+        
+        $rewardArr = ctx()->privateState->YuanbaoBuy_RewardRecord;
+        $count = array_count_values($rewardArr)[$typeId];
+        my_Assert($count < $Mo->limitNum, ErrCode::user_shop_LimitNum);
+        
+//        my_Assert(!in_array($typeId, ctx()->privateData()->YuanbaoBuy_RewardRecord), #           # 判断礼包ID是否已经领取
+//                ErrCode::active_hasgetted);
+        $err = StoreProc::AddMultiItemInStore($Mo->reward);                     # 发放奖励
+        my_Assert(ErrCode::ok == $err, $err);                                   # 发放奖励失败
+        ctx()->privateData(true)->YuanbaoBuy_RewardRecord[] = $typeId;          # 记录已领礼包ID
+                   
+        UserProc::updateUserInfo();                                             # 回写用户数据
+        return Resp::ok(array(                   
+                    "reward" => StoreProc::$reward,
+                    "reward_Gem" => StoreProc::$reward_Gem,
+                    "reward_equip" => StoreProc::$reward_equip,
+                    'gold' => ctx()->base()->gold,
+                    'cash' => ctx()->base()->cash,                  
+                    'store' => ctx()->store(),
+                    'heros' => ctx()->heros()
+        ));                                                                     # 设置返回值
+    }  
+    
     public static function GetTodayOnlineInfos() {
         return Resp::ok(array(
                     'onlineGiftts' => ctx()->privateState->onlineGiftts,
                     'onlineGiftIDs' => ctx()->privateState->onlineGiftIDs,                 
         )); 
     }
-    
+     
     /**
      * 清理/重置 在线礼包时间戳
      */
@@ -68,6 +100,13 @@ class ActiveProc {
         ctx()->privateState->onlineGiftts = 1;
         ctx()->privateState->onlineGiftIDs = array();       
     }
+    
+    /**
+     * 清理/重置 元宝商城购买记录
+     */
+    public static function ClearYanBaoBuyItemActive_drawReward() {
+        ctx()->privateState->YuanbaoBuy_RewardRecord = array();         
+    }
 
     /**
      * [6112] 领取连续在线礼包

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

@@ -508,6 +508,7 @@ class UserProc {
         self::ActiveRefershTsDeal();
         ActiveProc::DailyResetDay7Task();
         ActiveProc::ClearOnlineGiftTs();
+        ActiveProc::ClearYanBaoBuyItemActive_drawReward();
     }
 
     static function ActiveRefershTsDeal() {