cmd) { case CmdCode::hero_swith: # 6601 切换英雄 return HeroProc::SwithHero(); case CmdCode::hero_unlock: # 6602 解锁英雄 return self::UnlockHero(); case CmdCode::hero_buy: return self::BuyHero(); default: Err(ErrCode::cmd_err); } } /** * 购买角色 * @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($newHeroId) = req()->paras; # 切换英雄id my_Assert(GameConfig::hero_getItem($newHeroId) != null, "找不到英雄配置数据!"); // 解锁消耗, // 解锁成功. ctx()->heros->Dic->$newHeroId = new Ins_Hero(); return Resp::ok(); } /** * 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(); } }