Exemple #1
0
        private void GiveClientChargeItem(GameClient client, List <GoodsData> awardList)
        {
            int outBag;

            if (!RebornEquip.MoreIsCanIntoRebornOrBaseBag(client, awardList, out outBag))
            {
                Global.UseMailGivePlayerAward2(client, awardList, GLang.GetLang(553, new object[0]), GLang.GetLang(554, new object[0]), 0, 0, 0);
            }
            else
            {
                for (int i = 0; i < awardList.Count; i++)
                {
                    GoodsData goodsData = awardList[i];
                    if (null != goodsData)
                    {
                        goodsData.Id = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, goodsData.GoodsID, goodsData.GCount, goodsData.Quality, goodsData.Props, goodsData.Forge_level, goodsData.Binding, 0, goodsData.Jewellist, true, 1, "充值直购", goodsData.Endtime, goodsData.AddPropIndex, goodsData.BornIndex, goodsData.Lucky, goodsData.Strong, goodsData.ExcellenceInfo, 0, 0, null, null, 0, true);
                    }
                }
            }
        }
        public RegressActiveOpcode ProcessRegressAcitveStore(GameClient client, int StoreConfID, int Level, int GoodsID, int Count)
        {
            RegressActiveOpen   iflAct = HuodongCachingMgr.GetRegressActiveOpen();
            RegressActiveOpcode result;
            string Regtime;

            if (iflAct == null || !iflAct.InActivityTime())
            {
                result = RegressActiveOpcode.RegressActiveOpenErr;
            }
            else if (!iflAct.CanGiveAward())
            {
                result = RegressActiveOpcode.RegressActiveNotIn;
            }
            else if (!UserRegressActiveManager.GetRegressMinRegtime(client, out Regtime) || Regtime == null || Regtime.Equals(""))
            {
                result = RegressActiveOpcode.RegressActiveGetRegTime;
            }
            else
            {
                int ConfID;
                int CaleLevel = iflAct.GetUserActiveFile(Regtime, out ConfID);
                if (0 == CaleLevel)
                {
                    result = RegressActiveOpcode.RegressActiveGetFile;
                }
                else if (CaleLevel != Level)
                {
                    result = RegressActiveOpcode.RegressActiveStoreCheckFail;
                }
                else
                {
                    DateTime nowDateTime = TimeUtil.NowDateTime();
                    string   CurrDate    = new DateTime(nowDateTime.Year, nowDateTime.Month, nowDateTime.Day, nowDateTime.Hour, nowDateTime.Minute, nowDateTime.Second).ToString("yyyy-MM-dd HH:mm:ss");
                    int      CDate       = Global.GetOffsetDay(DateTime.Parse(CurrDate)) - Global.GetOffsetDay(DateTime.Parse(iflAct.FromDate));
                    if (CDate < 0)
                    {
                        result = RegressActiveOpcode.RegressActiveStoreCheckDayFail;
                    }
                    else
                    {
                        RegressActiveStore StoreAct = HuodongCachingMgr.GetRegressActiveStore();
                        if (null == StoreAct)
                        {
                            result = RegressActiveOpcode.RegressActiveStoreConfErr;
                        }
                        else
                        {
                            string    stage = string.Format("{0}_{1}", Global.GetOffsetDay(DateTime.Parse(iflAct.FromDate)), Global.GetOffsetDay(DateTime.Parse(iflAct.ToDate)));
                            int       needYuanBao;
                            int       Sum;
                            GoodsData goodData;
                            if (!StoreAct.RegressStoreGoodsBuyCheck(client, StoreConfID, Level, CDate + 1, GoodsID, Count, stage, out needYuanBao, out Sum, out goodData))
                            {
                                result = RegressActiveOpcode.RegressActiveStoreBuyFail;
                            }
                            else if (goodData == null)
                            {
                                result = RegressActiveOpcode.RegressActiveStoreCheckGoodFail;
                            }
                            else if (Sum <= 0 || needYuanBao <= 0)
                            {
                                result = RegressActiveOpcode.RegressActiveStoreCheckParmErr;
                            }
                            else
                            {
                                int BagInt;
                                if (!RebornEquip.OneIsCanIntoRebornOrBaseBag(client, goodData, out BagInt))
                                {
                                    if (BagInt == 1)
                                    {
                                        return(RegressActiveOpcode.RegressActiveSignRebornBagFail);
                                    }
                                    if (BagInt == 2)
                                    {
                                        return(RegressActiveOpcode.RegressActiveSignBaseBagFail);
                                    }
                                }
                                if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, needYuanBao, "三周年商城购买物品", true, true, false, DaiBiSySType.None))
                                {
                                    result = RegressActiveOpcode.RegressActiveStoreUserYuanBaoFail;
                                }
                                else
                                {
                                    string GetInfoStr = string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
                                    {
                                        client.ClientData.RoleID,
                                        StoreConfID,
                                        CDate,
                                        Sum,
                                        stage
                                    });
                                    string[] dbResult;
                                    if (TCPProcessCmdResults.RESULT_FAILED == Global.RequestToDBServer(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, 14135, GetInfoStr, out dbResult, 0))
                                    {
                                        result = RegressActiveOpcode.RegressActiveStoreInsertInfoErr;
                                    }
                                    else if (dbResult == null || dbResult.Length != 2 || Convert.ToInt32(dbResult[1]) != 0)
                                    {
                                        result = RegressActiveOpcode.RegressActiveStoreInsertInfoErr;
                                    }
                                    else
                                    {
                                        if (Global.GetGoodsRebornEquip(goodData.GoodsID) == 1)
                                        {
                                            Global.AddGoodsDBCommand_Hook(Global._TCPManager.TcpOutPacketPool, client, goodData.GoodsID, Count, goodData.Quality, goodData.Props, goodData.Forge_level, goodData.Binding, 15000, goodData.Jewellist, true, 1, "三周年商城购买", false, "1900-01-01 12:00:00", 0, 0, 0, 0, 0, 0, 0, false, null, null, "1900-01-01 12:00:00", 0, true);
                                        }
                                        else
                                        {
                                            Global.AddGoodsDBCommand_Hook(Global._TCPManager.TcpOutPacketPool, client, goodData.GoodsID, Count, goodData.Quality, goodData.Props, goodData.Forge_level, goodData.Binding, 0, goodData.Jewellist, true, 1, "三周年商城购买", false, "1900-01-01 12:00:00", 0, 0, 0, 0, 0, 0, 0, false, null, null, "1900-01-01 12:00:00", 0, true);
                                        }
                                        result = RegressActiveOpcode.RegressActiveSucc;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Exemple #3
0
        public int _CanUsingEquip(GameClient client, GoodsData goodsData, int toBagIndex, SystemXmlItem systemGoods = null)
        {
            if (null == systemGoods)
            {
                if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodsData.GoodsID, out systemGoods))
                {
                    return(-1);
                }
            }
            int categoriy = systemGoods.GetIntValue("Categoriy", -1);

            if (!RebornEquip.IsRebornEquip(goodsData.GoodsID))
            {
                if ((categoriy < 0 || categoriy >= 49) && categoriy != 340)
                {
                    return(-2);
                }
            }
            else
            {
                if (categoriy < 30 || categoriy > 38)
                {
                    return(-2);
                }
                int Suit  = systemGoods.GetIntValue("ToReborn", -1);
                int Level = systemGoods.GetIntValue("ToRebornLevel", -1);
                if (client.ClientData.RebornCount < Suit && client.ClientData.RebornLevel < Level)
                {
                    return(-4);
                }
                if (goodsData.GCount <= 0)
                {
                    return(-5);
                }
            }
            int nHandType = systemGoods.GetIntValue("HandType", -1);

            if (categoriy < 22 && categoriy >= 11)
            {
                int nActionType = systemGoods.GetIntValue("ActionType", -1);
                int nRet        = WeaponAdornManager.VerifyWeaponCanEquip(Global.CalcOriginalOccupationID(client), nHandType, nActionType, this.EquipDict);
                if (nRet < 0)
                {
                    return(nRet);
                }
            }
            if (categoriy <= 38 && categoriy >= 37)
            {
                int nRet = RebornEquip.VerifyWeaponCanEquip(client.UsingEquipMgr.EquipDict);
                if (nRet < 0)
                {
                    return(nRet);
                }
            }
            bool             is2Dot2Disable = GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System2Dot2);
            List <GoodsData> list           = null;
            int result;

            if (!this.EquipDict.TryGetValue(categoriy, out list))
            {
                if (categoriy == 23 && !is2Dot2Disable)
                {
                    result = OrnamentManager.getInstance()._CanUsingOrnament(client, toBagIndex, list);
                }
                else if (categoriy == 9 || categoriy == 10)
                {
                    result = this._CanUsingChongWu(categoriy);
                }
                else if (GoodsUtil.CanEquip(categoriy, goodsData.Site))
                {
                    result = 0;
                }
                else
                {
                    result = 0;
                }
            }
            else
            {
                int nCount = list.Count;
                if (categoriy < 22 && categoriy >= 11)
                {
                    if (nHandType == 2 || GameManager.MagicSwordMgr.IsMagicSword(client))
                    {
                        if (nCount >= 2)
                        {
                            return(-3);
                        }
                        return(0);
                    }
                }
                else if (categoriy == 6)
                {
                    if (nCount >= 2)
                    {
                        return(-3);
                    }
                    return(0);
                }
                else if (categoriy == 36)
                {
                    if (nCount >= 2)
                    {
                        return(-3);
                    }
                    return(0);
                }
                else if (categoriy == 9 || categoriy == 10)
                {
                    int nRet = this._CanUsingChongWu(categoriy);
                    if (nRet < 0)
                    {
                        return(nRet);
                    }
                }
                else if (categoriy == 23 && !is2Dot2Disable)
                {
                    return(OrnamentManager.getInstance()._CanUsingOrnament(client, toBagIndex, list));
                }
                result = ((list.Count < 1) ? 0 : -3);
            }
            return(result);
        }
        public RegressActiveOpcode ProcessRegressAcitveRecharge(GameClient client, int Level, int RechargeConfID)
        {
            RegressActiveOpen   iflAct = HuodongCachingMgr.GetRegressActiveOpen();
            RegressActiveOpcode result;
            string Regtime;

            if (iflAct == null || !iflAct.InActivityTime())
            {
                result = RegressActiveOpcode.RegressActiveOpenErr;
            }
            else if (!iflAct.CanGiveAward())
            {
                result = RegressActiveOpcode.RegressActiveNotIn;
            }
            else if (!UserRegressActiveManager.GetRegressMinRegtime(client, out Regtime) || Regtime == null || Regtime.Equals(""))
            {
                result = RegressActiveOpcode.RegressActiveGetRegTime;
            }
            else
            {
                int ConfID;
                int CaleLevel = iflAct.GetUserActiveFile(Regtime, out ConfID);
                if (0 == CaleLevel)
                {
                    result = RegressActiveOpcode.RegressActiveGetFile;
                }
                else if (CaleLevel != Level)
                {
                    result = RegressActiveOpcode.RegressActiveGetFile;
                }
                else
                {
                    DateTime nowDateTime = TimeUtil.NowDateTime();
                    string   endtime     = new DateTime(nowDateTime.Year, nowDateTime.Month, nowDateTime.Day, nowDateTime.Hour, nowDateTime.Minute, nowDateTime.Second).ToString("yyyy-MM-dd HH:mm:ss");
                    string   GetInfoStr  = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, iflAct.FromDate.Replace(':', '$'), endtime.Replace(':', '$'));
                    string[] dbResult;
                    if (TCPProcessCmdResults.RESULT_FAILED == Global.RequestToDBServer(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, 14136, GetInfoStr, out dbResult, 0))
                    {
                        result = RegressActiveOpcode.RegressActiveInputGetInfoErr;
                    }
                    else if (dbResult == null || dbResult.Length != 2 || Convert.ToInt32(dbResult[0]) != client.ClientData.RoleID)
                    {
                        result = RegressActiveOpcode.RegressActiveInputGetInfoErr;
                    }
                    else
                    {
                        int Money = Convert.ToInt32(dbResult[1]);
                        if (Money < 0)
                        {
                            Money = 0;
                        }
                        string   stage           = string.Format("{0}_{1}", Global.GetOffsetDay(DateTime.Parse(iflAct.FromDate)), Global.GetOffsetDay(DateTime.Parse(iflAct.ToDate)));
                        string   GetAwardInfoStr = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, 112, stage);
                        string   Repair          = "";
                        string[] dbResult2;
                        Global.RequestToDBServer(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, 14137, GetAwardInfoStr, out dbResult2, 0);
                        if (dbResult2 == null || dbResult2.Length != 4 || Convert.ToInt32(dbResult2[0]) != client.ClientData.RoleID)
                        {
                            result = RegressActiveOpcode.RegressActiveInputGetInfoErr;
                        }
                        else
                        {
                            if (!dbResult2[3].Equals(""))
                            {
                                string[] idList = dbResult2[3].Split(new char[]
                                {
                                    '_'
                                });
                                foreach (string it in idList)
                                {
                                    if (!it.Equals("") && Convert.ToInt32(it) == RechargeConfID)
                                    {
                                        return(RegressActiveOpcode.RegressActiveInputHas);
                                    }
                                }
                                Repair = this.RepairRegressStoreData(idList);
                                if (!string.IsNullOrEmpty(Repair) && !Repair.Equals(dbResult2[3]))
                                {
                                    string SqlStr = string.Format("{0}:{1}:{2}:{3}", new object[]
                                    {
                                        client.ClientData.RoleID,
                                        112,
                                        Repair,
                                        stage
                                    });
                                    string[] SqlCmd = Global.ExecuteDBCmd(14138, SqlStr, 0);
                                    if (SqlCmd == null || SqlCmd.Length != 4)
                                    {
                                        return(RegressActiveOpcode.RegressActiveUpdateInputInfoErr);
                                    }
                                }
                            }
                            RegressActiveTotalRecharge SignAct = HuodongCachingMgr.GetRegressActiveTotalRecharge();
                            List <GoodsData>           goodsList;
                            if (SignAct == null || !SignAct.InActivityTime())
                            {
                                result = RegressActiveOpcode.RegressActiveInputConfErr;
                            }
                            else if (SignAct.GiveAwardCheck(client, Level, Money, RechargeConfID, out goodsList))
                            {
                                result = RegressActiveOpcode.RegressActiveInputCheckAwardErr;
                            }
                            else if (goodsList == null)
                            {
                                result = RegressActiveOpcode.RegressActiveInputCheckAwardErr;
                            }
                            else
                            {
                                int BagInt;
                                if (!RebornEquip.MoreIsCanIntoRebornOrBaseBag(client, goodsList, out BagInt))
                                {
                                    if (BagInt == 1)
                                    {
                                        return(RegressActiveOpcode.RegressActiveSignRebornBagFail);
                                    }
                                    if (BagInt == 2)
                                    {
                                        return(RegressActiveOpcode.RegressActiveSignBaseBagFail);
                                    }
                                }
                                DateTime FromActDate  = new DateTime(nowDateTime.Year, nowDateTime.Month, nowDateTime.Day, 0, 0, 0);
                                DateTime ToActDate    = new DateTime(nowDateTime.Year, nowDateTime.Month, nowDateTime.Day, 23, 59, 59);
                                string   beginStr     = FromActDate.ToString("yyyy-MM-dd HH:mm:ss").Replace(':', '$');
                                string   endStr       = ToActDate.ToString("yyyy-MM-dd HH:mm:ss").Replace(':', '$');
                                string   keyHasStr    = string.Format("{0}_{1}", beginStr, endStr);
                                string   ativedata    = Repair + "_" + RechargeConfID.ToString();
                                string   WriteInfoStr = string.Format("{0}:{1}:{2}:{3}", new object[]
                                {
                                    client.ClientData.RoleID,
                                    112,
                                    ativedata,
                                    stage
                                });
                                string[] resData = Global.ExecuteDBCmd(14138, WriteInfoStr, 0);
                                if (resData == null || resData.Length != 4)
                                {
                                    result = RegressActiveOpcode.RegressActiveUpdateInputInfoErr;
                                }
                                else if (!SignAct.GiveAward(client, goodsList))
                                {
                                    result = RegressActiveOpcode.RegressActiveInputGiveAwardErr;
                                }
                                else
                                {
                                    result = RegressActiveOpcode.RegressActiveSucc;
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
        public RegressActiveOpcode ProcessRegressAcitveDaySignAward(GameClient client, int Level, int Day)
        {
            RegressActiveOpen   iflAct = HuodongCachingMgr.GetRegressActiveOpen();
            RegressActiveOpcode result;
            string Regtime;

            if (iflAct == null || !iflAct.InActivityTime())
            {
                result = RegressActiveOpcode.RegressActiveOpenErr;
            }
            else if (!iflAct.CanGiveAward())
            {
                result = RegressActiveOpcode.RegressActiveNotIn;
            }
            else if (!UserRegressActiveManager.GetRegressMinRegtime(client, out Regtime) || Regtime == null || Regtime.Equals(""))
            {
                result = RegressActiveOpcode.RegressActiveGetRegTime;
            }
            else
            {
                int ConfID;
                int CaleLevel = iflAct.GetUserActiveFile(Regtime, out ConfID);
                if (0 == CaleLevel)
                {
                    result = RegressActiveOpcode.RegressActiveGetFile;
                }
                else if (CaleLevel != Level)
                {
                    result = RegressActiveOpcode.RegressActiveSignCheckFail;
                }
                else
                {
                    string stage      = string.Format("{0}_{1}", Global.GetOffsetDay(DateTime.Parse(iflAct.FromDate)), Global.GetOffsetDay(DateTime.Parse(iflAct.ToDate)));
                    string GetInfoStr = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, 111, stage);
                    Dictionary <string, string> SignInfoStr = Global.sendToDB <Dictionary <string, string>, string>(14132, GetInfoStr, 0);
                    if (SignInfoStr == null)
                    {
                        result = RegressActiveOpcode.RegressActiveSignSelectFail;
                    }
                    else
                    {
                        DateTime nowDateTime = TimeUtil.NowDateTime();
                        DateTime FromActDate = new DateTime(nowDateTime.Year, nowDateTime.Month, nowDateTime.Day, 0, 0, 0);
                        DateTime ToActDate   = new DateTime(nowDateTime.Year, nowDateTime.Month, nowDateTime.Day, 23, 59, 59);
                        string   SignInfo;
                        Dictionary <int, int> Info = this.ProcessSignInfo(SignInfoStr, Global.GetOffsetDay(nowDateTime), out SignInfo);
                        if (Info == null)
                        {
                            result = RegressActiveOpcode.RegressActiveGetSignInfoErr;
                        }
                        else
                        {
                            Dictionary <int, int> Dict = this.ChangeData(SignInfoStr, Info);
                            int state;
                            if (!Dict.TryGetValue(Day, out state))
                            {
                                result = RegressActiveOpcode.RegressActiveSignNotDay;
                            }
                            else if (state == 1)
                            {
                                result = RegressActiveOpcode.RegressActiveSignHas;
                            }
                            else
                            {
                                RegressActiveSignGift SignAct = HuodongCachingMgr.GetRegressActiveSignGift();
                                List <GoodsData>      OutGoodsList;
                                int DBDay;
                                if (SignAct == null || !SignAct.InActivityTime())
                                {
                                    result = RegressActiveOpcode.RegressActiveSignConfErr;
                                }
                                else if (!SignAct.GetAwardGoodsList(client, Level, Day, out OutGoodsList, out DBDay))
                                {
                                    result = RegressActiveOpcode.RegressActiveSignGetAwardFail;
                                }
                                else
                                {
                                    int BagInt;
                                    if (!RebornEquip.MoreIsCanIntoRebornOrBaseBag(client, OutGoodsList, out BagInt))
                                    {
                                        if (BagInt == 1)
                                        {
                                            return(RegressActiveOpcode.RegressActiveSignRebornBagFail);
                                        }
                                        if (BagInt == 2)
                                        {
                                            return(RegressActiveOpcode.RegressActiveSignBaseBagFail);
                                        }
                                    }
                                    string beginStr  = FromActDate.ToString("yyyy-MM-dd HH:mm:ss").Replace(':', '$');
                                    string endStr    = ToActDate.ToString("yyyy-MM-dd HH:mm:ss").Replace(':', '$');
                                    string keyHasStr = string.Format("{0}_{1}", beginStr, endStr);
                                    SignInfo = SignInfo + "|" + DBDay.ToString();
                                    string WriteInfoStr = string.Format("{0}:{1}:{2}:{3}", new object[]
                                    {
                                        client.ClientData.RoleID,
                                        111,
                                        SignInfo,
                                        stage
                                    });
                                    string[] resData = Global.ExecuteDBCmd(14138, WriteInfoStr, 0);
                                    if (resData == null || resData.Length != 4)
                                    {
                                        result = RegressActiveOpcode.RegressActiveSignRecordFail;
                                    }
                                    else if (!SignAct.GiveAward(client, OutGoodsList))
                                    {
                                        result = RegressActiveOpcode.RegressActiveSignGiveAwardFail;
                                    }
                                    else
                                    {
                                        result = RegressActiveOpcode.RegressActiveSucc;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Exemple #6
0
        public EMagicSwordTowardType GetMagicSwordTypeByWeapon(int nOccu, List <GoodsData> list, GameClient client = null)
        {
            EMagicSwordTowardType result;

            lock (list)
            {
                EMagicSwordTowardType eType = EMagicSwordTowardType.EMST_Strength;
                if (!this.IsMagicSword(nOccu))
                {
                    result = EMagicSwordTowardType.EMST_Not;
                }
                else if (list == null || list.Count <= 0)
                {
                    result = eType;
                }
                else
                {
                    SystemXmlItem    systemGoods = null;
                    List <GoodsData> WeaponList  = new List <GoodsData>();
                    List <GoodsData> BaseWeap    = new List <GoodsData>();
                    List <GoodsData> RebornWeap  = new List <GoodsData>();
                    GoodsData        goodsData;
                    for (int i = 0; i < list.Count; i++)
                    {
                        goodsData = list[i];
                        if (null != goodsData)
                        {
                            int GoodId = goodsData.GoodsID;
                            if (RebornEquip.IsRebornEquipShengQi(GoodId) || RebornEquip.IsRebornEquipShengWu(GoodId))
                            {
                                RebornWeap.Add(goodsData);
                            }
                            else
                            {
                                BaseWeap.Add(goodsData);
                            }
                        }
                    }
                    if (client == null)
                    {
                        if (BaseWeap == null || BaseWeap.Count <= 0)
                        {
                            return(eType);
                        }
                        goodsData = RebornEquip.GetMagicWeaponGoods(BaseWeap, true);
                    }
                    else
                    {
                        SceneUIClasses sceneType = Global.GetMapSceneType(client.ClientData.MapCode);
                        if (sceneType != SceneUIClasses.ChongShengMap)
                        {
                            if (client.ClientData.RebornShowEquip == 0)
                            {
                                goodsData = RebornEquip.GetMagicWeaponGoods(BaseWeap, true);
                            }
                            else
                            {
                                if (client.ClientData.PropStrength >= client.ClientData.PropIntelligence)
                                {
                                    return(EMagicSwordTowardType.EMST_Strength);
                                }
                                return(EMagicSwordTowardType.EMST_Intelligence);
                            }
                        }
                        else
                        {
                            if (client.ClientData.PropStrength >= client.ClientData.PropIntelligence)
                            {
                                return(EMagicSwordTowardType.EMST_Strength);
                            }
                            return(EMagicSwordTowardType.EMST_Intelligence);
                        }
                    }
                    if (null == goodsData)
                    {
                        result = eType;
                    }
                    else if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodsData.GoodsID, out systemGoods))
                    {
                        result = eType;
                    }
                    else
                    {
                        int nStrength     = systemGoods.GetIntValue("Strength", -1);
                        int nIntelligence = systemGoods.GetIntValue("Intelligence", -1);
                        eType  = ((nStrength >= nIntelligence) ? EMagicSwordTowardType.EMST_Strength : EMagicSwordTowardType.EMST_Intelligence);
                        result = eType;
                    }
                }
            }
            return(result);
        }
Exemple #7
0
        public bool CanUseMagicOfMagicSword(GameClient client, int nMagicID)
        {
            bool result;

            if (null == client)
            {
                result = false;
            }
            else if (client.buffManager.IsBuffEnabled(121))
            {
                result = true;
            }
            else if (!this.IsMagicSword(client))
            {
                result = true;
            }
            else if (!this.IsVersionSystemOpenOfMagicSword())
            {
                result = false;
            }
            else
            {
                SystemXmlItem systemMagics = null;
                if (!GameManager.SystemMagicsMgr.SystemXmlItemDict.TryGetValue(nMagicID, out systemMagics))
                {
                    result = false;
                }
                else
                {
                    int nMagicDamageType = systemMagics.GetIntValue("DamageType", -1);
                    if (nMagicDamageType < 0)
                    {
                        result = true;
                    }
                    else
                    {
                        switch (nMagicDamageType)
                        {
                        case 1:
                            if (nMagicID != 10000)
                            {
                                switch (nMagicID)
                                {
                                case 10088:
                                case 10089:
                                case 10090:
                                case 10091:
                                    break;

                                default:
                                    goto IL_122;
                                }
                            }
                            return(true);

                        case 2:
                            if (nMagicID != 10100)
                            {
                                switch (nMagicID)
                                {
                                case 10188:
                                case 10189:
                                case 10190:
                                case 10191:
                                    break;

                                default:
                                    goto IL_122;
                                }
                            }
                            return(true);
                        }
IL_122:
                        List <GoodsData> WeaponList = client.UsingEquipMgr.GetWeaponEquipList();
                        lock (WeaponList)
                        {
                            if (WeaponList == null || WeaponList.Count <= 0)
                            {
                                result = false;
                            }
                            else
                            {
                                List <GoodsData> BaseWeap   = new List <GoodsData>();
                                List <GoodsData> RebornWeap = new List <GoodsData>();
                                foreach (GoodsData it in WeaponList)
                                {
                                    if (RebornEquip.IsRebornEquipShengQi(it.GoodsID) || RebornEquip.IsRebornEquipShengWu(it.GoodsID))
                                    {
                                        RebornWeap.Add(it);
                                    }
                                    else
                                    {
                                        BaseWeap.Add(it);
                                    }
                                }
                                SceneUIClasses sceneType = Global.GetMapSceneType(client.ClientData.MapCode);
                                GoodsData      goods;
                                if (sceneType != SceneUIClasses.ChongShengMap)
                                {
                                    if (client.ClientData.RebornShowEquip == 0)
                                    {
                                        goods = RebornEquip.GetMagicWeaponGoods(BaseWeap, true);
                                    }
                                    else
                                    {
                                        goods = RebornEquip.GetMagicWeaponGoods(RebornWeap, false);
                                    }
                                }
                                else
                                {
                                    goods = RebornEquip.GetMagicWeaponGoods(RebornWeap, false);
                                }
                                if (goods == null)
                                {
                                    result = false;
                                }
                                else
                                {
                                    SystemXmlItem systemGoods = null;
                                    if (RebornEquip.IsRebornEquipShengQi(goods.GoodsID) || RebornEquip.IsRebornEquipShengWu(goods.GoodsID))
                                    {
                                        if (client.ClientData.PropStrength >= client.ClientData.PropIntelligence)
                                        {
                                            RebornEquipXmlStruct REMap;
                                            if (!RebornEquip.EquipSQSW.TryGetValue(goods.GoodsID, out REMap))
                                            {
                                                return(false);
                                            }
                                            if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(REMap.LMJSModGoodID, out systemGoods))
                                            {
                                                return(false);
                                            }
                                        }
                                        else
                                        {
                                            RebornEquipXmlStruct REMap;
                                            if (!RebornEquip.EquipSQSW.TryGetValue(goods.GoodsID, out REMap))
                                            {
                                                return(false);
                                            }
                                            if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(REMap.FMJSModGoodID, out systemGoods))
                                            {
                                                return(false);
                                            }
                                        }
                                    }
                                    else if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goods.GoodsID, out systemGoods))
                                    {
                                        return(false);
                                    }
                                    int nStrength         = systemGoods.GetIntValue("Strength", -1);
                                    int nIntelligence     = systemGoods.GetIntValue("Intelligence", -1);
                                    int nWeaponDamageType = (nStrength >= nIntelligence) ? 1 : 2;
                                    if (nWeaponDamageType == nMagicDamageType)
                                    {
                                        result = true;
                                    }
                                    else
                                    {
                                        LogManager.WriteLog(LogTypes.Warning, string.Format("武器与技能类型不符,无法释放技能: RoleID={0}, 武器id{1}, 武器类型{2}, 技能id{3}, 技能类型{4}", new object[]
                                        {
                                            client.ClientData.RoleID,
                                            goods.GoodsID,
                                            nWeaponDamageType,
                                            nMagicID,
                                            nMagicDamageType
                                        }), null, true);
                                        result = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
 public bool ProcessZhuanPanChouJiangCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 2))
         {
             return(false);
         }
         int      roleID                    = Convert.ToInt32(cmdParams[0]);
         int      awardType                 = Convert.ToInt32(cmdParams[1]);
         DateTime now                       = TimeUtil.NowDateTime();
         ZhuanPanChouJiangData data         = new ZhuanPanChouJiangData();
         List <ZhuanPanItem>   zhuanPanList = new List <ZhuanPanItem>();
         int awardID = 0;
         int binding = 1;
         data.AwardType = awardType;
         lock (ZhuanPanManager.ZhuanPanRunTimeData.Mutex)
         {
             int addHours       = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanFree;
             int moneyTypeIndex = awardType - 1;
             if (moneyTypeIndex < 0 || moneyTypeIndex >= ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanConstArray.Count)
             {
                 data.Result = -200;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             int moneyType = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanConstArray[moneyTypeIndex][0];
             int subMoney  = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanConstArray[moneyTypeIndex][1];
             if (moneyType <= 0 || subMoney <= 0)
             {
                 data.Result = -200;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             int fuLiCount = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanZuanShiFuLi;
             Dictionary <int, Dictionary <int, ZhuanPanAwardItem> > zhuanPanAwardDict = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanAwardXmlDict;
             zhuanPanList = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanItemXmlList;
             if (now < ZhuanPanManager.ZhuanPanRunTimeData.BeginTime || now > ZhuanPanManager.ZhuanPanRunTimeData.EndTime)
             {
                 data.Result = -100;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             DateTime chouJiangTime = Global.GetRoleParamsDateTimeFromDB(client, "10165");
             if (chouJiangTime < ZhuanPanManager.ZhuanPanRunTimeData.BeginTime)
             {
                 chouJiangTime = ZhuanPanManager.ZhuanPanRunTimeData.BeginTime;
                 Global.SaveRoleParamsDateTimeToDB(client, "10165", chouJiangTime, true);
                 Global.SaveRoleParamsInt32ValueToDB(client, "10162", 0, true);
             }
             DateTime nextChouJiang = DateTime.MaxValue;
             if (addHours > 0)
             {
                 nextChouJiang = Global.GetRoleParamsDateTimeFromDB(client, "10155").AddHours((double)addHours);
             }
             if (!Global.CanAddGoodsNum(client, 1) || !RebornEquip.CanAddGoodsNum(client, 1))
             {
                 data.Result = -4;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             awardID = Global.GetRoleParamsInt32FromDB(client, "10162");
             if (awardID > 0)
             {
                 data.Result = -202;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             Dictionary <int, ZhuanPanAwardItem> zhuanPanAwardItemDict = null;
             if (!zhuanPanAwardDict.TryGetValue(awardType, out zhuanPanAwardItemDict))
             {
                 data.Result = -101;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             int roleFuliCout = Global.GetRoleParamsInt32FromDB(client, "10156");
             data.LeftFuLiCount = roleFuliCout;
             data.FreeTime      = nextChouJiang;
             bool free = false;
             if (awardType == 3)
             {
                 if (!zhuanPanAwardDict.ContainsKey(4))
                 {
                     data.Result = -101;
                     client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                     return(true);
                 }
                 if (now > nextChouJiang)
                 {
                     data.FreeTime = now.AddHours((double)addHours);
                     free          = true;
                 }
             }
             if (!free)
             {
                 if (!MoneyUtil.CheckHasMoney(client, moneyType, subMoney))
                 {
                     data.Result = -awardType;
                     client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                     return(true);
                 }
                 string strCostList = "";
                 if (!MoneyUtil.CostMoney(client, moneyType, subMoney, ref strCostList, "转盘抽奖", true))
                 {
                     data.Result = -awardType;
                     client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                     return(true);
                 }
             }
             if (awardType == 3)
             {
                 if (now > nextChouJiang)
                 {
                     Global.SaveRoleParamsDateTimeToDB(client, "10155", now, true);
                     data.FreeTime = now.AddHours((double)addHours);
                 }
                 else
                 {
                     binding = 0;
                     roleFuliCout--;
                     if (roleFuliCout < 1)
                     {
                         if (!zhuanPanAwardDict.TryGetValue(4, out zhuanPanAwardItemDict))
                         {
                             data.Result = -101;
                             client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                             return(true);
                         }
                         roleFuliCout = fuLiCount;
                         awardType    = 4;
                     }
                     if (roleFuliCout > ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanZuanShiFuLi)
                     {
                         roleFuliCout = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanZuanShiFuLi;
                     }
                     Global.SaveRoleParamsInt32ValueToDB(client, "10156", roleFuliCout, true);
                     data.LeftFuLiCount = roleFuliCout;
                 }
             }
             int random = Global.GetRandomNumber(1, 100000);
             foreach (KeyValuePair <int, ZhuanPanAwardItem> item in zhuanPanAwardItemDict)
             {
                 if (random >= item.Value.StartValue && random <= item.Value.EndValue)
                 {
                     awardID = item.Key;
                 }
             }
             if (zhuanPanList.Count < awardID || awardID <= 0)
             {
                 LogManager.WriteLog(LogTypes.Fatal, string.Format("转盘抽奖随机出的awardID={0}找不到对应的奖励配置", awardID), null, true);
                 data.Result = -201;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             data.Result = 1;
             ZhuanPanItem  award       = zhuanPanList[awardID - 1];
             SystemXmlItem systemGoods = null;
             int           goodID      = Convert.ToInt32(award.GoodsID.Split(new char[]
             {
                 ','
             })[0]);
             if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodID, out systemGoods))
             {
                 LogManager.WriteLog(LogTypes.Fatal, string.Format("转盘抽奖随机出的goodID={0}道具表中不存在", goodID), null, true);
                 string strinfo = string.Format("系统中不存在{0}", goodID);
                 GameManager.ClientMgr.SendSystemChatMessageToClient(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, strinfo);
                 data.Result = -201;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             string goodName = systemGoods.GetStringValue("Title");
             if (awardType == 3 && binding > 0)
             {
                 awardType = 4;
             }
             GameManager.logDBCmdMgr.AddDBLogInfo(-1, goodName, "转盘抽奖_类型:" + awardType, client.ClientData.RoleName, "系统", "修改", -1, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, null);
             string[] goods = award.GoodsID.Split(new char[]
             {
                 ','
             });
             goods[2]       = binding.ToString();
             data.GoodsItem = new ZhuanPanItem
             {
                 ID         = award.ID,
                 GoodsID    = string.Join(",", goods),
                 AwardLevel = award.AwardLevel,
                 GongGao    = award.GongGao,
                 AwardLabel = award.AwardLevel
             };
         }
         Global.SaveRoleParamsInt32ValueToDB(client, "10162", awardID, true);
         Global.SaveRoleParamsDateTimeToDB(client, "10165", now, true);
         Global.SaveRoleParamsInt32ValueToDB(client, "10166", binding, true);
         data.AwardType = awardType;
         client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
         client._IconStateMgr.CheckFreeZhuanPanChouState(client);
         client._IconStateMgr.SendIconStateToClient(client);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }