Browse Source

宠物蛋孵化

cyzhao 2 months ago
parent
commit
2018fc2e6a

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

@@ -407,6 +407,25 @@ class CmdCode {
      */
     const store_pet_downGradingQual = 6428;
     
+    /**
+     * 孵化宠物
+     */
+    const store_pet_breedEgg = 6429; 
+    
+    /**
+     * 加速孵化宠物
+     */
+    const store_pet_fastBreedEgg = 6430;
+    
+    /**
+     * 正常孵化完成点击领取
+     */
+    const store_pet_receiveBreedPet = 6431;
+    
+    /**
+     * 解锁孵化位置
+     */
+    const store_pet_unlockBreedLocation = 6432;
 // </editor-fold>
 // <editor-fold defaultstate="collapsed" desc="商城操作码 - 65xx">
 

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

@@ -448,7 +448,7 @@ class ErrCode {
     const user_store_NoEquip = 3301;
 
     /**
-     * 背包
+     * 背包不存在该物品
      */
     const user_store_NoItem = 3302;
 
@@ -556,6 +556,31 @@ class ErrCode {
      * 该区域最多展示8个灵宠
      */
     const user_store_ShowPetNumLimit = 3323;
+    
+    /**
+     * 没有可以孵化的位置
+     */
+    const user_store_NoBreedSlot = 3324;
+    
+    /**
+     * 不存在可以加速孵化的灵宠蛋
+     */
+    const user_store_NoExistBreedEgg = 3325;
+    
+    /**
+     * 孵化位置未解锁
+     */
+    const user_store_SlotNotUnlocked = 3326;
+    
+    /**
+     * 已经完成孵化
+     */
+    const user_store_CompleteBreed = 3327;
+    
+    /**
+     * 未完成孵化
+     */
+    const user_store_NoCompleteBreed = 3328;
 // </editor-fold>
 //
 //   // <editor-fold defaultstate="collapsed" desc="    shop 3400    ">

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2025-03-17 17:53:19
+ // 日期: 2025-03-24 14:31:28
 ////////////////////
 
 namespace loyalsoft;
@@ -1272,6 +1272,22 @@ class GameConfig {
         return self::get_hash_item('pet_compose', $itemid);
     }
     /**
+    * 宠物蛋
+    * @return \pet_egg
+    */
+    public static function pet_egg()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'pet_egg');
+    }
+    /**
+    * @return \sm_pet_egg pet_egg item数据 
+    */
+    public static function pet_egg_getItem($itemid)
+    { 
+        return self::get_hash_item('pet_egg', $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 
- // 日期: 2025-03-21 10:15:38
+ // 日期: 2025-03-25 10:27:29
 ////////////////////
 
 /**
@@ -1270,6 +1270,22 @@ class GameConfig {
         return self::get_hash_item('pet_compose', $itemid);
     }
     /**
+    * 宠物蛋
+    * @return \pet_egg
+    */
+    public static function pet_egg()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'pet_egg');
+    }
+    /**
+    * @return \sm_pet_egg pet_egg item数据 
+    */
+    public static function pet_egg_getItem($itemid)
+    { 
+        return self::get_hash_item('pet_egg', $itemid);
+    }
+    /**
     * 当前版本(时间戳)
     * @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 
- // 日期: 2025-03-05 09:22:01
+ // 日期: 2025-03-25 10:17:46
 ////////////////////
 
 

+ 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 
- // 日期: 2025-03-05 09:22:01
+ // 日期: 2025-03-25 10:17:46
 ////////////////////
 
 

+ 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-12-19 16:53:06
+ // 日期: 2025-03-25 10:28:17
 ////////////////////
 
 

+ 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 
- // 日期: 2025-02-28 14:39:17
+ // 日期: 2025-03-21 16:11:36
 ////////////////////
 
 

+ 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 
- // 日期: 2025-02-20 17:31:29
+ // 日期: 2025-03-24 14:10:31
 ////////////////////
 
 

+ 6 - 1
Gameserver/App/model/Const/sm_glc2.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2025-03-17 09:59:53
+ // 日期: 2025-03-24 16:44:08
 ////////////////////
 
 
@@ -113,5 +113,10 @@ class sm_glc2
     */
     public $Pet_MainShowPetList;
 
+    /**
+    * @var String 宠物孵化坑位信息;孵化坑位id,解锁花费原本数量;  
+    */
+    public $Pet_BreedLocationUnlockInfo;
+
 }
 

