Esempio n. 1
0
        private static FundItem initFundItem(GameClient client, EFund fundType)
        {
            FundItem result;

            lock (client.ClientData.LockFund)
            {
                FundInfo fundInfo = (from info in FundManager._fundDic.Values
                                     where info.FundType == (int)fundType
                                     orderby info.FundID
                                     select info).First <FundInfo>();
                FundItem item = new FundItem();
                item.FundID   = fundInfo.FundID;
                item.FundType = (int)fundType;
                item.BuyType  = 3;
                if (client.ClientData.VipLevel >= fundInfo.MinVip)
                {
                    item.BuyType = 2;
                }
                FundAwardInfo awardInfo = (from info in FundManager._fundAwardDic.Values
                                           where info.FundType == (int)fundType && info.FundID == fundInfo.FundID
                                           orderby info.AwardID
                                           select info).First <FundAwardInfo>();
                item.AwardID   = awardInfo.AwardID;
                item.AwardType = 3;
                FundManager.checkFundItemValue(client, item);
                result = item;
            }
            return(result);
        }
Esempio n. 2
0
        public static void FundMoneyCost(GameClient client, int moneyCost)
        {
            FundData fundData = FundManager.GetFundData(client);

            if (fundData != null && fundData.IsOpen)
            {
                if (fundData.FundDic.ContainsKey(3))
                {
                    FundItem fundItem = fundData.FundDic[3];
                    if (fundItem.BuyType == 1)
                    {
                        if (FundManager.DBFundMoney(client, new FundDBItem
                        {
                            UserID = client.strUserID,
                            RoleID = client.ClientData.RoleID,
                            Value1 = 0,
                            Value2 = moneyCost
                        }))
                        {
                            fundItem.Value2 += moneyCost;
                            FundAwardInfo awardInfo = FundManager._fundAwardDic[fundItem.AwardID];
                            if (fundItem.AwardType == 3 && fundItem.Value1 >= awardInfo.Value1 && fundItem.Value2 >= awardInfo.Value2)
                            {
                                fundItem.AwardType = 2;
                                FundManager.CheckActivityTip(client);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public static void FundChangeLife(GameClient client)
        {
            FundData fundData = GetFundData(client);

            if (fundData == null || !fundData.IsOpen)
            {
                return;
            }

            if (!fundData.FundDic.ContainsKey((int)EFund.ChangeLife))
            {
                return;
            }

            FundItem fundItem = fundData.FundDic[(int)EFund.ChangeLife];

            fundItem.Value1 = client.ClientData.ChangeLifeCount;
            fundItem.Value2 = client.ClientData.Level;

            if (fundItem.BuyType != (int)EFundBuy.Have || fundItem.AwardType != (int)EFundAward.Limit)
            {
                return;
            }

            FundAwardInfo awardInfo = _fundAwardDic[fundItem.AwardID];

            if (fundItem.Value1 >= awardInfo.Value1 && fundItem.Value2 >= awardInfo.Value2)
            {
                fundItem.AwardType = (int)EFundAward.Can;
                CheckActivityTip(client);
            }
        }
Esempio n. 4
0
        private static FundItem initFundItem(GameClient client, EFund fundType)
        {
            lock (client.ClientData.LockFund)
            {
                FundInfo fundInfo = (from info in _fundDic.Values
                                     where info.FundType == (int)fundType
                                     orderby info.FundID
                                     select info).First();

                FundItem item = new FundItem();
                item.FundID   = fundInfo.FundID;
                item.FundType = (int)fundType;
                item.BuyType  = (int)EFundBuy.Limit;
                if (client.ClientData.VipLevel >= fundInfo.MinVip)
                {
                    item.BuyType = (int)EFundBuy.Can;
                }

                FundAwardInfo awardInfo = (from info in _fundAwardDic.Values
                                           where info.FundType == (int)fundType && info.FundID == fundInfo.FundID
                                           orderby info.AwardID
                                           select info).First();

                item.AwardID   = awardInfo.AwardID;
                item.AwardType = (int)EFundAward.Limit;
                checkFundItemValue(client, item);

                return(item);
            }
        }
Esempio n. 5
0
        private static void initFundAwardNext(GameClient client, FundItem fundItem)
        {
            lock (client.ClientData.LockFund)
            {
                var tempAwardList = from info in _fundAwardDic.Values
                                    where info.FundType == fundItem.FundType && info.FundID == fundItem.FundID && info.AwardID > fundItem.AwardID
                                    orderby info.AwardID
                                    select info;
                //下一个奖励
                if (tempAwardList.Any())
                {
                    FundAwardInfo awardInfo = tempAwardList.First();
                    fundItem.AwardID = awardInfo.AwardID;

                    if (fundItem.Value1 >= awardInfo.Value1 && fundItem.Value2 >= awardInfo.Value2)
                    {
                        fundItem.AwardType = (int)EFundAward.Can;
                    }
                    else
                    {
                        fundItem.AwardType = (int)EFundAward.Limit;
                    }

                    return;
                }
            }

            //下一个基金
            var tempFundList = from info in _fundDic.Values
                               where info.FundType == fundItem.FundType && info.FundID > fundItem.FundID
                               orderby info.FundID
                               select info;

            if (tempFundList.Any())
            {
                FundInfo fundInfo = tempFundList.First();
                fundItem.FundID  = fundInfo.FundID;
                fundItem.BuyTime = DateTime.MinValue;
                fundItem.BuyType = (int)EFundBuy.Limit;
                if (client.ClientData.VipLevel >= fundInfo.MinVip)
                {
                    fundItem.BuyType = (int)EFundBuy.Can;
                }

                FundAwardInfo awardInfo = (from award in _fundAwardDic.Values
                                           where award.FundType == fundItem.FundType && award.FundID == fundItem.FundID && award.AwardID > fundItem.AwardID
                                           orderby award.AwardID
                                           select award).First();

                fundItem.AwardID   = awardInfo.AwardID;
                fundItem.AwardType = (int)EFundAward.Limit;
                fundItem.Value1    = 0;
                fundItem.Value2    = 0;
            }
        }
Esempio n. 6
0
        private static void initFundAwardNext(GameClient client, FundItem fundItem)
        {
            lock (client.ClientData.LockFund)
            {
                IOrderedEnumerable <FundAwardInfo> tempAwardList = from info in FundManager._fundAwardDic.Values
                                                                   where info.FundType == fundItem.FundType && info.FundID == fundItem.FundID && info.AwardID > fundItem.AwardID
                                                                   orderby info.AwardID
                                                                   select info;
                if (tempAwardList.Any <FundAwardInfo>())
                {
                    FundAwardInfo awardInfo = tempAwardList.First <FundAwardInfo>();
                    fundItem.AwardID = awardInfo.AwardID;
                    if (fundItem.Value1 >= awardInfo.Value1 && fundItem.Value2 >= awardInfo.Value2)
                    {
                        fundItem.AwardType = 2;
                    }
                    else
                    {
                        fundItem.AwardType = 3;
                    }
                    return;
                }
            }
            IOrderedEnumerable <FundInfo> tempFundList = from info in FundManager._fundDic.Values
                                                         where info.FundType == fundItem.FundType && info.FundID > fundItem.FundID
                                                         orderby info.FundID
                                                         select info;

            if (tempFundList.Any <FundInfo>())
            {
                FundInfo fundInfo = tempFundList.First <FundInfo>();
                fundItem.FundID  = fundInfo.FundID;
                fundItem.BuyTime = DateTime.MinValue;
                fundItem.BuyType = 3;
                if (client.ClientData.VipLevel >= fundInfo.MinVip)
                {
                    fundItem.BuyType = 2;
                }
                FundAwardInfo awardInfo = (from award in FundManager._fundAwardDic.Values
                                           where award.FundType == fundItem.FundType && award.FundID == fundItem.FundID && award.AwardID > fundItem.AwardID
                                           orderby award.AwardID
                                           select award).First <FundAwardInfo>();
                fundItem.AwardID   = awardInfo.AwardID;
                fundItem.AwardType = 3;
                fundItem.Value1    = 0;
                fundItem.Value2    = 0;
            }
        }
Esempio n. 7
0
        public static void FundMoneyCost(GameClient client, int moneyCost)
        {
            FundData fundData = GetFundData(client);

            if (fundData == null || !fundData.IsOpen)
            {
                return;
            }

            if (!fundData.FundDic.ContainsKey((int)EFund.Money))
            {
                return;
            }

            FundItem fundItem = fundData.FundDic[(int)EFund.Money];

            if (fundItem.BuyType != (int)EFundBuy.Have)
            {
                return;
            }

            FundDBItem dbItem = new FundDBItem();

            dbItem.UserID = client.strUserID;
            dbItem.RoleID = client.ClientData.RoleID;
            dbItem.Value1 = 0;
            dbItem.Value2 = moneyCost;
            bool result = DBFundMoney(client, dbItem);

            if (!result)
            {
                return;
            }

            fundItem.Value2 += moneyCost;
            FundAwardInfo awardInfo = _fundAwardDic[fundItem.AwardID];

            if (fundItem.AwardType == (int)EFundAward.Limit && fundItem.Value1 >= awardInfo.Value1 && fundItem.Value2 >= awardInfo.Value2)
            {
                fundItem.AwardType = (int)EFundAward.Can;
                CheckActivityTip(client);
            }
        }
Esempio n. 8
0
        public static void FundChangeLife(GameClient client)
        {
            FundData fundData = FundManager.GetFundData(client);

            if (fundData != null && fundData.IsOpen)
            {
                if (fundData.FundDic.ContainsKey(1))
                {
                    FundItem fundItem = fundData.FundDic[1];
                    fundItem.Value1 = client.ClientData.ChangeLifeCount;
                    fundItem.Value2 = client.ClientData.Level;
                    if (fundItem.BuyType == 1 && fundItem.AwardType == 3)
                    {
                        FundAwardInfo awardInfo = FundManager._fundAwardDic[fundItem.AwardID];
                        if (fundItem.Value1 >= awardInfo.Value1 && fundItem.Value2 >= awardInfo.Value2)
                        {
                            fundItem.AwardType = 2;
                            FundManager.CheckActivityTip(client);
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        private static bool InitConfig()
        {
            string fileName = "";

            try
            {
                FundManager._fundDic.Clear();
                fileName = Global.GameResPath("Config/Fund/FundSet.xml");
                XElement xml = CheckHelper.LoadXml(fileName, true);
                if (null == xml)
                {
                    return(false);
                }
                IEnumerable <XElement> nodes = xml.Elements();
                foreach (XElement xmlItem in nodes)
                {
                    if (xmlItem != null)
                    {
                        FundInfo config = new FundInfo();
                        config.FundID   = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "MainID", "0"));
                        config.FundType = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "PageID", "0"));
                        config.MinVip   = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "MinVip", "0"));
                        config.NextID   = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "NextID", "0"));
                        config.Price    = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "Price", "0"));
                        FundManager._fundDic.Add(config.FundID, config);
                    }
                }
                FundManager._fundAwardDic.Clear();
                fileName = Global.GameResPath("Config/Fund/Fund.xml");
                xml      = CheckHelper.LoadXml(fileName, true);
                if (null == xml)
                {
                    return(false);
                }
                nodes = xml.Elements();
                foreach (XElement xmlItem in nodes)
                {
                    if (xmlItem != null)
                    {
                        FundAwardInfo awardConfig = new FundAwardInfo();
                        awardConfig.AwardID     = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "ID", "0"));
                        awardConfig.FundID      = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "MainID", "0"));
                        awardConfig.FundType    = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "GoalType", "0"));
                        awardConfig.AwardIsBind = (Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "RewardType", "0")) > 0);
                        awardConfig.AwardCount  = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "RewardCount", "0"));
                        string[] numArr = Global.GetDefAttributeStr(xmlItem, "GoalNum", "0,0").Split(new char[]
                        {
                            ','
                        });
                        switch (awardConfig.FundType)
                        {
                        case 1:
                            awardConfig.Value1 = int.Parse(numArr[0]);
                            awardConfig.Value2 = int.Parse(numArr[1]);
                            break;

                        case 2:
                            awardConfig.Value1 = int.Parse(numArr[0]);
                            break;

                        case 3:
                            awardConfig.Value1 = int.Parse(numArr[0]);
                            awardConfig.Value2 = int.Parse(numArr[1]);
                            break;
                        }
                        FundManager._fundAwardDic.Add(awardConfig.AwardID, awardConfig);
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。", fileName), ex, true);
                return(false);
            }
            return(true);
        }
