/// <summary> /// 记录不同任务类型每天完成情况 /// </summary> /// <param name="pb">任务id</param> /// <param name="tasktype">任务类型</param> private static void TaskType(PlayerBusiness pb, string tasktype) { PlayerEx fx = pb.TaskDay; Variant v = fx.Value; if (v == null) { fx.Value = new Variant(); v = fx.Value; } DateTime dt = DateTime.Now; //保留7天记录 int delKey = Convert.ToInt32(dt.AddDays(-10).Date.ToString("yyyyMMdd")); //需要移除的Key List<string> keys = new List<string>(); foreach (var item in v) { if (Convert.ToInt32(item.Key) < delKey) { keys.Add(item.Key); } } if (keys.Count > 0) { foreach (string k in keys) { v.Remove(k); } } string day = dt.Date.ToString("yyyyMMdd"); Variant info; if (v.TryGetValueT(day, out info)) { info.SetOrInc(tasktype, 1); } else { info = new Variant(); info.SetOrInc(tasktype, 1); v.Add(day, info); } fx.Save(); pb.Call(ClientCommand.UpdateActorR, new PlayerExDetail(fx)); }
/// <summary> /// 星座加成 /// </summary> private void AddStar(PlayerProperty p) { if (Star == null || Star.Value == null) return; GameConfig gc = GameConfigAccess.Instance.FindOneById("ST_00001"); if (gc == null) return; Variant life = new Variant(); for (int j = 1; j < 13; j++) { IList o = Star.Value.GetValue<IList>(j.ToString()); if (o == null) continue; //得到某个星座配置 Variant v = gc.Value.GetVariantOrDefault(j.ToString()); if (v == null) continue; //得到要加的属性 string name = v.GetStringOrDefault("Name"); double num = 0; Variant c = v.GetVariantOrDefault("B"); if (c != null) { foreach (int i in o) { //num += PartAccess.Instance.StarForm(c.GetDoubleOrDefault("A"), i + 1, c.GetIntOrDefault("B"), c.GetDoubleOrDefault("C")); //num * Math.Pow(v.GetDoubleOrDefault("A"), n * (n - 1) / 2) //星阵属性加成 double b = c.GetDoubleOrDefault("B"); double a = c.GetDoubleOrDefault("A"); double n = (i + 1) * i / 2; num += Convert.ToInt32(b * Math.Pow(a, n)); } } if (o.Count == 14) { //激活所有的守护星额外加成 Variant other = v.GetVariantOrDefault("Life"); if (other != null) { foreach (var k in other) { life.SetOrInc(k.Key, Convert.ToDouble(k.Value)); } } } if (name == "BaoJiShangHai") { num = num / 100; } life.SetOrInc(name, num); } p.Add(life); }
/// <summary> /// 家园生产 /// </summary> /// <param name="note"></param> public static void HomeProduce(UserNote note) { string soleid = note.PlayerID + "HomeProduce"; if (!m_dic.TryAdd(soleid, soleid)) return; try { string id = note.GetString(0); int number = note.GetInt32(1); string npcid = note.GetString(2);//NPC if (!note.Player.EffectActive(npcid, "")) return; if (number <= 0) { note.Call(HomeCommand.HomeProduceR, false, TipManager.GetMessage(HomeReturn.PareError)); return; } //生产数量 GameConfig gc = GameConfigAccess.Instance.FindOneById(id); if (gc == null) { note.Call(HomeCommand.HomeProduceR, false, TipManager.GetMessage(HomeReturn.PareError)); return; } string subType = gc.SubType; PlayerEx home = note.Player.Home; if (home == null) { note.Call(HomeCommand.HomeProduceR, false, TipManager.GetMessage(HomeReturn.NoHome)); return; } //得到需要的道具数量,计算出当前可以生产道具的数量 Variant produces = home.Value.GetValueOrDefault<Variant>("Produces"); if (produces == null) { note.Call(HomeCommand.HomeProduceR, false, TipManager.GetMessage(HomeReturn.PareError)); return; } Variant v = produces.GetValueOrDefault<Variant>(subType); if (v == null) { note.Call(HomeCommand.HomeProduceR, false, TipManager.GetMessage(HomeReturn.PareError)); return; } IList petList = v.GetValue<IList>("PetList"); if (petList.Count == 0) { note.Call(HomeCommand.HomeProduceR, false, TipManager.GetMessage(HomeReturn.InPet)); return; } int yaoJi = 0; int juanZhou = 0; int sheJi = 0; int jiaGong = 0; int caiJi = 0; int jiazhengtotal = 0;//宠物家政值总数 Dictionary<string, Pet> producePet = new Dictionary<string, Pet>(); foreach (Variant d in petList) { yaoJi = yaoJi + d.GetIntOrDefault("YaoJi"); juanZhou = juanZhou + d.GetIntOrDefault("JuanZhou"); sheJi = sheJi + d.GetIntOrDefault("SheJi"); jiaGong = jiaGong + d.GetIntOrDefault("JiaGong"); caiJi = caiJi + d.GetIntOrDefault("CaiJi"); } jiazhengtotal = yaoJi + juanZhou + jiaGong + caiJi; Dictionary<string, int> dic = new Dictionary<string, int>(); dic.Add("YaoJi", yaoJi); dic.Add("JuanZhou", juanZhou); dic.Add("SheJi", sheJi); dic.Add("JiaGong", jiaGong); dic.Add("CaiJi", caiJi); //目标道具 string goodsid = gc.Value.GetStringOrDefault("GoodsID"); //生产所需时间,秒钟 int producetime = gc.Value.GetIntOrDefault("ProduceTime"); //所需家政信息 Variant homeInfo = gc.Value.GetValueOrDefault<Variant>("HomeValue"); //一条生产线可生产最大数量 int produceMax = gc.Value.GetIntOrDefault("Number"); if (number > produceMax) { note.Call(HomeCommand.HomeProduceR, false, string.Format(TipManager.GetMessage(HomeReturn.HomeProduce5),produceMax)); return; } int need = 0; foreach (var item in homeInfo) { if (!dic.ContainsKey(item.Key)) { note.Call(HomeCommand.HomeProduceR, false, TipManager.GetMessage(HomeReturn.ConfigError)); return; } if (dic[item.Key] < (int)item.Value) { note.Call(HomeCommand.HomeProduceR, false, TipManager.GetMessage(HomeReturn.PetHomeNo)); return; } need += Convert.ToInt32(item.Value); } //所需物品 IList needGoods = gc.Value.GetValue<IList>("NeedGoods"); PlayerEx b0 = note.Player.B0; //需要的物品数量 Dictionary<string, int> goods = new Dictionary<string, int>(); int goodsTotal = 0; foreach (Variant ng in needGoods) { int total = ng.GetIntOrDefault("Number") * number; string gs = ng.GetStringOrDefault("GoodsID"); if (BurdenManager.GoodsCount(b0, gs) < total) { note.Call(HomeCommand.HomeProduceR, false, TipManager.GetMessage(HomeReturn.GoodsNumberNo)); return; } if (goods.ContainsKey(gs)) { goods[gs] += total; } else { goods.Add(gs, total); } if (gs == "G_d000389" || gs == "G_d000390" || gs == "G_d000391") { goodsTotal += total; } } int isbinding = 0; foreach (var item in goods) { isbinding=BurdenManager.IsBinding(b0, item.Key, (int)item.Value); if (isbinding == 1) break; } Dictionary<string, Variant> info = new Dictionary<string, Variant>(); Variant vg = new Variant(); vg.Add("Number" + isbinding, number); info.Add(goodsid, vg); if (BurdenManager.IsFullBurden(b0, info)) { note.Call(HomeCommand.HomeProduceR, false, TipManager.GetMessage(HomeReturn.BurdenFull)); return; } DateTime dt=DateTime.UtcNow; if (v.ContainsKey("ProduceList")) { Variant mv = MemberAccess.MemberInfo(note.Player.MLevel); int produce = mv.GetIntOrDefault("Produce");//生产对列数 IList r = v.GetValue<IList>("ProduceList"); if (r.Count > 0) { for (int i = r.Count - 1; i >=0; i--) { DateTime t = ((DateTime)r[i]).ToUniversalTime(); if (t < dt) { //移除过期对列 r.Remove(r[i]); } } } if (r.Count >= produce) { note.Call(HomeCommand.HomeProduceR, false, TipManager.GetMessage(HomeReturn.HomeProduce2)); return; } } int totaltime = producetime * number; if (v.ContainsKey("ProduceList")) { IList pl = v.GetValue<IList>("ProduceList"); pl.Add(dt.AddSeconds(totaltime)); } else { v.Add("ProduceList", new List<DateTime>() { dt.AddSeconds(totaltime) }); } int b = 0; BurdenManager.Remove(b0, goods, out b); Variant us = new Variant(); foreach (var item in goods) { us.SetOrInc(item.Key,Convert.ToInt32(item.Value)); //生产消耗 note.Player.AddLog(Actiontype.GoodsUse, item.Key, Convert.ToInt32(item.Value), GoodsSource.HomeProduce, goodsid, number); note.Player.UpdateTaskGoods(item.Key); } //判断以前是否正在生产 //string gid = v.GetStringOrDefault("GoodsID"); //int num = v.GetIntOrDefault("Number"); //if (num > 0) //{ // GameConfig gcm = GameConfigAccess.Instance.FindOneById(gid); // if (gcm != null) // { // string title = TipManager.GetMessage(HomeReturn.HomeProduce3); // string content = string.Format(TipManager.GetMessage(HomeReturn.HomeProduce4), gcm.Name, num); // Variant gs = new Variant(); // gs.Add("G", gcm.ID); // gs.Add("A", num); // gs.Add("E", gcm.ID); // gs.Add("H", v.GetIntOrDefault("IsBinding")); // List<Variant> goodsList = new List<Variant>(); // if (number > 0) // { // goodsList.Add(gs); // } // else // { // goodsList = null; // } // int reTime = Convert.ToInt32(TipManager.GetMessage(EmailReturn.HameDay)); // if (EmailAccess.Instance.SendEmail(title, TipManager.GetMessage(PetsReturn.StealPet12), note.PlayerID, note.Player.Name, content, string.Empty, goodsList, reTime)) // { // note.Call(EmailCommand.NewEmailTotalR, EmailAccess.Instance.NewTotal(note.PlayerID)); // } // v["GoodsID"] = ""; // v["Number"] = 0; // } //} Variant gs1 = new Variant(); if (home.Save()) { gs1[goodsid] = number; note.Player.AddGoods(info, GoodsSource.HomeProduce); Variant tmp = new Variant(); tmp.Add(subType, v); note.Call(HomeCommand.HomeProduceR, true, tmp); Variant os=new Variant(); os["TotalTime"] = totaltime; note.Player.AddLogVariant(Actiontype.HomeProduce, us, gs1, os); } else { note.Call(HomeCommand.HomeProduceR, false, ""); } } finally { m_dic.TryRemove(soleid, out soleid); } }
/// <summary> /// 任务奖励 /// </summary> /// <param name="note"></param> /// <param name="obj">任务奖励</param> public static void Award(UserNote note) { string soleid = note.PlayerID + "Award"; if (!m_dic.TryAdd(soleid, soleid)) { return; } try { string id = note.GetString(0); IList list = note[1] as IList; #region 奖励判断 //得到指定的任务 Task task = TaskAccess.Instance.GetTaskInfo(id, note.PlayerID); if (task == null) { note.Call(TaskCommand.AwardR, false, null, TipManager.GetMessage(TaskReturn.TaskError)); return; } //得到基本配置表 GameConfig gc = GameConfigAccess.Instance.FindTaskId(task.Value.GetStringOrDefault("TaskID")); if (gc == null) { note.Call(TaskCommand.AwardR, false, null, TipManager.GetMessage(TaskReturn.TaskError)); return; } IList npcInfo = gc.Value.GetValue<IList>("NPCBaseInfo"); if (npcInfo == null) return; Variant npc = null; foreach (Variant model in npcInfo) { if (model.GetIntOrDefault("Type") == 1) { npc = model; break; } } if (npc == null) { return; } string npcid = npc.GetStringOrDefault("NPCID"); if (!TaskBusiness.TaskNpcCheck(note.Player, TaskCommand.AwardR, npcid)) { note.Call(TaskCommand.AwardR, false, null, TipManager.GetMessage(TaskReturn.Npc3)); return; } //表示任务完成条件已经满足,可以领奖 if (task.Value.GetIntOrDefault("Status") != 2) { note.Call(TaskCommand.AwardR, false, null, TipManager.GetMessage(TaskReturn.TaskAwardFail)); return; } ///得到包袱列表 PlayerEx burden = note.Player.B0; ///物品绑定状态 Dictionary<string, int> isbinding = new Dictionary<string, int>(); IList finish = task.Value.GetValue<IList>("Finish"); bool isback = false; foreach (Variant f in finish) { if (f.GetStringOrDefault("Type") == "10004") { isback = true; break; } } //bool IsGoods = false; ///得到奖励条件 IList award = task.Value.GetValue<IList>("Award"); ///得到可选的奖励 List<Variant> fixAward = new List<Variant>(); List<string> select = new List<string>();//可选的奖励 int m = 0; int n = 0; foreach (Variant w in award) { int selectType = w.GetIntOrDefault("SelectType"); string awardID = w.GetStringOrDefault("AwardID"); if (selectType > 0) { //可选择奖励的数量 if (m == 0) m = selectType; select.Add(awardID); if (list.Contains(awardID)) { fixAward.Add(w); n++; } } else { fixAward.Add(w); } } if (m != n) { note.Call(TaskCommand.AwardR, false, null, TipManager.GetMessage(TaskReturn.SelectAwardError)); return; } bool noGoods = false;//非道具的情况 ///宠物 Dictionary<string, int> pets = new Dictionary<string, int>(); Dictionary<string, Variant> dic = new Dictionary<string, Variant>(); foreach (Variant fix in fixAward) { if (fix.GetStringOrDefault("Type") != "20002") { noGoods = true; continue; } string goodsid = fix.GetStringOrDefault("GoodsID"); int count = fix.GetIntOrDefault("Count"); if (fix.GetStringOrDefault("GoodsType") == "112009") { if (!pets.ContainsKey(goodsid)) { pets.Add(goodsid, count); } else { pets[goodsid] += count; } continue; } Variant tmp; if (dic.TryGetValue(goodsid, out tmp)) { tmp.SetOrInc("Number1", count); } else { tmp = new Variant(); tmp.Add("Number1", count); GameConfig gc1 = GameConfigAccess.Instance.FindOneById(goodsid); if (gc1 == null) continue; GoodsAccess.Instance.TimeLines(gc1, tmp); dic.Add(goodsid, tmp); } } if (dic.Count > 0) { if (BurdenManager.IsFullBurden(burden, dic)) { note.Call(TaskCommand.AwardR, false, null, TipManager.GetMessage(TaskReturn.BurdenFull)); return; } } #endregion #region 任务奖励处理 task.Value["Status"] = 3; if (!task.Save()) return; //领奖成功 note.Call(TaskCommand.AwardR, true, null, task.ID); int tasktype = task.Value.GetIntOrDefault("TaskType"); string taskid = task.Value.GetStringOrDefault("TaskID"); TaskType(note.Player, tasktype.ToString()); Variant gs = new Variant(); //得到物品奖励 if (dic.Count > 0) { Dictionary<string, int> info = note.Player.AddGoods(dic, GoodsSource.TaskAward); foreach (var item in info) { gs.SetOrInc(item.Key, item.Value); } } //得到宠物奖励 if (pets.Count > 0) { AwardBusiness.TaskAward112009(note, pets); } Variant us = new Variant(); //物品回收处理 if (isback) { us = FinishBusiness.TaskFinish10004(note, finish); } Variant os = new Variant(); //非道具的奖励 if (noGoods) { if (task.Value.GetIntOrDefault("TaskType") == 2) { os=AwardBusiness.TaskAward20001(note, award, true); } else { os=AwardBusiness.TaskAward20001(note, award); } } os["ID"] = task.ID; os["TaskID"] = taskid; os["TaskType"] = tasktype; string des = gc.Value.GetStringOrDefault("Description"); string[] msg = des.Split('|'); if (msg.Length > 3) AwardBusiness.TaskEmail(note, msg); #endregion #region 触发新的任务 switch (tasktype) { case 2: note.Player.AddAcivity(ActivityType.DayTask, 1); break; case 4: note.Player.AddAcivity(ActivityType.LoopTask, 1); break; } if (tasktype == 2) { TaskBusiness.DayTask(note.Player, true); } else if (tasktype == 7) { TaskBusiness.FamilyTask(note.Player, true); } else if (tasktype == 8) { TaskBusiness.WeekTask(note.Player, npcid, true); } else { List<string> reatTask = new List<string>(); string[] strs = gc.Value.GetStringOrDefault("RearTask").Split(','); for (int i = 0; i < strs.Length; i++) { if (string.IsNullOrEmpty(strs[i])) continue; reatTask.Add(strs[i]); } if (reatTask.Count > 0) { TaskFinishActivation(note, reatTask); } } #endregion #region 任务成就 note.Player.FinishNote(FinishCommand.TotalTask, taskid, tasktype); if (tasktype == 0 || tasktype == 1 || tasktype == 2 || tasktype == 8) { //移除主线任务,支线任务 TaskBusiness.MainTask(note.PlayerID, task.ID, tasktype); } #endregion note.Player.AddLogVariant(Actiontype.TaskAward, us, gs, os); } finally { m_dic.TryRemove(soleid, out soleid); } }
/// <summary> /// 合成操作,将多个道具或装备合成新的道具[完成] /// </summary> /// <param name="note"></param> private void Fuse(UserNote note) { //合成配置的ID string mixid = note.GetString(0); //合成数量 int number = note.GetInt32(1); //提升成功率的数量 int upCount = note.GetInt32(2); string npcid = note.GetString(3); if (!note.Player.EffectActive(npcid, "")) return; GameConfig gc = GameConfigAccess.Instance.FindOneById(mixid); if (gc == null) { note.Call(FuseCommand.FuseR, false, TipManager.GetMessage(FuseReturn.FuseEquipNo)); return; } #region 目标道具基本信息,判断包袱是否满和角色游戏币是否满足 string upid = gc.Value.GetStringOrDefault("UpID"); string fuseGoodsID = gc.Value.GetStringOrDefault("GoodsID"); GameConfig fuseGC = GameConfigAccess.Instance.FindOneById(fuseGoodsID); int m = BurdenManager.StactCount(fuseGC); if (m == 0) { note.Call(FuseCommand.FuseR, false, TipManager.GetMessage(FuseReturn.FuseEquipError)); return; } int y = 0; int s = Math.DivRem(number, m, out y); //需要空格子的数量 int n = (y == 0) ? s : s + 1; PlayerEx burden = note.Player.B0; IList c = burden.Value.GetValue<IList>("C"); int grid = 0; int upNumber = 0; foreach (Variant d in c) { if (string.IsNullOrEmpty(d.GetStringOrDefault("E"))) grid++; //提升成功率的道具 if (upid == d.GetStringOrDefault("G")) { upNumber += d.GetIntOrDefault("A"); } } if (grid < n) { //表示包袱格子数不足 note.Call(FuseCommand.FuseR, false, TipManager.GetMessage(FuseReturn.FuseBurdenFull)); return; } if (upNumber < upCount) { note.Call(FuseCommand.FuseR, false, TipManager.GetMessage(FuseReturn.FuseGoodsLv)); return; } int score = 0;//合成所需游戏币 Variant price = fuseGC.Value.GetValueOrDefault<Variant>("Price"); Variant buy = price.GetValueOrDefault<Variant>("Buy"); score = buy.GetIntOrDefault("Score") * number; #endregion #region 判断合成所需材料是否够 IList mixNeed = gc.Value.GetValue<IList>("MixNeed"); int isBinding = 0; foreach (Variant d in mixNeed) { int total = 0; int numCount = d.GetIntOrDefault("Number") * number; foreach (Variant con in c) { if (con.GetStringOrDefault("G") == d.GetStringOrDefault("GoodsID")) { if (total < numCount && con.GetIntOrDefault("H") == 1) { //判断目标道具是否为绑定状态 isBinding = 1; } total += con.GetIntOrDefault("A"); } } if (total < numCount) { note.Call(FuseCommand.FuseR, false, TipManager.GetMessage(FuseReturn.FuseLessNo)); return; } } #endregion if (note.Player.Score < score || (!note.Player.AddScore(-score, FinanceType.Fuse))) { note.Call(FuseCommand.FuseR, false, TipManager.GetMessage(FuseReturn.FuseScore)); return; } #region 得到当前成功率 double lv = gc.Value.GetDoubleOrDefault("ChengGongLv"); if (upCount != 0) { lv = lv + GoodsAccess.Instance.GetSuccess(upCount); } int ml = note.Player.MLevel; Variant mv = MemberAccess.MemberInfo(ml); if (mv != null) { lv *= (1 + mv.GetDoubleOrDefault("FuseLv")); } //表示成功 bool isSuccess = NumberRandom.RandomHit(lv); #endregion //消耗道具数量 Variant us = new Variant(); #region 移除道具 foreach (Variant d in mixNeed) { int count = d.GetIntOrDefault("Number") * number; string gid = d.GetStringOrDefault("GoodsID"); if (!note.Player.RemoveGoods(gid, count,GoodsSource.Fuse)) { note.Call(FuseCommand.FuseR, false, TipManager.GetMessage(FuseReturn.FuseLessNo)); return; } us.SetOrInc(gid, count); } #endregion if (upCount > 0) { if (!note.Player.RemoveGoods(upid, upCount,GoodsSource.Fuse)) { note.Call(FuseCommand.FuseR, false, TipManager.GetMessage(FuseReturn.FuseGoodsLv)); return; } us.SetOrInc(upid, upCount); } //取得的物品 Variant gs = new Variant(); if (isSuccess) { Variant doc = new Variant(); doc.Add("Number" + isBinding, number); Dictionary<string, Variant> goods = new Dictionary<string, Variant>(); goods.Add(fuseGC.ID, doc); note.Player.AddGoods(goods, GoodsSource.Fuse); gs.SetOrInc(fuseGC.ID, number); } note.Player.UpdateBurden(); if (isSuccess) { note.Player.FinishNote(FinishCommand.HeChen, 1); string str = string.Format(TipManager.GetMessage(FuseReturn.FuseSuccess), fuseGC.Name, number); note.Call(FuseCommand.FuseR, true, str); } else { note.Call(FuseCommand.FuseR, false, TipManager.GetMessage(FuseReturn.FuseFail)); } Variant os = new Variant(); os["IsSuccess"] = isSuccess; os["Lv"] = lv; os["Score"] = -score; note.Player.AddLogVariant(Actiontype.Fuse, us, gs, os); }
/// <summary> /// 奖励类型[经验,晶币,游戏币] /// </summary> /// <param name="note"></param> /// <param name="award">奖励</param> /// <param name="isdouble">该是否可以任务</param> public static Variant TaskAward20001(UserNote note, IList award, bool isdouble = false) { bool isp = false;//是否双倍 PlayerEx assist = note.Player.Assist; Variant avs = assist.Value; //表示双倍日常任务经验 if (isdouble) { if (avs.ContainsKey("TSP")) { int tsp = avs.GetIntOrDefault("TSP"); if (tsp > 1) { avs["TSP"] = tsp - 1; } else { avs.Remove("TSP"); } assist.Save(); isp = true; note.Call(ClientCommand.UpdateActorR, new PlayerExDetail(assist)); } } Variant os = new Variant(); bool isfamily = false; foreach (Variant d in award) { if (d.GetStringOrDefault("Type") == "20001") { string name = d.GetStringOrDefault("Name"); int count = d.GetIntOrDefault("Count"); switch (name) { case "Experience": count = isp ? count * 2 : count; note.Player.AddExperience(count, FinanceType.Task); break; case "PetExperience": count = isp ? count * 2 : count; Pet p = note.Player.Pet; if (p != null) { note.Player.AddPetExp(note.Player.Pet, count, true, (int)FinanceType.Task); } if (note.Player.Mounts != null) { note.Player.AddMounts(count, GoodsSource.TaskAward); } break; case "Bond": note.Player.AddBond(count, FinanceType.Task); break; case "Score": note.Player.AddScore(count, FinanceType.Task); break; case "Dev": isfamily = Dev(note.Player, count); break; } if (name == "Dev") { if (isfamily) { os.SetOrInc(name, count); } } else { os.SetOrInc(name, count); } } } return os; }
/// <summary> /// 发送邮件 /// </summary> /// <param name="note"></param> public static void SendEmail(UserNote note) { Variant d = note.GetVariant(0); //标题 string title = d.GetStringOrDefault("mailtitle"); if (title.Length > 20) { note.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(EmailReturn.EmailTitalLength)); return; } if (d.GetStringOrEmpty("mailMess").Length > 300) { note.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(EmailReturn.EmailContent)); return; } //mailMess IList goodsList = d.GetValue<IList>("goodsList"); int fee = 5;//要扣除的邮费 int score = 0; if (d.ContainsKey("moneyGoods")) { Variant mg = d.GetVariantOrDefault("moneyGoods"); score = mg.GetIntOrDefault("Score"); if (mg != null) { fee += Convert.ToInt32(Math.Ceiling(score * 0.01)); } } if (goodsList.Count > 0) { fee += goodsList.Count * 10; } //发送物品物数量 if (note.Player.Score < (fee + score)) { //游戏币不足 note.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(EmailReturn.NoScore)); return; } PlayerEx b0 = note.Player.B0; IList c = b0.Value.GetValue<IList>("C"); if (!IsCheck(note.Player, goodsList, c)) return; string name = d.GetStringOrDefault("playerName"); if (note.Player.Name == name) { note.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(EmailReturn.NoSelf)); return; } PlayerBusiness pb = PlayersProxy.FindPlayerByName(name); if (pb == null) { note.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(EmailReturn.NoExists)); return; } if (!note.Player.AddScore(-(fee + score), FinanceType.EmailFee, string.Format("{0},{1},{2}", fee, score, pb.ID))) { note.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(EmailReturn.NoScore)); return; } Variant dic = new Variant(); //bool isChange = false; foreach (Variant gs in goodsList) { foreach (Variant con in c) { if (con.GetIntOrDefault("P") != gs.GetIntOrDefault("P")) continue; //如果道具非绑定不能发送 string goodsid = con.GetStringOrDefault("G"); int num = con.GetIntOrDefault("A"); BurdenManager.BurdenClear(con); note.Player.UpdateTaskGoods(goodsid); //记录邮寄道具情况 dic.SetOrInc(goodsid, num); } } string mid = ""; if (b0.Save()) { Email model = new Email(); model.ID = ObjectId.GenerateNewId().ToString(); model.Name = string.IsNullOrEmpty(title) ? string.Format(TipManager.GetMessage(EmailReturn.SendEmail1), note.Player.Name) : title; model.Status = 0; model.Ver = 1; model.MainType = EmailCommand.Personal; model.Created = DateTime.UtcNow; model.Value = EmailBase.CreateEmailValue(note.PlayerID, note.Player.Name, pb.ID, pb.Name, d); model.Save(); if (pb.Online) { //得到新邮件请查收 pb.Call(EmailCommand.NewEmailTotalR, EmailAccess.Instance.NewTotal(pb.ID)); } if (goodsList != null && goodsList.Count > 0) { note.Player.UpdateBurden(); } note.Call(EmailCommand.SendEmailR, true, EmailReturn.SendEmailSuccess); mid = model.ID; } if (dic.Count > 0) { foreach (var item in dic) { note.Player.AddLog(Actiontype.GoodsUse, item.Key, Convert.ToInt32(item.Value), GoodsSource.SendEmail, pb.Name, 0); } } }
/// <summary> /// 取出邮件物品 /// </summary> /// <param name="note"></param> public static void GetEmailGoods(UserNote note) { string soleid = note.PlayerID + "GetEmailGoods"; if (!m_dic.TryAdd(soleid, soleid)) return; try { string emailid = note.GetString(0); Email model = EmailAccess.Instance.FindOneById(emailid); if (model == null) { note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.NoEmail)); return; } //是否操作邮件 if (model.Ver != 10) { if (model.Status > 1) { note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.GetEmailGoods1)); // 物品已经提取,不能重复领取 return; } } Variant v = model.Value; if (note.PlayerID != v.GetStringOrDefault("ReceiveID")) { note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.NoReceiveID)); return; } if (v.GetIntOrDefault("IsHave") != 1) { note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.GetEmailGoods2)); return; } PlayerEx b0 = note.Player.B0; Variant bv = b0.Value; IList c = bv.GetValue<IList>("C"); IList goodslist = v.GetValue<IList>("GoodsList"); if (goodslist != null) { int count = BurdenManager.BurdenSpace(c); if (goodslist.Count > count) { note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.BurdenFull)); return; } } model.Status = 2; if (model.Save()) { int score = v.GetIntOrDefault("Score"); if (score > 0) { note.Player.AddScore(score, FinanceType.ExtractGoods); } if (goodslist != null) { Dictionary<string, Variant> dic = new Dictionary<string, Variant>(); foreach (Variant item in goodslist) { string gid = item.GetStringOrDefault("SoleID"); if (gid != item.GetStringOrDefault("GoodsID")) { Goods g = GoodsAccess.Instance.FindOneById(item.GetStringOrDefault("SoleID")); if (g == null) continue; g.PlayerID = note.PlayerID; if (!g.Save()) continue; Variant gv = g.Value; Variant m = BurdenManager.GetBurdenSpace(c); if (m == null) continue; m["E"] = g.ID; m["G"] = g.GoodsID; m["A"] = 1;//只能一件物品 m["S"] = gv.GetIntOrDefault("Sort"); m["H"] = 0; m["D"] = 0; m["T"] = null; //任务更新 note.Player.UpdateTaskGoods(g.GoodsID); //邮件日志 PlayerLog log = new PlayerLog(ServerLogger.zoneid, Actiontype.AddGoods); log.itemcnt = 1; log.itemtype = g.GoodsID; log.reserve_1 = (int)GoodsSource.ExtractGoods; log.remark = emailid; note.Player.WriteLog(log); } else { GameConfig gc = GameConfigAccess.Instance.FindOneById(gid); if (gc == null) continue; int num = item.GetIntOrDefault("Number"); int h = item.GetIntOrDefault("H"); h = h > 0 ? 1 : 0; Variant tmp; if (dic.TryGetValue(gid, out tmp)) { tmp.SetOrInc("Number" + h, num); } else { tmp = new Variant(); tmp.SetOrInc("Number" + h, num); dic.Add(gid, tmp); } } } //判断邮件状态 if (model.Ver == 10) { BurdenManager.BurdenBatchInsert(note.Player.B0, dic); model.Ver = 5; model.Save(); } else { note.Player.AddGoods(dic, GoodsSource.ExtractGoods, emailid); } } note.Call(EmailCommand.ExtractGoodsR, true, emailid); if (goodslist != null && goodslist.Count > 0) { note.Player.UpdateBurden(); } } } finally { m_dic.TryRemove(soleid, out soleid); } }
/// <summary> /// 暴星分享 /// </summary> /// <param name="note"></param> public static void StartStarShared(UserNote note) { string share = note.PlayerID + "Share"; try { if (!m_dic.ContainsKey(share)) return; string m = ""; //暴星 IList o = note.GetValue<IList>(0); int power = note.GetInt32(1); if (m_dic.TryGetValue(share, out m)) { int n=0; if (int.TryParse(m, out n)) { if (power > n) { power = n; } } } power = power > 30000 ? 30000 : power; int exp = 10 * power + 1000; List<string> shareList = new List<string>(); foreach (string id in o) { PlayerBusiness pb = PlayersProxy.FindPlayerByID(id); if (pb.SceneID != note.Player.SceneID) continue; if (note.Player.AState == ActionState.Fight) continue; PlayerEx star = pb.Star; Variant v = star.Value; Variant tmp; if (v.TryGetValue("Share", out tmp)) { //分享总次数 string msg = ""; if (tmp.GetIntOrDefault("Total") >= PartAccess.Instance.MedConfig("Total")) { msg = TipManager.GetMessage(StarReturn.StartStarShared1); //"你已经达到星力爆发分享次数总上限,无法获得经验值!"; pb.Call(ClientCommand.SendActivtyR, new object[] { "T02", msg }); continue; } //如果是同一开 if (tmp.GetLocalTimeOrDefault("ShareTime").Date == DateTime.Now.Date) { //每天最多分享10次暴星经验 if (tmp.GetIntOrDefault("Count") >= PartAccess.Instance.MedConfig("EveryDay")) { msg = TipManager.GetMessage(StarReturn.StartStarShared2);// "你已经达到当天的星力爆发分享次数上限,无法获得经验"; pb.Call(ClientCommand.SendActivtyR, new object[] { "T02", msg }); continue; } tmp.SetOrInc("Count", 1); } else { tmp["Count"] = 1; } tmp.SetOrInc("Exp", exp); tmp["ShareTime"] = DateTime.UtcNow; tmp.SetOrInc("Total", 1); } else { tmp = new Variant(); tmp.SetOrInc("Exp", exp);//总共 tmp.SetOrInc("Count", 1);// tmp["ShareTime"] = DateTime.UtcNow;//上次分享时间 tmp.SetOrInc("Total", 1);//当前分享次数 v.Add("Share", tmp); } star.Save(); pb.AddExperience(exp, FinanceType.StartStarShared); pb.Call(ClientCommand.UpdateActorR, new PlayerExDetail(star)); shareList.Add(pb.ID); } PlayersProxy.CallAll(StarCommand.StartStarSharedR, new object[] { note.PlayerID, shareList }); } finally { m_dic.TryRemove(share, out share); } }
/// <summary> /// 星力空瓶的使用 /// </summary> /// <param name="player"></param> /// <param name="gc"></param> /// <param name="p"></param> private static void Bottles(PlayerBusiness player, GameConfig gc, Variant p) { Variant v = gc.Value; //需要星力值 int outstar = v.GetIntOrDefault("OutStar"); if (player.StarPower < outstar) { player.UseGoodsR(false, TipManager.GetMessage(GoodsReturn.GoodsWashing6)); return; } Dictionary<string, Variant> dic = new Dictionary<string, Variant>(); //目标道具 string goodsid = v.GetStringOrDefault("GoodsID"); Variant tmp = new Variant(); tmp.SetOrInc("Number" + p.GetIntOrDefault("H"), 1); dic.Add(goodsid, tmp); if (BurdenManager.IsFullBurden(player.B0, dic)) { player.UseGoodsR(false, TipManager.GetMessage(GoodsReturn.BurdenB0Full)); return; } if (!player.AddStarPower(-outstar, FinanceType.UseGoods)) { player.UseGoodsR(false, TipManager.GetMessage(GoodsReturn.GoodsWashing6)); return; } if (player.RemoveGoods(p.GetIntOrDefault("P"), GoodsSource.DoubleUse)) { player.AddGoods(dic, GoodsSource.Bottles); player.UseGoodsR(true, goodsid); player.FinishNote(FinishCommand.StarBottle); } else { player.UseGoodsR(false, TipManager.GetMessage(GoodsReturn.UseGoods2)); } }
/// <summary> /// 回收一定数量的道具,表示在领奖的时候回 /// </summary> /// <param name="note">角色对象</param> /// <param name="s"></param> public static Variant TaskFinish10004(UserNote note, IList s) { Variant us = new Variant(); List<string> list = new List<string>(); bool ischange = false; foreach (Variant d in s) { //表示回收物品 if (d.GetIntOrDefault("Type") == 10004) { PlayerEx burden = note.Player.B0; IList c = burden.Value.GetValue<IList>("C"); //回收数量 int num = d.GetIntOrDefault("Total"); if (num == d.GetIntOrDefault("Cur")) { string goodsid = d.GetStringOrDefault("GoodsID"); note.Player.RemoveGoods(goodsid, num, GoodsSource.TaskFinish10004); us.SetOrInc(goodsid, num); ischange = true; } burden.Save(); } } if (ischange) { note.Player.UpdateBurden(); } return us; }