瀏覽代碼

金蛇接口

cyzhao 3 月之前
父節點
當前提交
ee5d79d9c9

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

@@ -223,6 +223,10 @@ class CmdCode {
      */
     const active_FlipCardLottery_DrawAccumulateReward = 6117;
 
+    /**
+     * 金蛇兌換
+     */
+    const active_FlipCardLottery_Exchange = 6118;
 // </editor-fold>
 // <editor-fold defaultstate="collapsed" desc="任务操作码 - 62xx">
 

+ 18 - 2
Gameserver/App/configs/GameConfig.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2025-02-13 17:24:54
+ // 日期: 2025-02-14 16:30:29
 ////////////////////
 
 namespace loyalsoft;
@@ -1144,7 +1144,7 @@ class GameConfig {
         return self::get_hash_item('activity_flipcardlottery_grandreward', $itemid);
     }
     /**
-    * 
+    * 金蛇累计表
     * @return \activity_flipcardlottery_accumulate
     */
     public static function activity_flipcardlottery_accumulate()
@@ -1160,6 +1160,22 @@ class GameConfig {
         return self::get_hash_item('activity_flipcardlottery_accumulate', $itemid);
     }
     /**
+    * 金蛇兑换功能表
+    * @return \activity_flipcardlottery_exchange
+    */
+    public static function activity_flipcardlottery_exchange()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'activity_flipcardlottery_exchange');
+    }
+    /**
+    * @return \sm_activity_flipcardlottery_exchange activity_flipcardlottery_exchange item数据 
+    */
+    public static function activity_flipcardlottery_exchange_getItem($itemid)
+    { 
+        return self::get_hash_item('activity_flipcardlottery_exchange', $itemid);
+    }
+    /**
     * 当前版本(时间戳)
     * @return \ver
     */

+ 18 - 2
Gameserver/App/model/Const/GameConfig.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2025-02-14 11:48:59
+ // 日期: 2025-02-14 16:30:29
 ////////////////////
 
 /**
@@ -1142,7 +1142,7 @@ class GameConfig {
         return self::get_hash_item('activity_flipcardlottery_grandreward', $itemid);
     }
     /**
-    * 
+    * 金蛇累计表
     * @return \activity_flipcardlottery_accumulate
     */
     public static function activity_flipcardlottery_accumulate()
@@ -1158,6 +1158,22 @@ class GameConfig {
         return self::get_hash_item('activity_flipcardlottery_accumulate', $itemid);
     }
     /**
+    * 金蛇兑换功能表
+    * @return \activity_flipcardlottery_exchange
+    */
+    public static function activity_flipcardlottery_exchange()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'activity_flipcardlottery_exchange');
+    }
+    /**
+    * @return \sm_activity_flipcardlottery_exchange activity_flipcardlottery_exchange item数据 
+    */
+    public static function activity_flipcardlottery_exchange_getItem($itemid)
+    { 
+        return self::get_hash_item('activity_flipcardlottery_exchange', $itemid);
+    }
+    /**
     * 当前版本(时间戳)
     * @return \ver
     */

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