Esempio n. 10
0
        private static FundData FundAward(GameClient client, int fundType)
        {
            FundData myData = FundManager.GetFundData(client);
            FundData result;

            if (!myData.IsOpen)
            {
                result = myData;
            }
            else
            {
                myData.FundType = fundType;
                if (!myData.FundDic.ContainsKey(fundType))
                {
                    myData.State = -1;
                    result       = myData;
                }
                else
                {
                    FundItem myItem = myData.FundDic[fundType];
                    if (myItem.BuyType != 1)
                    {
                        myData.State = -8;
                        result       = myData;
                    }
                    else if (myItem.AwardType == 3)
                    {
                        myData.State = -6;
                        result       = myData;
                    }
                    else if (myItem.AwardType == 1)
                    {
                        myData.State = -7;
                        result       = myData;
                    }
                    else
                    {
                        DateTime   buyTime = TimeUtil.NowDateTime();
                        FundDBItem dbItem  = new FundDBItem();
                        dbItem.zoneID   = client.ClientData.ZoneID;
                        dbItem.UserID   = client.strUserID;
                        dbItem.RoleID   = client.ClientData.RoleID;
                        dbItem.FundType = myData.FundType;
                        dbItem.FundID   = myItem.FundID;
                        dbItem.BuyTime  = buyTime;
                        dbItem.AwardID  = myItem.AwardID;
                        int  fundState  = 1;
                        bool isAwardMax = (from info in FundManager._fundAwardDic.Values
                                           where info.FundType == myItem.FundType && info.FundID == myItem.FundID && info.AwardID > myItem.AwardID
                                           select info).Any <FundAwardInfo>();
                        bool isFundMax = (from info in FundManager._fundDic.Values
                                          where info.FundType == myItem.FundType && info.FundID > myItem.FundID
                                          select info).Any <FundInfo>();
                        if (!isAwardMax && !isFundMax)
                        {
                            fundState = 2;
                        }
                        dbItem.State = fundState;
                        if (!FundManager.DBFundAward(client, dbItem))
                        {
                            myData.State = -1;
                            result       = myData;
                        }
                        else
                        {
                            FundAwardInfo awardInfo = FundManager._fundAwardDic[myItem.AwardID];
                            if (!FundManager.AddDiamone(client, awardInfo.AwardIsBind, awardInfo.AwardCount))
                            {
                                myData.State = -1;
                                result       = myData;
                            }
                            else
                            {
                                myData.State = 1;
                                if (dbItem.State == 2)
                                {
                                    myItem.AwardType = 1;
                                    FundManager.CheckActivityTip(client);
                                    result = myData;
                                }
                                else
                                {
                                    FundManager.initFundAwardNext(client, myItem);
                                    FundManager.CheckActivityTip(client);
                                    myData.FundType = fundType;
                                    result          = myData;
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Esempio n. 11
0
        private static FundData FundBuy(GameClient client, int fundType)
        {
            FundData myData = FundManager.GetFundData(client);
            FundData result;

            if (!myData.IsOpen)
            {
                result = myData;
            }
            else
            {
                myData.FundType = fundType;
                if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot9))
                {
                    myData.State = -2;
                    result       = myData;
                }
                else if (!myData.FundDic.ContainsKey(fundType))
                {
                    myData.State = -1;
                    result       = myData;
                }
                else
                {
                    FundItem myItem = myData.FundDic[fundType];
                    if (myItem.BuyType == 1)
                    {
                        myData.State = -4;
                        result       = myData;
                    }
                    else if (myItem.BuyType == 3)
                    {
                        myData.State = -5;
                        result       = myData;
                    }
                    else
                    {
                        FundInfo fundInfo = FundManager._fundDic[myItem.FundID];
                        if (fundInfo.Price > client.ClientData.UserMoney)
                        {
                            myData.State = -3;
                            result       = myData;
                        }
                        else if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, fundInfo.Price, "基金购买", true, false, false, DaiBiSySType.None))
                        {
                            myData.State = -1;
                            result       = myData;
                        }
                        else
                        {
                            DateTime buyTime = TimeUtil.NowDateTime();
                            if (!FundManager.DBFundBuy(client, new FundDBItem
                            {
                                zoneID = client.ClientData.ZoneID,
                                UserID = client.strUserID,
                                RoleID = client.ClientData.RoleID,
                                FundType = myData.FundType,
                                FundID = myItem.FundID,
                                BuyTime = buyTime,
                                State = 1
                            }))
                            {
                                myData.State = -1;
                                result       = myData;
                            }
                            else
                            {
                                myItem.BuyType = 1;
                                myItem.BuyTime = buyTime;
                                if (myItem.FundType == 2)
                                {
                                    myItem.Value1 = Global.GetOffsetDay(TimeUtil.NowDateTime()) - Global.GetOffsetDay(myItem.BuyTime) + 1;
                                }
                                FundAwardInfo awardInfo = FundManager._fundAwardDic[myItem.AwardID];
                                if (myItem.Value1 >= awardInfo.Value1 && myItem.Value2 >= awardInfo.Value2)
                                {
                                    myItem.AwardType = 2;
                                }
                                else
                                {
                                    myItem.AwardType = 3;
                                }
                                myData.State    = 1;
                                myData.FundType = fundType;
                                FundManager.CheckActivityTip(client);
                                result = myData;
                            }
                        }
                    }
                }
            }
            return(result);
        }
Esempio n. 12
0
        private static bool InitConfig()
        {
            string   fileName = "";
            XElement xml      = null;
            IEnumerable <XElement> nodes;

            try
            {
                #region ----------FundSet
                _fundDic.Clear();
                fileName = Global.GameResPath("Config/Fund/FundSet.xml");

                xml = CheckHelper.LoadXml(fileName);
                if (null == xml)
                {
                    return(false);
                }
                nodes = xml.Elements();
                foreach (var xmlItem in nodes)
                {
                    if (xmlItem == null)
                    {
                        continue;
                    }

                    FundInfo config = new FundInfo();
                    config.FundID   = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "MainID", "0"));
                    config.FundType = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "PageID", "0"));
                    config.MinVip   = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "MinVip", "0"));
                    config.NextID   = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "NextID", "0"));
                    config.Price    = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "Price", "0"));

                    _fundDic.Add(config.FundID, config);
                }
                #endregion

                #region ----------Fund
                _fundAwardDic.Clear();
                fileName = Global.GameResPath("Config/Fund/Fund.xml");

                xml = CheckHelper.LoadXml(fileName);
                if (null == xml)
                {
                    return(false);
                }
                nodes = xml.Elements();
                foreach (var xmlItem in nodes)
                {
                    if (xmlItem == null)
                    {
                        continue;
                    }

                    FundAwardInfo awardConfig = new FundAwardInfo();
                    awardConfig.AwardID     = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "ID", "0"));
                    awardConfig.FundID      = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "MainID", "0"));
                    awardConfig.FundType    = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "GoalType", "0"));
                    awardConfig.AwardIsBind = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "RewardType", "0")) > 0;
                    awardConfig.AwardCount  = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "RewardCount", "0"));

                    string[] numArr = Global.GetDefAttributeStr(xmlItem, "GoalNum", "0,0").Split(',');

                    switch (awardConfig.FundType)
                    {
                    case (int)EFund.ChangeLife:
                        awardConfig.Value1 = int.Parse(numArr[0]);
                        awardConfig.Value2 = int.Parse(numArr[1]);
                        break;

                    case (int)EFund.Login:
                        awardConfig.Value1 = int.Parse(numArr[0]);
                        break;

                    case (int)EFund.Money:
                        awardConfig.Value1 = int.Parse(numArr[0]);
                        awardConfig.Value2 = int.Parse(numArr[1]);
                        break;
                    }

                    _fundAwardDic.Add(awardConfig.AwardID, awardConfig);
                }

                #endregion
            }
            catch (System.Exception ex)
            {
                LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。", fileName), ex);
                return(false);
            }

            return(true);
        }
