cmd) { case CmdCode::hero_swith: # 6601 切换英雄 return HeroProc::SwithHero(); case CmdCode::hero_unlock: # 6602 解锁英雄 return self::UnlockHero(); case CmdCode::hero_strengthenStar: # 6603 角色升星 return self::HeroStrengthenStar(); default: Err(ErrCode::cmd_err); } } /** * 6603 角色升星 * @return type */ private static function HeroStrengthenStar(){ 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; if(ctx()->heros->CurrentHeroId == $heroId){ ctx()->heros->CurrentHeroId = $nextHeroId; } StlUtil::dictRemove(ctx()->heros->Dic, $heroId); UserProc::updateUserInfo(); return Resp::ok(array( 'store' => ctx()->store, 'heros'=>ctx()->heros, 'newHeroId'=>$nextHeroId, )); } /** * 购买角色 * @return type */ private static function BuyHero(){ list($heroId) = req()->paras; # 切换英雄id my_Assert(GameConfig::hero_getItem($heroId) != null, "找不到英雄配置数据!"); ctx()->heros->Dic->$heroId->isUnlock = 1; return Resp::ok(); } /** * 6602 解锁英雄 * @return type */ private static function UnlockHero() { 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); FightProc::skillUnlock_heroUnlock($heroId);//这个接口位置不能动 ctx()->heros->Dic->$heroId->isUnlock = 1;//解锁 ctx()->heros->Dic->$heroId->isNewHeadImgTip = 1; UserProc::updateUserInfo(); return Resp::ok(array( 'store' => ctx()->store, 'heros'=>ctx()->heros, 'skillUnlockRecord' => ctx()->privateState->skillUnlockRecord, )); } /** * 6601 切换英雄 */ private static function SwithHero() { list($newHeroId) = req()->paras; # 切换英雄id my_Assert(CommUtil::isPropertyExists(ctx()->heros->Dic, $newHeroId), "尚未获得此英雄!"); ctx()->heros->CurrentHeroId = $newHeroId; return Resp::ok(); } }