示例#1
0
        public override bool TakeAction()
        {
            PlayerChanceLogic pc = new PlayerChanceLogic();

            pc.SetUserAndType(m_UserId, m_RequestPacket.ChanceType);
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            Dictionary <int, int> dropDict = new Dictionary <int, int>();

            if (!pp.CheckPackageSlot(dropDict))
            {
                ErrorCode = (int)ErrorType.PackageSlotFull;
                ErrorInfo = "package is full";
                return(false);
            }
            var item = pc.OpenChance(m_RequestPacket.OpenIndex, m_RequestPacket.UseFree);

            if (item == null)
            {
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "you can not open this";
                return(false);
            }
            m_ResponsePacket.ChanceType     = m_RequestPacket.ChanceType;
            m_ResponsePacket.OpenedIndex    = m_RequestPacket.OpenIndex;
            m_ResponsePacket.OpenedGoodInfo = new PBItemInfo()
            {
                Type  = item.ItemId,
                Count = item.ItemCount
            };
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Id    = p.MyPlayer.Id,
                Coin  = p.MyPlayer.Coin,
                Money = p.MyPlayer.Money,
            };
            m_ResponsePacket.NextFreeTime = pc.MyChance.NextFreeTime;
            GetReward(item);
            return(true);
        }