Esempio n. 13
0
        /// <summary>
        /// 基金——领奖
        /// </summary>
        private static FundData FundAward(GameClient client, int fundType)
        {
            FundData myData = GetFundData(client);

            if (!myData.IsOpen)
            {
                return(myData);
            }
            myData.FundType = fundType;

            //类型错误
            if (!myData.FundDic.ContainsKey(fundType))
            {
                myData.State = (int)EFundError.Error;
                return(myData);
            }

            //未购买
            FundItem myItem = myData.FundDic[fundType];

            if (myItem.BuyType != (int)EFundBuy.Have)
            {
                myData.State = (int)EFundError.ENoBuy;
                return(myData);
            }

            //未达到领奖条件
            if (myItem.AwardType == (int)EFundAward.Limit)
            {
                myData.State = (int)EFundError.EAwardLimit;
                return(myData);
            }

            //已经领取
            if (myItem.AwardType == (int)EFundAward.Have)
            {
                myData.State = (int)EFundError.EAward;
                return(myData);
            }

            //数据库保存
            DateTime   buyTime = DateTime.Now;
            FundDBItem dbItem  = new FundDBItem();

            dbItem.zoneID   = client.ClientData.ZoneID;
            dbItem.UserID   = client.strUserID;
            dbItem.RoleID   = client.ClientData.RoleID;
            dbItem.FundType = myData.FundType;
            dbItem.FundID   = myItem.FundID;
            dbItem.BuyTime  = buyTime;
            dbItem.AwardID  = myItem.AwardID;

            int fundState = (int)EFundState.Now;
            //最大奖励
            bool isAwardMax = (from info in _fundAwardDic.Values
                               where info.FundType == myItem.FundType && info.FundID == myItem.FundID && info.AwardID > myItem.AwardID
                               select info).Any();
            //最大基金
            bool isFundMax = (from info in _fundDic.Values
                              where info.FundType == myItem.FundType && info.FundID > myItem.FundID
                              select info).Any();


            if (!isAwardMax && !isFundMax)
            {
                fundState = (int)EFundState.End;
            }

            dbItem.State = fundState;
            if (!DBFundAward(client, dbItem))
            {
                myData.State = (int)EFundError.Error;
                return(myData);
            }

            //领取奖励
            FundAwardInfo awardInfo    = _fundAwardDic[myItem.AwardID];
            bool          isAddDiamond = AddDiamone(client, awardInfo.AwardIsBind, awardInfo.AwardCount);

            if (!isAddDiamond)
            {
                myData.State = (int)EFundError.Error;
                return(myData);
            }

            //
            myData.State = (int)EFundError.Succ;
            if (dbItem.State == (int)EFundState.End)
            {
                myItem.AwardType = (int)EFundAward.Have;
                CheckActivityTip(client);
                return(myData);
            }

            initFundAwardNext(client, myItem);
            CheckActivityTip(client);

            myData.FundType = fundType;
            return(myData);
        }