+ 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 
- // 日期: 2025-02-07 14:17:58
+ // 日期: 2025-03-24 11:52:15
 ////////////////////
 
 

+ 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 
- // 日期: 2025-03-20 15:38:17
+ // 日期: 2025-03-24 16:00:40
 ////////////////////
 
 

+ 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 
- // 日期: 2025-03-20 15:38:17
+ // 日期: 2025-03-24 16:00:40
 ////////////////////
 
 

+ 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 
- // 日期: 2025-03-20 15:09:41
+ // 日期: 2025-03-25 10:08:15
 ////////////////////
 
 

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

@@ -0,0 +1,62 @@
+<?php
+////////////////////
+ // 由CodeGenerator创建。
+ // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
+ // author: gwang 
+ // 日期: 2025-03-21 17:38:28
+////////////////////
+
+
+/**
+ * Static Model pet_egg 宠物蛋
+ */
+class sm_pet_egg
+{
+
+    /**
+    * @var Int32 唯一  
+    */
+    public $id;
+
+    /**
+    * @var Int32 eggId  
+    */
+    public $typeId;
+
+    /**
+    * @var Int32 孵化时间 default(0) 
+    */
+    public $breedTs;
+
+    /**
+    * @var String 快速孵化消耗元宝数量  
+    */
+    public $fastBreed_cost;
+
+    /**
+    * @var String 产生的固定道具信息  
+    */
+    public $reward;
+
+    /**
+    * @var Int32 孵化概率道具 default(0) 
+    */
+    public $perItemId;
+
+    /**
+    * @var String 概率信息:稀有度,品阶,概率;  
+    */
+    public $per;
+
+    /**
+    * @var String 描述信息  
+    */
+    public $desc;
+
+    /**
+    * @var String 图片数据  
+    */
+    public $icon;
+
+}
+

+ 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 
- // 日期: 2025-03-20 16:37:08
+ // 日期: 2025-03-24 14:31:00
 ////////////////////
 
 

+ 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 
- // 日期: 2025-03-20 14:24:26
+ // 日期: 2025-03-25 09:49:15
 ////////////////////
 
 

+ 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 
- // 日期: 2025-03-20 14:24:26
+ // 日期: 2025-03-25 09:49:15
 ////////////////////
 
 

+ 28 - 0
Gameserver/App/model/User/Info_Store.php

