예제 #1
0
        int getRewardItemId(int luckyValue)
        {
            int itemId = 1;

            int r    = Common_Random.getRandom(1, 1000);
            int temp = 0;

            ConfigComponent       configCom    = Game.Scene.GetComponent <ConfigComponent>();
            List <ZhuanpanConfig> shopInfoList = new List <ZhuanpanConfig>();

            for (int i = 1; i < configCom.GetAll(typeof(ZhuanpanConfig)).Length + 1; ++i)
            {
                ZhuanpanConfig config = (ZhuanpanConfig)configCom.Get(typeof(ZhuanpanConfig), i);

                if (r <= (config.Probability + temp))
                {
                    itemId = config.itemId;
                    break;
                }
                else
                {
                    temp += config.Probability;
                }
            }

            return(itemId);
        }
예제 #2
0
        public void FaMahjong(List <List <MahjongInfo> > temp, List <MahjongInfo> rest)
        {
            List <MahjongInfo> mahjongList = new List <MahjongInfo>();

            for (int i = 0; i < m_mahjongList.Count; i++)
            {
                mahjongList.Add(m_mahjongList[i]);
            }

            foreach (var item in temp)
            {
                if (item == null)
                {
                    continue;
                }
                for (int i = 0; i < 13; i++)
                {
                    int r = Common_Random.getRandom(0, mahjongList.Count - 1);
                    item.Add(mahjongList[r]);

                    mahjongList.RemoveAt(r);
                }
            }

            for (int i = 0; i < mahjongList.Count; i++)
            {
                rest.Add(mahjongList[i]);
            }
            mahjongList.Clear();
        }
예제 #3
0
        /// <summary>
        /// 从12个活动里面随机获取六个活动
        /// </summary>
        /// <returns></returns>
        private string GetRandomIndex()
        {
            List <int>    randomIndexList = new List <int>();
            int           i      = 6;
            StringBuilder result = new StringBuilder();

            while (i > 0)
            {
                int index = Common_Random.getRandom(0, 11);
                if (!randomIndexList.Contains(index))
                {
                    randomIndexList.Add(index);
                    if (randomIndexList.Count == 1)
                    {
                        result.Append(index);
                    }
                    else
                    {
                        result.Append(";").Append(index);
                    }
                    --i;
                }
            }
            return(result.ToString());
        }
