public PartDetail(PartBase model) { m_pb = model; }
/// <summary> /// 黄钻奖励 /// </summary> /// <param name="note"></param> /// <param name="part"></param> /// <returns></returns> private static void Yellow(UserNote note, Variant part) { //note.Player.Yellow = 81; string msg = note.GetString(1); string id = part.GetStringOrDefault("ID"); string name = part.GetStringOrDefault("Name"); string subtype = part.GetStringOrDefault("SubType"); string soleid = note.Player.UserID + id; PartBase model = PartAccess.Instance.FindOneById(soleid); if (model == null) { model = new PartBase(); model.ID = soleid; model.Name = name; model.SubType = subtype; model.Created = DateTime.UtcNow; model.PlayerID = note.Player.UserID; model.PartID = id; model.Value = new Variant(); } Variant info = model.Value; DateTime dt = DateTime.UtcNow; Variant v = part.GetVariantOrDefault("Value"); if (v == null) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } Variant award = v.GetVariantOrDefault("Award"); if (award == null) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } if (note.Player.Yellow <= 0) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part14)); return; } if (msg == "n") { //表示领取年费奖励 if (note.Player.Yellow % 10 != 1) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part16)); return; } } else { //int lv = 0; //if (!int.TryParse(msg, out lv)) //{ // note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part11)); // return; //} //得到黄钻等级 msg = (note.Player.Yellow / 10).ToString(); } if (info.ContainsKey(msg)) { DateTime awardTime = info.GetDateTimeOrDefault(msg); //表示今日已经领取 if (awardTime.ToLocalTime().Date == dt.ToLocalTime().Date) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part5)); return; } } IList select = award.GetValue<IList>(msg); if (select == null) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part14)); return; } Variant goods = select[0] as Variant; if (goods == null) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part14)); return; } Dictionary<string, Variant> dic = PartAccess.Instance.GetPartAward(goods); if (dic.Count == 0) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } PlayerEx b0 = note.Player.B0; if (BurdenManager.IsFullBurden(b0, dic)) { //包袱满不能领取 note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part7)); return; } info[msg] = dt; string t = award.GetStringOrDefault("T"); string m = award.GetStringOrDefault("M"); if (model.Save()) { Dictionary<string, int> gos = note.Player.AddGoods(dic, GoodsSource.Yellow); note.Call(PartCommand.PartExchangeR, true, TipManager.GetMessage(PartReturn.Part15)); PartApprise(note, gos, t, m, false); } else { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part14)); } }
/// <summary> /// 充值奖励 /// </summary> /// <param name="note"></param> /// <param name="part"></param> private static void PartAward(UserNote note, Variant part) { string msg = note.GetString(1); int index = note.GetInt32(2); string id = part.GetStringOrDefault("ID"); string name = part.GetStringOrDefault("Name"); string subtype = part.GetStringOrDefault("SubType"); string soleid = note.PlayerID + id; //取得到活动信息 PartBase model = PartAccess.Instance.FindOneById(soleid); if (model == null) { model = new PartBase(); model.ID = note.PlayerID + id; model.Name = name; model.SubType = subtype; model.Created = DateTime.UtcNow; model.PlayerID = note.PlayerID; model.PartID = id; model.Value = new Variant(); } Variant info = model.Value; int cur = 0; int num = 0; if (subtype == PartType.CoinAchieve || subtype == PartType.CoinSupp) { num = Convert.ToInt32(msg); cur = info.GetIntOrDefault("Cur"); if (cur < num) { //活动其间充值金额不足 note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part4)); return; } //不能重复领取 if (subtype == PartType.CoinAchieve) { if (info.ContainsKey(msg)) { //该项活动已经领取,不能重复领取 note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part5)); return; } } } string rs = note.Player.RoleID + note.Player.Sex; Variant config = part.GetVariantOrDefault("Value"); if (config == null) { //活动配置数据不正确 note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } Variant award = config.GetVariantOrDefault("Award"); if (award == null) { //活动配置数据不正确 note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } Variant tmp = null; //选择的奖励 if (subtype == PartType.LevelAchieve) { if (info.Count > 0) { //该项活动已经领取,不能重复领取 note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part5)); return; } foreach (var item in award) { string[] strs = item.Key.Split('-'); int min = Convert.ToInt32(strs[0]); int max = Convert.ToInt32(strs[1]); if (note.Player.Level >= min && note.Player.Level <= max) { tmp = item.Value as Variant; break; } } } else { tmp = award.GetVariantOrDefault(msg); } if (tmp == null) { //活动配置数据不正确 note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } IList select = tmp.GetValue<IList>(rs); if (select == null) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } Variant goods = select[index] as Variant; if (goods == null) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } Dictionary<string, Variant> dic = PartAccess.Instance.GetPartAward(goods); if (dic.Count == 0) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } if (BurdenManager.IsFullBurden(note.Player.B0, dic)) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part7)); return; } if (subtype == PartType.CoinSupp) { info.SetOrInc("Cur", -num); //记录兑换次数 info.SetOrInc(msg, 1); } else { info[msg] = DateTime.UtcNow; } GoodsSource gs; if (subtype == PartType.CoinSupp) { gs = GoodsSource.CoinSupp; } else if (subtype == PartType.CoinAchieve) { gs = GoodsSource.CoinAchieve; } else { gs = GoodsSource.LevelAchieve; } if (model.Save()) { Dictionary<string, int> gos = note.Player.AddGoods(dic, gs); note.Call(PartCommand.PartExchangeR, true, TipManager.GetMessage(PartReturn.Part15)); //活动通告 PartApprise(note, gos, tmp.GetStringOrDefault("T"), tmp.GetStringOrDefault("M")); } else { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part8)); } }
/// <summary> /// 领取奖励 /// </summary> /// <param name="note"></param> /// <param name="part">活动</param> private static void NowAward(UserNote note, Variant part) { int index = note.GetInt32(2); string soleid = note.PlayerID + part.GetStringOrDefault("ID"); PartBase model = PartAccess.Instance.FindOneById(soleid); if (model == null) { model = new PartBase(); model.ID = soleid; model.Name = part.GetStringOrDefault("Name"); model.SubType = part.GetStringOrDefault("SubType"); model.Created = DateTime.UtcNow; model.PlayerID = note.PlayerID; model.PartID = part.GetStringOrDefault("ID"); model.Value = new Variant(); } Variant v = part.GetVariantOrDefault("Value"); if (v == null) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } DateTime dt = DateTime.Now; string name = dt.ToString("yyyyddMM"); if (model.Value.ContainsKey(name)) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part5)); return; } Variant dayaward = v.GetVariantOrDefault("DayAward"); if (dayaward == null) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } Variant info = null; foreach (var tt in dayaward) { string[] strs = tt.Key.Split('-'); int min = Convert.ToInt32(strs[0]); int max = Convert.ToInt32(strs[1]); if (note.Player.Level >= min && note.Player.Level <= max) { info = tt.Value as Variant; break; } } if (info == null) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } IList ls = info.GetValue<IList>(note.Player.RoleID + "" + note.Player.Sex); if (ls == null) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } Variant goods = ls[index] as Variant; Dictionary<string, Variant> dic = PartAccess.Instance.GetPartAward(goods); PlayerEx b0 = note.Player.B0; if (BurdenManager.IsFullBurden(b0, dic)) { //包袱满不能领取 note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part7)); return; } model.Value[name] = dt; string t = dayaward.GetStringOrDefault("T"); string m = dayaward.GetStringOrDefault("M"); if (model.Save()) { Dictionary<string, int> gos = note.Player.AddGoods(dic, GoodsSource.Yellow); note.Call(PartCommand.PartExchangeR, true, TipManager.GetMessage(PartReturn.Part15)); PartApprise(note, gos, t, m, false); } else { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part14)); } }
/// <summary> /// 物品兑换 /// </summary> /// <param name="note"></param> /// <param name="part"></param> private static void Exchange(UserNote note, Variant part) { string msg = note.GetString(1); int index = note.GetInt32(2); string id = part.GetStringOrDefault("ID"); string name = part.GetStringOrDefault("Name"); string subtype = part.GetStringOrDefault("SubType"); string soleid = note.PlayerID + id; //取得到活动信息 PartBase model = PartAccess.Instance.FindOneById(soleid); if (model == null) { model = new PartBase(); model.ID = note.PlayerID + id; model.Name = name; model.SubType = subtype; model.Created = DateTime.UtcNow; model.PlayerID = note.PlayerID; model.PartID = id; model.Value = new Variant(); } Variant info = model.Value; string rs = note.Player.RoleID + note.Player.Sex; Variant config = part.GetVariantOrDefault("Value"); if (config == null) { //活动配置数据不正确 note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } Variant award = config.GetVariantOrDefault("Award"); if (award == null) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } Variant tmp = award.GetVariantOrDefault(msg); //选择的奖励 if (tmp == null) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } IList select = tmp.GetValue<IList>(rs); if (select == null) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } Variant goods = select[index] as Variant; if (goods == null) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } Dictionary<string, Variant> dic = PartAccess.Instance.GetPartAward(goods); if (dic.Count == 0) { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part6)); return; } PlayerEx b0 = note.Player.B0; if (BurdenManager.IsFullBurden(b0, dic)) { //包袱满不能领取 note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part7)); return; } string goodsid = config.GetStringOrDefault("GoodsID"); int number = Convert.ToInt32(msg); int total = BurdenManager.GoodsCount(b0, goodsid); if (total < number) { //兑换需要的道具数量不足 note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part12)); return; } if (note.Player.RemoveGoods(goodsid, number, GoodsSource.Exchange)) { //总共兑换次数 info.SetOrInc(msg, 1); string t = award.GetStringOrDefault("T"); string m = award.GetStringOrDefault("M"); if (model.Save()) { Dictionary<string, int> gos = note.Player.AddGoods(dic, GoodsSource.Exchange); note.Call(PartCommand.PartExchangeR, true, TipManager.GetMessage(PartReturn.Part15)); PartApprise(note, gos, t, m); } else { //没有达到兑换条件 note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part13)); } } else { note.Call(PartCommand.PartExchangeR, false, TipManager.GetMessage(PartReturn.Part12)); } }
/// <summary> /// 充值活动 /// </summary> /// <param name="note"></param> public static void Recharge(UserNote note) { //充值成功 int coin = note.GetInt32(0); if (coin <= 0) return; List<Variant> list = MallAccess.CoinPart(); foreach (Variant gc in list) { Variant v = gc.GetVariantOrDefault("Value"); if (v == null) continue; DateTime dt = DateTime.UtcNow; if (v.ContainsKey("OpenTime")) { //开服天数 int day = v.GetIntOrDefault("OpenTime"); //开服时间 DateTime zep = ConfigLoader.Config.ZoneEpoch.ToUniversalTime(); //表示活动还没有开始 if (zep > dt) continue; //表示活动已经结束 if (zep.AddDays(day) < dt) continue; } else { DateTime startTime = v.GetDateTimeOrDefault("StartTime"); //表示活动还没有开始 if (startTime > dt) continue; DateTime endTime = v.GetDateTimeOrDefault("EndTime"); //表示活动已经结束 if (endTime < dt) continue; } string id = gc.GetStringOrDefault("ID"); string name = gc.GetStringOrDefault("Name"); string subType = gc.GetStringOrDefault("SubType"); if (subType == PartType.CoinSupp || subType == PartType.CoinAchieve) { string soleid = note.PlayerID + id; PartBase model = PartAccess.Instance.FindOneById(soleid); if (model == null) { model = new PartBase(); model.ID = soleid; model.Name = name; model.SubType = subType; model.Created = DateTime.UtcNow; model.PlayerID = note.PlayerID; model.PartID = id; model.Value = new Variant(); } //晶币充值总数 model.Value.SetOrInc("Total", coin); model.Value.SetOrInc("Cur", coin); model.Save(); } } }