/// <summary> /// 保存Monster /// </summary> public void OnLoadDynamicMonsters(Monster monster) { QingGongYanInfo InfoData = GetInfoData(); if (null != InfoData) { return; } // 是不是庆功宴的Monster if (InfoData.NpcID == monster.MonsterInfo.ExtensionID) { return; } // 怪物方向 monster.Direction = (double)InfoData.Direction; // 保存起来便于释放 QingGongYanMonster = monster; string roleName = GameManager.GameConfigMgr.GetGameConfigItemStr("qinggongyan_rolename", "神秘人"); string broadCastMsg = StringUtil.substitute(Global.GetLang("{0}举办的庆功宴刚刚开启了,大家快去参加呀"), roleName); //播放用户行为消息 Global.BroadcastRoleActionMsg(null, RoleActionsMsgTypes.Bulletin, broadCastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.SysHintAndChatBox); }
/// <summary> /// 开启庆功宴 /// </summary> private void OpenQingGongYan() { QingGongYanOpenFlag = true; QingGongYanInfo InfoData = GetInfoData(); if (null == InfoData) { return; } GameMap gameMap = GameManager.MapMgr.DictMaps[InfoData.MapCode]; // 策划要求x, y改成直接传值 NPC npc = NPCGeneralManager.GetNPCFromConfig(InfoData.MapCode, InfoData.NpcID, InfoData.X, InfoData.Y, InfoData.Direction); if (null != npc) { if (NPCGeneralManager.AddNpcToMap(npc)) { QingGongYanNpc = npc; //播放用户行为消息 string guildName = GameManager.GameConfigMgr.GetGameConfigItemStr(GameConfigNames.QGYGuildName, ""); string broadCastMsg = StringUtil.substitute(Global.GetLang("为庆祝{0}战盟在罗兰城战中取得胜利,慷慨的罗兰城主正在勇者大陆摆开宴席,恭候各位光临!"), guildName); Global.BroadcastRoleActionMsg(null, RoleActionsMsgTypes.Bulletin, broadCastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.SysHintAndChatBox); } else { LogManager.WriteLog(LogTypes.Error, string.Format("OpenQingGongYan, AddNpcToMap Faild !InfoData.MapCode={0}, InfoData.NpcID={1}", InfoData.MapCode, InfoData.NpcID)); } } }
/// <summary> /// 此时是否需要开启庆功宴 /// </summary> private bool IfNeedOpenQingGongYan() { // 没有档次 QingGongYanInfo InfoData = GetInfoData(); if (null == InfoData) { return(false); } int DBStartDay = GameManager.GameConfigMgr.GetGameConfigItemInt(GameConfigNames.QGYStartDay, 0); int currDay = Global.GetOffsetDay(TimeUtil.NowDateTime()); // 今天没有庆功宴 if (DBStartDay != currDay) { return(false); } // 在举办时间外 if (TimeUtil.NowDateTime() < DateTime.Parse(InfoData.BeginTime) || TimeUtil.NowDateTime() > DateTime.Parse(InfoData.OverTime)) { return(false); } // 如果已经开启,刷过怪 if (true == QingGongYanOpenFlag) { return(false); } return(true); }
/// <summary> /// 此时是否需要关闭庆功宴 /// </summary> private bool IfNeedCloseQingGongYan() { // 没有档次 QingGongYanInfo InfoData = GetInfoData(); if (null == InfoData) { return(false); } int DBStartDay = GameManager.GameConfigMgr.GetGameConfigItemInt(GameConfigNames.QGYStartDay, 0); int currDay = Global.GetOffsetDay(TimeUtil.NowDateTime()); // 今天没有庆功宴 if (DBStartDay != currDay) { return(false); } // 在结束时间之前 if (TimeUtil.NowDateTime() <= DateTime.Parse(InfoData.OverTime)) { return(false); } // 没有开启的标志 if (false == QingGongYanOpenFlag) { return(false); } return(true); }
/// <summary> /// 关闭庆功宴 /// </summary> private void CloseQingGongYan() { // 销毁怪物 if (null != QingGongYanNpc) { NPCGeneralManager.RemoveMapNpc(QingGongYanNpc.MapCode, QingGongYanNpc.NpcID); QingGongYanNpc = null; } QingGongYanOpenFlag = false; // log it... // 档次没有配置 QingGongYanInfo InfoData = GetInfoData(); if (null == InfoData) { return; } if (InfoData.ZuanShiCoe <= 0) { return; } int JoinMoney = GameManager.GameConfigMgr.GetGameConfigItemInt(GameConfigNames.QGYJoinMoney, 0); int ZuanShiAward = JoinMoney / InfoData.ZuanShiCoe; int DBRoleID = GameManager.GameConfigMgr.GetGameConfigItemInt(GameConfigNames.QGYRoleID, 0); if (DBRoleID <= 0) { return; } //string sContent = "您在2015年02月02日 20:00举办的宴会已成功结束,共获得收益200钻石。"; string sContent = string.Format(Global.GetLang("您在{0:0000}年{1:00}月{2:00}日 {3:00}点{4:00}分举办的宴会已成功结束,共获得收益{5}钻石。"), TimeUtil.NowDateTime().Year, TimeUtil.NowDateTime().Month, TimeUtil.NowDateTime().Day, DateTime.Parse(InfoData.BeginTime).Hour, DateTime.Parse(InfoData.BeginTime).Minute, ZuanShiAward); Global.UseMailGivePlayerAward3(DBRoleID, null, Global.GetLang("庆功宴"), sContent, ZuanShiAward); // 清空记录 Global.UpdateDBGameConfigg(GameConfigNames.QGYRoleID, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYRoleID, ""); Global.UpdateDBGameConfigg(GameConfigNames.QGYGuildName, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYGuildName, ""); Global.UpdateDBGameConfigg(GameConfigNames.QGYStartDay, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYStartDay, ""); Global.UpdateDBGameConfigg(GameConfigNames.QGYGrade, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYGrade, ""); Global.UpdateDBGameConfigg(GameConfigNames.QGYJoinCount, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJoinCount, ""); Global.UpdateDBGameConfigg(GameConfigNames.QGYJoinMoney, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJoinMoney, ""); Global.UpdateDBGameConfigg(GameConfigNames.QGYJuBanMoney, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJuBanMoney, ""); //播放用户行为消息 string broadCastMsg = StringUtil.substitute(Global.GetLang("本次罗兰宴会已圆满结束,愿大家满载而归!")); Global.BroadcastRoleActionMsg(null, RoleActionsMsgTypes.Bulletin, broadCastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.SysHintAndChatBox); }
private void OpenQingGongYan() { this.QingGongYanOpenFlag = true; QingGongYanInfo InfoData = this.GetInfoData(); if (null != InfoData) { GameMap gameMap = GameManager.MapMgr.DictMaps[InfoData.MapCode]; NPC npc = NPCGeneralManager.GetNPCFromConfig(InfoData.MapCode, InfoData.NpcID, InfoData.X, InfoData.Y, InfoData.Direction); if (null != npc) { if (NPCGeneralManager.AddNpcToMap(npc)) { GameManager.ClientMgr.BroadcastServerCmd(733, "1", false); this.QingGongYanNpc = npc; string guildName = GameManager.GameConfigMgr.GetGameConfigItemStr("qinggongyan_guildname", ""); string broadCastMsg = StringUtil.substitute(GLang.GetLang(524, new object[0]), new object[] { guildName }); Global.BroadcastRoleActionMsg(null, RoleActionsMsgTypes.Bulletin, broadCastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.SysHintAndChatBox, 0, 0, 100, 100); } else { LogManager.WriteLog(LogTypes.Error, string.Format("OpenQingGongYan, AddNpcToMap Faild !InfoData.MapCode={0}, InfoData.NpcID={1}", InfoData.MapCode, InfoData.NpcID), null, true); } } } }
/// <summary> /// 此时是否需要关闭庆功宴 /// </summary> public bool IfNeedCloseQingGongYan() { // 没有档次 QingGongYanInfo InfoData = GetInfoData(); if (null != InfoData) { return(false); } int DBStartDay = Convert.ToInt32(GameManager.GameConfigMgr.GetGameConfigItemStr("qinggongyan_startday", "0")); int currDay = Global.GetOffsetDay(DateTime.Now); // 今天没有庆功宴 if (DBStartDay != currDay) { return(false); } // 在结束时间之前 if (DateTime.Now <= DateTime.Parse(InfoData.OverTime)) { return(false); } // 没有开启的标志 if (false == QingGongYanOpenFlag) { return(false); } return(true); }
/// <summary> /// 此时是否需要开启庆功宴 /// </summary> public bool IfNeedOpenQingGongYan() { // 没有档次 QingGongYanInfo InfoData = GetInfoData(); if (null != InfoData) { return(false); } int DBStartDay = Convert.ToInt32(GameManager.GameConfigMgr.GetGameConfigItemStr("qinggongyan_startday", "0")); int currDay = Global.GetOffsetDay(DateTime.Now); // 今天没有庆功宴 if (DBStartDay != currDay) { return(false); } // 在举办时间外 if (DateTime.Now < DateTime.Parse(InfoData.BeginTime) || DateTime.Now > DateTime.Parse(InfoData.OverTime)) { return(false); } // 如果已经开启,刷过怪 if (true == QingGongYanOpenFlag) { return(false); } return(true); }
/// <summary> /// 加载配置文件 GleeFeastAward.xml /// </summary> public void LoadQingGongYanConfig() { lock (_QingGongYanMutex) { QingGongYanDict.Clear(); string fileName = "Config/GleeFeastAward.xml"; GeneralCachingXmlMgr.RemoveCachingXml(Global.GameResPath(fileName)); XElement xml = GeneralCachingXmlMgr.GetXElement(Global.GameResPath(fileName)); if (null == xml) { return; } IEnumerable <XElement> xmlItems = xml.Elements(); foreach (var xmlItem in xmlItems) { QingGongYanInfo InfoData = new QingGongYanInfo(); InfoData.Index = (int)Global.GetSafeAttributeLong(xmlItem, "ID"); InfoData.NpcID = (int)Global.GetSafeAttributeLong(xmlItem, "NPCID"); InfoData.MapCode = (int)Global.GetSafeAttributeLong(xmlItem, "MapCode"); InfoData.X = (int)Global.GetSafeAttributeLong(xmlItem, "X"); InfoData.Y = (int)Global.GetSafeAttributeLong(xmlItem, "Y"); InfoData.Direction = (int)Global.GetSafeAttributeLong(xmlItem, "Direction"); // Week /*string[] strWeek = Global.GetSafeAttributeStr(xmlItem, "Week").Split(','); * if (null != strWeek) * { * for (int i = 0; i < strWeek.Length; i++) * { * InfoData.DayOfWeek.Add(Convert.ToInt32(strWeek[i])); * } * }*/ string[] strBanTime = Global.GetSafeAttributeStr(xmlItem, "ProhibitedTime").Split('|'); for (int i = 0; i < strBanTime.Length; i++) { InfoData.ProhibitedTimeList.Add(strBanTime[i]); } InfoData.BeginTime = Global.GetSafeAttributeStr(xmlItem, "BeginTime"); InfoData.OverTime = Global.GetSafeAttributeStr(xmlItem, "OverTime"); InfoData.FunctionID = (int)Global.GetSafeAttributeLong(xmlItem, "FunctionID"); InfoData.HoldBindJinBi = (int)Global.GetSafeAttributeLong(xmlItem, "ConductBindJinBi"); InfoData.TotalNum = (int)Global.GetSafeAttributeLong(xmlItem, "SumNum"); InfoData.SingleNum = (int)Global.GetSafeAttributeLong(xmlItem, "UseNum"); InfoData.JoinBindJinBi = (int)Global.GetSafeAttributeLong(xmlItem, "BindJinBi"); InfoData.ExpAward = (int)Global.GetSafeAttributeLong(xmlItem, "EXPAward"); InfoData.XingHunAward = (int)Global.GetSafeAttributeLong(xmlItem, "XingHunAward"); InfoData.ZhanGongAward = (int)Global.GetSafeAttributeLong(xmlItem, "ZhanGongAward"); InfoData.ZuanShiCoe = (int)Global.GetSafeAttributeLong(xmlItem, "ZuanShiRatio"); QingGongYanDict[InfoData.Index] = InfoData; } } }
/// <summary> /// 根据流水号取得庆功宴相关配置 /// </summary> private QingGongYanInfo GetQingGongYanConfig(int index) { QingGongYanInfo InfoData = null; lock (_QingGongYanMutex) { if (QingGongYanDict.ContainsKey(index)) { InfoData = QingGongYanDict[index]; } } return(InfoData); }
/// <summary> /// 开启庆功宴 /// </summary> public void OpenQingGongYan() { QingGongYanOpenFlag = true; QingGongYanInfo InfoData = GetInfoData(); if (null != InfoData) { return; } // 生成怪物 GameManager.MonsterZoneMgr.AddDynamicMonsters(InfoData.MapCode, InfoData.NpcID, -1, 1, InfoData.X, InfoData.Y, 1); }
private void CloseQingGongYan() { if (null != this.QingGongYanNpc) { NPCGeneralManager.RemoveMapNpc(this.QingGongYanNpc.MapCode, this.QingGongYanNpc.NpcID); this.QingGongYanNpc = null; GameManager.ClientMgr.BroadcastServerCmd(733, "0", false); } this.QingGongYanOpenFlag = false; QingGongYanInfo InfoData = this.GetInfoData(); if (null != InfoData) { if (InfoData.ZuanShiCoe > 0) { int JoinMoney = GameManager.GameConfigMgr.GetGameConfigItemInt("qinggongyan_joinmoney", 0); int ZuanShiAward = JoinMoney / InfoData.ZuanShiCoe; int DBRoleID = GameManager.GameConfigMgr.GetGameConfigItemInt("qinggongyan_roleid", 0); if (DBRoleID > 0) { string sContent = string.Format(GLang.GetLang(525, new object[0]), new object[] { TimeUtil.NowDateTime().Year, TimeUtil.NowDateTime().Month, TimeUtil.NowDateTime().Day, DateTime.Parse(InfoData.BeginTime).Hour, DateTime.Parse(InfoData.BeginTime).Minute, ZuanShiAward }); Global.UseMailGivePlayerAward3(DBRoleID, null, GLang.GetLang(526, new object[0]), sContent, ZuanShiAward, 0, 0); Global.UpdateDBGameConfigg("qinggongyan_roleid", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_roleid", ""); Global.UpdateDBGameConfigg("qinggongyan_guildname", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_guildname", ""); Global.UpdateDBGameConfigg("qinggongyan_startday", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_startday", ""); Global.UpdateDBGameConfigg("qinggongyan_grade", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_grade", ""); Global.UpdateDBGameConfigg("qinggongyan_joincount", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joincount", ""); Global.UpdateDBGameConfigg("qinggongyan_joinmoney", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joinmoney", ""); Global.UpdateDBGameConfigg("qinggongyan_jubanmoney", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_jubanmoney", ""); string broadCastMsg = StringUtil.substitute(GLang.GetLang(527, new object[0]), new object[0]); Global.BroadcastRoleActionMsg(null, RoleActionsMsgTypes.Bulletin, broadCastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.SysHintAndChatBox, 0, 0, 100, 100); } } } }
private bool IfNeedCloseQingGongYan() { QingGongYanInfo InfoData = this.GetInfoData(); bool result; if (null == InfoData) { result = false; } else { int DBStartDay = GameManager.GameConfigMgr.GetGameConfigItemInt("qinggongyan_startday", 0); int currDay = Global.GetOffsetDay(TimeUtil.NowDateTime()); result = (DBStartDay == currDay && !(TimeUtil.NowDateTime() <= DateTime.Parse(InfoData.OverTime)) && this.QingGongYanOpenFlag); } return(result); }
/// <summary> /// 举办庆功宴 /// </summary> public QingGongYanResult HoldQingGongYan(GameClient client, int index, int onlyCheck = 0) { // 是不是王城占领者 if (!Global.IsKingCityLeader(client)) { return(QingGongYanResult.NotKing); } QingGongYanInfo InfoData = GetQingGongYanConfig(index); if (null == InfoData) { return(QingGongYanResult.ErrorParam); } /// 此时是否能够开启庆功宴 if (InfoData.IfBanTime(TimeUtil.NowDateTime())) { return(QingGongYanResult.OutTime); } int DBStartDay = GameManager.GameConfigMgr.GetGameConfigItemInt(GameConfigNames.QGYStartDay, 0); int currDay = Global.GetOffsetDay(TimeUtil.NowDateTime()); // 如果今天有庆功宴 并且庆功宴结束时间还没到 提示已经申请 if (DBStartDay == currDay && TimeUtil.NowDateTime() <= DateTime.Parse(InfoData.OverTime)) { return(QingGongYanResult.RepeatHold); } // 计算申请之后,庆功宴的举办时间 int startDay = 0; // 在庆功宴开始时间之前,就在今天开启 if (TimeUtil.NowDateTime() < DateTime.Parse(InfoData.BeginTime)) { startDay = currDay; } // 否则在明天开启 else { startDay = currDay + 1; } // 如果计算出来的举办时间和数据库的举办时间相同,则返回已经申请 if (startDay == DBStartDay) { return(QingGongYanResult.RepeatHold); } // 检查举办所需金币是否足够 if (InfoData.HoldBindJinBi > 0) { if (InfoData.HoldBindJinBi > Global.GetTotalBindTongQianAndTongQianVal(client)) { return(QingGongYanResult.MoneyNotEnough); } } if (onlyCheck > 0) { return(QingGongYanResult.CheckSuccess); } // 扣除举办所需金币 if (InfoData.HoldBindJinBi > 0) { if (!Global.SubBindTongQianAndTongQian(client, InfoData.HoldBindJinBi, "举办庆功宴")) { return(QingGongYanResult.MoneyNotEnough); } } Global.UpdateDBGameConfigg(GameConfigNames.QGYRoleID, client.ClientData.RoleID.ToString()); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYRoleID, client.ClientData.RoleID.ToString()); BangHuiMiniData bangHuiMiniData = Global.GetBangHuiMiniData(client.ClientData.Faction); if (null != bangHuiMiniData) { Global.UpdateDBGameConfigg(GameConfigNames.QGYGuildName, bangHuiMiniData.BHName); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYGuildName, bangHuiMiniData.BHName); } else { Global.UpdateDBGameConfigg(GameConfigNames.QGYGuildName, ""); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYGuildName, ""); } GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYGuildName, client.ClientData.RoleName); Global.UpdateDBGameConfigg(GameConfigNames.QGYStartDay, startDay.ToString()); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYStartDay, startDay.ToString()); Global.UpdateDBGameConfigg(GameConfigNames.QGYGrade, index.ToString()); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYGrade, index.ToString()); Global.UpdateDBGameConfigg(GameConfigNames.QGYJoinCount, "0"); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJoinCount, "0"); Global.UpdateDBGameConfigg(GameConfigNames.QGYJoinMoney, "0"); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJoinMoney, "0"); // 为了合服,要记录举办人花了多少金币 Global.UpdateDBGameConfigg(GameConfigNames.QGYJuBanMoney, InfoData.HoldBindJinBi.ToString()); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJuBanMoney, InfoData.HoldBindJinBi.ToString()); // log it... GameManager.logDBCmdMgr.AddDBLogInfo(-1, "举办庆功宴", startDay.ToString(), "", client.ClientData.RoleName, "", index, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId); EventLogManager.AddRoleEvent(client, OpTypes.Hold, OpTags.QingGongYan, LogRecordType.OffsetDayId, startDay); return(QingGongYanResult.Success); }
/// <summary> /// 参加庆功宴 /// </summary> public QingGongYanResult JoinQingGongYan(GameClient client) { if (null == QingGongYanMonster) { return(QingGongYanResult.OutTime); } QingGongYanInfo InfoData = GetInfoData(); if (null != InfoData) { return(QingGongYanResult.OutTime); } int JoinCount = Convert.ToInt32(GameManager.GameConfigMgr.GetGameConfigItemStr("qinggongyan_joincount", "0")); if (JoinCount > 0) { if (JoinCount >= InfoData.TotalNum) { return(QingGongYanResult.TotalNotEnough); } } // 检查举办所需金币是否足够 if (InfoData.JoinBindJinBi > 0) { if (InfoData.JoinBindJinBi > client.ClientData.YinLiang) { return(QingGongYanResult.MoneyNotEnough); } } String QingGongYanJoinFlag = Global.GetRoleParamByName(client, RoleParamName.QingGongYanJoinFlag); int currDay = Global.GetOffsetDay(DateTime.Now); int lastJoinDay = 0; int joinCount = 0; // day:count if (null != QingGongYanJoinFlag) { string[] fields = QingGongYanJoinFlag.Split(','); if (2 == fields.Length) { lastJoinDay = Convert.ToInt32(fields[0]); joinCount = Convert.ToInt32(fields[1]); } } if (currDay != lastJoinDay) { joinCount = 0; } if (InfoData.SingleNum > 0) { if (joinCount >= InfoData.SingleNum) { return(QingGongYanResult.CountNotEnough); } } // 扣除举办所需金币 if (InfoData.JoinBindJinBi > 0) { if (!GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, InfoData.JoinBindJinBi, "举办庆功宴")) { return(QingGongYanResult.MoneyNotEnough); } } // 计数 string roleParam = currDay.ToString() + "," + (joinCount + 1).ToString(); Global.UpdateRoleParamByName(client, RoleParamName.QingGongYanJoinFlag, roleParam, true); // 参加计数叠加 GameManager.GameConfigMgr.ModifyGameConfigItem("qinggongyan_joincount", 1); // 记录缴纳的 GameManager.GameConfigMgr.ModifyGameConfigItem("qinggongyan_joinmoney", InfoData.JoinBindJinBi); // 发奖 if (InfoData.ExpAward > 0) { GameManager.ClientMgr.ProcessRoleExperience(client, InfoData.ExpAward); } if (InfoData.XingHunAward > 0) { GameManager.ClientMgr.ModifyStarSoulValue(client, InfoData.XingHunAward, "庆功宴", true, true); } if (InfoData.ZhanGongAward > 0) { Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.GuildZhanGong, Global.GetRoleParamsInt32FromDB(client, RoleParamName.GuildZhanGong) + InfoData.ZhanGongAward, true); GameManager.ClientMgr.NotifySelfParamsValueChange(client, RoleCommonUseIntParamsIndexs.ZhanGong, InfoData.ZhanGongAward); } // log it GameManager.logDBCmdMgr.AddDBLogInfo(-1, "参加庆功宴", "", "", client.ClientData.RoleName, "", 1, client.ClientData.ZoneID, client.strUserID); return(QingGongYanResult.Success); }
/// <summary> /// 举办庆功宴 /// </summary> public QingGongYanResult HoldQingGongYan(GameClient client, int index) { // 是不是王城占领者 QingGongYanInfo InfoData = GetQingGongYanConfig(index); if (null != InfoData) { return(QingGongYanResult.ErrorParam); } /// 此时是否能够开启庆功宴 if (!InfoData.IfDayOfWeek(DateTime.Now)) { return(QingGongYanResult.OutTime); } int DBStartDay = Convert.ToInt32(GameManager.GameConfigMgr.GetGameConfigItemStr("qinggongyan_startday", "0")); int currDay = Global.GetOffsetDay(DateTime.Now); // 如果今天有庆功宴 并且庆功宴结束时间还没到 提示已经申请 if (DBStartDay == currDay && DateTime.Now <= DateTime.Parse(InfoData.OverTime)) { return(QingGongYanResult.RepeatHold); } // 计算申请之后,庆功宴的举办时间 int startDay = 0; // 在庆功宴开始时间之前,就在今天开启 if (DateTime.Now < DateTime.Parse(InfoData.BeginTime)) { startDay = currDay; } // 否则在明天开启 else { startDay = currDay + 1; } // 如果计算出来的举办时间和数据库的举办时间相同,则返回已经申请 if (startDay == DBStartDay) { return(QingGongYanResult.RepeatHold); } // 检查举办所需金币是否足够 if (InfoData.HoldBindJinBi > 0) { if (InfoData.HoldBindJinBi > client.ClientData.YinLiang) { return(QingGongYanResult.MoneyNotEnough); } } // 扣除举办所需金币 if (InfoData.HoldBindJinBi > 0) { if (!GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, InfoData.HoldBindJinBi, "举办庆功宴")) { return(QingGongYanResult.MoneyNotEnough); } } GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_roleid", client.ClientData.RoleID.ToString()); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_rolename", client.ClientData.RoleName); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_startday", startDay.ToString()); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_grade", index.ToString()); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joincount", "0"); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joinmoney", "0"); // log it... GameManager.logDBCmdMgr.AddDBLogInfo(-1, "参加庆功宴", startDay.ToString(), "", client.ClientData.RoleName, "", index, client.ClientData.ZoneID, client.strUserID); return(QingGongYanResult.Success); }
public QingGongYanResult HoldQingGongYan(GameClient client, int index, int onlyCheck = 0) { QingGongYanResult result; if (!Global.IsKingCityLeader(client)) { result = QingGongYanResult.NotKing; } else { QingGongYanInfo InfoData = this.GetQingGongYanConfig(index); if (null == InfoData) { result = QingGongYanResult.ErrorParam; } else if (InfoData.IfBanTime(TimeUtil.NowDateTime())) { result = QingGongYanResult.OutTime; } else { int DBStartDay = GameManager.GameConfigMgr.GetGameConfigItemInt("qinggongyan_startday", 0); int currDay = Global.GetOffsetDay(TimeUtil.NowDateTime()); if (DBStartDay == currDay && TimeUtil.NowDateTime() <= DateTime.Parse(InfoData.OverTime)) { result = QingGongYanResult.RepeatHold; } else { int startDay; if (TimeUtil.NowDateTime() < DateTime.Parse(InfoData.BeginTime)) { startDay = currDay; } else { startDay = currDay + 1; } if (startDay == DBStartDay) { result = QingGongYanResult.RepeatHold; } else { if (InfoData.HoldBindJinBi > 0) { if (InfoData.HoldBindJinBi > Global.GetTotalBindTongQianAndTongQianVal(client)) { return(QingGongYanResult.MoneyNotEnough); } } if (onlyCheck > 0) { result = QingGongYanResult.CheckSuccess; } else { if (InfoData.HoldBindJinBi > 0) { if (!Global.SubBindTongQianAndTongQian(client, InfoData.HoldBindJinBi, "举办庆功宴")) { return(QingGongYanResult.MoneyNotEnough); } } Global.UpdateDBGameConfigg("qinggongyan_roleid", client.ClientData.RoleID.ToString()); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_roleid", client.ClientData.RoleID.ToString()); BangHuiMiniData bangHuiMiniData = Global.GetBangHuiMiniData(client.ClientData.Faction, 0); if (null != bangHuiMiniData) { Global.UpdateDBGameConfigg("qinggongyan_guildname", bangHuiMiniData.BHName); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_guildname", bangHuiMiniData.BHName); } else { Global.UpdateDBGameConfigg("qinggongyan_guildname", ""); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_guildname", ""); } GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_guildname", client.ClientData.RoleName); Global.UpdateDBGameConfigg("qinggongyan_startday", startDay.ToString()); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_startday", startDay.ToString()); Global.UpdateDBGameConfigg("qinggongyan_grade", index.ToString()); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_grade", index.ToString()); Global.UpdateDBGameConfigg("qinggongyan_joincount", "0"); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joincount", "0"); Global.UpdateDBGameConfigg("qinggongyan_joinmoney", "0"); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joinmoney", "0"); Global.UpdateDBGameConfigg("qinggongyan_jubanmoney", InfoData.HoldBindJinBi.ToString()); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_jubanmoney", InfoData.HoldBindJinBi.ToString()); GameManager.logDBCmdMgr.AddDBLogInfo(-1, "举办庆功宴", startDay.ToString(), "", client.ClientData.RoleName, "", index, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, null); EventLogManager.AddRoleEvent(client, OpTypes.Hold, OpTags.QingGongYan, LogRecordType.OffsetDayId, new object[] { startDay }); result = QingGongYanResult.Success; } } } } } return(result); }
public QingGongYanResult JoinQingGongYan(GameClient client) { QingGongYanResult result; if (null == this.QingGongYanNpc) { result = QingGongYanResult.OutTime; } else { QingGongYanInfo InfoData = this.GetInfoData(); if (null == InfoData) { result = QingGongYanResult.OutTime; } else { int JoinCount = GameManager.GameConfigMgr.GetGameConfigItemInt("qinggongyan_joincount", 0); if (JoinCount > 0) { if (JoinCount >= InfoData.TotalNum) { return(QingGongYanResult.TotalNotEnough); } } if (InfoData.JoinBindJinBi > 0) { if (InfoData.JoinBindJinBi > Global.GetTotalBindTongQianAndTongQianVal(client)) { return(QingGongYanResult.MoneyNotEnough); } } string QingGongYanJoinFlag = Global.GetRoleParamByName(client, "QingGongYanJoinFlag"); int currDay = Global.GetOffsetDay(TimeUtil.NowDateTime()); int lastJoinDay = 0; int joinCount = 0; if (null != QingGongYanJoinFlag) { string[] fields = QingGongYanJoinFlag.Split(new char[] { ',' }); if (2 == fields.Length) { lastJoinDay = Convert.ToInt32(fields[0]); joinCount = Convert.ToInt32(fields[1]); } } if (currDay != lastJoinDay) { joinCount = 0; } if (InfoData.SingleNum > 0) { if (joinCount >= InfoData.SingleNum) { return(QingGongYanResult.CountNotEnough); } } if (InfoData.JoinBindJinBi > 0) { if (!Global.SubBindTongQianAndTongQian(client, InfoData.JoinBindJinBi, "参加庆功宴")) { return(QingGongYanResult.MoneyNotEnough); } } string roleParam = currDay.ToString() + "," + (joinCount + 1).ToString(); Global.UpdateRoleParamByName(client, "QingGongYanJoinFlag", roleParam, true); Global.UpdateDBGameConfigg("qinggongyan_joincount", (JoinCount + 1).ToString()); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joincount", (JoinCount + 1).ToString()); int JoinMoney = GameManager.GameConfigMgr.GetGameConfigItemInt("qinggongyan_joinmoney", 0); Global.UpdateDBGameConfigg("qinggongyan_joinmoney", (JoinMoney + InfoData.JoinBindJinBi).ToString()); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joinmoney", (JoinMoney + InfoData.JoinBindJinBi).ToString()); if (InfoData.ExpAward > 0) { GameManager.ClientMgr.ProcessRoleExperience(client, (long)InfoData.ExpAward, true, true, false, "none"); } if (InfoData.XingHunAward > 0) { GameManager.ClientMgr.ModifyStarSoulValue(client, InfoData.XingHunAward, "庆功宴", true, true); } if (InfoData.ZhanGongAward > 0) { int nZhanGong = InfoData.ZhanGongAward; if (GameManager.ClientMgr.AddBangGong(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, ref nZhanGong, AddBangGongTypes.BG_QGY, 0)) { if (0 != nZhanGong) { GameManager.logDBCmdMgr.AddDBLogInfo(-1, "战功", "罗兰宴会领取", "系统", client.ClientData.RoleName, "增加", nZhanGong, client.ClientData.ZoneID, client.strUserID, client.ClientData.BangGong, client.ServerId, null); } } GameManager.SystemServerEvents.AddEvent(string.Format("角色获取帮贡, roleID={0}({1}), BangGong={2}, newBangGong={3}", new object[] { client.ClientData.RoleID, client.ClientData.RoleName, client.ClientData.BangGong, nZhanGong }), EventLevels.Record); } GameManager.logDBCmdMgr.AddDBLogInfo(-1, "参加庆功宴", "", "", client.ClientData.RoleName, "", 1, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, null); EventLogManager.AddRoleEvent(client, OpTypes.Join, OpTags.QingGongYan, LogRecordType.OffsetDayId, new object[] { currDay }); result = QingGongYanResult.Success; } } return(result); }
/// <summary> /// 参加庆功宴 /// </summary> public QingGongYanResult JoinQingGongYan(GameClient client) { if (null == QingGongYanNpc) { return(QingGongYanResult.OutTime); } QingGongYanInfo InfoData = GetInfoData(); if (null == InfoData) { return(QingGongYanResult.OutTime); } int JoinCount = GameManager.GameConfigMgr.GetGameConfigItemInt(GameConfigNames.QGYJoinCount, 0); if (JoinCount > 0) { if (JoinCount >= InfoData.TotalNum) { return(QingGongYanResult.TotalNotEnough); } } // 检查参加所需金币是否足够 if (InfoData.JoinBindJinBi > 0) { if (InfoData.JoinBindJinBi > Global.GetTotalBindTongQianAndTongQianVal(client)) { return(QingGongYanResult.MoneyNotEnough); } } String QingGongYanJoinFlag = Global.GetRoleParamByName(client, RoleParamName.QingGongYanJoinFlag); int currDay = Global.GetOffsetDay(TimeUtil.NowDateTime()); int lastJoinDay = 0; int joinCount = 0; // day:count if (null != QingGongYanJoinFlag) { string[] fields = QingGongYanJoinFlag.Split(','); if (2 == fields.Length) { lastJoinDay = Convert.ToInt32(fields[0]); joinCount = Convert.ToInt32(fields[1]); } } if (currDay != lastJoinDay) { joinCount = 0; } if (InfoData.SingleNum > 0) { if (joinCount >= InfoData.SingleNum) { return(QingGongYanResult.CountNotEnough); } } // 扣除参加所需金币 if (InfoData.JoinBindJinBi > 0) { if (!Global.SubBindTongQianAndTongQian(client, InfoData.JoinBindJinBi, "参加庆功宴")) { return(QingGongYanResult.MoneyNotEnough); } } // 玩家计数 string roleParam = currDay.ToString() + "," + (joinCount + 1).ToString(); Global.UpdateRoleParamByName(client, RoleParamName.QingGongYanJoinFlag, roleParam, true); // 参加全局计数叠加 // 由于这里是异步操作,数量可能会少 Global.UpdateDBGameConfigg(GameConfigNames.QGYJoinCount, (JoinCount + 1).ToString()); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJoinCount, (JoinCount + 1).ToString()); // 记录缴纳的 int JoinMoney = GameManager.GameConfigMgr.GetGameConfigItemInt(GameConfigNames.QGYJoinMoney, 0); Global.UpdateDBGameConfigg(GameConfigNames.QGYJoinMoney, (JoinMoney + InfoData.JoinBindJinBi).ToString()); GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJoinMoney, (JoinMoney + InfoData.JoinBindJinBi).ToString()); // 发奖 if (InfoData.ExpAward > 0) { GameManager.ClientMgr.ProcessRoleExperience(client, InfoData.ExpAward); } if (InfoData.XingHunAward > 0) { GameManager.ClientMgr.ModifyStarSoulValue(client, InfoData.XingHunAward, "庆功宴", true, true); } if (InfoData.ZhanGongAward > 0) { int nZhanGong = InfoData.ZhanGongAward; if (GameManager.ClientMgr.AddBangGong(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, ref nZhanGong, AddBangGongTypes.BG_QGY)) { //[bing] 记录战功增加流向log if (0 != nZhanGong) { GameManager.logDBCmdMgr.AddDBLogInfo(-1, "战功", "罗兰宴会领取", "系统", client.ClientData.RoleName, "增加", nZhanGong, client.ClientData.ZoneID, client.strUserID, client.ClientData.BangGong, client.ServerId); } } GameManager.SystemServerEvents.AddEvent(string.Format("角色获取帮贡, roleID={0}({1}), BangGong={2}, newBangGong={3}", client.ClientData.RoleID, client.ClientData.RoleName, client.ClientData.BangGong, nZhanGong), EventLevels.Record); } // log it GameManager.logDBCmdMgr.AddDBLogInfo(-1, "参加庆功宴", "", "", client.ClientData.RoleName, "", 1, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId); EventLogManager.AddRoleEvent(client, OpTypes.Join, OpTags.QingGongYan, LogRecordType.OffsetDayId, currDay); return(QingGongYanResult.Success); }
/// <summary> /// 关闭庆功宴 /// </summary> public void CloseQingGongYan() { // 销毁怪物 if (null != QingGongYanMonster) { GameManager.MonsterMgr.DeadMonsterImmediately(QingGongYanMonster); QingGongYanMonster = null; } QingGongYanOpenFlag = false; // log it... // 档次没有配置 QingGongYanInfo InfoData = GetInfoData(); if (null != InfoData) { return; } if (InfoData.ZuanShiCoe <= 0) { return; } int JoinMoney = Convert.ToInt32(GameManager.GameConfigMgr.GetGameConfigItemStr("qinggongyan_joinmoney", "0")); if (JoinMoney <= 0) { return; } int ZuanShiAward = JoinMoney / InfoData.ZuanShiCoe; if (ZuanShiAward <= 0) { return; } int DBRoleID = Convert.ToInt32(GameManager.GameConfigMgr.GetGameConfigItemStr("qinggongyan_roleid", "0")); if (DBRoleID <= 0) { return; } //string sContent = "您在2015年02月02日 20:00举办的宴会已成功结束,共获得收益200钻石。"; string sContent = string.Format("您在{0:0000}年{1:00}月{2:00}日 {3}举办的宴会已成功结束,共获得收益{4}钻石。", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, InfoData.BeginTime); Global.UseMailGivePlayerAward3(DBRoleID, null, sContent, "庆功宴", ZuanShiAward); // 清空记录 GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_roleid", "0"); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_startday", "0"); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_grade", "0"); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joincount", "0"); GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joinmoney", "0"); string roleName = GameManager.GameConfigMgr.GetGameConfigItemStr("qinggongyan_rolename", "神秘人"); string broadCastMsg = StringUtil.substitute(Global.GetLang("{0}举办的庆功宴刚刚结束了,大家快去参加呀"), roleName); //播放用户行为消息 Global.BroadcastRoleActionMsg(null, RoleActionsMsgTypes.Bulletin, broadCastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.SysHintAndChatBox); }