Example #1
0
        public override bool TakeAction()
        {
            DTHero          heroData   = CacheSet.HeroTable.GetData(m_RequestPacket.HeroType);
            PlayerHeroLogic playerHero = new PlayerHeroLogic();

            playerHero.SetUser(m_UserId).SetHero(m_RequestPacket.HeroType);
            if (!playerHero.DataCheck())
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "wrong HeroId";
                return(false);
            }

            Hero myHero = playerHero.GetHeroInfo();
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            ItemListItem item = new ItemListItem();

            item.Id    = heroData.StarLevelUpItemId;
            item.Count = heroData.StarLevelUpItemCount[myHero.HeroStarLevel];
            if (!package.DeductInventory(item))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "not enough piece";
                return(false);
            }
            playerHero.StarLevelUp();
            myHero = playerHero.GetHeroInfo();
            m_ResponsePacket.LobbyHeroInfo = new PBLobbyHeroInfo()
            {
                Type      = m_RequestPacket.HeroType,
                StarLevel = myHero.HeroStarLevel,
                Might     = myHero.Might,
            };
            m_ResponsePacket.ItemInfo = new PBItemInfo()
            {
                Type  = item.Id,
                Count = package.MyPackage.Inventories[item.Id]
            };
            return(true);
        }