Esempio n. 14
0
        /// <summary>
        /// 基金——购买
        /// </summary>
        private static FundData FundBuy(GameClient client, int fundType)
        {
            FundData myData = GetFundData(client);

            if (!myData.IsOpen)
            {
                return(myData);
            }
            myData.FundType = fundType;

            // 如果1.9的功能没开放
            if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot9))
            {
                myData.State = (int)EFundError.ENoOpen;
                return(myData);
            }

            //类型错误
            if (!myData.FundDic.ContainsKey(fundType))
            {
                myData.State = (int)EFundError.Error;
                return(myData);
            }

            //已购买
            FundItem myItem = myData.FundDic[fundType];

            if (myItem.BuyType == (int)EFundBuy.Have)
            {
                myData.State = (int)EFundError.EIsBuy;
                return(myData);
            }

            //vip限制
            if (myItem.BuyType == (int)EFundBuy.Limit)
            {
                myData.State = (int)EFundError.EVipLimit;
                return(myData);
            }

            //购买钻石不足
            FundInfo fundInfo = _fundDic[myItem.FundID];

            if (fundInfo.Price > client.ClientData.UserMoney)
            {
                myData.State = (int)EFundError.ENoMoney;
                return(myData);
            }

            //扣钱
            bool result = GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, fundInfo.Price, "基金购买", true, 1, false);

            if (!result)
            {
                myData.State = (int)EFundError.Error;
                return(myData);
            }

            //数据库保存
            DateTime   buyTime = DateTime.Now;
            FundDBItem dbItem  = new FundDBItem();

            dbItem.zoneID   = client.ClientData.ZoneID;
            dbItem.UserID   = client.strUserID;
            dbItem.RoleID   = client.ClientData.RoleID;
            dbItem.FundType = myData.FundType;
            dbItem.FundID   = myItem.FundID;
            dbItem.BuyTime  = buyTime;
            dbItem.State    = (int)EFundState.Now;
            if (!DBFundBuy(client, dbItem))
            {
                myData.State = (int)EFundError.Error;
                return(myData);
            }

            myItem.BuyType = (int)EFundBuy.Have;
            myItem.BuyTime = buyTime;

            if (myItem.FundType == (int)EFund.Login)
            {
                myItem.Value1 = Global.GetOffsetDay(DateTime.Now) - Global.GetOffsetDay(myItem.BuyTime) + 1;
            }

            //检查奖励
            FundAwardInfo awardInfo = _fundAwardDic[myItem.AwardID];

            if (myItem.Value1 >= awardInfo.Value1 && myItem.Value2 >= awardInfo.Value2)
            {
                myItem.AwardType = (int)EFundAward.Can;
            }
            else
            {
                myItem.AwardType = (int)EFundAward.Limit;
            }

            myData.State    = (int)EFundError.Succ;
            myData.FundType = fundType;

            CheckActivityTip(client);
            return(myData);
        }