Пример #1
0
        public override bool TakeAction()
        {
            PlayerHeroLogic playerHero = new PlayerHeroLogic();

            playerHero.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
            if (!playerHero.DataCheck())
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "wrong HeroId";
                return(false);
            }
            if (playerHero.GetHeroInfo().HeroStarLevel < GameConsts.Hero.MaxStarLevel)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "Star level not enough";
                return(false);
            }
            Hero myHero = playerHero.GetHeroInfo();
            DTHeroConsciousnessBase heroConsciousness = CacheSet.HeroConsciousnessBaseTable.GetData(myHero.ConsciousnessLevel);

            if (heroConsciousness.LevelUpItemId == -1)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "reached max level";
                return(false);
            }
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            if (!p.DeductSpirit(heroConsciousness.LevelUpItemCount))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "Spirit not enough";
                return(false);
            }
            playerHero.ConsciousnessLevelUp();
            myHero = playerHero.GetHeroInfo();
            m_ResponsePacket.LobbyHeroInfo = new PBLobbyHeroInfo()
            {
                Type = myHero.HeroType,
                ConsciousnessLevel = myHero.ConsciousnessLevel,
                Might = myHero.Might,
            };
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Id = p.MyPlayer.Id, Spirit = p.MyPlayer.Spirit
            };
            return(true);
        }