Exemplo n.º 1
0
        public override bool TakeAction()
        {
            m_ResponsePacket.ChanceType = m_RequestPacket.ChanceType;
            PlayerChanceLogic pc = new PlayerChanceLogic();

            pc.SetUserAndType(m_UserId, m_RequestPacket.ChanceType);
            m_ResponsePacket.NextRefreshTime = pc.MyChance.NextRefreshTime;
            m_ResponsePacket.NextFreeTime    = pc.MyChance.NextFreeTime;
            foreach (var reward in pc.MyChance.UnopenedChanceRewards)
            {
                PBItemInfo item = new PBItemInfo()
                {
                    Type  = reward.Value.ItemId,
                    Count = reward.Value.ItemCount
                };
                m_ResponsePacket.GoodInfo.Add(item);
            }
            foreach (var opened in pc.MyChance.OpenedChanceRewards)
            {
                m_ResponsePacket.OpenedIndex.Add(opened.Key);
                PBItemInfo item = new PBItemInfo()
                {
                    Type  = opened.Value.ItemId,
                    Count = opened.Value.ItemCount
                };
                m_ResponsePacket.OpenedGoodInfo.Add(item);
                m_ResponsePacket.GoodInfo.Add(item);
            }
            m_ResponsePacket.FreeChanceTimes = pc.MyChance.TotalFreeCount;
            return(true);
        }
Exemplo n.º 2
0
        public override bool TakeAction()
        {
            m_ResponsePacket.ChanceType = m_RequestPacket.ChanceType;
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            PlayerChanceLogic pc = new PlayerChanceLogic();

            pc.SetUserAndType(m_UserId, m_RequestPacket.ChanceType);
            if (!pc.ResetRewards(false))
            {
                ErrorCode = (int)ErrorType.RequireNotMet;
                ErrorInfo = "You have not enough money";
                return(false);
            }
            m_ResponsePacket.PlayerInfo = new PBPlayerInfo()
            {
                Id    = m_UserId,
                Coin  = p.MyPlayer.Coin,
                Money = p.MyPlayer.Money
            };
            foreach (var item in pc.MyChance.UnopenedChanceRewards)
            {
                m_ResponsePacket.GoodInfo.Add(new PBItemInfo()
                {
                    Type  = item.Value.ItemId,
                    Count = item.Value.ItemCount
                });
            }
            m_ResponsePacket.FreeChanceTimes = pc.MyChance.TotalFreeCount;
            return(true);
        }
Exemplo n.º 3
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 items = pc.OpenAllChance();

            if (items == null)
            {
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "you can not open this";
                return(false);
            }
            m_ResponsePacket.ChanceType = m_RequestPacket.ChanceType;
            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,
            };

            foreach (var iteminfo in items)
            {
                m_ResponsePacket.OpenedIndex.Add(iteminfo.Key);
                m_ResponsePacket.OpenedGoodInfo.Add(new PBItemInfo()
                {
                    Type  = iteminfo.Value.ItemId,
                    Count = iteminfo.Value.ItemCount
                });
                GetItems(iteminfo.Value);
            }

            ReceiveItemMethodType type = m_RequestPacket.ChanceType == (int)ChanceType.Money ? ReceiveItemMethodType.CoinChance : ReceiveItemMethodType.MoneyChance;
            PBReceivedItems       receivedItems;

            pp.GetItems(m_DropItems, type, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
            return(true);
        }
Exemplo n.º 4
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);
        }