瀏覽代碼

限时贩售

cyzhao 8 月之前
父節點
當前提交
4c481f406c

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

@@ -169,7 +169,10 @@ class CmdCode {
      */
     const cmd_active_day7_accumulateDrawreward = 6107;
 
-
+    /**
+     * 限时贩售
+     */
+    const cmd_active_limitTsBuy = 6108;
 // </editor-fold>
 // <editor-fold defaultstate="collapsed" desc="任务操作码 - 62xx">
 

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-09-13 11:23:39
+ // 日期: 2024-10-10 10:09:20
 ////////////////////
 
 namespace loyalsoft;
@@ -895,6 +895,38 @@ class GameConfig {
         return self::get_hash_item('activity_lotteryitem_exchange', $itemid);
     }
     /**
+    * 限时贩售
+    * @return \activity_promopackinfo
+    */
+    public static function activity_promopackinfo()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'activity_promopackinfo');
+    }
+    /**
+    * @return \sm_activity_promopackinfo activity_promopackinfo item数据 
+    */
+    public static function activity_promopackinfo_getItem($itemid)
+    { 
+        return self::get_hash_item('activity_promopackinfo', $itemid);
+    }
+    /**
+    * 限时贩售不同礼包分类
+    * @return \activity_promopackinfo_type
+    */
+    public static function activity_promopackinfo_type()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'activity_promopackinfo_type');
+    }
+    /**
+    * @return \sm_activity_promopackinfo_type activity_promopackinfo_type itemArray 
+    */
+    public static function activity_promopackinfo_type_getItemArray($key)
+    { 
+        return self::get_hash_item('activity_promopackinfo_type', $key);
+    }
+    /**
     * 当前版本(时间戳)
     * @return \ver
     */

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-09-30 09:43:47
+ // 日期: 2024-10-10 10:09:20
 ////////////////////
 
 /**
@@ -893,6 +893,38 @@ class GameConfig {
         return self::get_hash_item('activity_lotteryitem_exchange', $itemid);
     }
     /**
+    * 限时贩售
+    * @return \activity_promopackinfo
+    */
+    public static function activity_promopackinfo()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'activity_promopackinfo');
+    }
+    /**
+    * @return \sm_activity_promopackinfo activity_promopackinfo item数据 
+    */
+    public static function activity_promopackinfo_getItem($itemid)
+    { 
+        return self::get_hash_item('activity_promopackinfo', $itemid);
+    }
+    /**
+    * 限时贩售不同礼包分类
+    * @return \activity_promopackinfo_type
+    */
+    public static function activity_promopackinfo_type()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'activity_promopackinfo_type');
+    }
+    /**
+    * @return \sm_activity_promopackinfo_type activity_promopackinfo_type itemArray 
+    */
+    public static function activity_promopackinfo_type_getItemArray($key)
+    { 
+        return self::get_hash_item('activity_promopackinfo_type', $key);
+    }
+    /**
     * 当前版本(时间戳)
     * @return \ver
     */

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-09-30 09:39:33
+ // 日期: 2024-10-09 10:23:21
 ////////////////////
 
 

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-09-30 09:39:33
+ // 日期: 2024-10-09 10:23:21
 ////////////////////
 
 

+ 62 - 0
Gameserver/App/model/Const/sm_activity_promopackinfo.php

@@ -0,0 +1,62 @@
+<?php
+////////////////////
+ // 由CodeGenerator创建。
+ // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
+ // author: gwang 
+ // 日期: 2024-10-09 17:58:39
+////////////////////
+
+
+/**
+ * Static Model activity_promopackinfo 限时贩售
+ */
+class sm_activity_promopackinfo
+{
+
+    /**
+    * @var Int32 索引  
+    */
+    public $id;
+
+    /**
+    * @var Int32 礼包id  
+    */
+    public $typeId;
+
+    /**
+    * @var String 礼包名称  
+    */
+    public $name;
+
+    /**
+    * @var String 礼包描述信息  
+    */
+    public $desc;
+
+    /**
+    * @var Int32 奖励类别
+    *  1、资源补给礼包
+    *  2、关卡等级礼包 
+    *  3、洗练石相关礼包 
+    *  4、角色相关礼包
+    *  5、角色碎片相关礼包  
+    */
+    public $type;
+
+    /**
+    * @var String 奖励信息  
+    */
+    public $reward;
+
+    /**
+    * @var Int32 限购数量 default(0) 
+    */
+    public $limitNum;
+
+    /**
+    * @var String 购买金钱消耗  
+    */
+    public $cost;
+
+}
+