예제 #4
0
        static public string getTips()
        {
            if (TipsConfig.getInstance().getDataList().Count > 0)
            {
                int r = Common_Random.getRandom(1, TipsConfig.getInstance().getDataList().Count);
                return(TipsConfig.getInstance().getDataList()[r - 1]);
            }

            return("");
        }
        protected override async void Run(Session session, C2G_GetFriendTreasure message, Action <G2C_GetFriendTreasure> reply)
        {
            G2C_GetFriendTreasure response = new G2C_GetFriendTreasure();

            try
            {
                //获取房间信息
                DBProxyComponent       proxyComponent = Game.Scene.GetComponent <DBProxyComponent>();
                List <FriendKeyConsum> consums        = await proxyComponent.QueryJson <FriendKeyConsum>($"{{UId:{message.UId},CreateTime:/^{DateTime.Now.GetCurrentDay()}/}}");

                if (consums.Count > 0)
                {
                    if (consums[0].ConsumCount >= 5)
                    {
                        if (consums[0].GetCount >= 5)
                        {
                            response.Error   = ErrorCode.ERR_Common;
                            response.Message = "今日领取次数已经满5次,不能领取";
                            reply(response);
                            return;
                        }
                        else
                        {
                            //可以领取
                            consums[0].GetCount    += 1;
                            consums[0].ConsumCount -= 5;
                            await proxyComponent.Save(consums[0]);

                            int rd = Common_Random.getRandom(1, 100);
                            if (rd > 69)
                            {
                                //一个话费红包和五千金币
                                await DBCommonUtil.changeWealthWithStr(message.UId, "111:1;1:5000", "好友房开启宝箱获得");

                                response.Reward = "111:1;1:5000";
                            }
                            else if (rd >= 69 && rd < 99)
                            {
                                //二个话费红包和一千金币
                                await DBCommonUtil.changeWealthWithStr(message.UId, "111:2;1:10000", "好友房开启宝箱获得");

                                response.Reward = "111:2;1:10000";
                            }
                            else
                            {
                                //五个话费红包和一千金币
                                await DBCommonUtil.changeWealthWithStr(message.UId, "111:5;1:10000", "好友房开启宝箱获得");

                                response.Reward = "111:5;1:10000";
                            }

                            response.AlGetCount = consums[0].GetCount;
                            response.KeyCount   = consums[0].ConsumCount;
                        }
                    }
                    else
                    {
                        response.Error   = ErrorCode.ERR_Common;
                        response.Message = "今日剩余消耗的钥匙次数不满五个,不能领取";
                        reply(response);
                        return;
                    }
                }
                else
                {
                    response.Error   = ErrorCode.ERR_Common;
                    response.Message = "今日消耗的钥匙不足五个,不能领取";
                    reply(response);
                    return;
                }
                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
예제 #6
0
        public async Task useProp(G2C_UseItem response, long uid, int prop_id)
        {
            string                endTime            = "";
            DBProxyComponent      proxyComponent     = Game.Scene.GetComponent <DBProxyComponent>();
            List <PlayerBaseInfo> playerBaseInfoList = await proxyComponent.QueryJson <PlayerBaseInfo>($"{{_id:{uid}}}");

            PlayerBaseInfo playerBaseInfo = playerBaseInfoList[0];

            switch (prop_id)
            {
            // 表情包
            case 104:
            {
                // 未过期
                if (playerBaseInfo.EmogiTime.CompareTo(CommonUtil.getCurTimeNormalFormat()) > 0)
                {
                    endTime = (CommonUtil.timeAddDays(playerBaseInfo.EmogiTime, 30));
                }
                // 已过期
                else
                {
                    endTime = (CommonUtil.timeAddDays(CommonUtil.getCurTimeNormalFormat(), 30));
                }

                playerBaseInfo.EmogiTime = endTime;
                response.time            = endTime;

                await proxyComponent.Save(playerBaseInfo);
            }
            break;

            // VIP7天体验卡
            case 107:
            {
                // 未过期
                if (playerBaseInfo.VipTime.CompareTo(CommonUtil.getCurTimeNormalFormat()) > 0)
                {
                    endTime = (CommonUtil.timeAddDays(playerBaseInfo.VipTime, 7));
                }
                // 已过期
                else
                {
                    endTime = (CommonUtil.timeAddDays(CommonUtil.getCurTimeNormalFormat(), 7));
                }

                playerBaseInfo.VipTime = endTime;
                response.time          = endTime;

                await proxyComponent.Save(playerBaseInfo);
            }
            break;

            // VIP月卡
            case 108:
            {
                // 未过期
                if (playerBaseInfo.VipTime.CompareTo(CommonUtil.getCurTimeNormalFormat()) > 0)
                {
                    endTime = (CommonUtil.timeAddDays(playerBaseInfo.VipTime, 30));
                }
                // 已过期
                else
                {
                    endTime = (CommonUtil.timeAddDays(CommonUtil.getCurTimeNormalFormat(), 30));
                }

                playerBaseInfo.VipTime = endTime;
                response.time          = endTime;

                await proxyComponent.Save(playerBaseInfo);
            }
            break;

            // VIP季卡
            case 109:
            {
                // 未过期
                if (playerBaseInfo.VipTime.CompareTo(CommonUtil.getCurTimeNormalFormat()) > 0)
                {
                    endTime = (CommonUtil.timeAddDays(playerBaseInfo.VipTime, 90));
                }
                // 已过期
                else
                {
                    endTime = (CommonUtil.timeAddDays(CommonUtil.getCurTimeNormalFormat(), 90));
                }

                playerBaseInfo.VipTime = endTime;
                response.time          = endTime;

                await proxyComponent.Save(playerBaseInfo);
            }
            break;

            // 话费礼包
            case 111:
            {
                int    huafei = Common_Random.getRandom(5, 20);
                string reward = ("3:" + huafei);
                response.reward = reward;

                await DBCommonUtil.changeWealthWithStr(playerBaseInfo.Id, reward, "道具使用:拆话费礼包获得的话费");
            }
            break;
            }
        }
예제 #7
0
        // 供外部调用:发牌
        public void FaMahjong(List <MahjongInfo> zhuangjia, List <MahjongInfo> other1, List <MahjongInfo> other2, List <MahjongInfo> other3, List <MahjongInfo> rest)
        {
            List <MahjongInfo> mahjongList = new List <MahjongInfo>();

            for (int i = 0; i < m_mahjongList.Count; i++)
            {
                mahjongList.Add(m_mahjongList[i]);
            }

            // 先给庄家发牌:14张
            {
                for (int i = 0; i < 13; i++)
                {
                    int r = Common_Random.getRandom(0, mahjongList.Count - 1);
                    zhuangjia.Add(mahjongList[r]);

                    mahjongList.RemoveAt(r);
                }
            }

            // 给其他玩家1发牌:13张
            {
                for (int i = 0; i < 13; i++)
                {
                    int r = Common_Random.getRandom(0, mahjongList.Count - 1);
                    other1.Add(mahjongList[r]);

                    mahjongList.RemoveAt(r);
                }
            }

            // 给其他玩家2发牌:13张
            {
                for (int i = 0; i < 13; i++)
                {
                    int r = Common_Random.getRandom(0, mahjongList.Count - 1);
                    other2.Add(mahjongList[r]);

                    mahjongList.RemoveAt(r);
                }
            }

            // 给其他玩家3发牌:13张
            {
                for (int i = 0; i < 13; i++)
                {
                    int r = Common_Random.getRandom(0, mahjongList.Count - 1);
                    other3.Add(mahjongList[r]);

                    mahjongList.RemoveAt(r);
                }
            }

            // 剩余的牌
            {
                for (int i = 0; i < mahjongList.Count; i++)
                {
                    rest.Add(mahjongList[i]);
                }

                mahjongList.Clear();
            }
        }
예제 #8
0
        public static async Task <PlayerBaseInfo> addPlayerBaseInfo(long uid, string Phone, string name, string head)
        {
            DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>();
            ConfigComponent  configCom      = Game.Scene.GetComponent <ConfigComponent>();
            AccountInfo      accountInfo    = await DBCommonUtil.getAccountInfo(uid);

            List <PlayerBaseInfo> playerBaseInfos = await proxyComponent.QueryJson <PlayerBaseInfo>($"{{_id:{uid}}}");

            if (playerBaseInfos.Count > 0)
            {
                return(playerBaseInfos[0]);
            }

            PlayerBaseInfo playerBaseInfo = ComponentFactory.CreateWithId <PlayerBaseInfo>(IdGenerater.GenerateId());

            playerBaseInfo.Id = uid;

            if (string.IsNullOrEmpty(name))
            {
                playerBaseInfo.Name = uid.ToString();
            }
            else
            {
                List <PlayerBaseInfo> playerBaseInfos_temp =
                    await proxyComponent.QueryJson <PlayerBaseInfo>($"{{Name:'{name}'}}");

                // 昵称已经有人用了
                if (playerBaseInfos_temp.Count > 0)
                {
                    playerBaseInfo.Name = (name + uid.ToString().Substring(6));
                }

                playerBaseInfo.Name = name;
            }

            if (string.IsNullOrEmpty(head))
            {
                int random = Common_Random.getRandom(1, 5);
                //百分之五十的概率随机生成男生或女生头像
                int rate = Common_Random.getRandom(1, 100);
                if (rate <= 50)
                {
                    playerBaseInfo.Icon = $"f_icon{random}";
                }
                else
                {
                    playerBaseInfo.Icon = $"m_icon{random}";
                }
            }
            else
            {
                playerBaseInfo.Icon = head;
            }

            if (accountInfo != null)
            {
                accountInfo.Phone = Phone;
            }
            else
            {
                Log.Error("addPlayerBaseInfo() accountInfo==null  uid = " + uid);
            }

            playerBaseInfo.PlayerSound = Common_Random.getRandom(1, 4);
            await proxyComponent.Save(playerBaseInfo);

            await proxyComponent.Save(accountInfo);

            Log.Debug("增加新用户完毕");

            //// 插入任务数据
            //{
            //    Log.Debug("增加新用户任务");

            //    for (int i = 1; i < configCom.GetAll(typeof(TaskConfig)).Length + 1; ++i)
            //    {
            //        int id = 100 + i;
            //        TaskConfig config = (TaskConfig) configCom.Get(typeof(TaskConfig), id);
            //        TaskProgressInfo progress =
            //            ComponentFactory.CreateWithId<TaskProgressInfo>(IdGenerater.GenerateId());
            //        progress.IsGet = false;
            //        progress.UId = uid;
            //        progress.Name = config.Name;
            //        progress.TaskId = (int) config.Id;
            //        progress.IsComplete = false;
            //        progress.Target = config.Target;
            //        progress.Reward = config.Reward;
            //        progress.Desc = config.Desc;
            //        progress.CurProgress = 0;

            //        await proxyComponent.Save(progress);
            //    }

            //    Log.Debug("增加新用户任务完毕");
            //}
            //插入新用户成就
            //{
            //    Log.Debug("增加新用户成就");
            //    for (int i = 1; i < configCom.GetAll(typeof(ChengjiuConfig)).Length + 1; ++i)
            //    {
            //        int id = 100 + i;
            //        ChengjiuConfig config = (ChengjiuConfig) configCom.Get(typeof(ChengjiuConfig), id);
            //        ChengjiuInfo chengjiu = ComponentFactory.CreateWithId<ChengjiuInfo>(IdGenerater.GenerateId());
            //        chengjiu.IsGet = false;
            //        chengjiu.UId = uid;
            //        chengjiu.Name = config.Name;
            //        chengjiu.TaskId = (int) config.Id;
            //        chengjiu.IsComplete = false;
            //        chengjiu.Target = config.Target;
            //        chengjiu.Reward = config.Reward;
            //        chengjiu.Desc = config.Desc;
            //        chengjiu.CurProgress = 0;

            //        await proxyComponent.Save(chengjiu);
            //    }

            //    Log.Debug("增加新用户成就完毕");
            //}

            return(playerBaseInfo);
        }