@@ -8,7 +8,7 @@
 
 
 /**
- * Static Model activity_flipcardlottery_accumulate 
+ * Static Model activity_flipcardlottery_accumulate 金蛇累计表
  */
 class sm_activity_flipcardlottery_accumulate
 {

+ 42 - 0
Gameserver/App/model/Const/sm_activity_flipcardlottery_exchange.php

@@ -0,0 +1,42 @@
+<?php
+////////////////////
+ // 由CodeGenerator创建。
+ // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
+ // author: gwang 
+ // 日期: 2025-02-14 14:17:32
+////////////////////
+
+
+/**
+ * Static Model activity_flipcardlottery_exchange 金蛇兑换功能表
+ */
+class sm_activity_flipcardlottery_exchange
+{
+
+    /**
+    * @var Int32 用途未知!!请到数据库中添加字段注释。  
+    */
+    public $id;
+
+    /**
+    * @var Int32 兑换最大次数 default(0) 
+    */
+    public $exchangeNum;
+
+    /**
+    * @var String 消耗人身果信息  
+    */
+    public $cost;
+
+    /**
+    * @var String 兑换奖品信息  
+    */
+    public $reward;
+
+    /**
+    * @var String 描述  
+    */
+    public $desc;
+
+}
+

+ 3 - 53
Gameserver/App/model/Const/sm_activity_flipcardlottery_grandreward.php

@@ -23,70 +23,20 @@ class sm_activity_flipcardlottery_grandreward
     */
     public $typeId;
 
-    /**
-    * @var Int32 概率  
-    */
-    public $per;
-
-    /**
-    * @var String 奖励信息  
-    */
-    public $reward_1;
-
-    /**
-    * @var Int32 该大奖所属轮次开始次数  
-    */
-    public $flipCount_start_1;
-
-    /**
-    * @var Int32 该大奖所属轮次结束次数  
-    */
-    public $flipCount_end_1;
-
-    /**
-    * @var String 奖励信息  
-    */
-    public $reward_2;
-
-    /**
-    * @var Int32 该大奖所属轮次开始次数  
-    */
-    public $flipCount_start_2;
-
-    /**
-    * @var Int32 该大奖所属轮次结束次数  
-    */
-    public $flipCount_end_2;
-
-    /**
-    * @var String 奖励信息  
-    */
-    public $reward_3;
-
-    /**
-    * @var Int32 该大奖所属轮次开始次数  
-    */
-    public $flipCount_start_3;
-
-    /**
-    * @var Int32 该大奖所属轮次结束次数  
-    */
-    public $flipCount_end_3;
-
     /**
     * @var String 奖励信息  
     */
-    public $reward_4;
+    public $reward;
 
     /**
     * @var Int32 该大奖所属轮次开始次数  
     */
-    public $flipCount_start_4;
+    public $flipCount_start;
 
     /**
     * @var Int32 该大奖所属轮次结束次数  
     */
-    public $flipCount_end_4;
+    public $flipCount_end;
 
 }
 

+ 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 
- // 日期: 2025-02-07 14:46:09
+ // 日期: 2025-02-14 16:01:32
 ////////////////////
 
 

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

