Kaynağa Gözat

宝石合成接口提交

cyzhao 1 yıl önce
ebeveyn
işleme
dbf18bfce5

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

@@ -380,6 +380,11 @@ class ErrCode {
      * 同一件装备无法镶嵌多个技能相同的宝石
      */
     const user_store_SameGemCanotEquip= 3305;
+    
+    /**
+     * 前端给的宝石合成数量对不上
+     */
+    const user_store_GemCanotCompose = 3306;
 // </editor-fold>
 //
     

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-08 11:29:51
+ // 日期: 2024-04-09 16:00:42
 ////////////////////
 
 /**

+ 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 
- // 日期: 2024-04-08 11:12:23
+ // 日期: 2024-04-08 11:31:49
 ////////////////////
 
 

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-03-20 15:21:16
+ // 日期: 2024-04-08 15:03:38
 ////////////////////
 
 

+ 7 - 2
Gameserver/App/model/Const/sm_gem.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-04-02 15:29:19
+ // 日期: 2024-04-08 17:28:40
 ////////////////////
 
 
@@ -18,6 +18,11 @@ class sm_gem
     */
     public $id;
 
+    /**
+    * @var Int32 宝石id,命名规律:宝石品质*100000+宝石部位*1000  
+    */
+    public $typeId;
+
     /**
     * @var Int32 宝石上装备部位Id default(0) 
     */
@@ -29,7 +34,7 @@ class sm_gem
     public $qual;
 
     /**
-    * @var String 合成条件内容  
+    * @var String 合成条件内容,合成当前宝石所需宝石需求,按部位_品阶_数量进行填写  
     */
     public $synthesis;
 

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-03-28 15:48:13
+ // 日期: 2024-04-08 17:02:46
 ////////////////////
 
 

+ 162 - 14
Gameserver/App/process/StoreProc.php

@@ -221,14 +221,137 @@ class StoreProc {
         list($gemIds) = req()->paras;
         $user = ctx();
 
+        //做校验
+        $composeArr = array();
+        $list = explode(';', $gemIds);
+        krsort($list);
+              
         
+        foreach ($list as $str) {
+            $gemUidList = explode(',', $str);
+            $firstGemUId = $gemUidList[0];
+            $qual = 0;
+            $posId = 0;
+            if(StlUtil::dictHasProperty($user->store->gemStore, $gemUidList[0])){
+                $ins_gem = $user->store->gemStore->$firstGemUId;
+                $qual = $ins_gem->mo()->qual;
+                $posId = $ins_gem->mo()->position;
+            }    
+            //查找要合成的宝石配置信息
+            $gemConf = self::GemComposeSynthesis($qual, $posId);
+            $synthesisList = explode('_', $gemConf->synthesis);
+            $composePosition = $synthesisList[0];
+            $composeQual = $synthesisList[1];
+            $composeNum = $synthesisList[2];             
+                                      
+            foreach ($composeArr as $val) {
+                if($val->mo()->qual == $composeQual && $val->mo()->position == $composePosition){                        
+                    $gemUidList[] = $val->uid;
+                }
+            }
+            
+            if(count($gemUidList) >= $composeNum){                                   
+                if($gemConf != null){    
+                    $maxGemNum = intval(count($gemUidList) / $composeNum);
+                    $index = 0;
+                    $res = 0;
+                    foreach ($gemUidList as $uid) {
+                        my_Assert(self::GemIsCanCompose($uid) == false && $user->store->gemStore->$uid->isUnlock == 0, ErrCode::user_store_GemCanotCompose);
+                        
+                        $index += 1;
+                        self::RemoveGemInStore($uid);
+                        //$composeArr 有的话删除                    
+                        for ($i = 0; $i < count($composeArr); $i++) {
+                            if($composeArr[$i]->uid == $uid){
+                                StlUtil::arrayRemoveAt($composeArr, $i);
+                                break;
+                            }
+                        }
+                                                                    
+                        if($index % $composeNum == 0){
+                            $res +=1;
+                            $composeGem = self::initGem($gemConf->typeId);
+                            self::PutGemInStore2($composeGem,$maxGemNum);
+                            $composeArr[] = $composeGem;//临时放这                                             
+                        }
+                        
+                        if($res >= $maxGemNum){
+                            break;
+                        }
+                        
+                    }
+                                     
+                }                           
+            }
+            
+        }
+        $resultArr = array();
+        foreach ($composeArr as $value) {
+            $resultArr[] = $value->uid;
+        }
         
-        //my_Assert(StlUtil::dictHasProperty($user->store->equip, $uid), ErrCode::user_store_NoEquip);
+        krsort($resultArr);
+        ctx($user);    
         UserProc::updateUserInfo();
-        return Resp::ok(array(
-                    'gold' => $user->baseInfo->gold,
+        return Resp::ok(array(                    
+                    'composeGemIds' => $resultArr,
                     'store' => $user->store,));
     }
+    
+    /**
+     * 该宝石是否可以参与合成,其他页镶嵌的,已经被锁的都不能参与
+     * @param type $uid
+     * @return bool
+     */
+    private static function GemIsCanCompose($uid) {
+        $Ins_gemItem = ctx()->store->gemStore->$uid;
+        
+        $equipGemDic = ctx()->store->gemEquip;
+        $equipPag = ctx()->store->equipPag;
+        
+        $isExist = false;
+        foreach ($equipGemDic as $pag => $dic) {
+            if($equipPag == $pag){
+                continue;
+            }
+            if(StlUtil::dictHasProperty($dic, $Ins_gemItem->mo()->position)){
+                $posId = $Ins_gemItem->mo()->position;
+                $tDic = $dic->$posId;
+                foreach ($tDic as $index => $ins_gem) {
+                    if($ins_gem->uid == $Ins_gemItem->uid){
+                        $isExist = true;
+                        break;
+                    }
+                }
+            }
+            
+            if ($isExist)
+            {
+                break;
+            }            
+        }   
+        
+        return $isExist;
+    }
+    
+    private static function GemComposeSynthesis($qual,$posId) {
+        $gem = GameConfig::gem();
+        foreach ($gem as $key => $value) {             
+                if($value->synthesis != null){
+                    $synthesisList = explode('_', $value->synthesis);
+                    $composePosition = $synthesisList[0];
+                    $composeQual = $synthesisList[1];
+                    $composeNum = $synthesisList[2];
+                    
+                    if($composeQual != 0 && $composePosition != 0 && $composeQual== $qual && $posId == $composePosition){
+                        return $value;
+                    }
+                    
+                }                               
+            }
+            
+        return null;
+    }
 
     /**
      * 装备宝石
@@ -545,24 +668,49 @@ class StoreProc {
     /**
      * 新宝石入库
      */
-    public static function PutGemInStore($id,$num) {
-        $length = ctx()->store->gemLength;
-        
+    public static function PutGemInStore($id,$num) {     
         for ($i = 0; $i < $num; $i++) {
-            $length +=1;
-            $gem = new Ins_Gem();
-            $gem->uid = $length;
-            $gem->typeId = $id;
-            $gem->predicateId = self::RandomGemPredicateId($id);           
-            $tag = self::CheckNewGemTip($gem);
-            $gem->isNew = $tag; 
-            
+            $gem = self::initGem($id);
+            $length = $gem->uid;           
             ctx()->store->gemStore->$length = $gem;
         }
         
+    }
+    
+    public static function PutGemInStore2($gem,$num) {  
+        for ($i = 0; $i < $num; $i++) {           
+            $length = $gem->uid;        
+            ctx()->store->gemStore->$length = $gem;
+        }        
+    }
+    
+    public static function initGem($id) {
+        $length = ctx()->store->gemLength;
+        $length +=1;
+        $gem = new Ins_Gem();
+        $gem->uid = $length;
+        $gem->typeId = $id;
+        $gem->predicateId = self::RandomGemPredicateId($id);           
+        $tag = self::CheckNewGemTip($gem);
+        $gem->isNew = $tag; 
+                                   
         ctx()->store->gemLength = $length;
+        
+        return $gem;
     }
     
+    /**
+     * 从仓库移除宝石
+     */
+    public static function RemoveGemInStore($uid) {
+        if(StlUtil::dictHasProperty(ctx()->store->gemStore, $uid)){
+            StlUtil::dictRemove(ctx()->store->gemStore, $uid);
+        }
+               
+        return 0;
+    }
+
+
     /**
      * 新宝石随机词条 临时等刚哥
      */