private static bool MakeRewardConfigWithRewardInfos(List <STRewardInfo> listRewards, out mw.RewardConfig configReward) { configReward = GMTActivityMananger.GetNewConfigReward(); if (null == configReward) { CErrMgr.SetLastErrMsg(EErrType.ERR_ACTIVITY_REWARD_ID_MAX); return(false); } // 最大4个 不然客户端排版会出问题 for (int i = 0; i < listRewards.Count; i++) { if (listRewards[i].count > 9999) { CErrMgr.SetLastErrMsg(EErrType.ERR_ACTIVITY_REWARD_ITEM_COUNT); return(false); } if (i == 0) { configReward.reward_idx_1 = (mw.Enums.RewardType)listRewards[0].type; configReward.reward_type_1 = listRewards[0].item; configReward.reward_count_1 = listRewards[0].count; configReward.max_rand_1 = 10000; configReward.min_rand_1 = 1; } else if (i == 1) { configReward.reward_idx_2 = (mw.Enums.RewardType)listRewards[1].type; configReward.reward_type_2 = listRewards[1].item; configReward.reward_count_2 = listRewards[1].count; configReward.max_rand_2 = 10000; configReward.min_rand_2 = 1; } else if (i == 2) { configReward.reward_idx_3 = (mw.Enums.RewardType)listRewards[2].type; configReward.reward_type_3 = listRewards[2].item; configReward.reward_count_3 = listRewards[2].count; configReward.max_rand_3 = 10000; configReward.min_rand_3 = 1; } else if (i == 3) { configReward.reward_idx_4 = (mw.Enums.RewardType)listRewards[3].type; configReward.reward_type_4 = listRewards[3].item; configReward.reward_count_4 = listRewards[3].count; configReward.max_rand_4 = 10000; configReward.min_rand_4 = 1; } } return(true); }
public static mw.RewardConfig GetNewConfigReward() { if (spareRewardIds.Count == 0) { CErrMgr.SetLastErrMsg(EErrType.ERR_ACTIVITY_REWARD_ID_MAX); return(null); } mw.RewardConfig config = new mw.RewardConfig(); config.id = spareRewardIds.First(); AddRewardNode(config); return(config); }
public static mw.ActivityConfig GetNewConfigActivity() { if (spareActivityIds.Count == 0) { CErrMgr.SetLastErrMsg(EErrType.ERR_ACTIVITY_ID_MAX); return(null); } mw.ActivityConfig config = new mw.ActivityConfig(); config.id = spareActivityIds.First(); config.sign = 1; config.gmt_no_use = "0"; config.name = ""; AddActivityNode(config); return(config); }
public static mw.AchieveConfig GetNewConfigAchieve(mw.Enums.TaskType type) { if (spareAchieveIds.Count == 0) { CErrMgr.SetLastErrMsg(EErrType.ERR_ACTIVITY_ACHIEVE_ID_MAX); return(null); } mw.AchieveConfig config = new mw.AchieveConfig(); for (int i = MinAchieveID; i <= MaxAchieveID; ++i) { uint id = CUtils.MakeLong((ushort)type, (ushort)i); if (spareAchieveIds.Contains(id)) { config.id = i; config.type = type; break; } } AddAchieveNode(config); return(config); }
private static bool DoAddQuest(int activiytId, List <STQuestInfo> quests, ref List <mw.AchieveConfig> listAchieve, ref List <mw.RewardConfig> listReward) { for (int i = 0; i < quests.Count; ++i) { mw.Enums.TaskType taskType = (mw.Enums.TaskType)quests[i].type; mw.AchieveConfig configAchieve = GMTActivityMananger.GetNewConfigAchieve(taskType); if (null == configAchieve) { return(false); } configAchieve.activity = activiytId; configAchieve.taskFlag = (quests[i].overlap) ? 1 : 0; configAchieve.opt_type_1 = quests[i].type; configAchieve.opt_val_1_a = quests[i].count_a; configAchieve.opt_val_1_b = quests[i].count_b; configAchieve.opt_val_1_c = quests[i].count_c; if (quests[i].count_a < 1 || quests[i].count_a > 9999 || quests[i].count_b < 0 || quests[i].count_b > 9999 || quests[i].count_c < 0 || quests[i].count_c > 9999 ) { CErrMgr.SetLastErrMsg(EErrType.ERR_ACTIVITY_ACHIEVE_REQUEST_COUNT); return(false); } if (quests[i].rewards.Count == 0 || quests[i].rewards.Count > 4) { CErrMgr.SetLastErrMsg(EErrType.ERR_ACTIVITY_REWARD_COUNT); return(false); } mw.RewardConfig configReward = null; bool ret = MakeRewardConfigWithRewardInfos(quests[i].rewards, out configReward); if (null != configReward) { listReward.Add(configReward); } if (!ret) { return(false); } configAchieve.reward = configReward.id; int taskDescTextId = 0; if (!string.IsNullOrEmpty(quests[i].desc)) { taskDescTextId = TextManager.CreateText(); TextManager.SetText(taskDescTextId, quests[i].desc); } // 这里贼乱, name 是活动标题, txt是活动内容, desc 是活动任务描述 configAchieve.desc = taskDescTextId; listAchieve.Add(configAchieve); } return(true); }
public static string AddNewActivity(string title, string desc, bool firstmark, int order, List <STQuestInfo> quests) { mw.ActivityConfig configActivity = null; if (quests.Count == 0) { CErrMgr.SetLastErrMsg(EErrType.ERR_ACTIVITY_ACHIEVE_ZERO); goto err; } configActivity = GMTActivityMananger.GetNewConfigActivity(); if (null == configActivity) { goto err; } configActivity.NeedFlag = (firstmark)?1:0; configActivity.sortvalue = order; List <mw.AchieveConfig> listAchieve = new List <mw.AchieveConfig>(); List <mw.RewardConfig> listReward = new List <mw.RewardConfig>(); if (!DoAddQuest(configActivity.id, quests, ref listAchieve, ref listReward)) { goto err; } int titleTextId = 0; if (!string.IsNullOrEmpty(title)) { titleTextId = TextManager.CreateText(); TextManager.SetText(titleTextId, title); } int descTextId = 0; if (!string.IsNullOrEmpty(desc)) { descTextId = TextManager.CreateText(); TextManager.SetText(descTextId, desc); } foreach (var ach in listAchieve) { ach.name = titleTextId; ach.txt = descTextId; } // 创建条件满足 STActivityInfo stActivity = ConvertToSTActivity(configActivity); m_listActivity4Client.Add(stActivity); GMTActivityMananger.SaveTable(); string res = JsonConvert.SerializeObject(stActivity); return("{\"error\":0, \"data\":" + res + "}"); // 创建条件不满足, 上方textid 创建还没销毁, 后面补充 err: // 销毁 (还没写) if (null != configActivity) { GMTActivityMananger.RemoveActivityNode(configActivity.id); } return(CErrMgr.GetLastErrMsg()); }