コード例 #1
0
ファイル: FundManager.cs プロジェクト: chenchungit/ky
        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);
            }
        }
コード例 #2
0
 private static bool DBFundMoney(GameClient client, FundDBItem item)
 {
     return(Global.sendToDB <bool, FundDBItem>(13119, item, client.ServerId));
 }
コード例 #3
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);
        }
コード例 #4
0
ファイル: FundManager.cs プロジェクト: chenchungit/ky
        private static bool DBFundMoney(GameClient client, FundDBItem item)
        {
            bool result = Global.sendToDB <bool, FundDBItem>((int)TCPGameServerCmds.CMD_DB_FUND_MONEY, item, client.ServerId);

            return(result);
        }
コード例 #5
0
ファイル: FundManager.cs プロジェクト: chenchungit/ky
        /// <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);
        }
コード例 #6
0
ファイル: FundManager.cs プロジェクト: chenchungit/ky
        /// <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);
        }