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

            ph.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
            Hero           hero       = ph.GetHeroInfo();
            int            skillLevel = hero.SkillLevels[m_RequestPacket.SkillIndex];
            DTSkillLevelUp skillData  = CacheSet.SkillLevelUpTable.GetData(h => (h.HeroType == m_RequestPacket.HeroType && h.SkillIndex == m_RequestPacket.SkillIndex && h.SkillLevel == skillLevel));
            PlayerLogic    p          = new PlayerLogic();

            p.SetUser(m_UserId);
            if (hero.HeroLv < skillData.RequiresHeroLevel || hero.HeroStarLevel < skillData.RequiresHeroStarLevel)
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "require not met";
                return(false);
            }
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            if (!p.DeductCoin(skillData.CoinCost))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You do not have enough coin";
                return(false);
            }
            if (!ph.SkillLevelUp(m_RequestPacket.SkillIndex, skillData.CostEXP))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You do not have enough exp";
                return(false);
            }

            m_ResponsePacket.HeroInfo = new PBLobbyHeroInfo()
            {
                Type = hero.HeroType,
            };
            m_ResponsePacket.HeroInfo.SkillLevels.AddRange(hero.SkillLevels);
            m_ResponsePacket.HeroInfo.SkillExps.AddRange(hero.SkillExps);
            return(true);
        }