Przeglądaj źródła

解锁升星接口完成

cyzhao 11 miesięcy temu
rodzic
commit
07f42102c0
1 zmienionych plików z 65 dodań i 13 usunięć
  1. 65 13
      Gameserver/App/process/HeroProc.php

+ 65 - 13
Gameserver/App/process/HeroProc.php

@@ -38,12 +38,46 @@ class HeroProc {
      * @return type
      */
     private static function HeroStrengthenStar(){
-        list($heroId) = req()->paras;                                        # 切换英雄id
-        my_Assert(GameConfig::hero_getItem($heroId) != null, "找不到英雄配置数据!");
-       
-        //ctx()->heros->Dic->$heroId->isUnlock = 1;
-
-        return Resp::ok();
+        list($heroId) = req()->paras;             
+        
+        $mo = GameConfig::hero_getItem($heroId);
+        my_Assert($mo != null, ErrCode::err_const_no);
+        
+        my_Assert(StlUtil::dictHasProperty(ctx()->heros->Dic, $heroId), "找不到英雄配置数据!");
+        my_Assert(ctx()->heros->Dic->$heroId->isUnlock == 1, "英雄未解锁!");
+        
+        $nextMo = null;       
+        $typeList = GameConfig::heroType_typeId_getItemArray($mo->typeID);
+        foreach ($typeList as $item) {
+            if($item->starLv == $mo->starLv +1){
+                $nextMo = $item;
+                break;
+            }
+                
+        }
+        
+        my_Assert($nextMo != null, "没有下一星级配置信息");
+        
+        $heroDebrisList = explode(',', $nextMo->heroDebris_need);
+        $itemId = $heroDebrisList[0];
+        $itemNum = $heroDebrisList[1];
+        
+        my_Assert(StlUtil::dictHasProperty(ctx()->store->items, $itemId) && ctx()->store->items->$itemId >= $itemNum, ErrCode::notenough_item);      
+        ctx()->store->removeItem($itemId, $itemNum);
+        
+        $nextHeroId = $nextMo->id;
+        
+        $ins_hero = new Ins_Hero(ctx()->heros->Dic->$heroId);
+        $ins_hero->Id = $nextHeroId;                     
+        ctx()->heros->Dic->$nextHeroId = $ins_hero;
+        
+        StlUtil::dictRemove(ctx()->heros->Dic, $heroId);
+                
+        UserProc::updateUserInfo();
+        return Resp::ok(array(                   
+                    'store' => ctx()->store,
+                    'heros'=>ctx()->heros,
+        ));
     }
     
     /**
@@ -64,13 +98,31 @@ class HeroProc {
      * @return type
      */
     private static function UnlockHero() {
-        list($newHeroId) = req()->paras;                                        # 切换英雄id
-        my_Assert(GameConfig::hero_getItem($newHeroId) != null, "找不到英雄配置数据!");
-        // 解锁消耗,
-        // 解锁成功.
-        ctx()->heros->Dic->$newHeroId = new Ins_Hero();
-
-        return Resp::ok();
+        list($heroId) = req()->paras;             
+        
+        $mo = GameConfig::hero_getItem($heroId);
+        my_Assert($mo != null, ErrCode::err_const_no);
+        
+        my_Assert(StlUtil::dictHasProperty(ctx()->heros->Dic, $heroId), "找不到英雄配置数据!");
+        my_Assert(ctx()->heros->Dic->$heroId->isUnlock == 0, "英雄已经解锁!");
+        
+        //$heroDebris_need = $mo->heroDebris_need;
+        $heroDebrisList = explode(',', $mo->heroDebris_need);
+        $itemId = $heroDebrisList[0];
+        $itemNum = $heroDebrisList[1];
+        
+        my_Assert(StlUtil::dictHasProperty(ctx()->store->items, $itemId) && ctx()->store->items->$itemId >= $itemNum, ErrCode::notenough_item);
+        
+        ctx()->store->removeItem($itemId, $itemNum);
+        
+        ctx()->heros->Dic->$heroId->isUnlock = 1;//解锁
+                           
+        UserProc::updateUserInfo();
+        return Resp::ok(array(                   
+                    'store' => ctx()->store,
+                    'heros'=>ctx()->heros,
+        ));
+       
     }
 
     /**