Ejemplo n.º 1
0
        /// <summary>
        /// 系统邮件
        /// </summary>
        public static Email SendAuctionEmail(
            Dictionary<string, object> dic,
            string type, 
            string auctionid, 
            string receiveID, 
            string receiveName,
            int Score,
            int Coin,
            List<Variant> GoodsList
            )
        {
            Email email = new Email();
            email.ID = ObjectId.GenerateNewId().ToString();
            email.Status = 0;//0表示未读取过,1已读取
            email.Ver = 1;
            email.MainType = EmailCommand.System;
            email.Created = DateTime.UtcNow;
            GameConfig gc = GameConfigAccess.Instance.FindOneById(type);
            Variant d = new Variant(16);
            string Title = gc.Value.GetStringOrDefault("Title");
            string Source = gc.Value.GetStringOrDefault("Source");
            string Content = gc.Value.GetStringOrDefault("Content");
            foreach (string k in dic.Keys)
            {
                Title = Title.Replace(k, dic[k].ToString());
                Content = Content.Replace(k, dic[k].ToString());
            }
            email.Name = Title;
            d.Add("Title", Title);
            d.Add("Source", Source);
            d.Add("Content", Content);
            d.Add("SendID", EmailCommand.System);
            d.Add("SendName", Source);
            d.Add("ReceiveID", receiveID);
            d.Add("ReceiveName", receiveName);
            //d.Add("Take", string.Empty);
            DateTime dt = DateTime.UtcNow;
            d.Add("UpdateDate", dt);
            d.Add("EndDate", dt.AddDays(30));
            d.Add("AuctionID", auctionid);
            d.Add("Score", Score);
            d.Add("Coin", Coin);
            d.Add("GoodsList", GoodsList);
            if (d.GetIntOrDefault("Score") > 0 || d.GetIntOrDefault("Coin") > 0 || (GoodsList!=null && GoodsList.Count > 0))
            {
                d.Add("IsHave", 1);
            }
            else
            {
                d.Add("IsHave", 0);
            }

            email.Value = d;
            email.Save();
            return email;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 家族的创建
        /// </summary>
        /// <param name="note"></param>
        public static void FamilyCreate(UserNote note)
        {
            //家族名称
            string name = note.GetString(0).Trim();

            string npcid = note.GetString(1);//NPC
            if (!note.Player.EffectActive(npcid, ""))
                return;

            string checkmsg = NameManager.Instance.CheckName(name);
            if (!string.IsNullOrEmpty(checkmsg))
            {
                note.Call(FamilyCommand.FamilyCreateR, false, checkmsg);
                return;
            }

            //得到玩家家族信息
            PlayerEx family = note.Player.Family;
            if (family.Value.GetStringOrDefault("FamilyID") != string.Empty)
            {
                note.Call(FamilyCommand.FamilyCreateR, false, TipManager.GetMessage(FamilyReturn.FamilyExist));
                return;
            }
            if (family.Value.GetStringOrDefault("FreezeDate") != string.Empty)
            {
                DateTime FreezeDate = family.Value.GetDateTimeOrDefault("FreezeDate");
                if (FreezeDate.ToLocalTime() > DateTime.Now)
                {
                    note.Call(FamilyCommand.FamilyCreateR, false, string.Format(TipManager.GetMessage(FamilyReturn.FreezeDate), FreezeDate.ToLocalTime().ToString()));
                    return;
                }
            }
            if (name.Length > 7)
            {
                note.Call(FamilyCommand.FamilyCreateR, false, TipManager.GetMessage(FamilyReturn.NameOutLength));
                return;
            }

            if (FamilyAccess.Instance.FamilyIsExist(name))
            {
                note.Call(FamilyCommand.FamilyCreateR, false, TipManager.GetMessage(FamilyReturn.FamilyNameExist));
                return;
            }

            if (note.Player.Level < 10)
            {
                //玩家等级不足
                note.Call(FamilyCommand.FamilyCreateR, false, TipManager.GetMessage(FamilyReturn.NoLevel));
                return;
            }

            if (family.Value.GetStringOrDefault("FamilyID") != string.Empty)
            {
                note.Call(FamilyCommand.FamilyCreateR, false, TipManager.GetMessage(FamilyReturn.ExistFamily));
                return;
            }

            //创建家族需要2000000石币
            if (note.Player.Score < 400000 || (!note.Player.AddScore(-400000, FinanceType.FamilyCreate)))
            {
                note.Call(FamilyCommand.FamilyCreateR, false, TipManager.GetMessage(FamilyReturn.NoScore));
                return;
            }

            string[] msg = TipManager.GetMessage(FamilyReturn.CreateFamilyEmail).Split('|');
            if (msg.Length < 3)
                return;

            WordAccess.Instance.SetUsed(name);

            Family model = Family.Create(FamilyBase.FamilyValue(note));
            model.ID = ObjectId.GenerateNewId().ToString();
            model.Name = name;
            model.Created = DateTime.UtcNow;
            model.Modified = DateTime.UtcNow;
            //model.Save();

            FamilyAccess.Instance.Insert(model);

            //更新用户家族信息
            family.Value["FamilyID"] = model.ID;
            family.Value["FamilyName"] = name;

            //是否在冻结期
            family.Value["FreezeDate"] = DateTime.UtcNow;
            family.Value["FamilyRoleID"] = 0;
            family.Value["Devote"] = 0;//当前对家族的贡献值
            family.Save();

            Email email = new Email();
            email.ID = ObjectId.GenerateNewId().ToString();
            email.Name = string.Format(msg[1], model.Name);//msg[1].Replace("FamilyName", model.Name);
            email.Status = 0;
            email.Ver = 1;
            email.MainType = EmailCommand.System;
            email.Created = DateTime.UtcNow;
            Variant v = new Variant();
            v.Add("mailMess", string.Format(msg[2], model.Name));
            v.Add("reTime", 30);
            email.Value = EmailAccess.Instance.CreateEmailValue(EmailCommand.System, msg[0], note.PlayerID, note.Player.Name, v);
            email.Save();

            Variant self = new Variant();
            self.Add("Family", note.Player.Family);

            note.Call(FamilyCommand.FamilyCreateR, true, self);
            note.Player.SetFamilyName(name, StrsRole[0]);
            note.Call(EmailCommand.NewEmailTotalR, EmailAccess.Instance.NewTotal(note.PlayerID));

            UserNote note1 = new UserNote(note.Player, FamilyCommand.AddFamily, new object[] { 0 });
            Notifier.Instance.Publish(note1);

            Variant os = new Variant();
            os["ID"] = model.ID;
            os["Name"] = model.Name;
            os["TargetID"] = note.PlayerID;
            os["TargetName"] = note.Player.Name;
            os["Status"] = 0;
            note.Player.AddLogVariant(Actiontype.FamilyLog, null, null, os);
        }
Ejemplo n.º 3
0
        /// <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);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 邮件物品提取
        /// </summary>
        /// <param name="note"></param>
        public static void ExtractGoods(UserNote note)
        {
            if (!m_dic.TryAdd(note.PlayerID, note.PlayerID))
                return;
            try
            {
                string EmailID = note.GetString(0);
                string GoodsID = note.GetString(1);
                Email email = EmailAccess.Instance.FindOneById(EmailID);
                if (email == null)
                {
                    note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.NoEmail));
                    return;
                }
                if (note.PlayerID != email.Value.GetStringOrDefault("ReceiveID"))
                {
                    note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.NoReceiveID));
                    return;
                }

                //得到邮件的物品列表
                IList GoodsList = email.Value.GetValue<IList>("GoodsList");

                if (GoodsID == string.Empty)
                {
                    int s0 = email.Value.GetIntOrDefault("Score");//石币
                    if (s0 <= 0)
                    {
                        return;
                    }
                    email.Value["Coin"] = 0;
                    email.Value["Score"] = 0;
                    if (GoodsList != null)
                    {
                        if (GoodsList.Count == 0)
                        {
                            email.Value["IsHave"] = 0;
                        }
                    }
                    else
                    {
                        email.Value["IsHave"] = 0;
                    }
                    email.Save();
                    note.Player.AddScore(s0, FinanceType.ExtractGoods);
                    note.Call(EmailCommand.ExtractGoodsR, true, GoodsID);
                    return;
                }

                Variant v = null;
                foreach (Variant d in GoodsList)
                {
                    if (d.GetStringOrDefault("SoleID") == GoodsID)
                    {
                        v = d;
                        break;
                    }
                }

                if (v == null)
                {
                    note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.NoReceiveID));
                    return;
                }
                //int Coin = v.GetIntOrDefault("Coin");
                int Score = v.GetIntOrDefault("Score");
                string SoleID = v.GetStringOrDefault("SoleID");
                //if (note.Player.Coin < Coin)
                //{
                //    //晶币不足
                //    note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.NoCoin));
                //    return;
                //}

                if (note.Player.Score < Score)
                {
                    //游戏币不足
                    note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.NoScore));
                    return;
                }

                //货物提取后,

                Email ev = new Email();
                ev.ID = ObjectId.GenerateNewId().ToString();
                ev.Name = email.Name;
                ev.Status = 0;
                ev.Ver = 1;
                ev.MainType = EmailCommand.System;
                ev.Created = DateTime.UtcNow;

                Variant gs = new Variant();
                Variant moneyGoods = new Variant();
                //moneyGoods.Add("Coin", Coin);
                moneyGoods.Add("Score", Score);
                gs.Add("moneyGoods", moneyGoods);
                gs.Add("GoodsList", new List<Variant>());
                gs.Add("mailMess", "");
                gs.Add("reTime", 15);
                ev.Value = EmailBase.CreateEmailValue(EmailCommand.System, TipManager.GetMessage(EmailReturn.ExtractGoods1), email.Value.GetStringOrDefault("SendID"), email.Value.GetStringOrDefault("SendName"), gs);
                Goods g = GoodsAccess.Instance.FindOneById(GoodsID);
                //普通包袱
                PlayerEx burden = note.Player.B0;
                IList c = burden.Value.GetValue<IList>("C");
                if (g != null)
                {
                    Variant n = BurdenManager.GetBurdenSpace(c);
                    if (n == null)
                    {
                        note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.BurdenFull));
                        return;
                    }

                    if (!note.Player.AddScore(-Score, FinanceType.ExtractGoods))
                    {
                        note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.NoScore));
                        return;
                    }

                    n["E"] = g.ID;
                    n["G"] = g.GoodsID;
                    n["A"] = 1;
                    n["S"] = g.Value.GetIntOrDefault("Sort");
                    n["H"] = 0;
                    n["D"] = 0;

                    Variant tmp = new Variant();
                    if (g.Value.ContainsKey("BaoShiInfo"))
                    {
                        tmp.Add("BaoShiInfo", g.Value.GetValue<object>("BaoShiInfo"));
                    }
                    if (g.Value.ContainsKey("Stamina"))
                    {
                        Variant Stamina = g.Value.GetVariantOrDefault("Stamina");
                        tmp.Add("Stamina", Stamina.GetIntOrDefault("V"));
                    }
                    if (g.Value.ContainsKey("PetsWild"))
                    {
                        tmp.Add("PetsWild", g.Value.GetIntOrDefault("PetsWild"));
                    }

                    n["T"] = tmp;

                    g.PlayerID = note.PlayerID;
                    g.Save();
                    burden.Save();
                    GoodsList.Remove(v);
                    if (email.Value.GetIntOrDefault("Coin") <= 0 && email.Value.GetIntOrDefault("Score") <= 0 && GoodsList.Count == 0)
                    {
                        email.Value["IsHave"] = 0;
                    }
                    email.Save();

                    note.Call(EmailCommand.ExtractGoodsR, true, GoodsID);
                    if (Score != 0)
                    {
                        ev.Save();
                        PlayerBusiness OnLineBusiness = PlayersProxy.FindPlayerByID(email.Value.GetStringOrDefault("SendID"));
                        if (OnLineBusiness != null && OnLineBusiness.Online)
                        {
                            OnLineBusiness.Call(EmailCommand.NewEmailTotalR, EmailAccess.Instance.NewTotal(note.PlayerID));
                        }
                    }
                    note.Player.UpdateTaskGoods(g.GoodsID);
                    //Variant list = new Variant();
                    //list.Add("B0", burden);
                    //note.Call(BurdenCommand.BurdenListR, list);
                    note.Player.UpdateBurden();
                    return;
                }

                GameConfig gc = GameConfigAccess.Instance.FindOneById(SoleID);
                if (gc != null)
                {
                    //道具数量
                    int num = v.GetIntOrDefault("Number");
                    //是否绑定
                    int h = v.GetIntOrDefault("H");
                    Dictionary<string, Variant> dic = new Dictionary<string, Variant>();
                    Variant mv = new Variant();
                    if (h == 0)
                    {
                        mv.Add("Number0", num);
                    }
                    else
                    {
                        mv.Add("Number1", num);
                    }
                    dic.Add(SoleID, mv);
                    //得到堆叠数

                    if (BurdenManager.IsFullBurden(note.Player.B0, dic))
                    {
                        note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.BurdenFull));
                        return;
                    }

                    if (Score > 0)
                    {
                        if (!note.Player.AddScore(-Score, FinanceType.ExtractGoods))
                        {
                            note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.NoScore));
                            return;
                        }
                    }

                    GoodsList.Remove(v);
                    if (email.Value.GetIntOrDefault("Coin") <= 0 && email.Value.GetIntOrDefault("Score") <= 0 && GoodsList.Count == 0)
                    {
                        email.Value["IsHave"] = 0;
                    }
                    email.Save();
                    note.Call(EmailCommand.ExtractGoodsR, true, GoodsID);
                    note.Player.AddGoods(dic, GoodsSource.GM);
                    return;
                }
                note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.DataError));
            }
            finally
            {
                string n;
                m_dic.TryRemove(note.PlayerID, out n);
            }
        }