Переглянути джерело

宠物接口移到pet里面

cyzhao 1 місяць тому
батько
коміт
2324a62dfc

+ 567 - 0
Gameserver/App/process/PetProc.php

@@ -293,4 +293,571 @@ class PetProc {
                     'store' => ctx()->store,
         ));
     }
+    
+    /**
+     * 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 StoreProc::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 宠物降品   
+     */
+    public static function Pet_DownGradingQual() {
+        list($uid) = req()->paras;
+
+        $petDic = ctx()->store->pet;
+        my_Assert(StlUtil::dictHasProperty($petDic, $uid), ErrCode::user_store_NotExistPet);
+        $ins_pet = new Ins_Pet($petDic->$uid);
+
+        $NotDownGradingList = explode(',', glc()->equipQual_NotDownGrading);
+        my_Assert(!in_array($ins_pet->qual, $NotDownGradingList), ErrCode::user_store_equip_minQual);
+
+        $itemNum = 0;
+        for ($i = 1; $i < $ins_pet->level; $i++) {
+            $mo = GameConfig::pet_levelupgrade_getItem($ins_pet->mo()->rarity, $ins_pet->qual, $i);       
+            $itemNum += $mo->costItem;
+        }       
+        StoreProc::AddMultiItemInStore(6 . ',' . $itemNum);
+               
+        self::ComposeMaterial_Fallback_Pet($ins_pet->mo()->petType, $ins_pet->qual);
+
+        $ins_pet->level = 1;
+        $sList2 = explode(';', glc()->equipQualUnlockSkillId);
+        foreach ($sList2 as $str3) {
+            $s = explode(',', $str3);
+            if (in_array($ins_pet->qual, $s)) {
+                $ins_pet->qual = $s[0];
+                break;
+            }
+        }
+
+        ctx()->store->pet->$uid = $ins_pet;
+        //FightProc::Ranking_FightPower();
+        UserProc::updateUserInfo();
+        return Resp::ok(array(
+                    //'gold' => ctx()->baseInfo->gold,
+                    'store' => ctx()->store,
+        ));
+    }
+
+    private static function ComposeMaterial_Fallback_Pet($type, $qual) {
+        $sList2 = explode(';', glc()->equipQualUnlockSkillId);
+        foreach ($sList2 as $str) {
+            $s = explode(',', $str);
+            if (in_array($qual, $s)) {
+                $max = $qual;
+                $min = $s[0];
+                $num = 0;
+                for ($i = $min; $i < $max; $i++) {
+                    $mo = GameConfig::pet_compose_getItem($i);
+                    $num += explode(',', $mo->compose_condition)[2];
+                }
+
+                $typeId = StoreProc::ComposeMaterial($type, $min,902);
+                StoreProc::AddMultiItemInStore($typeId . ',' . $num);
+                break;
+            }
+        }
+    }
+    
+    
+    /*
+     * 6427 宠物降级
+     */
+
+    public static function Pet_DownGradingLevel() {
+        list($uid) = req()->paras; //宠物uid
+
+        $petDic = ctx()->store->pet;
+        my_Assert(StlUtil::dictHasProperty($petDic, $uid), ErrCode::user_store_NotExistPet);
+        $ins_pet = new Ins_Pet($petDic->$uid);
+
+        my_Assert($ins_pet->level > 1, ErrCode::user_store_equip_minlevel);      
+     
+        $itemNum = 0;
+        for ($i = 1; $i < $ins_pet->level; $i++) {
+            $mo = GameConfig::pet_levelupgrade_getItem($ins_pet->mo()->rarity, $ins_pet->qual, $i);       
+            $itemNum += $mo->costItem;
+        }       
+        StoreProc::AddMultiItemInStore(6 . ',' . $itemNum);
+
+       
+        
+        $ins_pet->level = 1;
+        ctx()->store->pet->$uid = $ins_pet;
+
+        //FightProc::Ranking_FightPower();
+        UserProc::updateUserInfo();
+        return Resp::ok(array(
+                    //'gold' => ctx()->baseInfo->gold,
+                    'store' => ctx()->store,
+        ));
+    }
+    
+    /**
+     * 6426 宠物一键合成    
+     * @return type
+     */
+    public static function Pet_OnekeyCompose() {
+        $store = ctx()->store(true);
+        $petDic = $store->pet;
+        $arr = array();                                                         # 待处理装备临时数组
+        $composePet = array();                                                  # 合成记录
+        foreach ($petDic as $pet) {
+            if ($pet->qual < 4) {                                               # 4 品以上的不参与合成
+                $arr[] = new Ins_Pet($pet);
+            }
+        }      
+
+        while (count($arr) > 0) {                                               # 循环处理每一个装备
+            $pet_compose = array_pop($arr);                                     # 从末尾弹出一个元素做合成运算
+            if (null == $pet_compose) {                                         # 防御空对象
+                break;
+            }
+            $eqQualCfg = GameConfig::pet_compose_getItem($pet_compose->qual); # 按照品阶查询合成配置数据
+            my_Assert(null != $eqQualCfg, ErrCode::err_const_no);               # 防御配置数据错误
+            list($type, $costQual, $num) = explode(',', $eqQualCfg->compose_condition); # 从配置提取合成条件
+            $composeArr = array();                                              # 消耗集合
+            foreach ($arr as $v) {                                              # 从剩余元素中查找合成所需
+                if ($v->qual == $costQual) {                                    # 同品阶
+                    if (($type == 1) ? $v->typeId == $pet_compose->typeId #     # type: 1 与本体相同 2 同部位即可
+                                    : $v->mo()->petType == $pet_compose->mo()->petType) {
+                        $composeArr[] = $v;                                     # 成为消耗品
+                    }
+                    if (count($composeArr) >= $num) {                           # 达到消耗数量就停
+                        break;
+                    }
+                }
+            }
+            if (count($composeArr) >= $num) {                                   # 合成的回收 不合成的可不能给回收了
+                $uid = $pet_compose->uid;
+                $newPet = self::ComposeNewPet($pet_compose);                    # 原地合成
+                self::petLevelChange_Material_Recovery($newPet->mo()->rarity, $newPet->qual, $newPet->level); # 回收材料
+                $newPet->level = 1;
+                $petDic->$uid = $newPet;
+                               
+                $composePet[] = $uid;                                           # 添加合成记录
+                foreach ($composeArr as $val) {                                 # 回收消耗的装备中所含材料
+                    self::petLevelChange_Material_Recovery($val->mo()->rarity, $val->qual, $val->level); # 回收材料
+                    StlUtil::dictRemove(ctx()->store(true)->pet, $val->uid);    # 背包删除
+                    if(ctx()->store(true)->petUid_fight_position == $val->uid){
+                        ctx()->store(true)->petUid_fight_position = 0;
+                    }                 
+                    foreach (ctx()->store(true)->petUids_supportFight_position as $k => $pUid) {
+                        if($pUid == $val->uid){
+                            StlUtil::dictRemove(ctx()->store(true)->petUids_supportFight_position, $k);                            
+                            break;
+                        }
+                    }
+                                      
+                    StlUtil::arrayRemove($arr, $val); # 从arr中删掉已消耗装备
+                }
+            }
+        }
+
+       
+        UserProc::updateUserInfo();                                             # 回存玩家数据
+        return Resp::ok(array(#                                                 # 返回给客户端的数据                   
+                    'store' => ctx()->store,
+                    'composeEquip' => $composePet,
+                    'task' => ctx()->task,
+        ));
+    }
+    
+    /**
+     * 6425 宠物合成    
+     * @return Resp
+     */
+    public static function Pet_Compose() {
+        list($uid, $petUids_cost, $composeMaterial_typeIds) = req()->paras;
+       
+        $petDic = ctx()->store->pet;
+        my_Assert(StlUtil::dictHasProperty($petDic, $uid), ErrCode::user_store_NotExistPet);
+        $ins_pet = new Ins_Pet($petDic->$uid);
+
+        my_Assert($ins_pet->qual < 11, ErrCode::user_store_equip_qualMaxLimit);
+        $composeMo = GameConfig::pet_compose_getItem($ins_pet->qual);
+        my_Assert(null != $composeMo, ErrCode::err_const_no);
+        $arr = explode(',', $composeMo->compose_condition);
+
+        $type = $arr[0];
+        $costQual = $arr[1];
+        $num = $arr[2];
+
+        $all_num = 0;
+
+        $materialItemType = 0;
+        $materialItemNum = 0;
+        if ($type == 2 && $composeMaterial_typeIds != null) {//部位去校验
+            $str = explode(',', $composeMaterial_typeIds);
+            $materialItemType = $str[0];
+            $materialItemNum = count($str);
+            foreach ($str as $s) {
+                $composeMaterial_itemTypeId = StoreProc::ComposeMaterial($ins_pet->mo()->petType, $costQual,902);
+                my_Assert($composeMaterial_itemTypeId == $s, ErrCode::user_store_equip_composeMaterialErr);
+                $all_num += 1;
+            }
+        }
+
+        if ($petUids_cost != null) {
+            $costPetsArr = explode(',', $petUids_cost);
+            $all_num += count($costPetsArr);
+
+            foreach ($costPetsArr as $pUid) {
+                my_Assert(StlUtil::dictHasProperty($petDic, $pUid), ErrCode::user_store_NotExistPet);
+
+                my_Assert(ctx()->store(true)->petUid_fight_position != $pUid, ErrCode::user_store_NotSelectPet_fight);
+                my_Assert(!in_array($pUid, ctx()->store(true)->petUids_supportFight_position), ErrCode::user_store_NotSelectPet_supportfight);
+                
+                $costIns_pet = new Ins_Pet($petDic->$pUid);
+                my_Assert($costIns_pet->qual == $costQual, ErrCode::user_store_equipMaterialQualErr);
+                if ($type == 1) {//本体                
+                    my_Assert($costIns_pet->typeId == $ins_pet->typeId, ErrCode::user_store_equipMaterialTypeErr);
+                } else {
+                    my_Assert($costIns_pet->mo()->petType == $ins_pet->mo()->petType, ErrCode::user_store_equipMaterialTypeErr);
+                }
+            }
+        }
+        my_Assert($all_num == $num, ErrCode::user_store_equipMaterialNumErr);
+        ctx()->store(true)->pet->$uid = self::ComposeNewPet($ins_pet);
+
+        //消耗的装备 回收         
+        if ($petUids_cost != null) {
+            $costPetsArr = explode(',', $petUids_cost);
+            foreach ($costPetsArr as $pUid) {
+                $costIns_Equip = new Ins_Pet($petDic->$pUid);
+                self::petLevelChange_Material_Recovery($costIns_Equip->mo()->rarity, $costIns_Equip->qual, $costIns_Equip->level);
+                StlUtil::dictRemove(ctx()->store(true)->pet, $pUid);              
+            }
+        }
+
+        if ($materialItemType != 0) {
+            ctx()->store(true)->removeItem($materialItemType, $materialItemNum);
+        }
+        
+        UserProc::updateUserInfo();
+        return Resp::ok(array(                 
+                    'store' => ctx()->store,
+                    'task' => ctx()->task,
+        ));
+    }
+    
+    /**
+     * 装备等级提升 消耗的金币图纸回收
+     * @param type $rarity
+     * @param type $qual
+     * @param type $posId
+     * @param type $level
+     */
+    public static function petLevelChange_Material_Recovery($rarity, $qual,$level) {    
+        $num = 0;
+       
+        for ($i = 1; $i <= $level - 1; $i++) {
+            $mo = GameConfig::pet_levelupgrade_getItem($rarity, $qual, $i);         
+            $num += $mo->costItem;
+        }
+        if ($num > 0) {        
+            StoreProc::AddMultiItemInStore(6 . ',' . $num);
+        }
+    }
+    
+    /**
+     * 合成一个新的装备
+     * @param type Ins_Equip
+     */
+    public static function ComposeNewPet(&$ins_pet) {
+        $newPetTypeId = $ins_pet->typeId;
+        $qual = $ins_pet->qual + 1;
+        if ($ins_pet->qual < 4) {
+            //$newEquipTypeId = substr($ins_pet->typeId, 0, strlen($ins_equip->typeId) - 5);
+            $rarity = substr($ins_pet->typeId, -2);
+            $mo = GameConfig::pet_getItem($ins_pet->typeId);
+            $newPetTypeId = $mo->type. "0" . $qual . $rarity;
+        }
+
+        $ins_pet->typeId = $newPetTypeId;
+        $ins_pet->qual = $qual;
+
+        return $ins_pet;
+    }
+    
+    
+    /**
+     *6424 灵宠等级提升   
+     * @return Resp
+     */
+    public static function Pet_LevelUpgrade(){
+        list($uid) = req()->paras; //装备uid
+
+        my_Assert(StlUtil::dictHasProperty(ctx()->store->pet, $uid), ErrCode::user_store_NotExistPet);
+        $ins_pet = new Ins_Pet(ctx()->store->pet->$uid);
+        my_Assert($ins_pet->level < $ins_pet->Pet_MaxLevel(), ErrCode::user_store_LevelLimit);
+
+        $mo = $ins_pet->petLevelMo();
+
+        $costTuzhiId = 6;
+        $tuzhiNum = 0;
+        if (StlUtil::dictHasProperty(ctx()->store->items, $costTuzhiId)) {
+            $tuzhiNum = ctx()->store->items->$costTuzhiId;
+        }
+        my_Assert($tuzhiNum >= $mo->costItem, ErrCode::notenough_item);
+
+        ctx()->store(true)->removeItem($costTuzhiId,$mo->costItem);
+     
+        $ins_pet->level += 1;
+        ctx()->store->pet->$uid = $ins_pet;
+     
+        UserProc::updateUserInfo();
+        return Resp::ok(array(                   
+                    'store' => ctx()->store,              
+        ));
+    }
+    
+    /**
+     * 6423 展示空闲灵宠
+     * @return Resp
+     */
+    public static function Pet_SelectShowPet(){
+        list($uid) = req()->paras;
+        
+        $petDic = ctx()->store->pet;
+        my_Assert(StlUtil::dictHasProperty($petDic, $uid), ErrCode::user_store_NotExistPet);
+        
+        my_Assert(count(ctx()->store()->mainShowPetList)< GameConfig::glc2()->Pet_MainShowPetList , ErrCode::user_store_ShowPetNumLimit);
+        
+        my_Assert(ctx()->store->petUid_fight_position != $uid, ErrCode::user_store_NotSelectPet_fight);
+        my_Assert(!in_array($uid, ctx()->store->petUids_supportFight_position), ErrCode::user_store_NotSelectPet_supportfight);
+        
+        if(in_array($uid,ctx()->store()->mainShowPetList)){
+            StlUtil::arrayRemove(ctx()->store()->mainShowPetList, $uid);
+        } else {
+            ctx()->store()->mainShowPetList[] = $uid;
+        }
+        
+        UserProc::updateUserInfo();
+        return Resp::ok(array());
+    }
+
+    /**
+     * 6422 出战/替换/上阵
+     */
+    public static function Pet_ChangeFightPosition() {
+        list($type, $uid, $index) = req()->paras;
+
+        if ($type == 1) {//出战、替换
+            ctx()->store(true)->petUid_fight_position = $uid;
+        } else if ($type == 2) {
+            ctx()->store(true)->petUids_supportFight_position->$index = $uid;
+        }
+
+        if ($type == 0 && $index == 0 && $uid != 0) {//上阵点击空白的地方
+            if (ctx()->store(true)->petUid_fight_position == 0) {
+                ctx()->store(true)->petUid_fight_position = $uid;
+            } else {
+                $list = StlUtil::dictToArray(ctx()->store(true)->petUids_supportFight_position);    
+                if (count($list) === 0) {
+                    $key = 1;
+                    ctx()->store(true)->petUids_supportFight_position->$key = $uid;
+                } else {
+                    for ($i = 1; $i <= 2; $i++) {
+                        if (!StlUtil::dictHasProperty(ctx()->store(true)->petUids_supportFight_position, $i) || ctx()->store(true)->petUids_supportFight_position->$i == 0) {
+                            ctx()->store(true)->petUids_supportFight_position->$i = $uid;
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+
+        UserProc::updateUserInfo();
+        return Resp::ok(array());
+    }
+    
+
+    /**
+     * 6421 移除宠物上的新的标志
+     */
+    public static function Pet_RemoveNewTip() {
+        list($uid) = req()->paras;
+
+        $petDic = ctx()->store->pet;
+        my_Assert(StlUtil::dictHasProperty($petDic, $uid), ErrCode::user_store_NotExistPet);
+
+        ctx()->store->pet->$uid->isNew = 0;
+
+        UserProc::updateUserInfo();
+        return Resp::ok(array());
+    }
+    
 }

+ 12 - 574
Gameserver/App/process/StoreProc.php

@@ -62,29 +62,29 @@ class StoreProc {
                 return StoreProc::Equip_DownGradingQual();
 
             case CmdCode::store_pet_removeNewTip:                               # 6421 移除宠物上的新的标志
-                return StoreProc::Pet_RemoveNewTip();
+                return PetProc::Pet_RemoveNewTip();
             case CmdCode::store_pet_changeFightPosition:                        # 6422 出战/替换/上阵
-                return StoreProc::Pet_ChangeFightPosition();
+                return PetProc::Pet_ChangeFightPosition();
             case CmdCode::store_pet_selectShowPet:                              # 6423 展示空闲灵宠
-                return StoreProc::Pet_SelectShowPet();
+                return PetProc::Pet_SelectShowPet();
             case CmdCode::store_pet_levelUpgrade:                               # 6424 灵宠等级提升   
-                return StoreProc::Pet_LevelUpgrade();
+                return PetProc::Pet_LevelUpgrade();
             case CmdCode::store_pet_compose:                                    # 6425 宠物合成    
-                return StoreProc::Pet_Compose();
+                return PetProc::Pet_Compose();
             case CmdCode::store_pet_onekeyCompose:                              # 6426 宠物一键合成    
-                return StoreProc::Pet_OnekeyCompose();              
+                return PetProc::Pet_OnekeyCompose();              
             case CmdCode::store_pet_downGradingLevel:                           # 6427 宠物降级
-                return StoreProc::Pet_DownGradingLevel();              
+                return PetProc::Pet_DownGradingLevel();              
             case CmdCode::store_pet_downGradingQual:                            # 6428 宠物降品   
-                return StoreProc::Pet_DownGradingQual();
+                return PetProc::Pet_DownGradingQual();
             case CmdCode::store_pet_breedEgg:                                   # 6429 孵化宠物
-                return StoreProc::Pet_BreedEgg();               
+                return PetProc::Pet_BreedEgg();               
             case CmdCode::store_pet_fastBreedEgg:                               # 6430 加速孵化宠物
-                return StoreProc::Pet_FastBreedEgg();    
+                return PetProc::Pet_FastBreedEgg();    
             case CmdCode::store_pet_receiveBreedPet:                            # 6431 正常孵化完成点击领取
-                return StoreProc::Pet_ReceiveBreedPet();    
+                return PetProc::Pet_ReceiveBreedPet();    
             case CmdCode::store_pet_unlockBreedLocation:                        # 6432 解锁孵化位置
-                return StoreProc::Pet_UnlockBreedLocation();
+                return PetProc::Pet_UnlockBreedLocation();                
             case CmdCode::store_pet_areaLevelUpgrade:                           # 6433 区域等级升级
                 return PetProc::Pet_UnlockBreedLocation();         
             case CmdCode::store_pet_replaceDispatchPet:                         # 6434 点击宠物 更换派遣宠物  废弃
@@ -99,569 +99,7 @@ class StoreProc {
                 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 宠物降品   
-     */
-    public static function Pet_DownGradingQual() {
-        list($uid) = req()->paras;
-
-        $petDic = ctx()->store->pet;
-        my_Assert(StlUtil::dictHasProperty($petDic, $uid), ErrCode::user_store_NotExistPet);
-        $ins_pet = new Ins_Pet($petDic->$uid);
-
-        $NotDownGradingList = explode(',', glc()->equipQual_NotDownGrading);
-        my_Assert(!in_array($ins_pet->qual, $NotDownGradingList), ErrCode::user_store_equip_minQual);
-
-        $itemNum = 0;
-        for ($i = 1; $i < $ins_pet->level; $i++) {
-            $mo = GameConfig::pet_levelupgrade_getItem($ins_pet->mo()->rarity, $ins_pet->qual, $i);       
-            $itemNum += $mo->costItem;
-        }       
-        StoreProc::AddMultiItemInStore(6 . ',' . $itemNum);
-               
-        self::ComposeMaterial_Fallback_Pet($ins_pet->mo()->petType, $ins_pet->qual);
-
-        $ins_pet->level = 1;
-        $sList2 = explode(';', glc()->equipQualUnlockSkillId);
-        foreach ($sList2 as $str3) {
-            $s = explode(',', $str3);
-            if (in_array($ins_pet->qual, $s)) {
-                $ins_pet->qual = $s[0];
-                break;
-            }
-        }
-
-        ctx()->store->pet->$uid = $ins_pet;
-        //FightProc::Ranking_FightPower();
-        UserProc::updateUserInfo();
-        return Resp::ok(array(
-                    //'gold' => ctx()->baseInfo->gold,
-                    'store' => ctx()->store,
-        ));
-    }
-
-    private static function ComposeMaterial_Fallback_Pet($type, $qual) {
-        $sList2 = explode(';', glc()->equipQualUnlockSkillId);
-        foreach ($sList2 as $str) {
-            $s = explode(',', $str);
-            if (in_array($qual, $s)) {
-                $max = $qual;
-                $min = $s[0];
-                $num = 0;
-                for ($i = $min; $i < $max; $i++) {
-                    $mo = GameConfig::pet_compose_getItem($i);
-                    $num += explode(',', $mo->compose_condition)[2];
-                }
-
-                $typeId = self::ComposeMaterial($type, $min,902);
-                StoreProc::AddMultiItemInStore($typeId . ',' . $num);
-                break;
-            }
-        }
-    }
-    
-    
-    /*
-     * 6427 宠物降级
-     */
-
-    public static function Pet_DownGradingLevel() {
-        list($uid) = req()->paras; //宠物uid
-
-        $petDic = ctx()->store->pet;
-        my_Assert(StlUtil::dictHasProperty($petDic, $uid), ErrCode::user_store_NotExistPet);
-        $ins_pet = new Ins_Pet($petDic->$uid);
-
-        my_Assert($ins_pet->level > 1, ErrCode::user_store_equip_minlevel);      
-     
-        $itemNum = 0;
-        for ($i = 1; $i < $ins_pet->level; $i++) {
-            $mo = GameConfig::pet_levelupgrade_getItem($ins_pet->mo()->rarity, $ins_pet->qual, $i);       
-            $itemNum += $mo->costItem;
-        }       
-        StoreProc::AddMultiItemInStore(6 . ',' . $itemNum);
-
-       
-        
-        $ins_pet->level = 1;
-        ctx()->store->pet->$uid = $ins_pet;
-
-        //FightProc::Ranking_FightPower();
-        UserProc::updateUserInfo();
-        return Resp::ok(array(
-                    //'gold' => ctx()->baseInfo->gold,
-                    'store' => ctx()->store,
-        ));
-    }
-    
-    /**
-     * 6426 宠物一键合成    
-     * @return type
-     */
-    public static function Pet_OnekeyCompose() {
-        $store = ctx()->store(true);
-        $petDic = $store->pet;
-        $arr = array();                                                         # 待处理装备临时数组
-        $composePet = array();                                                  # 合成记录
-        foreach ($petDic as $pet) {
-            if ($pet->qual < 4) {                                               # 4 品以上的不参与合成
-                $arr[] = new Ins_Pet($pet);
-            }
-        }      
-
-        while (count($arr) > 0) {                                               # 循环处理每一个装备
-            $pet_compose = array_pop($arr);                                     # 从末尾弹出一个元素做合成运算
-            if (null == $pet_compose) {                                         # 防御空对象
-                break;
-            }
-            $eqQualCfg = GameConfig::pet_compose_getItem($pet_compose->qual); # 按照品阶查询合成配置数据
-            my_Assert(null != $eqQualCfg, ErrCode::err_const_no);               # 防御配置数据错误
-            list($type, $costQual, $num) = explode(',', $eqQualCfg->compose_condition); # 从配置提取合成条件
-            $composeArr = array();                                              # 消耗集合
-            foreach ($arr as $v) {                                              # 从剩余元素中查找合成所需
-                if ($v->qual == $costQual) {                                    # 同品阶
-                    if (($type == 1) ? $v->typeId == $pet_compose->typeId #     # type: 1 与本体相同 2 同部位即可
-                                    : $v->mo()->petType == $pet_compose->mo()->petType) {
-                        $composeArr[] = $v;                                     # 成为消耗品
-                    }
-                    if (count($composeArr) >= $num) {                           # 达到消耗数量就停
-                        break;
-                    }
-                }
-            }
-            if (count($composeArr) >= $num) {                                   # 合成的回收 不合成的可不能给回收了
-                $uid = $pet_compose->uid;
-                $newPet = self::ComposeNewPet($pet_compose);                    # 原地合成
-                self::petLevelChange_Material_Recovery($newPet->mo()->rarity, $newPet->qual, $newPet->level); # 回收材料
-                $newPet->level = 1;
-                $petDic->$uid = $newPet;
-                               
-                $composePet[] = $uid;                                           # 添加合成记录
-                foreach ($composeArr as $val) {                                 # 回收消耗的装备中所含材料
-                    self::petLevelChange_Material_Recovery($val->mo()->rarity, $val->qual, $val->level); # 回收材料
-                    StlUtil::dictRemove(ctx()->store(true)->pet, $val->uid);    # 背包删除
-                    if(ctx()->store(true)->petUid_fight_position == $val->uid){
-                        ctx()->store(true)->petUid_fight_position = 0;
-                    }                 
-                    foreach (ctx()->store(true)->petUids_supportFight_position as $k => $pUid) {
-                        if($pUid == $val->uid){
-                            StlUtil::dictRemove(ctx()->store(true)->petUids_supportFight_position, $k);                            
-                            break;
-                        }
-                    }
-                                      
-                    StlUtil::arrayRemove($arr, $val); # 从arr中删掉已消耗装备
-                }
-            }
-        }
-
-       
-        UserProc::updateUserInfo();                                             # 回存玩家数据
-        return Resp::ok(array(#                                                 # 返回给客户端的数据                   
-                    'store' => ctx()->store,
-                    'composeEquip' => $composePet,
-                    'task' => ctx()->task,
-        ));
-    }
-    
-    /**
-     * 6425 宠物合成    
-     * @return Resp
-     */
-    public static function Pet_Compose() {
-        list($uid, $petUids_cost, $composeMaterial_typeIds) = req()->paras;
-       
-        $petDic = ctx()->store->pet;
-        my_Assert(StlUtil::dictHasProperty($petDic, $uid), ErrCode::user_store_NotExistPet);
-        $ins_pet = new Ins_Pet($petDic->$uid);
-
-        my_Assert($ins_pet->qual < 11, ErrCode::user_store_equip_qualMaxLimit);
-        $composeMo = GameConfig::pet_compose_getItem($ins_pet->qual);
-        my_Assert(null != $composeMo, ErrCode::err_const_no);
-        $arr = explode(',', $composeMo->compose_condition);
-
-        $type = $arr[0];
-        $costQual = $arr[1];
-        $num = $arr[2];
-
-        $all_num = 0;
-
-        $materialItemType = 0;
-        $materialItemNum = 0;
-        if ($type == 2 && $composeMaterial_typeIds != null) {//部位去校验
-            $str = explode(',', $composeMaterial_typeIds);
-            $materialItemType = $str[0];
-            $materialItemNum = count($str);
-            foreach ($str as $s) {
-                $composeMaterial_itemTypeId = self::ComposeMaterial($ins_pet->mo()->petType, $costQual,902);
-                my_Assert($composeMaterial_itemTypeId == $s, ErrCode::user_store_equip_composeMaterialErr);
-                $all_num += 1;
-            }
-        }
-
-        if ($petUids_cost != null) {
-            $costPetsArr = explode(',', $petUids_cost);
-            $all_num += count($costPetsArr);
-
-            foreach ($costPetsArr as $pUid) {
-                my_Assert(StlUtil::dictHasProperty($petDic, $pUid), ErrCode::user_store_NotExistPet);
-
-                my_Assert(ctx()->store(true)->petUid_fight_position != $pUid, ErrCode::user_store_NotSelectPet_fight);
-                my_Assert(!in_array($pUid, ctx()->store(true)->petUids_supportFight_position), ErrCode::user_store_NotSelectPet_supportfight);
-                
-                $costIns_pet = new Ins_Pet($petDic->$pUid);
-                my_Assert($costIns_pet->qual == $costQual, ErrCode::user_store_equipMaterialQualErr);
-                if ($type == 1) {//本体                
-                    my_Assert($costIns_pet->typeId == $ins_pet->typeId, ErrCode::user_store_equipMaterialTypeErr);
-                } else {
-                    my_Assert($costIns_pet->mo()->petType == $ins_pet->mo()->petType, ErrCode::user_store_equipMaterialTypeErr);
-                }
-            }
-        }
-        my_Assert($all_num == $num, ErrCode::user_store_equipMaterialNumErr);
-        ctx()->store(true)->pet->$uid = self::ComposeNewPet($ins_pet);
-
-        //消耗的装备 回收         
-        if ($petUids_cost != null) {
-            $costPetsArr = explode(',', $petUids_cost);
-            foreach ($costPetsArr as $pUid) {
-                $costIns_Equip = new Ins_Pet($petDic->$pUid);
-                self::petLevelChange_Material_Recovery($costIns_Equip->mo()->rarity, $costIns_Equip->qual, $costIns_Equip->level);
-                StlUtil::dictRemove(ctx()->store(true)->pet, $pUid);              
-            }
-        }
-
-        if ($materialItemType != 0) {
-            ctx()->store(true)->removeItem($materialItemType, $materialItemNum);
-        }
-        
-        UserProc::updateUserInfo();
-        return Resp::ok(array(                 
-                    'store' => ctx()->store,
-                    'task' => ctx()->task,
-        ));
-    }
-    
-    /**
-     * 装备等级提升 消耗的金币图纸回收
-     * @param type $rarity
-     * @param type $qual
-     * @param type $posId
-     * @param type $level
-     */
-    public static function petLevelChange_Material_Recovery($rarity, $qual,$level) {    
-        $num = 0;
-       
-        for ($i = 1; $i <= $level - 1; $i++) {
-            $mo = GameConfig::pet_levelupgrade_getItem($rarity, $qual, $i);         
-            $num += $mo->costItem;
-        }
-        if ($num > 0) {        
-            StoreProc::AddMultiItemInStore(6 . ',' . $num);
-        }
-    }
-    
-    /**
-     * 合成一个新的装备
-     * @param type Ins_Equip
-     */
-    public static function ComposeNewPet(&$ins_pet) {
-        $newPetTypeId = $ins_pet->typeId;
-        $qual = $ins_pet->qual + 1;
-        if ($ins_pet->qual < 4) {
-            //$newEquipTypeId = substr($ins_pet->typeId, 0, strlen($ins_equip->typeId) - 5);
-            $rarity = substr($ins_pet->typeId, -2);
-            $mo = GameConfig::pet_getItem($ins_pet->typeId);
-            $newPetTypeId = $mo->type. "0" . $qual . $rarity;
-        }
-
-        $ins_pet->typeId = $newPetTypeId;
-        $ins_pet->qual = $qual;
-
-        return $ins_pet;
-    }
-    
-    
-    /**
-     *6424 灵宠等级提升   
-     * @return Resp
-     */
-    public static function Pet_LevelUpgrade(){
-        list($uid) = req()->paras; //装备uid
-
-        my_Assert(StlUtil::dictHasProperty(ctx()->store->pet, $uid), ErrCode::user_store_NotExistPet);
-        $ins_pet = new Ins_Pet(ctx()->store->pet->$uid);
-        my_Assert($ins_pet->level < $ins_pet->Pet_MaxLevel(), ErrCode::user_store_LevelLimit);
-
-        $mo = $ins_pet->petLevelMo();
-
-        $costTuzhiId = 6;
-        $tuzhiNum = 0;
-        if (StlUtil::dictHasProperty(ctx()->store->items, $costTuzhiId)) {
-            $tuzhiNum = ctx()->store->items->$costTuzhiId;
-        }
-        my_Assert($tuzhiNum >= $mo->costItem, ErrCode::notenough_item);
-
-        ctx()->store(true)->removeItem($costTuzhiId,$mo->costItem);
-     
-        $ins_pet->level += 1;
-        ctx()->store->pet->$uid = $ins_pet;
-     
-        UserProc::updateUserInfo();
-        return Resp::ok(array(                   
-                    'store' => ctx()->store,              
-        ));
-    }
-    
-    /**
-     * 6423 展示空闲灵宠
-     * @return Resp
-     */
-    public static function Pet_SelectShowPet(){
-        list($uid) = req()->paras;
-        
-        $petDic = ctx()->store->pet;
-        my_Assert(StlUtil::dictHasProperty($petDic, $uid), ErrCode::user_store_NotExistPet);
-        
-        my_Assert(count(ctx()->store()->mainShowPetList)< GameConfig::glc2()->Pet_MainShowPetList , ErrCode::user_store_ShowPetNumLimit);
-        
-        my_Assert(ctx()->store->petUid_fight_position != $uid, ErrCode::user_store_NotSelectPet_fight);
-        my_Assert(!in_array($uid, ctx()->store->petUids_supportFight_position), ErrCode::user_store_NotSelectPet_supportfight);
-        
-        if(in_array($uid,ctx()->store()->mainShowPetList)){
-            StlUtil::arrayRemove(ctx()->store()->mainShowPetList, $uid);
-        } else {
-            ctx()->store()->mainShowPetList[] = $uid;
-        }
-        
-        UserProc::updateUserInfo();
-        return Resp::ok(array());
-    }
-
-    /**
-     * 6422 出战/替换/上阵
-     */
-    public static function Pet_ChangeFightPosition() {
-        list($type, $uid, $index) = req()->paras;
-
-        if ($type == 1) {//出战、替换
-            ctx()->store(true)->petUid_fight_position = $uid;
-        } else if ($type == 2) {
-            ctx()->store(true)->petUids_supportFight_position->$index = $uid;
-        }
-
-        if ($type == 0 && $index == 0 && $uid != 0) {//上阵点击空白的地方
-            if (ctx()->store(true)->petUid_fight_position == 0) {
-                ctx()->store(true)->petUid_fight_position = $uid;
-            } else {
-                if (count(StlUtil::dictToArray(ctx()->store(true)->petUids_supportFight_position)) == 0) {
-                    $key = 1;
-                    ctx()->store(true)->petUids_supportFight_position->$key = $uid;
-                } else {
-                    for ($i = 1; $i <= 2; $i++) {
-                        if (!StlUtil::dictHasProperty(ctx()->store(true)->petUids_supportFight_position, $i) || ctx()->store(true)->petUids_supportFight_position->$i == 0) {
-                            ctx()->store(true)->petUids_supportFight_position->$i = $uid;
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-
-        UserProc::updateUserInfo();
-        return Resp::ok(array());
-    }
-
-    /**
-     * 6421 移除宠物上的新的标志
-     */
-    public static function Pet_RemoveNewTip() {
-        list($uid) = req()->paras;
-
-        $petDic = ctx()->store->pet;
-        my_Assert(StlUtil::dictHasProperty($petDic, $uid), ErrCode::user_store_NotExistPet);
-
-        ctx()->store->pet->$uid->isNew = 0;
-
-        UserProc::updateUserInfo();
-        return Resp::ok(array());
-    }
-
     /**
      * 6420 降品
      */

+ 1 - 1
Gameserver/App/triggers/cyzhao.php

@@ -7,4 +7,4 @@ new Req('{"uid":"0AD47A961006418C24E000EDF5AC0501","cmd":6000,"paras":[172239384
 req()->uid = "0AD47A961006418C24E000EDF5AC0501";
 req()->zoneid = 1;
 
-echo FightProc::ResetWorldBossRank_StartTs();
+echo FightProc::triggerSettleRankReward_worldBoss();