@@ -76,6 +76,12 @@ class Info_Store extends Object_ext {
      */
     public $cuid = 10000;   
     
+    
+    /**
+     * @var int $petUid
+     */
+    public $petUid = 1;   
+    
     /**
      *  宠物背包数据
      */
@@ -99,6 +105,11 @@ class Info_Store extends Object_ext {
      */
     public $petUids_supportFight_position;
     
+    /**
+     * 孵蛋坑位信息
+     * @var type
+     */
+    public $breedEggLocation;
 
     public function initialize() {
         StoreProc::AddMultiItemInStore(glc()->Init_Packet_Items, "UsrInit");
@@ -128,6 +139,23 @@ class Info_Store extends Object_ext {
                 }
                 $this->gemEquip->$k = $item;
             }
+            
+            $str = GameConfig::glc2()->Pet_BreedLocationUnlockInfo;
+            if($str != null){
+                $list[] = explode(';', $str);
+                foreach ($list as $value) {
+                    $s = explode(',', $value);
+                    $k = $s[0]; 
+                    $ins_breed = new Ins_BreedEggSlot();
+                    $ins_breed->uid = $k;
+                    $ins_breed->unlock = 0;       
+                    if($s[1] == 0){                                            
+                        $ins_breed->unlock = 1;                       
+                    }
+                    $this->breedEggLocation->$k = $ins_breed;
+                }
+            }
+            
         } else {
             parent::__construct($arg);
         }

+ 60 - 0
Gameserver/App/model/User/Ins_BreedEggSlot.php

@@ -0,0 +1,60 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+namespace loyalsoft;
+
+/**
+ * Description of Ins_BreedEggSlot
+ *
+ * @author c'y'zhao
+ */
+class Ins_BreedEggSlot extends Object_ext{
+    /**
+     * 坑位id
+     */
+    public $uid = 0;       
+    
+    /**
+     * 坑位上孵化的蛋
+     */
+    public $eggId = 0;       
+    
+    /**
+     * 开始孵化时间
+     * @var type
+     */
+    public $endTs = 0;
+    
+    /**
+     * 是否解锁 0:没有
+     * @var type
+     */
+    public $unlock = 0;
+
+    /**
+     * 构造函数
+     * @param type $args
+     */
+    public function __construct($args = null) {
+        if($args !=null){
+            parent::__construct($args);
+        } else {
+            
+        }                
+    }
+    
+    /**
+     * 配置
+     * @return sm_pet_egg
+     */
+    public function mo() {
+        $mo = GameConfig::pet_egg_getItem($this->eggId);
+        my_Assert(null != $mo, ErrCode::err_const_no);
+        return $mo;
+    }
+}

+ 1 - 1
Gameserver/App/model/User/Ins_Equip.php

@@ -56,7 +56,7 @@ class Ins_Equip extends Object_ext{
     
     /**
      * 配置
-     * @return sm_gem
+     * @return sm_equip
      */
     public function mo() {
         $mo = GameConfig::equip_getItem($this->typeId);

+ 1 - 1
Gameserver/App/process/ActiveProc.php

@@ -110,7 +110,7 @@ class ActiveProc {
 
         if (count($arr) > 0) {
             foreach ($arr as $uid) {
-                StlUtil::arrayRemove($activeTaskInfo, $uid);
+                StlUtil::dictRemove($activeTaskInfo, $uid);                
             }
         }
 

+ 4 - 4
Gameserver/App/process/FightPower_Calculate.php

@@ -114,14 +114,14 @@ class FightPower_Calculate {
         $hpParas = glc()->fightPower_MulHp;
         $fightPower_bitHitParas = GameConfig::glc2()->fightPower_bitHitParas;
 
-        $addDamage_ActionKey = E_PredicateActionType::addDamage;
-        $dic->$addDamage_ActionKey += $mo->attack;
-        $dic->$addDamage_ActionKey += $attck;
+//        $addDamage_ActionKey = E_PredicateActionType::addDamage;
+//        $dic->$addDamage_ActionKey += $mo->attack;
+//        $dic->$addDamage_ActionKey += $attck;
         
         $addAtk_ActionKey = E_PredicateActionType::addAtk;
         $addAtk = $dic->$addAtk_ActionKey;
                 
-        $base_addDamage = $dic->$addDamage_ActionKey + $addAtk;                           // 基础攻击
+        $base_addDamage = $addAtk + $mo->attack +$attck;                           // 基础攻击
 
 
         $addHp_ActionKey = E_PredicateActionType::addHp;

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

@@ -77,10 +77,192 @@ class StoreProc {
                 return StoreProc::Pet_DownGradingLevel();              
             case CmdCode::store_pet_downGradingQual:                            # 6428 宠物降品   
                 return StoreProc::Pet_DownGradingQual();
+            case CmdCode::store_pet_breedEgg:                                   # 6429 孵化宠物
+                return StoreProc::Pet_BreedEgg();               
+            case CmdCode::store_pet_fastBreedEgg:                               # 6430 加速孵化宠物
+                return StoreProc::Pet_FastBreedEgg();    
+            case CmdCode::store_pet_receiveBreedPet:                            # 6431 正常孵化完成点击领取
+                return StoreProc::Pet_ReceiveBreedPet();    
+            case CmdCode::store_pet_unlockBreedLocation:                        # 6432 解锁孵化位置
+                return StoreProc::Pet_UnlockBreedLocation();
             default:
                 Err(ErrCode::cmd_err);
         }
     }
+    /**
+     * 6432 解锁孵化位置
+     * @return Resp
+     */
+    public static function Pet_UnlockBreedLocation() {
+        list($slotId) = req()->paras;
+        
+        $list = explode(';',GameConfig::glc2()->Pet_BreedLocationUnlockInfo);
+        foreach ($list as $value) {
+            $s = explode(',', $value);
+            if($s[0] == $slotId){
+                my_Assert(ctx()->baseInfo->cash >= $s[1], ErrCode::notenough_cash_msg);
+                ctx()->base()->Consume_Cash($s[1]);
+                $breed = new Ins_BreedEggSlot(ctx()->store->breedEggLocation->$slotId);
+                $breed->unlock = 1;
+                ctx()->store()->breedEggLocation->$slotId = $breed;
+                break;
+            }               
+        }
+        
+        UserProc::updateUserInfo();
+        return Resp::ok(array(
+                    'cash' => ctx()->baseInfo->cash,
+                    'store' => ctx()->store,                   
+        ));
+    }
+    
+    /**
+     * 6431 正常孵化完成点击领取
+     * @return Resp
+     */
+    public static function Pet_ReceiveBreedPet() {
+        list($slotId) = req()->paras;
+        
+        $ins_breed = new Ins_BreedEggSlot(ctx()->store()->breedEggLocation->$slotId);    
+        my_Assert($ins_breed->eggId != 0, ErrCode::user_store_NoExistBreedEgg);
+        my_Assert($ins_breed->unlock == 1, ErrCode::user_store_SlotNotUnlocked);                  
+        my_Assert(now() >= $ins_breed->endTs, ErrCode::user_store_NoCompleteBreed);
+                    
+        StoreProc::AddMultiItemInStore($ins_breed->mo()->reward);
+        
+        //随机一个灵宠      
+        $str = explode(';', $ins_breed->mo()->per);
+        $newPet = self::RandObtainPet($str);
+                     
+        $uid = 0;
+        if($newPet != null){           
+            $uid = $newPet->uid;
+            ctx()->store()->pet->$uid = $newPet;
+        }
+        
+        UserProc::updateUserInfo();
+        return Resp::ok(array(
+                    'cash' => ctx()->baseInfo->cash,
+                    'store' => ctx()->store,
+                    'newPetUid'=>$uid,
+        ));
+    }
+    
+    /**
+     * 6430 加速孵化宠物
+     * @return Resp
+     */
+    public static function Pet_FastBreedEgg() {
+        list($slotId) = req()->paras;
+        $ins_breed = new Ins_BreedEggSlot(ctx()->store()->breedEggLocation->$slotId);    
+        my_Assert($ins_breed->eggId != 0, ErrCode::user_store_NoExistBreedEgg);
+        my_Assert($ins_breed->unlock == 1, ErrCode::user_store_SlotNotUnlocked);                  
+        my_Assert(now() < $ins_breed->endTs, ErrCode::user_store_CompleteBreed);
+        
+        $num = $ins_breed->mo()->breedTs/60/10;
+        $cash_one = $ins_breed->mo()->fastBreed_cost/$num;
+        
+        $ts = $ins_breed->endTs - now();
+        $costNum = ceil($ts/60/10);
+        
+        my_Assert(ctx()->baseInfo->cash >= $costNum*$cash_one, ErrCode::notenough_cash_msg);
+        ctx()->base()->Consume_Cash($costNum*$cash_one);
+        
+        StoreProc::AddMultiItemInStore($ins_breed->mo()->reward);
+        
+        //随机一个灵宠      
+        $str = explode(';', $ins_breed->mo()->per);
+        $newPet = self::RandObtainPet($str);
+                     
+        $uid = 0;
+        if($newPet != null){           
+            $uid = $newPet->uid;
+            ctx()->store()->pet->$uid = $newPet;
+        }
+        
+        UserProc::updateUserInfo();
+        return Resp::ok(array(
+                    'cash' => ctx()->baseInfo->cash,
+                    'store' => ctx()->store,
+                    'newPetUid'=>$uid,
+        ));
+    }
+    
+    /**
+     * 初始化一个宠物
+     * @param type $rarity
+     * @param type $qual
+     * @param type $petType
+     */
+    public static function RandObtainPet($str) {
+        //随机一个灵宠
+        $randNum = rand(1,10000);             
+        $start = 0;
+        $end = 0;
+        
+        $rarity = 0;
+        $qual = 0;
+        $petType = 0;
+        foreach ($str as $key => $value) {
+            $s = explode(',', $value);
+            $end += $s[3]*100; 
+            if($randNum > $start && $randNum <= $end){
+                $rarity = $s[0]; 
+                $qual = $s[1];
+                $petType = $s[2];
+                break;
+            }
+            $start = $end;
+        }
+        
+        $dic = GameConfig::pet();
+        $petArr = array();
+        foreach ($dic as $typeId => $mo) {
+            if($mo->petType == $petType && $mo->qual == $qual && $mo->rarity == $rarity){
+                $petArr[] = $typeId;
+            }
+        }
+        $typeId = 0;
+        if(count($petArr) > 0){
+            $num = rand(0,count($petArr)-1);
+            $typeId = $petArr[$num];                                
+        }
+        if($typeId != 0){
+            return self::initPet($typeId);
+        }
+                
+        return null;
+    }
+    
+    /**
+     * 6429 孵化宠物
+     * @return Resp
+     */
+    public static function Pet_BreedEgg() {
+        list($slotId,$eggId) = req()->paras;
+        
+        my_Assert(StlUtil::dictHasProperty(ctx()->store->items, $eggId), ErrCode::user_store_NoItem);
+        $mo = GameConfig::item_getItem($eggId);
+        my_Assert($mo != null, ErrCode::err_const_no);
+        my_Assert($mo->itemType == 103, ErrCode::user_store_NoItem);             
+        
+        $ins_breed = new Ins_BreedEggSlot(ctx()->store()->breedEggLocation->$slotId);       
+        my_Assert($ins_breed->eggId == 0 && $ins_breed->unlock == 1, ErrCode::user_store_NoBreedSlot);
+        ctx()->store()->removeItem($eggId, 1);
+        
+        //$ins_breed = ctx()->store()->breedEggLocation->$slot;
+ 
+        $ins_breed->eggId = $eggId;       
+        $ts = $ins_breed->mo()->breedTs;
+        $ins_breed->endTs = now()+$ts;  
+        ctx()->store()->breedEggLocation->$slotId = $ins_breed;
+               
+        UserProc::updateUserInfo();
+        return Resp::ok(array(
+                    //'gold' => ctx()->baseInfo->gold,
+                    'store' => ctx()->store,
+        ));
+    }
     
     /**
      * 6428 宠物降品   
@@ -1638,6 +1820,17 @@ class StoreProc {
             }
         }
     }
+    
+    public static function initPet($typeId, $uid = 0) {
+        if ($uid == 0) {
+            $uid = ctx()->store->petUid+1;
+        }
+        $ins_Pet = new Ins_Pet();
+        $ins_Pet->uid = $uid;
+        $ins_Pet->typeId = $typeId;
+        $ins_Pet->qual = GameConfig::pet_getItem($typeId)->qual;
+        return $ins_Pet;
+    }
 
     /**
      * 装备回存