+ 62 - 0
Gameserver/App/model/Const/sm_activity_promopackinfo_type.php

@@ -0,0 +1,62 @@
+<?php
+////////////////////
+ // 由CodeGenerator创建。
+ // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
+ // author: gwang 
+ // 日期: 2024-10-09 17:58:39
+////////////////////
+
+
+/**
+ * Static Model activity_promopackinfo_type 限时贩售不同礼包分类
+ */
+class sm_activity_promopackinfo_type
+{
+
+    /**
+    * @var Int32 索引  
+    */
+    public $id;
+
+    /**
+    * @var Int32 礼包id  
+    */
+    public $typeId;
+
+    /**
+    * @var String 礼包名称  
+    */
+    public $name;
+
+    /**
+    * @var String 礼包描述信息  
+    */
+    public $desc;
+
+    /**
+    * @var Int32 奖励类别
+    *  1、资源补给礼包
+    *  2、关卡等级礼包 
+    *  3、洗练石相关礼包 
+    *  4、角色相关礼包
+    *  5、角色碎片相关礼包  
+    */
+    public $type;
+
+    /**
+    * @var String 奖励信息  
+    */
+    public $reward;
+
+    /**
+    * @var Int32 限购数量 default(0) 
+    */
+    public $limitNum;
+
+    /**
+    * @var String 购买金钱消耗  
+    */
+    public $cost;
+
+}
+

+ 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-09-06 10:05:38
+ // 日期: 2024-10-09 18:05:52
 ////////////////////
 
 

+ 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-09-29 18:03:18
+ // 日期: 2024-10-09 15:05:52
 ////////////////////
 
 

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-09-29 16:05:51
+ // 日期: 2024-09-30 12:05:51
 ////////////////////
 
 

+ 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-09-29 17:38:12
+ // 日期: 2024-10-09 17:59:19
 ////////////////////
 
 

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-09-29 17:38:12
+ // 日期: 2024-10-09 17:59:19
 ////////////////////
 
 

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-09-29 16:26:42
+ // 日期: 2024-10-09 17:59:19
 ////////////////////
 
 

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-09-29 14:45:19
+ // 日期: 2024-10-09 17:33:16
 ////////////////////
 
 

+ 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-09-30 09:18:21
+ // 日期: 2024-09-30 11:05:09
 ////////////////////
 
 

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-09-29 14:56:14
+ // 日期: 2024-10-09 17:17:51
 ////////////////////
 
 

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-09-29 14:56:14
+ // 日期: 2024-10-09 17:17:51
 ////////////////////
 
 

+ 15 - 1
Gameserver/App/model/User/Info_PrivateState.php

