/// <summary> /// 获取领地信息字典项的发送tcp对象 /// </summary> public TCPOutPacket GetBangHuiLingDiItemsDictTCPOutPacket(TCPOutPacketPool pool, int cmdID) { Dictionary <int, BangHuiLingDiItemData> bangHuiLingDiItemDataDict = new Dictionary <int, BangHuiLingDiItemData>(); BangHuiLingDiInfoData bangHuiLingDiInfoData = null; lock (_BangHuiLingDiItemsDict) { foreach (var key in _BangHuiLingDiItemsDict.Keys) { bangHuiLingDiInfoData = _BangHuiLingDiItemsDict[key]; bangHuiLingDiItemDataDict[key] = new BangHuiLingDiItemData() { LingDiID = bangHuiLingDiInfoData.LingDiID, BHID = bangHuiLingDiInfoData.BHID, ZoneID = bangHuiLingDiInfoData.ZoneID, BHName = bangHuiLingDiInfoData.BHName, LingDiTax = bangHuiLingDiInfoData.LingDiTax, WarRequest = bangHuiLingDiInfoData.WarRequest, AwardFetchDay = bangHuiLingDiInfoData.AwardFetchDay, }; } } TCPOutPacket tcpOutPacket = DataHelper.ObjectToTCPOutPacket <Dictionary <int, BangHuiLingDiItemData> >(bangHuiLingDiItemDataDict, pool, cmdID); return(tcpOutPacket); }
/// <summary> /// 在王城争夺战中去掉今天 /// </summary> protected static void RemoveTodayInWarRequest() { int day = DateTime.Now.DayOfYear; BangHuiLingDiItemData lingDiItem = JunQiManager.GetItemByLingDiID((int)LingDiIDs.HuangGong); if (null == lingDiItem) { return; } Dictionary <int, int> warRequestMap = GetWarRequstMap(lingDiItem.WarRequest); if (!warRequestMap.ContainsValue(day)) { return; } for (int n = 0; n < warRequestMap.Count; n++) { if (warRequestMap.Values.ElementAt(n) == day) { //移除今天 warRequestMap.Remove(warRequestMap.Keys.ElementAt(n)); break; } } //重新生成争夺战请求字符串 String nowWarRequest = GeWarRequstString(warRequestMap); //提交给gameserver SetCityWarRequestToDBServer((int)LingDiIDs.HuangGong, nowWarRequest); }
public static string GetNextCityBattleTime() { string unKown = GLang.GetLang(43, new object[0]); int day = TimeUtil.NowDateTime().DayOfYear; BangHuiLingDiItemData lingDiItem = JunQiManager.GetItemByLingDiID(6); string result; if (null == lingDiItem) { result = unKown; } else { Dictionary <int, int> warRequestMap = WangChengManager.GetWarRequstMap(lingDiItem.WarRequest); List <DateTime> lsDays = new List <DateTime>(); for (int i = 0; i < warRequestMap.Count; i++) { DateTime dt = TimeUtil.NowDateTime(); int span = warRequestMap.Values.ElementAt(i) - day; if (span >= 0) { dt = dt.AddDays((double)span); } else { int yearNext = dt.Year + 1; dt = DateTime.Parse(string.Format("{0}-01-01", yearNext)).AddDays((double)(warRequestMap.Values.ElementAt(i) - 1)); } lsDays.Add(dt); } lsDays.Sort(delegate(DateTime l, DateTime r) { int result2; if (l.Ticks < r.Ticks) { result2 = -1; } else if (l.Ticks > r.Ticks) { result2 = 1; } else { result2 = 0; } return(result2); }); if (lsDays.Count > 0) { DateTime nextDate = lsDays[0]; if (WangChengManager.WangChengZhanFightingDayTimes != null && WangChengManager.WangChengZhanFightingDayTimes.Length > 0) { return(lsDays[0].ToString("yyyy-MM-dd " + string.Format("{0:00}:{1:00}", WangChengManager.WangChengZhanFightingDayTimes[0].FromHour, WangChengManager.WangChengZhanFightingDayTimes[0].FromMinute))); } } result = unKown; } return(result); }
public static bool IsExistCityWarToday() { int day = TimeUtil.NowDateTime().DayOfYear; BangHuiLingDiItemData lingDiItem = JunQiManager.GetItemByLingDiID(6); bool result; if (null == lingDiItem) { result = false; } else { Dictionary <int, int> warRequestMap = WangChengManager.GetWarRequstMap(lingDiItem.WarRequest); result = warRequestMap.ContainsValue(day); } return(result); }
private static bool CanGetAWards(GameClient client, long nowTicks) { bool result; if (nowTicks - client.ClientData.EnterMapTicks < (long)HuangChengManager.MaxHavingSheLiZhiYuanSecs) { result = false; } else if (client.ClientData.Faction <= 0) { result = false; } else { BangHuiLingDiItemData bangHuiLingDiItemData = JunQiManager.GetAnyLingDiItemDataByBHID(client.ClientData.Faction); result = (null != bangHuiLingDiItemData); } return(result); }
/// <summary> /// 是否能够获取奖励 /// </summary> /// <param name="client"></param> /// <returns></returns> private static bool CanGetAWards(GameClient client, long nowTicks) { if (nowTicks - client.ClientData.EnterMapTicks < MaxHavingSheLiZhiYuanSecs) { return(false); } if (client.ClientData.Faction <= 0) { return(false); } BangHuiLingDiItemData bangHuiLingDiItemData = JunQiManager.GetAnyLingDiItemDataByBHID(client.ClientData.Faction); if (null == bangHuiLingDiItemData) { return(false); } return(true); }
/// <summary> /// 判断当天是否存在王城争夺战 /// </summary> /// <returns></returns> public static bool IsExistCityWarToday() { int day = DateTime.Now.DayOfYear; BangHuiLingDiItemData lingDiItem = JunQiManager.GetItemByLingDiID((int)LingDiIDs.HuangGong); if (null == lingDiItem) { return(false); } Dictionary <int, int> warRequestMap = GetWarRequstMap(lingDiItem.WarRequest); if (!warRequestMap.ContainsValue(day)) { return(false); } return(true); }
public TCPOutPacket GetBangHuiLingDiItemsDictTCPOutPacket(TCPOutPacketPool pool, int cmdID) { Dictionary <int, BangHuiLingDiItemData> bangHuiLingDiItemDataDict = new Dictionary <int, BangHuiLingDiItemData>(); lock (this._BangHuiLingDiItemsDict) { foreach (int key in this._BangHuiLingDiItemsDict.Keys) { BangHuiLingDiInfoData bangHuiLingDiInfoData = this._BangHuiLingDiItemsDict[key]; bangHuiLingDiItemDataDict[key] = new BangHuiLingDiItemData { LingDiID = bangHuiLingDiInfoData.LingDiID, BHID = bangHuiLingDiInfoData.BHID, ZoneID = bangHuiLingDiInfoData.ZoneID, BHName = bangHuiLingDiInfoData.BHName, LingDiTax = bangHuiLingDiInfoData.LingDiTax, WarRequest = bangHuiLingDiInfoData.WarRequest, AwardFetchDay = bangHuiLingDiInfoData.AwardFetchDay }; } } return(DataHelper.ObjectToTCPOutPacket <Dictionary <int, BangHuiLingDiItemData> >(bangHuiLingDiItemDataDict, pool, cmdID)); }
protected static void RemoveTodayInWarRequest() { int day = TimeUtil.NowDateTime().DayOfYear; BangHuiLingDiItemData lingDiItem = JunQiManager.GetItemByLingDiID(6); if (null != lingDiItem) { Dictionary <int, int> warRequestMap = WangChengManager.GetWarRequstMap(lingDiItem.WarRequest); if (warRequestMap.ContainsValue(day)) { for (int i = 0; i < warRequestMap.Count; i++) { if (warRequestMap.Values.ElementAt(i) == day) { warRequestMap.Remove(warRequestMap.Keys.ElementAt(i)); break; } } string nowWarRequest = WangChengManager.GeWarRequstString(warRequestMap); WangChengManager.SetCityWarRequestToDBServer(6, nowWarRequest); } } }
/// <summary> /// 返回下次王城争霸赛的时间和帮会 /// </summary> public static String GetCityBattleTimeAndBangHuiListString() { if (null == WangChengZhanFightingDayTimes || WangChengZhanFightingDayTimes.Length <= 0) { return(""); } int day = DateTime.Now.DayOfYear; BangHuiLingDiItemData lingDiItem = JunQiManager.GetItemByLingDiID((int)LingDiIDs.HuangGong); if (null == lingDiItem) { return(""); } Dictionary <int, int> warRequestMap = GetWarRequstMap(lingDiItem.WarRequest); List <DateTime> lsDays = new List <DateTime>(); //这儿考虑跨年和不跨年是为了兼容旧的dayOfYear的存储方式,实际上跨年的比较少,毕竟也就那么几天 for (int n = 0; n < warRequestMap.Count; n++) { DateTime dt = DateTime.Now; int span = warRequestMap.Values.ElementAt(n) - day; if (span >= 0) { //未跨年 dt = dt.AddDays(span); } else//小于0表示跨年,实际上申请数量最多几十天 { //跨年了--->先到下一年 int yearNext = dt.Year + 1; dt = DateTime.Parse(String.Format("{0}-01-01", yearNext)); dt = dt.AddDays(warRequestMap.Values.ElementAt(n) - 1); } lsDays.Add(dt); } //依次从小到大进行排序 lsDays.Sort(delegate(DateTime l, DateTime r) { if (l.Ticks < r.Ticks) { return(-1); } else if (l.Ticks > r.Ticks) { return(1); } return(0); }); String timeBangHuiString = ""; //组装字符串,最多10条 for (int index = 0; index < lsDays.Count && index < 10; index++) { DateTime nextDate = lsDays[index]; int dayID = nextDate.DayOfYear; for (int n = 0; n < warRequestMap.Count; n++) { //查询帮会ID,查询到就生成字符串 if (dayID == warRequestMap.Values.ElementAt(n)) { int bangHuiID = warRequestMap.Keys.ElementAt(n); String strTime, strBH; GetWarTimeStringAndBHName(dayID, bangHuiID, out strTime, out strBH); if (timeBangHuiString.Length > 0) { timeBangHuiString += ","; } timeBangHuiString += String.Format("{0},{1}", strTime, strBH); break; } }//这个循环跳出后会继续外面的小循环 } return(timeBangHuiString); }
/// <summary> /// 返回下次王城争霸赛的时间和帮会 /// </summary> public static bool GetNextCityBattleTimeAndBangHui(out int dayID, out int bangHuiID) { dayID = -1; bangHuiID = -1; int day = DateTime.Now.DayOfYear; BangHuiLingDiItemData lingDiItem = JunQiManager.GetItemByLingDiID((int)LingDiIDs.HuangGong); if (null == lingDiItem) { return(false); } Dictionary <int, int> warRequestMap = GetWarRequstMap(lingDiItem.WarRequest); List <DateTime> lsDays = new List <DateTime>(); //这儿考虑跨年和不跨年是为了兼容旧的dayOfYear的存储方式,实际上跨年的比较少,毕竟也就那么几天 for (int n = 0; n < warRequestMap.Count; n++) { DateTime dt = DateTime.Now; int span = warRequestMap.Values.ElementAt(n) - day; if (span >= 0) { //未跨年 dt = dt.AddDays(span); } else//小于0表示跨年,实际上申请数量最多几十天 { //跨年了--->先到下一年 int yearNext = dt.Year + 1; dt = DateTime.Parse(String.Format("{0}-01-01", yearNext)); dt = dt.AddDays(warRequestMap.Values.ElementAt(n) - 1); } lsDays.Add(dt); } //依次从小到大进行排序 lsDays.Sort(delegate(DateTime l, DateTime r) { if (l.Ticks < r.Ticks) { return(-1); } else if (l.Ticks > r.Ticks) { return(1); } return(0); }); if (lsDays.Count > 0) { DateTime nextDate = lsDays[0]; //返回时 分 if (null != WangChengZhanFightingDayTimes && WangChengZhanFightingDayTimes.Length > 0) { dayID = nextDate.DayOfYear; for (int n = 0; n < warRequestMap.Count; n++) { //查询帮会ID if (dayID == warRequestMap.Values.ElementAt(n)) { bangHuiID = warRequestMap.Keys.ElementAt(n); return(true); } } return(false); } } return(false); }
/// <summary> /// 返回下次王城争霸赛的时间 /// </summary> public static String GetNextCityBattleTime() { //实现过程不采用 GetNextCityBattleTimeAndBangHui()了,这个函数是先写的 String unKown = Global.GetLang("没有帮派申请"); int day = DateTime.Now.DayOfYear; BangHuiLingDiItemData lingDiItem = JunQiManager.GetItemByLingDiID((int)LingDiIDs.HuangGong); if (null == lingDiItem) { return(unKown); } Dictionary <int, int> warRequestMap = GetWarRequstMap(lingDiItem.WarRequest); List <DateTime> lsDays = new List <DateTime>(); for (int n = 0; n < warRequestMap.Count; n++) { DateTime dt = DateTime.Now; int span = warRequestMap.Values.ElementAt(n) - day; if (span >= 0) { //未跨年 dt = dt.AddDays(span); } else { //跨年了--->先到下一年 int yearNext = dt.Year + 1; dt = DateTime.Parse(String.Format("{0}-01-01", yearNext)); dt = dt.AddDays(warRequestMap.Values.ElementAt(n) - 1); } lsDays.Add(dt); } lsDays.Sort(delegate(DateTime l, DateTime r) { if (l.Ticks < r.Ticks) { return(-1); } else if (l.Ticks > r.Ticks) { return(1); } return(0); }); if (lsDays.Count > 0) { DateTime nextDate = lsDays[0]; //返回时 分 if (null != WangChengZhanFightingDayTimes && WangChengZhanFightingDayTimes.Length > 0) { return(lsDays[0].ToString("yyyy-MM-dd " + String.Format("{0:00}:{1:00}", WangChengZhanFightingDayTimes[0].FromHour, WangChengZhanFightingDayTimes[0].FromMinute))); } } return(unKown); }
public static string GetCityBattleTimeAndBangHuiListString() { string result; if (WangChengManager.WangChengZhanFightingDayTimes == null || WangChengManager.WangChengZhanFightingDayTimes.Length <= 0) { result = ""; } else { int day = TimeUtil.NowDateTime().DayOfYear; BangHuiLingDiItemData lingDiItem = JunQiManager.GetItemByLingDiID(6); if (null == lingDiItem) { result = ""; } else { Dictionary <int, int> warRequestMap = WangChengManager.GetWarRequstMap(lingDiItem.WarRequest); List <DateTime> lsDays = new List <DateTime>(); for (int i = 0; i < warRequestMap.Count; i++) { DateTime dt = TimeUtil.NowDateTime(); int span = warRequestMap.Values.ElementAt(i) - day; if (span >= 0) { dt = dt.AddDays((double)span); } else { int yearNext = dt.Year + 1; dt = DateTime.Parse(string.Format("{0}-01-01", yearNext)).AddDays((double)(warRequestMap.Values.ElementAt(i) - 1)); } lsDays.Add(dt); } lsDays.Sort(delegate(DateTime l, DateTime r) { int result2; if (l.Ticks < r.Ticks) { result2 = -1; } else if (l.Ticks > r.Ticks) { result2 = 1; } else { result2 = 0; } return(result2); }); string timeBangHuiString = ""; int index = 0; while (index < lsDays.Count && index < 10) { int dayID = lsDays[index].DayOfYear; for (int i = 0; i < warRequestMap.Count; i++) { if (dayID == warRequestMap.Values.ElementAt(i)) { int bangHuiID = warRequestMap.Keys.ElementAt(i); string strTime; string strBH; WangChengManager.GetWarTimeStringAndBHName(dayID, bangHuiID, out strTime, out strBH); if (timeBangHuiString.Length > 0) { timeBangHuiString += ","; } timeBangHuiString += string.Format("{0},{1}", strTime, strBH); break; } } index++; } result = timeBangHuiString; } } return(result); }
public static bool GetNextCityBattleTimeAndBangHui(out int dayID, out int bangHuiID) { dayID = -1; bangHuiID = -1; int day = TimeUtil.NowDateTime().DayOfYear; BangHuiLingDiItemData lingDiItem = JunQiManager.GetItemByLingDiID(6); bool result; if (null == lingDiItem) { result = false; } else { Dictionary <int, int> warRequestMap = WangChengManager.GetWarRequstMap(lingDiItem.WarRequest); List <DateTime> lsDays = new List <DateTime>(); for (int i = 0; i < warRequestMap.Count; i++) { DateTime dt = TimeUtil.NowDateTime(); int span = warRequestMap.Values.ElementAt(i) - day; if (span >= 0) { dt = dt.AddDays((double)span); } else { int yearNext = dt.Year + 1; dt = DateTime.Parse(string.Format("{0}-01-01", yearNext)).AddDays((double)(warRequestMap.Values.ElementAt(i) - 1)); } lsDays.Add(dt); } lsDays.Sort(delegate(DateTime l, DateTime r) { int result2; if (l.Ticks < r.Ticks) { result2 = -1; } else if (l.Ticks > r.Ticks) { result2 = 1; } else { result2 = 0; } return(result2); }); if (lsDays.Count > 0) { DateTime nextDate = lsDays[0]; if (WangChengManager.WangChengZhanFightingDayTimes != null && WangChengManager.WangChengZhanFightingDayTimes.Length > 0) { dayID = nextDate.DayOfYear; for (int i = 0; i < warRequestMap.Count; i++) { if (dayID == warRequestMap.Values.ElementAt(i)) { bangHuiID = warRequestMap.Keys.ElementAt(i); return(true); } } return(false); } } result = false; } return(result); }