//刷新当前的功能开启状态,处理有关逻辑 public static void RefreshGongNeng(GameClient client) { CaiJiLogic.InitRoleDailyCaiJiData(client, false, false); HuanYingSiYuanManager.getInstance().InitRoleDailyHYSYData(client); Global.InitRoleDailyTaskData(client, false); // 检测触发开启守护之灵 GuardStatueManager.Instance().OnTaskComplete(client); // 检测开启梅林魔法书 [XSea 2015/6/23] GameManager.MerlinMagicBookMgr.InitMerlinMagicBook(client); // 魂石系统 SoulStoneManager.Instance().CheckOpen(client); ZhengBaManager.Instance().CheckGongNengCanOpen(client); FundManager.initFundData(client); CoupleArenaManager.Instance().CheckGongNengOpen(client); }
// 玩家激活图鉴 public void HandleActiveTuJian(GameClient client, string[] itemArr) { if (itemArr == null || itemArr.Length == 0 || client == null) { return; } bool anySuccess = false; foreach (string strItemID in itemArr) { // 客户端请求激活的图鉴Item int itemID = Convert.ToInt32(strItemID); TuJianItem item = null; TuJianType type = null; if (!TuJianItems.TryGetValue(itemID, out item) || !TuJianTypes.TryGetValue(item.TypeID, out type)) { continue; } // 等级不满足 if (client.ClientData.ChangeLifeCount < type.OpenChangeLife || (client.ClientData.ChangeLifeCount == type.OpenChangeLife && client.ClientData.Level < type.OpenLevel)) { continue; } int hadReferCnt = 0; if (client.ClientData.PictureJudgeReferInfo.ContainsKey(itemID)) { hadReferCnt = client.ClientData.PictureJudgeReferInfo[itemID]; } // 已激活 if (hadReferCnt >= item.CostGoodsCnt) { continue; } int needReferCnt = item.CostGoodsCnt - hadReferCnt; int hasGoodsCnt = Global.GetTotalGoodsCountByID(client, item.CostGoodsID); // 材料不足 if (hasGoodsCnt <= 0) { continue; } // 允许提交一部分材料 int thisTimeReferCnt = Math.Min(needReferCnt, hasGoodsCnt); bool usedBinding_just_placeholder = false; bool usedTimeLimited_just_placeholder = false; // 扣除物品失败 if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.CostGoodsID, thisTimeReferCnt, false, out usedBinding_just_placeholder, out usedTimeLimited_just_placeholder)) { continue; } string strDbCmd = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, itemID, hadReferCnt + thisTimeReferCnt); string[] dbRsp = Global.ExecuteDBCmd((int)TCPGameServerCmds.CMD_DB_REFERPICTUREJUDGE, strDbCmd, client.ServerId); if (dbRsp == null || dbRsp.Length != 1 || Convert.ToInt32(dbRsp[0]) <= 0) { LogManager.WriteLog(LogTypes.Error, string.Format("角色RoleID={0},RoleName={1} 激活图鉴Item={2}时,与db通信失败,物品已扣除GoodsID={3},Cnt={4}", client.ClientData.RoleID, client.ClientData.RoleName, itemID, item.CostGoodsID, thisTimeReferCnt)); continue; } anySuccess = true; if (!client.ClientData.PictureJudgeReferInfo.ContainsKey(itemID)) { client.ClientData.PictureJudgeReferInfo.Add(itemID, hadReferCnt + thisTimeReferCnt); } else { client.ClientData.PictureJudgeReferInfo[itemID] = hadReferCnt + thisTimeReferCnt; } } // 只有在任何一项提交成功时,才重新计算属性加成 if (anySuccess) { UpdateTuJianProps(client); // 激活的图鉴项变化了,检查守护雕像的激活情况 GuardStatueManager.Instance().OnActiveTuJian(client); // 七日活动 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.CompleteTuJian)); // 通知客户端属性变化 GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); // 总生命值和魔法值变化通知(同一个地图才需要通知) GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); } }
public bool GM_OneKeyActiveTuJianType(GameClient client, int typeId, out string failedMsg) { failedMsg = string.Empty; if (client == null) { failedMsg = "unknown"; return(false); } TuJianType type = null; if (!TuJianTypes.TryGetValue(typeId, out type)) { failedMsg = "图鉴类型找不到: " + typeId.ToString(); return(false); } // 等级不满足 if (client.ClientData.ChangeLifeCount < type.OpenChangeLife || (client.ClientData.ChangeLifeCount == type.OpenChangeLife && client.ClientData.Level < type.OpenLevel)) { failedMsg = "该项图鉴未开启,类型=" + typeId.ToString() + " ,需求转生:" + type.OpenChangeLife + " , 等级:" + type.OpenLevel; return(false); } bool bRealRefer = false; foreach (var itemId in type.ItemList) { TuJianItem item = null; if (!TuJianItems.TryGetValue(itemId, out item)) { continue; } // 该子项已激活 if (client.ClientData.PictureJudgeReferInfo.ContainsKey(itemId) && client.ClientData.PictureJudgeReferInfo[itemId] >= item.CostGoodsCnt) { continue; } string strDbCmd = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, itemId, item.CostGoodsCnt); string[] dbRsp = Global.ExecuteDBCmd((int)TCPGameServerCmds.CMD_DB_REFERPICTUREJUDGE, strDbCmd, client.ServerId); if (dbRsp == null || dbRsp.Length != 1 || Convert.ToInt32(dbRsp[0]) <= 0) { failedMsg = "数据库异常"; return(false); } bRealRefer = true; if (!client.ClientData.PictureJudgeReferInfo.ContainsKey(itemId)) { client.ClientData.PictureJudgeReferInfo.Add(itemId, item.CostGoodsCnt); } else { client.ClientData.PictureJudgeReferInfo[itemId] = item.CostGoodsCnt; } } // 只有在任何一项提交成功时,才重新计算属性加成 if (bRealRefer) { client.sendCmd(DataHelper.ObjectToTCPOutPacket <Dictionary <int, int> >(client.ClientData.PictureJudgeReferInfo, Global._TCPManager.TcpOutPacketPool, (int)TCPGameServerCmds.CMD_SPR_REFERPICTUREJUDGE)); UpdateTuJianProps(client); // 激活的图鉴项变化了,检查守护雕像的激活情况 GuardStatueManager.Instance().OnActiveTuJian(client); // 七日活动 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.CompleteTuJian)); // 通知客户端属性变化 GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); // 总生命值和魔法值变化通知(同一个地图才需要通知) GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); } return(true); }
private string TodayAward(GameClient client, bool isAll, int todayID) { #region 验证 string result = "{0}:{1}"; if (!IsGongNengOpened()) { return(string.Format(result, (int)ETodayState.NotOpen, 0)); } //单个领取 TodayInfo oneInfo = null; if (!isAll) { oneInfo = GetTadayInfoByID(client, todayID); if (oneInfo == null) { return(string.Format(result, (int)ETodayState.NoType, 0)); } if ((oneInfo.NumMax - oneInfo.NumEnd) <= 0) { return(string.Format(result, (int)ETodayState.IsAward, 0)); } } //获取可领取数据 List <TodayInfo> listAll = new List <TodayInfo>();; if (isAll) { listAll = InitToday(client); } else { listAll.Add(oneInfo); } if (listAll.IsNullOrEmpty()) { return(string.Format(result, (int)ETodayState.NoType, 0)); } //在副本中,不能领取client.ClientData.CopyMapID var fubenList = from info in listAll where info.FuBenID > 0 && client.ClientData.FuBenID > 0 && client.ClientData.FuBenID == info.FuBenID && info.NumMax - info.NumEnd > 0 select info; if (fubenList.Any()) { return(string.Format(result, (int)ETodayState.IsFuben, 0)); } //可以领取 var awardList = from info in listAll where info.NumMax - info.NumEnd > 0 select info; if (!awardList.Any()) { return(string.Format(result, (int)ETodayState.IsAllAward, 0)); } //奖励物品数量 int goodsCount = 0; foreach (var info in awardList) { goodsCount += info.AwardInfo.GoodsList.Count; } //背包 if (!Global.CanAddGoodsNum(client, goodsCount)) { return(string.Format(result, (int)ETodayState.NoBag, 0)); } #endregion #region 设置次数 bool b = false; foreach (var info in awardList) { SystemXmlItem fuBenInfo = null; if (info.Type == (int)(ETodayType.Tao)) { TaskData taskData = GetTaoTask(client); if (taskData != null) { b = Global.CancelTask(client, taskData.DbID, taskData.DoingTaskID); if (!b) { return(string.Format(result, (int)ETodayState.TaoCancel, 0)); } } } else if (!GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(info.FuBenID, out fuBenInfo)) { return(string.Format(result, (int)ETodayState.EFubenConfig, 0)); } b = SetFinishNum(client, info, fuBenInfo); if (!b) { return(string.Format(result, (int)ETodayState.Fail, 0)); } } #endregion #region 发奖 TodayAwardInfo awardInfo = new TodayAwardInfo(); //(物品) foreach (var info in awardList) { int num = info.NumMax - info.NumEnd; for (int i = 0; i < info.AwardInfo.GoodsList.Count; i++) { GoodsData goods = info.AwardInfo.GoodsList[i]; Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, goods.GoodsID, goods.GCount * num, goods.Quality, "", goods.Forge_level, goods.Binding, 0, "", true, 1, /**/ "每日专享", Global.ConstGoodsEndTime, goods.AddPropIndex, goods.BornIndex, goods.Lucky, goods.Strong, goods.ExcellenceInfo, goods.AppendPropLev); } awardInfo.AddAward(info.AwardInfo, num); } //(数值) //经验值 if (awardInfo.Exp > 0) { GameManager.ClientMgr.ProcessRoleExperience(client, (long)awardInfo.Exp); GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(Global.GetLang("恭喜获得经验 +{0}"), awardInfo.Exp), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.OnlyErr, (int)HintErrCodeTypes.None); } //绑金 if (awardInfo.GoldBind > 0) { GameManager.ClientMgr.AddMoney1(client, (int)awardInfo.GoldBind, "每日专享", true); } //魔晶 if (awardInfo.MoJing > 0) { GameManager.ClientMgr.ModifyTianDiJingYuanValue(client, (int)awardInfo.MoJing, "每日专享", true, true); } //成就 if (awardInfo.ChengJiu > 0) { GameManager.ClientMgr.ModifyChengJiuPointsValue(client, (int)awardInfo.ChengJiu, "每日专享", true, true); } //声望 if (awardInfo.ShengWang > 0) { GameManager.ClientMgr.ModifyShengWangValue(client, (int)awardInfo.ShengWang, "每日专享", true, true); } ; //战功 if (awardInfo.ZhanGong > 0) { int zhanGong = (int)awardInfo.ZhanGong; GameManager.ClientMgr.AddBangGong(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, ref zhanGong, AddBangGongTypes.Today); } //绑钻 if (awardInfo.DiamondBind > 0 || awardInfo.ExtDiamondBind > 0) { GameManager.ClientMgr.AddUserGold(client, (int)(awardInfo.DiamondBind + awardInfo.ExtDiamondBind), "每日专享"); } ; //星魂 if (awardInfo.XingHun > 0) { GameManager.ClientMgr.ModifyStarSoulValue(client, (int)awardInfo.XingHun, "每日专享", true, true); } ; //元素粉末 if (awardInfo.YuanSuFenMo > 0) { GameManager.ClientMgr.ModifyYuanSuFenMoValue(client, (int)awardInfo.YuanSuFenMo, "每日专享", true); } ; //守护点数 if (awardInfo.ShouHuDianShu > 0) { GuardStatueManager.Instance().AddGuardPoint(client, (int)awardInfo.ShouHuDianShu, "每日专享"); } //再造点数 if (awardInfo.ZaiZao > 0) { GameManager.ClientMgr.ModifyZaiZaoValue(client, (int)awardInfo.ZaiZao, "每日专享", true, true); } //灵晶 if (awardInfo.LingJing > 0) { GameManager.ClientMgr.ModifyMUMoHeValue(client, (int)awardInfo.LingJing, "每日专享", true); } ; //荣耀 if (awardInfo.RongYao > 0) { GameManager.ClientMgr.ModifyTianTiRongYaoValue(client, (int)awardInfo.RongYao, "每日专享"); } ; #endregion return(GetTodayData(client)); }