Ver Fonte

宝石镶嵌

cyzhao há 3 anos atrás
pai
commit
de65d1cc3e

+ 10 - 0
Gameserver/Amfphp/base/CmdCode.php

@@ -631,6 +631,16 @@ class CmdCode {
      */
     const cmd_store_GemResearchLvUp = 6425;
 
+    /**
+     * 宝石镶嵌
+     */
+    const cmd_store_GemSet = 6426;
+    
+    /*
+     * 宝石卸下
+     */
+    const cmd_store_GemRemove = 6427;
+    
 // </editor-fold>
     //
     // <editor-fold defaultstate="collapsed" desc="活动操作码 - 65xx">

+ 5 - 0
Gameserver/Amfphp/base/ErrCode.php

@@ -580,6 +580,11 @@ class ErrCode {
     const store_GemComploseMaterialNotEnough = 3420;
 
     const store_ComploseGemNotEnough = 3421;
+    
+    /**
+     * 言灵身上没有宝石
+     */
+    const store_YanLingNotGem = 3422;
 // </editor-fold>
     //  
     // <editor-fold defaultstate="collapsed" desc="   任务错误码 35xx系列   ">

+ 6 - 0
Gameserver/Amfphp/model/User/Ins_YanLin.php

@@ -38,6 +38,12 @@ class Ins_YanLin extends Object_ext {
      * @var type
      */
     public $level = 1;
+    
+    /**
+     * 镶嵌宝石id
+     * @var type
+     */
+    public $gemId = 0;
 
     public function __construct($args = null) {
         parent::__construct($args);

+ 81 - 81
Gameserver/Amfphp/process/HeroProc.php

@@ -736,53 +736,53 @@ class HeroProc {
      * @return resp
      */
     static function StrengthenStar_old() {
-        list($yanlingUid, $uidList) = req()->paras;
-        $store = req()->userInfo->game->store;
-        my_Assert(StlUtil::dictHasProperty($store->yanling, $yanlingUid), ErrCode::hero_yanling_notfound);
-        my_Assert(!in_array($yanlingUid, $uidList), ErrCode::hero_yanling_repeat);
-        my_Assert($store->yanling->$yanlingUid->starLv < 5, ErrCode::hero_yanling_repeat);
-
-        $tag = true;
-        foreach ($uidList as $costUid) {
-            if (StlUtil::dictHasProperty($store->yanling, $costUid)) {          # 校验是否是同类型
-                $confDic = GameConfig::item_yanling_getItem($store->yanling->$costUid->typeId);
-                my_Assert(null != $confDic, ErrCode::hero_const_no_err);
-                if ($confDic->type != GameConfig::item_yanling_getItem($store->yanling->$yanlingUid->typeId)->type) {
-                    $tag = false;
-                    break;
-                }
-
-                if ($store->yanling->$costUid->herouid != 0) {
-                    $tag = false;
-                    break;
-                }
-            } else {
-                $tag = false;
-                break;
-            }
-        }
-
-        my_Assert($tag, ErrCode::hero_yanling_errorYanling);
-        $exp = 0;
-        foreach ($uidList as $costuid) {
-            $confDic = GameConfig::item_yanling_getItem($store->yanling->$costuid->typeId);
-            my_Assert(null != $confDic, ErrCode::hero_const_no_err);
-            $exp += $confDic->addStarExp;
-            StlUtil::dictRemove($store->yanling, $costuid);
-        }
-
-        $store->yanling->$yanlingUid->curStarExp += $exp;
-        $dic = GameConfig::item_yanling_getItem($store->yanling->$yanlingUid->typeId);
-
-        if ($store->yanling->$yanlingUid->curStarExp >= $dic->maxStarExp) {
-            $store->yanling->$yanlingUid->curStarExp = 0;
-            $store->yanling->$yanlingUid->starLv += 1;
-            $store->yanling->$yanlingUid->typeId = $dic->nextId;
-        }
-
-        req()->userInfo->game->store = $store;
-        UserProc::updateUserInfo();
-        return Resp::ok(array('store' => req()->userInfo->game->store,));
+//        list($yanlingUid, $uidList) = req()->paras;
+//        $store = req()->userInfo->game->store;
+//        my_Assert(StlUtil::dictHasProperty($store->yanling, $yanlingUid), ErrCode::hero_yanling_notfound);
+//        my_Assert(!in_array($yanlingUid, $uidList), ErrCode::hero_yanling_repeat);
+//        my_Assert($store->yanling->$yanlingUid->starLv < 5, ErrCode::hero_yanling_repeat);
+//
+//        $tag = true;
+//        foreach ($uidList as $costUid) {
+//            if (StlUtil::dictHasProperty($store->yanling, $costUid)) {          # 校验是否是同类型
+//                $confDic = GameConfig::item_yanling_getItem($store->yanling->$costUid->typeId);
+//                my_Assert(null != $confDic, ErrCode::hero_const_no_err);
+//                if ($confDic->type != GameConfig::item_yanling_getItem($store->yanling->$yanlingUid->typeId)->type) {
+//                    $tag = false;
+//                    break;
+//                }
+//
+//                if ($store->yanling->$costUid->herouid != 0) {
+//                    $tag = false;
+//                    break;
+//                }
+//            } else {
+//                $tag = false;
+//                break;
+//            }
+//        }
+//
+//        my_Assert($tag, ErrCode::hero_yanling_errorYanling);
+//        $exp = 0;
+//        foreach ($uidList as $costuid) {
+//            $confDic = GameConfig::item_yanling_getItem($store->yanling->$costuid->typeId);
+//            my_Assert(null != $confDic, ErrCode::hero_const_no_err);
+//            $exp += $confDic->addStarExp;
+//            StlUtil::dictRemove($store->yanling, $costuid);
+//        }
+//
+//        $store->yanling->$yanlingUid->curStarExp += $exp;
+//        $dic = GameConfig::item_yanling_getItem($store->yanling->$yanlingUid->typeId);
+//
+//        if ($store->yanling->$yanlingUid->curStarExp >= $dic->maxStarExp) {
+//            $store->yanling->$yanlingUid->curStarExp = 0;
+//            $store->yanling->$yanlingUid->starLv += 1;
+//            $store->yanling->$yanlingUid->typeId = $dic->nextId;
+//        }
+//
+//        req()->userInfo->game->store = $store;
+//        UserProc::updateUserInfo();
+//        return Resp::ok(array('store' => req()->userInfo->game->store,));
     }
 
     /**
@@ -902,40 +902,40 @@ class HeroProc {
      * 言灵升级  2021.4(cyzhao)
      */
     static function YanlinUpLevel_old() {
-        list($yanlingUid, $type) = req()->paras;                                # 参数: 言灵uid,升级类型:1/5级.
-        $store = ctx()->store();
-        my_Assert(StlUtil::dictHasProperty($store->yanling, $yanlingUid), ErrCode::hero_yanling_notfound);
-        $allDic = GameConfig::yanlingLeve();
-        $maxLevel = count((array) $allDic);
-        $curlv = $store->yanling->$yanlingUid->level;
-        my_Assert($curlv <= ctx()->base()->level, "请提升指挥官等级.");           # 言灵等级不能超过指挥官等级.-gwang 2021.4.20
-        my_Assert($curlv < $maxLevel, ErrCode::hero_yanling_levelMax);
-
-        $maxLv = $curlv + $type;
-        if ($maxLv > $maxLevel) {
-            $maxLv = $maxLevel;
-        }
-        $goldNum = 0;
-        $pointNum = 0;
-        for ($index = $curlv; $index < $maxLv; $index++) {
-            my_Assert(StlUtil::dictHasProperty($allDic, $index), ErrCode::hero_yanling_levelconst_no);
-            $mo = GameConfig::yanlingLeve_getItem($index);
-            $goldNum += $mo->goldCost;
-            $pointNum += $mo->pointCost;
-        }
-        my_Assert(req()->userInfo->game->base()->Consume_Gold($goldNum), ErrCode::notenough_gold_msg);
-//        my_Assert(Data_UserGame::Consume_ResPoint(req()->userInfo->game->baseInfo, $pointNum), ErrCode::notenough_resPoint);
-        my_Assert(req()->userInfo->game->base()->Consume_ResPoint($pointNum), ErrCode::notenough_resPoint);
-        $store->yanling->$yanlingUid->level += $type;                           # 增加等级
-        if ($store->yanling->$yanlingUid->level > $maxLevel) {
-            $store->yanling->$yanlingUid->level = $maxLevel;
-        }
-        TaskProc::OnYanlingLevelUp($store->yanling->$yanlingUid->typeId, $store->yanling->$yanlingUid->level); # 言灵升级
-//        req()->userInfo->game->store = $store;
-        UserProc::updateUserInfo();                                             # 回写玩家数据
-        return Resp::ok(array('store' => req()->userInfo->game->store, #
-                    'gold' => ctx()->base()->gold, #
-                    'resPoint' => ctx()->base()->resPoint));
+//        list($yanlingUid, $type) = req()->paras;                                # 参数: 言灵uid,升级类型:1/5级.
+//        $store = ctx()->store();
+//        my_Assert(StlUtil::dictHasProperty($store->yanling, $yanlingUid), ErrCode::hero_yanling_notfound);
+//        $allDic = GameConfig::yanlingLeve();
+//        $maxLevel = count((array) $allDic);
+//        $curlv = $store->yanling->$yanlingUid->level;
+//        my_Assert($curlv <= ctx()->base()->level, "请提升指挥官等级.");           # 言灵等级不能超过指挥官等级.-gwang 2021.4.20
+//        my_Assert($curlv < $maxLevel, ErrCode::hero_yanling_levelMax);
+//
+//        $maxLv = $curlv + $type;
+//        if ($maxLv > $maxLevel) {
+//            $maxLv = $maxLevel;
+//        }
+//        $goldNum = 0;
+//        $pointNum = 0;
+//        for ($index = $curlv; $index < $maxLv; $index++) {
+//            my_Assert(StlUtil::dictHasProperty($allDic, $index), ErrCode::hero_yanling_levelconst_no);
+//            $mo = GameConfig::yanlingLeve_getItem($index);
+//            $goldNum += $mo->goldCost;
+//            $pointNum += $mo->pointCost;
+//        }
+//        my_Assert(req()->userInfo->game->base()->Consume_Gold($goldNum), ErrCode::notenough_gold_msg);
+////        my_Assert(Data_UserGame::Consume_ResPoint(req()->userInfo->game->baseInfo, $pointNum), ErrCode::notenough_resPoint);
+//        my_Assert(req()->userInfo->game->base()->Consume_ResPoint($pointNum), ErrCode::notenough_resPoint);
+//        $store->yanling->$yanlingUid->level += $type;                           # 增加等级
+//        if ($store->yanling->$yanlingUid->level > $maxLevel) {
+//            $store->yanling->$yanlingUid->level = $maxLevel;
+//        }
+//        TaskProc::OnYanlingLevelUp($store->yanling->$yanlingUid->typeId, $store->yanling->$yanlingUid->level); # 言灵升级
+////        req()->userInfo->game->store = $store;
+//        UserProc::updateUserInfo();                                             # 回写玩家数据
+//        return Resp::ok(array('store' => req()->userInfo->game->store, #
+//                    'gold' => ctx()->base()->gold, #
+//                    'resPoint' => ctx()->base()->resPoint));
     }
 
 //

+ 57 - 1
Gameserver/Amfphp/process/StoreProc.php

@@ -69,12 +69,68 @@ class StoreProc {
                 return StoreProc::GemComposeItem();
             case CmdCode::cmd_store_GemResearchLvUp:                            # 6425 
                 return StoreProc::GemResearchLvUp();
-            
+            case CmdCode::cmd_store_GemSet:
+                return StoreProc::GemSetYanLing();
+            case CmdCode::cmd_store_GemRemove:
+                return StoreProc::GemRemoveYanLing();
             default:
                 Err(ErrCode::cmd_err);
         }
     }
     
+    /**
+     * 宝石镶嵌
+     */
+    static function GemSetYanLing() {
+        list($gemId,$yanlingUid) = req()->paras;                                        
+        $user = req()->userInfo->game;
+        
+        $yanling = $user->store->yanling;        
+        my_Assert(CommUtil::isPropertyExists($yanling, $yanlingUid), ErrCode::hero_yanling_errorYanling);       
+        my_Assert(CommUtil::isPropertyExists($user->store->items,$gemId) && $user->store->items->$gemId >0, ErrCode::store_itemno_err);
+        
+        StoreProc::removeItemFromStore($user->store, $gemId);
+        if(!StlUtil::dictHasProperty($yanling->$yanlingUid,"gemId")){//临时
+            $yanling->$yanlingUid->gemId = 0;
+        }
+        
+        $yanling->$yanlingUid->gemId = $gemId;
+        
+        $user->store->yanling = $yanling;        
+        req()->userInfo->game = $user;
+               
+        UserProc::updateUserInfo();                                             # 回写玩家数据
+        return Resp::ok(array(
+                    "store" => $user->store, #                                  # 目前来看只涉及到items变化                  
+        ));
+    }
+
+    /**
+     * 从严灵上卸下宝石
+     */
+    static function GemRemoveYanLing() {
+        list($yanlingUid) = req()->paras;                                       
+        $user = req()->userInfo->game;
+        my_Assert(CommUtil::isPropertyExists($user->store->yanling, $yanlingUid), ErrCode::hero_yanling_errorYanling); 
+        $gemId = $user->store->yanling->$yanlingUid->gemId;
+        
+        my_Assert($gemId != 0, ErrCode::store_YanLingNotGem);
+        
+        $goodsStr = $gemId.",1";
+        StoreProc::AddMultiItemInStore($goodsStr);
+        $user->store->yanling->$yanlingUid->gemId = 0;
+        
+        
+        req()->userInfo->game = $user;
+               
+        UserProc::updateUserInfo();                                             # 回写玩家数据
+        return Resp::ok(array(
+                    "store" => $user->store, #                                  # 目前来看只涉及到items变化               
+        ));
+        
+    }
+
+
     /**
      * 宝石合成
      */