@@ -357,7 +357,21 @@ class Info_PrivateState extends Object_ext {
      * @var type
      */
     public $shop_gateGift_showGateId = 0;
-
+    
+    /**
+     * 限时贩售 商品
+     * @var type
+     */
+    #[ArrayType]
+    public $limitTsBuy_RandIds = array();
+    
+    /**
+     * 限时贩售购买记录
+     * @var type
+     */
+    #[ArrayType]
+    public $limitTsBuy_RewardRecord = array();
+       
     public function initialize() {
         $this->junbeiShopNumRecord = new \stdClass();
         $this->junbeiShop_AllNumRecord = new \stdClass();

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

@@ -36,11 +36,13 @@ class ActiveProc {
                 return ActiveProc::LotteryExchangeItem();
             case CmdCode::cmd_active_day7_accumulateDrawreward:                 # 6107 7日签到 累计天数宝箱奖励领取
                 return ActiveProc::Day7_AccumulateDrawreward();
+            case CmdCode::cmd_active_limitTsBuy:                                # 6108 限时贩售
+                return ActiveProc::LimitTsBuy_Drawreward();
             default:
                 Err(ErrCode::cmd_err);
         }
     }
-
+        
     static function ResetActive() {
 
     }
@@ -323,7 +325,7 @@ class ActiveProc {
         ctx()->privateState->LoginDays[] = $index;
         ctx()->privateState->day7_accumulate += 1;
     }
-
+           
     /**
      * 6101 签到
      * @return type
@@ -394,6 +396,70 @@ class ActiveProc {
         }
 
 
+        UserProc::updateUserInfo();                                             # 回存
+        return Resp::ok(array('gold' => ctx()->baseInfo->gold,
+                    'cash' => ctx()->baseInfo->cash,
+                    'store' => ctx()->store,
+                    'privateState' => ctx()->privateState,
+                    'reward' => StoreProc::$reward,
+                    'reward_Gem' => StoreProc::$reward_Gem,
+        ));
+    }
+    
+    /**
+     * 限时贩卖 2天一刷
+     */
+    public static function ResetLimitTsBuy() {
+        $mo = GameConfig::subfun_unlock_getItem(Enum_SubFunType::LimitTsSale);       
+        $startDay = TimeUtil::totalDays($mo->startTs);
+        $nextDay = TimeUtil::totalDays();
+        
+        $num = $nextDay - $startDay;
+        $val = intval($num / 2);               
+        $yushu = $val % 5;  
+        $type = $yushu +1;
+        
+        $arr = GameConfig::activity_promopackinfo_type_getItemArray($type);
+        $count = count($arr);
+        
+        $ret = array();
+        if($count == 6){
+            $ret = $arr;
+        } else {
+            for ($i = 0; $i < 6; $i++) {
+                $count = count($arr);
+                $rand = rand(0,$count-1);
+                $ret[] = $arr[$rand];
+                StlUtil::arrayRemoveAt($arr, $rand);
+                if(count($arr) == 0){
+                    break;
+                }
+            }           
+        }
+        ctx()->privateState->limitTsBuy_RandIds = array();
+        foreach ($ret as $mo) {
+            ctx()->privateState->limitTsBuy_RandIds[] = $mo->typeId;
+        }
+        
+    }
+
+    /**
+     * 6108 限时贩售
+     */
+    public static function LimitTsBuy_Drawreward() {
+        list($typeId) = req()->paras;                                           # 参数: 领取第x天的奖励
+        
+        my_Assert(in_array($typeId, ctx()->privateState->limitTsBuy_RewardRecord), ErrCode::active_const_no_err);
+        $mo = GameConfig::activity_promopackinfo_getItem($typeId);              # 查询奖励数据
+        my_Assert(null != $mo, ErrCode::err_const_no);                          # 防御找不到配置
+        
+        $rewardArr = ctx()->privateState->limitTsBuy_RewardRecord;
+        $count = array_count_values(array_keys($rewardArr, $typeId))[$typeId];
+        my_Assert($count < $mo->limitNum, ErrCode::user_shop_LimitNum);
+            
+        StoreProc::AddMultiItemInStore($mo->reward);                            # 发放奖励
+        ctx()->privateState->limitTsBuy_RewardRecord[] = $typeId;
+        
         UserProc::updateUserInfo();                                             # 回存
         return Resp::ok(array('gold' => ctx()->baseInfo->gold,
                     'cash' => ctx()->baseInfo->cash,

+ 11 - 2
Gameserver/App/process/FightProc.php

@@ -1011,8 +1011,17 @@ class FightProc {
     static function SubFunDateInit_Config() {
         $dic = GameConfig::subfun_unlock();
         foreach ($dic as $id => $mo) {
-            if ($mo->type == 3 && $mo->id == Enum_SubFunType::LimitTsSale && ctx()->privateState->nextDayLogin == 0) {
-                ctx()->privateState->nextDayLogin = now();
+            if ($mo->type == 3 && $mo->id == Enum_SubFunType::LimitTsSale && ctx()->privateState->nextDayLogin == 0 && now()>= $mo->startTs) {
+                $startDay = TimeUtil::totalDays($mo->startTs);
+                $nextDay = TimeUtil::totalDays();
+                
+                $num = $nextDay - $startDay;
+                $yushu = $num % 2;//余数只会是0 或 1; 0:两天后在刷新,1就是已经过了一天了,在过一天就刷新,当前时间减一天
+                if($yushu == 1){
+                    ctx()->privateState->nextDayLogin = now() - 86400;
+                }
+                                              
+                ActiveProc::ResetLimitTsBuy();
             }
         }
     }

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

@@ -495,6 +495,8 @@ class UserProc {
         $nextDay = TimeUtil::totalDays(ctx()->privateState->nextDayLogin);
         if($curDay - $nextDay>= 2){
             ctx()->privateState->nextDayLogin = now();
+            ActiveProc::ResetLimitTsBuy();     
+            ctx()->privateState->limitTsBuy_RewardRecord = array();
         }
     }