@@ -525,6 +525,19 @@ class Info_PrivateState extends Object_ext {
     #[ArrayType]
     public $flipCardLottery_AccumulateReward = array();
 
+    /**
+     * 兑换记录
+     * @var type
+     */
+    #[ArrayType]
+    public $flipCardLottery_exchange = array();  
+    
+    /**
+     * 金蛇献瑞 重置大奖次数
+     * @var type
+     */
+    public $flipCardNum_turnNum = 0;
+    
     public function initialize() {      
         $this->onlineGiftts = 1;
     }

+ 164 - 91
Gameserver/App/process/ActiveProc.php

@@ -55,9 +55,11 @@ class ActiveProc {
             case CmdCode::active_FlipCardLottery_BuyTickets:                    # 6115 金蛇献瑞购买抽奖券
                 return self::FlipCardLottery_BuyTickets();
             case CmdCode::active_FlipCardLottery_DrawGrandReward:               # 6116 领取大奖信息
-                return self::FlipCardLottery_DrawGrandReward();  
+                return self::FlipCardLottery_DrawGrandReward();
             case CmdCode::active_FlipCardLottery_DrawAccumulateReward:          # 6117 领取卡牌累计次数奖励    
                 return self::FlipCardLottery_DrawAccumulateReward();
+            case CmdCode::active_FlipCardLottery_Exchange:                      # 6118 金蛇兌換    6118 金蛇兌換    
+                return self::FlipCardLottery_Exchange();
             default:
                 Err(ErrCode::cmd_err);
         }
@@ -72,7 +74,7 @@ class ActiveProc {
         self::ClearOnlineGiftTs();
         ActiveProc::ClearYanBaoBuyItemActive_drawReward();
     }
-        
+
     /**
      * 重置金蛇数据
      */
@@ -82,15 +84,17 @@ class ActiveProc {
         if (now() >= $mo->startTs && now() < $mo->endTs && $mo->endTs != ctx()->privateState->flipCardLottery_endTs) {//当活动重启再次开启的时候再重置数据
             ctx()->privateState->flipCardLottery_endTs = $mo->endTs;
             ctx()->privateState->flipCardNum_all = 0;
+            ctx()->privateState->flipCardNum_turnNum = 0;
             //初始化大奖
             ctx()->privateState->flipCard_RewardRecord = array();
-            ctx()->privateData(true)->flipCard_randGrandReward = self::RandGrandReward();
-            
+            ctx()->privateData(true)->flipCard_randGrandReward = self::RandGrandRewardOrder();
+
             ctx()->privateState->flipCardLottery_AccumulateReward = array();
             //初始化对应任务数据
             self::InitFlipLotteryTask();
         }
     }
+
     /**
      * 初始化金蛇任务数据
      */
@@ -99,23 +103,23 @@ class ActiveProc {
         $arr = array();
         foreach ($activeTaskInfo as $taskUid => $ins_task) {
             $ins_taskStep_active = new Ins_TaskStep_Active($ins_task);
-            if($ins_taskStep_active->mo()->type == Enum_ActiveTaskType::FlipCardLotteryTask){
+            if ($ins_taskStep_active->mo()->type == Enum_ActiveTaskType::FlipCardLotteryTask) {
                 $arr[] = $taskUid;
             }
         }
-        
-        if(count($arr) > 0){
+
+        if (count($arr) > 0) {
             foreach ($arr as $uid) {
                 StlUtil::arrayRemove($activeTaskInfo, $uid);
             }
         }
-        
-        $list = explode(',',GameConfig::glc2()->FlipCardLotteryTask);
+
+        $list = explode(',', GameConfig::glc2()->FlipCardLotteryTask);
         $length = ctx()->task->activeTaskLength;
-        foreach ($list as $taskId){
+        foreach ($list as $taskId) {
             $mo = GameConfig::activeTask_getItem($taskId);
             my_Assert(null != $mo, ErrCode::err_const_no);
-            
+
             $length += 1;
             $ins_TaskStep_Active = new Ins_TaskStep_Active($mo->id);
             $ins_TaskStep_Active->uid = $length;
@@ -125,34 +129,81 @@ class ActiveProc {
         ctx()->task->activeTaskLength = $length;
         self::autoRecoverState_activeTask();
     }
-    
+
+    /**
+     * 6118 金蛇兌換 
+     */
+    public static function FlipCardLottery_Exchange() {
+        list($id) = req()->paras;
+
+        $arr = array_count_values(ctx()->privateState->flipCardLottery_exchange);
+        $num = $arr[$id];
+
+        $mo = GameConfig::activity_flipcardlottery_exchange_getItem($id);
+        my_Assert($mo != null, ErrCode::err_const_no);
+        my_Assert($num < $mo->exchangeNum, ErrCode::active_lotteryExchangeNumLimit);
+
+        $itemNum = 0;
+        $cost = explode(',', $mo->cost);
+        $costId = $cost[0];
+        if (StlUtil::dictHasProperty(ctx()->store->items, $costId)) {
+            $itemNum = ctx()->store->items->$costId;
+        }
+
+        my_Assert($itemNum >= $cost[1], ErrCode::notenough_item);
+        ctx()->store->removeItem($costId, $cost[1]);
+
+        StoreProc::AddMultiItemInStore($mo->reward);
+        ctx()->privateState->flipCardLottery_exchange[] = $id;
+
+        UserProc::updateUserInfo();
+        return Resp::ok(array(
+                    "store" => ctx()->store,
+                    'cash' => ctx()->baseInfo->cash,
+                    'gold' => ctx()->baseInfo->gold,
+                    'reward' => StoreProc::$reward,
+                    'reward_Gem' => StoreProc::$reward_Gem,
+                    'reward_equip' => StoreProc::$reward_equip,
+        ));
+
+//        return Resp::ok(array(
+//                    'gold' => ctx()->baseInfo->gold,
+//                    'cash' => ctx()->baseInfo->cash,
+//                    'store' => ctx()->store,
+//                    'heros' => ctx()->heros,
+//                    'privateState' => ctx()->privateState,                                             
+//                    'reward_equip'=> StoreProc::$reward_equip,
+//                    'reward_Gem'=> StoreProc::$reward_Gem,
+//                    'reward'=> StoreProc::$reward,           
+//        ));
+    }
+
     /**
      * 6117 领取卡牌累计次数奖励    
      */
     public static function FlipCardLottery_DrawAccumulateReward() {
         $dic = GameConfig::activity_flipcardlottery_accumulate();
-        
+
         $accumulateRewardList = ctx()->privateState->flipCardLottery_AccumulateReward;
         $allNum = ctx()->privateState->flipCardNum_all;
         foreach ($dic as $numId => $mo) {
-            if($allNum >= $numId && !in_array($numId, $accumulateRewardList)){
+            if ($allNum >= $numId && !in_array($numId, $accumulateRewardList)) {
                 StoreProc::AddMultiItemInStore($mo->reward);
             }
         }
-        
+
         return Resp::ok(array(
                     'gold' => ctx()->baseInfo->gold,
                     'cash' => ctx()->baseInfo->cash,
                     'store' => ctx()->store,
                     'heros' => ctx()->heros,
-                    'privateState' => ctx()->privateState,                                             
-                    'reward_equip'=> StoreProc::$reward_equip,
-                    'reward_Gem'=> StoreProc::$reward_Gem,
-                    'reward'=> StoreProc::$reward,           
+                    'privateState' => ctx()->privateState,
+                    'reward_equip' => StoreProc::$reward_equip,
+                    'reward_Gem' => StoreProc::$reward_Gem,
+                    'reward' => StoreProc::$reward,
         ));
     }
-    
-    
+
     /**
      * 6116 领取大奖信息
      * @return type
@@ -162,7 +213,7 @@ class ActiveProc {
         $lineArr = array();
         $list = ctx()->privateState->flipCard_randGrandReward;
         $index = 0;
-        foreach ($list as $id) {
+        foreach ($list as $orderId) {
             $mo = GameConfig::activity_flipCardLottery_lineIds_getItem($index);
             $s = explode(',', $mo->cardIds);
             $tag = true;
@@ -172,32 +223,40 @@ class ActiveProc {
                     break;
                 }
             }
-            
-            if($tag){
-                $lineArr[] = $id;
+
+            if ($tag) {
+                $lineArr[] = $orderId;
             }
-            
+
             $index += 1;
         }
-        
+
         if (count($lineArr) >= GameConfig::glc2()->FlipCardLottery_ResetNum) {
+            $reward = self::GetCurGrandReward();
+            if ($reward != "") {
+                $str = explode(';', $reward);
+                foreach ($lineArr as $orderId) {                   
+                    $s = explode(',', $str[$orderId]);
+                    StoreProc::AddMultiItemInStore($s[0] . ',' . $s[1]);
+                }
+            }
+
             ctx()->privateState->flipCard_RewardRecord = array();
-            ctx()->privateData(true)->flipCard_randGrandReward = self::RandGrandReward();
+            ctx()->privateData(true)->flipCard_randGrandReward = self::RandGrandRewardOrder();
+            ctx()->privateState->flipCardNum_turnNum += 1;
         }
-        
+
         return Resp::ok(array(
                     'gold' => ctx()->baseInfo->gold,
                     'cash' => ctx()->baseInfo->cash,
                     'store' => ctx()->store,
                     'heros' => ctx()->heros,
-                    'privateState' => ctx()->privateState,                                             
-                    'reward_equip'=> StoreProc::$reward_equip,
-                    'reward_Gem'=> StoreProc::$reward_Gem,
-                    'reward'=> StoreProc::$reward,           
+                    'privateState' => ctx()->privateState,
+                    'reward_equip' => StoreProc::$reward_equip,
+                    'reward_Gem' => StoreProc::$reward_Gem,
+                    'reward' => StoreProc::$reward,
         ));
-        
     }
-    
 
     /*
      * 6114 金蛇献瑞抽奖
@@ -239,7 +298,7 @@ class ActiveProc {
         $dic = GameConfig::activity_flipCardLottery_lineIds();
         $lineList = array();
 
-        $curUnlockLine = 999;
+        $curUnlockLine = array();
         foreach ($dic as $id => $mo) {
             $s = explode(',', $mo->cardIds);
             $tag = true;
@@ -253,7 +312,7 @@ class ActiveProc {
             if ($tag) {
                 $lineList[] = $id;
                 if (in_array($cardId, $s)) {
-                    $curUnlockLine = $id;
+                    $curUnlockLine[] = $id;
                 }
             }
         }
@@ -269,7 +328,7 @@ class ActiveProc {
                     'privateState' => ctx()->privateState,
                     'cardReward' => $rewardStr,
                     //'grandReward' => $grandReward,
-                    'curUnlockLine'=> $curUnlockLine,
+                    'curUnlockLine' => $curUnlockLine,
 //                    'reward_equip'=> StoreProc::$reward_equip,
                     'cardId' => $cardId,
         ));
@@ -285,25 +344,32 @@ class ActiveProc {
         return false;
     }
 
+    public static function GetCurGrandReward() {
+        $turnNum = ctx()->privateState->flipCardNum_turnNum;
+        //$lineList = array();
+
+        $dic = GameConfig::activity_flipcardlottery_grandreward();
+        $reward = "";
+        foreach ($dic as $id => $mo) {
+            if ($turnNum >= $mo->flipCount_start && $turnNum <= $mo->flipCount_end) {
+                $reward = $mo->reward;
+                break;
+            }
+        }
+
+        return $reward;
+    }
+
     /**
      * 初始化大奖信息 12个大奖在数组的位置对应了 界面上 0-12个位置
      * @return type
      */
-    public static function RandGrandReward() {
-        $lineList = array();
-        $dic = GameConfig::activity_flipcardlottery_grandreward();     
-        foreach ($dic as $id => $mo) {
-            $lineList[] = $id;
-        }
+    public static function RandGrandRewardOrder() {
+        $numbers = range(0, 11);
 
-        $typeIdArr = array();
-        $num = count($lineList);
-        for ($i = 0; $i < $num; $i++) {
-            $rand = rand(0, count($lineList) - 1);
-            $typeIdArr[] = $lineList[$rand];
-            StlUtil::arrayRemoveAt($lineList, $rand);
-        }
-        return $typeIdArr;
+// 使用shuffle函数打乱数组顺序
+        shuffle($numbers);
+        return $numbers;
     }
 
     /**
@@ -312,55 +378,62 @@ class ActiveProc {
      */
     public static function RandCardReward() {
         $randGrandReward = ctx()->privateState->flipCard_randGrandReward;
+        $grandReward = self::GetCurGrandReward();
+        $gList = explode(';', $grandReward);
 
         $cId = 0;
-        while (true) {
-            $perNum = 0; //大奖总概率
-            foreach ($randGrandReward as $id) {
-                $perNum += GameConfig::activity_flipcardlottery_grandreward_getItem($id)->per;
-            }
-
-            $rand = rand(1, $perNum);
-            $start = 0;
-            $end = 0;
-            $lineId = null;
-            $grandId = null;
-            $index = 0;
-            foreach ($randGrandReward as $id) {
-                $mo = GameConfig::activity_flipcardlottery_grandreward_getItem($id);
-                $end += $mo->per;
-                if ($rand >= $start && $rand < $end) {
-                    $lineId = $index;
-                    $grandId = $id;
+        $index = 0;
+        $noflipArr = array();
+        foreach ($randGrandReward as $orderId) {
+            $mo = GameConfig::activity_flipCardLottery_lineIds_getItem($index);
+            $s = explode(',', $mo->cardIds);
+            $tag = true;
+            foreach ($s as $cId) {
+                if (!self::isExistCard($cId)) {
+                    $tag = false;
                     break;
                 }
-                $start = $end;
-                $index += 1;
             }
-            if ($lineId != null && $grandId != null) {
-                $lineMo = GameConfig::activity_flipCardLottery_lineIds_getItem($lineId);
-                $str = explode(',', $lineMo->cardIds);
-                $cardArr = array();
-                $isExistNoFlip = false;
-                foreach ($str as $cardId) {
-                    if (!self::isExistCard($cardId)) {
-                        $cardArr[] = $cardId;
-                        $isExistNoFlip = true;
-                    }
-                }
 
-                if ($isExistNoFlip) {
-                    $n = rand(0, count($cardArr) - 1);
-                    $cId = $cardArr[$n];
-                    break;
-                } else {
-                    StlUtil::arrayRemove($randGrandReward, $grandId);
-                }
-            } else {
+            if (!$tag) {//true 意思就是没有被全部翻牌
+                $noflipArr[] = $orderId;
+            }
+            $index += 1;
+        }
+
+        $perNum = 0; //大奖总概率
+        foreach ($noflipArr as $k) {
+            $s = explode(',', $gList[$k]);
+            $perNum += $s[2];
+        }
+        $rand = rand(1, $perNum);
+        $start = 0;
+        $end = 0;
+        $grandId = null;
+        foreach ($noflipArr as $k) {
+            $s = explode(',', $gList[$k]);
+            $end += $s[2];
+            if ($rand >= $start && $rand < $end) {
+                $grandId = $k;
                 break;
             }
+            $start = $end;
         }
 
+        if ($grandId != null) {
+            $lineId = array_search($grandId, $randGrandReward);
+            $lineMo = GameConfig::activity_flipCardLottery_lineIds_getItem($lineId);
+            $str = explode(',', $lineMo->cardIds);
+            $cardArr = array();
+            foreach ($str as $cardId) {
+                if (!self::isExistCard($cardId)) {
+                    $cardArr[] = $cardId;
+                }
+            }
+
+            $n = rand(0, count($cardArr) - 1);
+            $cId = $cardArr[$n];
+        }
         return $cId;
     }