public string GetMsg(string sceneName, string playerName, string goods, GoodsSource source) { var config = GameConfigAccess.Instance.FindOneById(goods); if (config == null) { return null; } int index = (int)source; switch (source) { case GoodsSource.KillApc: index = GoodsReturn.RareKillApc; break; case GoodsSource.OpenBox: index = GoodsReturn.RareOpenBox; break; case GoodsSource.Clap: index = GoodsReturn.RareClap; break; case GoodsSource.DrawCard: index = GoodsReturn.RareDrawCard; break; default: return null; } string msg = TipManager.GetMessage(index); if (string.IsNullOrEmpty(msg)) { return null; } return string.Format(msg, playerName, sceneName, config.Name); }
/// <summary> /// 添加物品,包袱是否已经满各模块自己检查 /// </summary> /// <param name="goods">道具</param> /// <param name="source">来源</param> /// <param name="remark"></param> /// <param name="count"> /// 商城购卖时,记录消费晶币,骨币,战绩数量 /// 也可以存其它类型 /// </param> /// <returns></returns> public Dictionary<string, int> AddGoods(Dictionary<string, Variant> goods, GoodsSource source, string remark = null, int count = 0) { Dictionary<string, int> v = BurdenManager.BurdenBatchInsert(m_b0, goods); if (v == null || v.Count == 0) { return v; } UpdateBurden(); foreach (var item in v) { PlayerLog log = new PlayerLog(ServerLogger.zoneid, Actiontype.AddGoods); log.itemcnt = item.Value; log.itemtype = item.Key; log.reserve_1 = (int)source; log.remark = remark; log.reserve_2 = count; this.WriteLog(log); UpdateTaskGoods(item.Key); } var scene = this.Scene; if (scene != null && this.Online && source != GoodsSource.GMGet) { foreach (string gid in v.Keys) { //珍稀物品发送通知: string position = RareGoodsManager.Instance.GetMsgTo(gid); if (!string.IsNullOrEmpty(position)) { string msg = RareGoodsManager.Instance.GetMsg(scene.Name, this.Name, gid, source); if (msg != null) { PlayersProxy.CallAll(ClientCommand.SendActivtyR, new object[] { position, msg }); } } } } return v; }
/// <summary> /// 添加会员成长度 /// </summary> /// <param name="czd">增加值</param> /// <param name="gs">成长度来源</param> public void AddCZD(int czd, GoodsSource gs) { if (czd <= 0) return; //得到最大等级 int max = MemberAccess.MemberMax(); if (czd > 200000000) return; CZD += czd; if (MLevel >= max) return; int mlevel = MLevel; while (true) { Variant mv = MemberAccess.MemberInfo(MLevel); if (mv == null) break; int a = mv.GetIntOrDefault("A"); if (CZD < a) break; MLevel++; //CZD -= a; if (MLevel >= max) break; } //保存会员等级与会员当前成长度 if (PlayerAccess.Instance.SaveValue(PID, new Tuple<string, BsonValue>("MLevel", MLevel), new Tuple<string, BsonValue>("CZD", CZD))) { if (MLevel > mlevel) { for (int i = mlevel + 1; i <= MLevel; i++) { UserNote note2 = new UserNote(this, MemberCommand.MemberUp, new object[] { i }); Notifier.Instance.Publish(note2); } } } //通知客户端 Variant v = new Variant(3); v.Add("CZD", CZD); v.Add("MLevel", MLevel); UpdataActorR(v); //记录日志 AddLog(Actiontype.CZD, MLevel.ToString(), czd, gs, mlevel.ToString(), 0); }
/// <summary> /// 坐骑得到经验 /// </summary> /// <param name="exp">得到经验</param> /// <param name="gs">经验来源</param> /// <returns></returns> public bool AddMounts(int exp,GoodsSource gs) { if (m_mounts == null) return false; GameConfig gc = GameConfigAccess.Instance.FindOneById(m_mounts.MountsID); if (gc == null) { return false; } Variant v = gc.Value; if (v == null) { return false; } Variant ex = v.GetVariantOrDefault("Exp"); int max = 1; foreach (var item in ex) { int m = Convert.ToInt32(item.Key); if (m > max) { max = m; } } if (m_mounts.Level >= max) { //已经升到最高级 return false; } m_mounts.Experience += exp; int level = m_mounts.Level; bool isup = false; while (true) { if (m_mounts.Level >= max) break; int maxExp = ex.GetIntOrDefault(m_mounts.Level.ToString()); if (m_mounts.Experience < maxExp) break; m_mounts.Experience -= maxExp; m_mounts.Level++; m_mounts.Update = DateTime.UtcNow; isup = true; } if (m_mounts.Save()) { //表示升级更新出战宠属性 if (m_mounts.Status == 1 && isup) { PetAccess.PetReset(m_pet, Skill, false, m_mounts); } MountsUpdate(m_mounts, new List<string>() { "Experience", "Level" }); } //坐骑取得经验 日志 PlayerLog log = new PlayerLog(ServerLogger.zoneid, Actiontype.MountsExp); //升到的等级 log.level = m_mounts.Level; log.modifyexp = exp;//得到坐骑经验 log.reserve_1 = (int)gs; //升之前的等级 log.reserve_2 = level; log.remark = m_mounts.ID; log.touid = PID; this.WriteLog(log); return true; }
/// <summary> /// 移除指定的所有道具 /// </summary> /// <param name="goodsid"></param> /// <returns></returns> public int RemoveGoodsAll(string goodsid,GoodsSource gs) { int count = BurdenManager.RemoveAll(m_b0, goodsid); if (count > 0) { UpdateTaskGoods(goodsid); AddLog(Actiontype.GoodsUse, goodsid, count, gs, "", 0); } return count; }
/// <summary> /// 移除指定位置的道具 /// </summary> /// <param name="p">格子位置</param> /// <param name="isall">false移除一个,true使用该格子中所有道具</param> /// <returns></returns> public bool RemoveGoods(int p, GoodsSource gs, bool isall = false) { string goodsid; int number = 0;//移除数量 if (BurdenManager.RemoveGoods(m_b0, p, isall, out goodsid, out number)) { if (string.IsNullOrEmpty(goodsid) || number <= 0) return false; UpdateTaskGoods(goodsid); AddLog(Actiontype.GoodsUse, goodsid, number, gs, "", 0); return true; } return false; }
/// <summary> /// 移除指定时间的道具 /// </summary> /// <param name="goodsid">道具</param> /// <param name="endtime">时间</param> /// <param name="number">数量</param> /// <returns></returns> public bool RemoveGoods(string goodsid, DateTime endtime, int number, GoodsSource gs) { if (BurdenManager.Remove(m_b0, goodsid, endtime, number)) { UpdateTaskGoods(goodsid); AddLog(Actiontype.GoodsUse, goodsid, number, gs, "", 0); return true; } return false; }
/// <summary> /// 移除指定道具 /// </summary> /// <param name="goodsid">道具ID</param> /// <returns></returns> public bool RemoveGoods(string goodsid,GoodsSource gs) { if (BurdenManager.Remove(m_b0, goodsid)) { UpdateTaskGoods(goodsid); AddLog(Actiontype.GoodsUse, goodsid, 1, gs, "", 0); return true; } return false; }
/// <summary> /// 移除装备在角色身上的坐骑与时装 /// </summary> /// <param name="goodsid"></param> /// <param name="number"></param> /// <param name="gs"></param> /// <returns></returns> public bool RemoveEquips(string goodsid, GoodsSource gs) { AddLog(Actiontype.GoodsUse, goodsid, 1, gs, "", 0); return true; }
/// <summary> /// 添加日志 /// </summary> /// <param name="t">操作类型</param> /// <param name="itemtype"></param> /// <param name="itemcnt"></param> /// <param name="source">来源</param> /// <param name="remark">备注</param> /// <param name="reserve_2"></param> public void AddLog(Actiontype t, string itemtype, int itemcnt, GoodsSource source, string remark, int reserve_2) { PlayerLog log = new PlayerLog(ServerLogger.zoneid, t); log.itemtype = itemtype; log.itemcnt = itemcnt; log.reserve_1 = (int)source; log.remark = remark; log.reserve_2 = reserve_2; this.WriteLog(log); }
/// <summary> /// 添加1个非绑定的物品 /// </summary> /// <param name="goodsid"></param> /// <param name="endTime"></param> /// <param name="source"></param> /// <returns></returns> public bool AddGoodsNobingOne(string goodsid, DateTime endTime, GoodsSource source = GoodsSource.None) { Dictionary<string, Variant> dic = new Dictionary<string, Variant>(1); Variant v = new Variant(2); v.Add("Number0", 1); v.Add("EndTime", endTime); dic.Add(goodsid, v); Dictionary<string, int> list = AddGoods(dic, source); return list.Count > 0; }
/// <summary> /// 提取技能或放生得到经验 /// </summary> /// <param name="player">角色</param> /// <param name="id">宠物唯一标识</param> /// <param name="petsid">宠物</param> /// <param name="ft">操作方式</param> /// <param name="pl">宠物所有位置</param> /// <param name="gs">操作</param> public static void PetExp(PlayerBusiness player, string id, string petsid, FinanceType ft, GoodsSource gs, int pl,int level) { GameConfig gc = GameConfigAccess.Instance.FindOneById(petsid); if (gc == null) return; Variant v = gc.Value; if (v == null) return; //角色得到经验 int p1exp = v.GetIntOrDefault("P1exp"); //宠物取得经验 int p2exp = v.GetIntOrDefault("P2exp"); if (p1exp > 0) { player.AddExperience(p1exp, ft); } if (p2exp > 0 && player.Pet != null) { player.AddPetExp(player.Pet, p2exp, true, (int)ft); } player.AddLog(Actiontype.PetRemove, petsid, level, gs, id, pl); }