Example #1
0
        public override bool TakeAction()
        {
            PlayerHeroLogic hero = new PlayerHeroLogic();

            hero.SetUser(m_UserId).SetHero(m_RequestPacket.HeroId);
            SoulLogic          soul    = new SoulLogic();
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            if (m_RequestPacket.HasPutOnSoulId)
            {
                soul.SetSoul(m_RequestPacket.PutOnSoulId);
                if (soul.MySoul == null)
                {
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "wrong soulID";
                    return(false);
                }
                int eid = CacheSet.SoulTable.GetData(soul.MySoul.TypeId).Type;
                if (!package.DeductSoul(m_RequestPacket.PutOnSoulId))
                {
                    ErrorCode = (int)ErrorType.RequireNotMet;
                    ErrorInfo = "wrong soulID";
                    return(false);
                }
                if (!hero.DressSoul(eid, m_RequestPacket.PutOnSoulId))
                {
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "wrong soulID";
                    return(false);
                }
                m_ResponsePacket.PutOnSoulId = m_RequestPacket.PutOnSoulId;
                m_ResponsePacket.HeroId      = m_RequestPacket.HeroId;
            }
            else if (m_RequestPacket.HasTakeOffSoulId)
            {
                soul.SetSoul(m_RequestPacket.TakeOffSoulId);
                if (soul.MySoul == null)
                {
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "wrong soulID";
                    return(false);
                }
                int eid = CacheSet.SoulTable.GetData(soul.MySoul.TypeId).Type;
                if (!hero.UndressSoul(eid, m_RequestPacket.TakeOffSoulId))
                {
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "wrong soulID";
                    return(false);
                }
                package.AddSoul(m_RequestPacket.TakeOffSoulId, soul.MySoul.TypeId);
                m_ResponsePacket.HeroId        = m_RequestPacket.HeroId;
                m_ResponsePacket.TakeOffSoulId = m_RequestPacket.TakeOffSoulId;
            }
            else
            {
                //TODO
            }
            if (m_RequestPacket.HeroId > 0)
            {
                hero.RefreshMight();
                var heroInfo = hero.GetHeroInfo();
                m_ResponsePacket.HeroInfo = new PBLobbyHeroInfo()
                {
                    Type  = heroInfo.HeroType,
                    Might = heroInfo.Might,
                };
            }
            return(true);
        }