Ejemplo n.º 1
0
        public void TestListAdd()
        {
            Variant v = new Variant(Variant.EnumType.List);

            Assert.Throws<VariantException>(delegate { v.Add("key", new Variant()); });
            Assert.Throws<VariantException>(delegate { v.Add(new DateTime(0), new Variant()); });

            v.Add(new Variant("value1"));
            v.Add(new Variant(2.0));

            Assert.AreEqual(v.Count, 2);
            Assert.IsFalse(v.Empty);

            Assert.AreEqual(Variant.EnumType.String, v[0].Type);
            Assert.AreEqual("value1", v[0].As<string>());
            Assert.AreEqual(Variant.EnumType.Double, v[1].Type);
            Assert.AreEqual(2.0, v[1].As<double>());

            Assert.Throws<VariantException>(delegate { Variant w = v[-1]; });
            Assert.Throws<VariantException>(delegate { Variant w = v[2]; });

            v[0] = new Variant("other");
            Assert.AreEqual(v[0].As<string>(), "other");

            v.Clear();
            Assert.AreEqual(v.Count, 0);
            Assert.IsTrue(v.Empty);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// GM取得拍卖行数据
        /// </summary>
        /// <param name="note"></param>
        public static object GMAuctionList(Notification note)
        {
            string[] strs = GMBusiness.GetCommand(note);
            if (strs.Length < 3)
                return null;
            PlayerBusiness player = PlayersProxy.FindPlayerByName(strs[0].Trim());
            if (player == null)
                return null;
            int pageIndex = 0;

            if (!int.TryParse(strs[1].Trim(), out pageIndex))
                return null;
            int pageSize = 6;

            int total = 0;
            int curIndex = 0;
            List<Auction> auctionList = AuctionAccess.Instance.AuctionSellerList(player.ID, pageSize, pageIndex, out total, out curIndex);
            List<Variant> list = new List<Variant>();
            foreach (Auction model in auctionList)
            {
                Variant mv = model.Value;
                Variant v = new Variant();
                foreach (var item in mv)
                {
                    v.Add(item.Key, item.Value);
                }
                v.Add("ID", model.ID);
                v.Add("Name", model.Name);
                list.Add(v);
            }
            return new object[] { list, total, curIndex };
        }
Ejemplo n.º 3
0
        /// <summary>
        /// GM取得拍卖行数据
        /// </summary>
        /// <param name="note"></param>
        /// <param name="strs"></param>
        public static void GMAuctionList(GMNote note, string[] strs)
        {
            if (strs.Length < 3)
                return;
            PlayerBusiness player = PlayersProxy.FindPlayerByName(strs[0].Trim());
            if (player == null)
                return;
            int pageIndex = 0;

            if (!int.TryParse(strs[1].Trim(), out pageIndex))
                return;
            int pageSize = 6;

            int total = 0;
            int curIndex = 0;
            List<Auction> auctionList = AuctionAccess.Instance.AuctionSellerList(player.ID, pageSize, pageIndex, out total, out curIndex);
            List<Variant> list = new List<Variant>();
            foreach (Auction model in auctionList)
            {
                Variant mv = model.Value;
                Variant v = new Variant();
                foreach (var item in mv)
                {
                    v.Add(item.Key, item.Value);
                }
                v.Add("ID", model.ID);
                v.Add("Name", model.Name);
                list.Add(v);
            }
            note.Call(GMCommand.GMAuctionListR, list, total, curIndex);
        }
Ejemplo n.º 4
0
        public void TestBagAdd()
        {
            Variant v = new Variant(Variant.EnumType.Bag);

            Assert.Throws<VariantException>(delegate { v.Add(new Variant()); });
            Assert.Throws<VariantException>(delegate { v.Add(new DateTime(0), new Variant()); });

            v.Add("key1", new Variant("value1"));
            v.Add("key2", new Variant(1.0));
            v.Add("key1", new Variant("value2"));

            Assert.AreEqual(v.Count, 3);
            Assert.IsFalse(v.Empty);

            Assert.IsTrue(v.ContainsKey("key1"));
            Assert.IsTrue(v.ContainsKey("key2"));

            Assert.AreEqual(v["key1"].Type, Variant.EnumType.String);
            Assert.AreEqual(v["key1"].As<string>(), "value1");
            Assert.AreEqual(v["key2"].Type, Variant.EnumType.Double);
            Assert.AreEqual(v["key2"].As<double>(), 1.0);

            v["key1"] = new Variant("other");
            Assert.AreEqual(v["key1"].As<string>(), "other");

            v.Remove("key1");
            Assert.AreEqual(1, v.Count);

            v.Remove("key2");
            Assert.AreEqual(v.Count, 0);
            Assert.IsTrue(v.Empty);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 添加好友
        /// </summary>
        /// <param name="note"></param>
        public static void AddFriends(UserNote note)
        {
            string name = note.GetString(0);
            if (note.Player.Name == name)
            {
                return;
            }
            PlayerEx social = note.Player.Social;
            if (social == null)
            {
                note.Call(SocialCommand.AddFriendsR, false, TipManager.GetMessage(SocialReturn.UserInfoError));
                return;
            }

            PlayerBusiness player = PlayersProxy.FindPlayerByName(name);
            if (player == null)
            {
                note.Call(SocialCommand.AddFriendsR, false, TipManager.GetMessage(SocialReturn.UserInfoError));
                return;
            }

            if (social.Value != null)
            {
                if (SocialBusiness.IsLet(social, player.ID, new List<string> { "Friends" }))
                {
                    note.Call(SocialCommand.AddFriendsR, false, TipManager.GetMessage(SocialReturn.Friends));
                    return;
                }

                if (SocialBusiness.IsLet(social, player.ID, new List<string> { "Enemy" }))
                {
                    note.Call(SocialCommand.AddFriendsR, false, TipManager.GetMessage(SocialReturn.Master));
                    return;
                }
            }

            Variant v = new Variant();
            v.Add("PlayerID", player.ID);
            v.Add("Created", DateTime.UtcNow);
            IList list = social.Value.GetValue<IList>("Friends");
            int num = 0;
            if (list == null)
            {
                social.Value["Friends"] = new List<Variant>() { v };
                num = 1;
            }
            else
            {
                list.Add(v);
                num = list.Count;
            }
            social.Save();

            note.Call(SocialCommand.AddFriendsR, true, new PlayerSimple(player, 3));

            //添加好友
            note.Player.FinishNote(FinishCommand.Friends, num);
        }
Ejemplo n.º 6
0
        public void TestBag()
        {
            Variant v1 = new Variant(Variant.EnumType.Bag);
            v1.Add("key1", new Variant("value1"));
            v1.Add("key2", new Variant(1.0));

            byte[] bytes = BinaryWriter.ToBytes(v1);
            Variant v2 = BinaryReader.FromBytes(bytes);

            Assert.AreEqual(v2.Type, Variant.EnumType.Bag);
            Assert.IsTrue(v1.Equals(v2));
        }
Ejemplo n.º 7
0
        public void TestList()
        {
            Variant v1 = new Variant(Variant.EnumType.List);
            v1.Add(new Variant("value1"));
            v1.Add(new Variant(1.0));

            string xml = XmlWriter.ToString(v1);
            Variant v2 = XmlReader.FromString(xml);

            Assert.AreEqual(v2.Type, Variant.EnumType.List);
            Assert.IsTrue(v1.Equals(v2));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 进入扣除
        /// </summary>
        /// <param name="player"></param>
        public override bool IntoPart(PlayerBusiness player)
        {
            if (BurdenManager.GoodsCount(player.B0, m_elements[0]) > 0)
            {
                //请先处理包袱中的【守护凭证】后再进入
                player.Call(ClientCommand.IntoSceneR, false, null,TipManager.GetMessage(ClientReturn.ProBusiness1));
                return false;
            }

            Dictionary<string, Variant> dic = new Dictionary<string, Variant>();
            Variant v = new Variant();
            v.Add("Number1", 1);
            v.Add("EndTime", this.EndTime.AddHours(1));//活动结束后一个小时道具过期

            dic.Add(m_elements[0], v);

            if (BurdenManager.IsFullBurden(player.B0, dic))
            {
                //包袱满,请整理你的包袱再进行该操作
                player.Call(ClientCommand.IntoSceneR, false, null, TipManager.GetMessage(ClientReturn.ProBusiness2));
                return false;
            }

            bool pass = (m_part.Coin == 0 && m_part.Score == 0);
            if ((!pass) && m_part.Score > 0)
            {
                pass = player.AddScore(-m_part.Score, FinanceType.Part);
            }
            if ((!pass) && m_part.Coin > 0)
            {
                pass = player.AddCoin(-m_part.Coin, FinanceType.Part);
            }
            if (!pass)
            {
                player.Call(ClientCommand.IntoSceneR, false, null, m_part.CoinMsg);
                return false;
            }

            if (m_part.MaxInto > 0)
            {
                m_playerInto.SetOrInc(player.PID, 1);
            }

            //进入场景成功,发送道具
            player.AddGoods(dic, GoodsSource.Pro);
            player.MoreFight = 0;
            player.NoFight = 0;
            player.Call(ActivityCommand.GetDefendCardR, MainScene.Players.Count);
            //进入守护战争,记录活跃度
            player.AddAcivity(ActivityType.Pro, 1);
            return true;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 添加仇人
        /// </summary>
        /// <param name="note"></param>
        public static void AddEnemy(UserNote note)
        {
            string name = note.GetString(0);

            PlayerEx Social = note.Player.Social;
            if (Social == null)
            {
                note.Call(SocialCommand.AddEnemyR, false, TipManager.GetMessage(SocialReturn.UserInfoError));
                return;
            }
            PlayerBusiness player = PlayersProxy.FindPlayerByName(name);
            if (player == null)
            {
                note.Call(SocialCommand.AddEnemyR, false, TipManager.GetMessage(SocialReturn.UserInfoError));
                return;
            }
            if (SocialBusiness.IsLet(Social, player.ID, new List<string> { "Enemy" }))
            {
                note.Call(SocialCommand.AddEnemyR, false, TipManager.GetMessage(SocialReturn.Enemy));
                return;
            }
            if (SocialBusiness.IsLet(Social, player.ID, new List<string> {  "Friends" }))
            {
                note.Call(SocialCommand.AddEnemyR, false, TipManager.GetMessage(SocialReturn.Friends));
                return;
            }
            if (SocialBusiness.IsLet(Social, player.ID, new List<string> {  "Apprentice" }))
            {
                note.Call(SocialCommand.AddEnemyR, false, TipManager.GetMessage(SocialReturn.Apprentice));
                return;
            }
            if (SocialBusiness.IsLet(Social, player.ID, new List<string> {  "Master" }))
            {
                note.Call(SocialCommand.AddEnemyR, false, TipManager.GetMessage(SocialReturn.Master));
                return;
            }

            IList Enemy = Social.Value.GetValue<IList>("Enemy");
            Variant v = new Variant();
            v.Add("PlayerID", player.ID);
            v.Add("Created", DateTime.UtcNow);
            if (Enemy == null)
            {
                Social.Value["Enemy"] = new List<Variant> { v };
            }
            else
            {
                Enemy.Add(v);
            }
            Social.Save();
            note.Call(SocialCommand.AddEnemyR, true, new PlayerSimple(player, 3));
        }
Ejemplo n.º 10
0
        public void TestTSAdd()
        {
            Variant v = new Variant(Variant.EnumType.TimeSeries);

            Assert.Throws<VariantException>(delegate { v.Add(new Variant()); });
            Assert.Throws<VariantException>(delegate { v.Add("key", new Variant()); });

            v.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value1"));
            v.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant(1.0));

            Assert.AreEqual(v.Count, 2);
            Assert.IsFalse(v.Empty);
        }
Ejemplo n.º 11
0
        public void TestListComparison()
        {
            Variant v1 = new Variant(Variant.EnumType.List);
            v1.Add(new Variant("value1"));
            v1.Add(new Variant("value2"));

            Variant v2 = new Variant(Variant.EnumType.List);
            v2.Add(new Variant("value2"));
            v2.Add(new Variant("value1"));

            Assert.AreEqual(0, v1.CompareTo(v1));
            Assert.AreEqual(-1, v1.CompareTo(v2));
            Assert.AreEqual(1, v2.CompareTo(v1));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 申请交易
        /// </summary>
        /// <param name="note"></param>
        public static void DealApply(UserNote note)
        {
            string playerid = note.GetString(0);

            if (note.Player.Value.ContainsKey("Deal"))
            {
                note.Call(DealCommand.DealApplyR, false, TipManager.GetMessage(DealReturn.DealOther));
                return;
            }
            PlayerBusiness OnlineBusiness = PlayersProxy.FindPlayerByID(playerid);
            if (OnlineBusiness == null || (!OnlineBusiness.Online))
            {
                note.Call(DealCommand.DealApplyR, false, TipManager.GetMessage(DealReturn.NoLine));
                return;
            }

            if (OnlineBusiness.AState == ActionState.Fight)
            {
                note.Call(DealCommand.DealApplyR, false, TipManager.GetMessage(DealReturn.Fighting));
                return;
            }

            if (OnlineBusiness.Value.ContainsKey("Deal"))
            {
                Variant dy = OnlineBusiness.Value.GetVariantOrDefault("Deal");
                if (dy.GetIntOrDefault("Status") >= 0)
                {
                    note.Call(DealCommand.DealApplyR, false, TipManager.GetMessage(DealReturn.DealOther));
                    return;
                }
            }

            Variant d0 = new Variant();
            d0.Add("Status", 0);
            d0.Add("PlayerID", playerid);//被邀请者
            d0.Add("Goods", null);
            if (!note.Player.Value.ContainsKey("Deal"))
                note.Player.Value.Add("Deal", d0);

            Variant d1 = new Variant();
            d1.Add("Status", 0);
            d1.Add("PlayerID", note.PlayerID);//邀请者
            d1.Add("Goods", null);
            if (!OnlineBusiness.Value.ContainsKey("Deal"))
                OnlineBusiness.Value.Add("Deal", d1);

            OnlineBusiness.Call(DealCommand.DealApplyR, true, note.PlayerID);
            note.Call(DealCommand.DealApplyR, true, note.PlayerID);
        }
Ejemplo n.º 13
0
 /// <summary>
 /// 加入家族
 /// </summary>
 /// <param name="note"></param>
 /// <returns></returns>
 public static Variant PersonInfo(string playerid, int roleid)
 {
     Variant d = new Variant();
     d.Add("PlayerID", playerid);//用户ID
     d.Add("AddDate", DateTime.UtcNow);//添加时间
     d.Add("Devote", 0);//玩家贡献
     d.Add("RoleID", roleid);//职业0族长,1副族长,2族员
     d.Add("Fire", 0);//开除权限,0没有,1有
     //d.PlayerID = playerid;//用户ID
     //d.AddDate = DateTime.UtcNow;//添加时间
     //d.Devote = 0;//玩家贡献
     //d.RoleID = roleid;//职业0族长,1副族长,2族员
     //d.Fire = 0;//开除权限,0没有,1有
     return d;
 }
Ejemplo n.º 14
0
        /// <summary>
        /// 添加点券
        /// </summary>
        /// <param name="bond"></param>
        /// <param name="eType"></param>
        /// <param name="des"></param>
        /// <returns></returns>
        public bool AddBond(int bond, FinanceType ft, string remark = null)
        {
            if (bond != 0)
            {
                BsonDocument modified = PlayerAccess.Instance.SafeUpdate(_id, "Bond", bond);
                if (modified == null)
                {
                    return false;
                }
                long newBond = Convert.ToInt64(modified["Bond"]);
                this.Bond = newBond;
                Variant v = new Variant(2);
                v.Add("Bond", this.Bond);

                this.UpdataActorR(v);
                //写日志
                PayLog log = new PayLog(ServerLogger.zoneid, Actiontype.Bond);
                log.modifyfee = bond;
                log.totalfee = newBond;
                log.toopenid = UserID;
                log.touid = PID;
                log.reserve_1 = (int)ft;
                log.remark = remark;
                this.WriteLog(log);
            }
            return true;
        }
Ejemplo n.º 15
0
        protected override void Exec()
        {
            if (PlayerAccess.Instance.FightValueClear())
            {
                //在线用户列表
                foreach (PlayerBusiness user in PlayersProxy.Players)
                {
                    user.FightValue = 0;

                    Variant v = new Variant();
                    v.Add("ID", user.ID);
                    v.Add("FightValue", user.FightValue);
                    user.Call(ClientCommand.UpdateActorR, v);
                }
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 /// 创建家族的动态值
 /// </summary>
 /// <param name="note"></param>
 /// <returns></returns>
 public static Variant FamilyValue(UserNote note)
 {
     Variant d = new Variant();
     d.Add("Level", 1);
     d.Add("Experience", 0);
     d.Add("Notice", string.Empty);
     d.Add("Persons", new List<Variant>() { PersonInfo(note.PlayerID, 0) });
     d.Add("Skill", null);
     //d.Add("Level", 1);
     //d.Level = 1;
     //d.Experience = 0;
     //d.Notice = string.Empty;
     //d.Persons = new List<Variant>() { PersonInfo(note.PlayerID,0) };
     //d.Skill = null;//技能
     return d;
 }
Ejemplo n.º 17
0
        /// <summary>
        /// 领取奖励
        /// </summary>
        /// <param name="note"></param>
        public static void BossAward(UserNote note)
        {
            string fid = note.Player.Family.Value.GetStringOrDefault("FamilyID");
            if (string.IsNullOrEmpty(fid))
            {
                note.Call(FamilyCommand.BossAwardR, false, TipManager.GetMessage(FamilyReturn.NoAddFamily));
                return;
            }

            string bid = note.GetString(0);
            var p = GameConfigAccess.Instance.FindOneById(bid);
            if (p == null)
            {
                return;
            }

            string gid = note.GetString(1); //FamilyBossAccess.Instance.ViewAward(fid + bid, note.Player.ID);
            if (string.IsNullOrEmpty(gid))
            {
                return;
            }

            string[] tt = gid.Split('$');
            int number = 1;
            if (tt.Length != 2 || (!int.TryParse(tt[1], out number)))
            {
                number = 1;
            }
            string goodsid = tt[0];

            //TODO:检查包袱
            Dictionary<string, Variant> goods = new Dictionary<string, Variant>();
            Variant tmp = new Variant();
            tmp.Add("Number1", number);
            goods.Add(goodsid, tmp);
            if (BurdenManager.GetBurdenSpace(note.Player.B0.Value.GetValue<IList>("C")) == null)
            {
                note.Call(FamilyCommand.BossAwardR, false, TipManager.GetMessage(ActivityReturn.SignAward4));
                return;
            }

            //if (BurdenManager.IsFullBurden(note.Player.B0, goods))
            //{
            //    note.Call(FamilyCommand.BossAwardR, false, TipManager.GetMessage(ActivityReturn.SignAward4));
            //    return;
            //}

            if (FamilyBossAccess.Instance.GetAward(fid + bid, note.Player.ID, gid))
            {
                //发放物品
                note.Player.AddGoods(goods, GoodsSource.FamilyBoss);
                note.Call(FamilyCommand.BossAwardR, true, gid);
            }
            else
            {
                //已领取..
                note.Call(FamilyCommand.BossAwardR, false, TipManager.GetMessage(FamilyReturn.CannotBossAward));
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// 清理完成条件
 /// </summary>
 /// <returns></returns>
 public static Variant FinishClear()
 {
     Variant v = new Variant();
     foreach (string k in m_dic.Keys)
     {
         v.Add(k, 0);
     }
     return v;
 }
Ejemplo n.º 19
0
 /// <summary>
 /// 奖励清理
 /// </summary>
 /// <returns></returns>
 public static Variant AwardClear()
 {
     Variant v = new Variant();
     foreach (int k in n_dic.Keys)
     {
         v.Add(k.ToString(), 0);
     }
     return v;
 }
Ejemplo n.º 20
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.º 21
0
        /// <summary>
        /// 计算装备磨损
        /// </summary>
        private void Abrade()
        {
            int index = NumberRandom.Next(10);
            var p = m_equips.Value.GetVariantOrDefault("P" + index);

            if (p == null)
                return;

            string goodsid = p.GetStringOrDefault("E");

            if (string.IsNullOrEmpty(goodsid))
                return;

            Goods g = GoodsAccess.Instance.FindOneById(goodsid);

            if (g == null)
                return;

            Variant v = g.Value;
            if (v == null)
                return;

            Variant stamina = v.GetVariantOrDefault("Stamina");
            if (stamina.GetIntOrDefault("V") <= 0)
                return;

            stamina.SetOrInc("V", -1);
            if (!g.Save())
                return;

            Variant t = new Variant();
            t.Add("ID", g.ID);
            t.Add("Stamina", stamina);
            //更新道具持久度
            Call(GoodsCommand.GetGoodsDetailR, true, t);

            //重新计算角色属性
            if (stamina.GetIntOrDefault("V") <= 0)
            {
                RefreshPlayer(string.Empty, null, ResetEquipsAdd);
            }
            Call(GoodsCommand.GetEquipPanelR, true, g.ID);
        }
Ejemplo n.º 22
0
        public void TestTSEnumeration()
        {
            Variant v = new Variant(Variant.EnumType.TimeSeries);

            v.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value1"));
            v.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value2"));

            IEnumerator<VariantItem> en = v.GetEnumerator();

            en.Reset();
            Assert.IsTrue(en.MoveNext());
            Assert.Throws<VariantException>(delegate { string k = en.Current.Key; });
            Assert.AreEqual("value1", en.Current.Value.As<string>());
            Assert.AreEqual(new DateTime(2010, 1, 2, 3, 4, 5, 6), en.Current.Time);
            Assert.IsTrue(en.MoveNext());
            Assert.Throws<VariantException>(delegate { string k = en.Current.Key; });
            Assert.AreEqual("value2", en.Current.Value.As<string>());
            Assert.AreEqual(new DateTime(2010, 1, 3, 3, 4, 5, 6), en.Current.Time);
            Assert.IsFalse(en.MoveNext());
        }
Ejemplo n.º 23
0
        public void TestTSComparison()
        {
            Variant v1 = new Variant(Variant.EnumType.TimeSeries);
            v1.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value1"));
            v1.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value2"));

            Variant v2 = new Variant(Variant.EnumType.TimeSeries);
            v2.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value1"));
            v2.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value2"));

            Variant v3 = new Variant(Variant.EnumType.TimeSeries);
            v3.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value2"));
            v3.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value1"));

            Assert.AreEqual(0, v1.CompareTo(v1));
            Assert.AreEqual(-1, v1.CompareTo(v2));
            Assert.AreEqual(1, v2.CompareTo(v1));
            Assert.AreEqual(-1, v1.CompareTo(v3));
            Assert.AreEqual(1, v3.CompareTo(v1));
        }
Ejemplo n.º 24
0
        public void TestBagComparison()
        {
            Variant v1 = new Variant(Variant.EnumType.Bag);
            v1.Add("key1", new Variant("value1"));
            v1.Add("key2", new Variant("value2"));

            Variant v2 = new Variant(Variant.EnumType.Bag);
            v2.Add("key1", new Variant("value1"));
            v2.Add("key2", new Variant("value2"));

            Variant v3 = new Variant(Variant.EnumType.Bag);
            v3.Add("key2", new Variant("value1"));
            v3.Add("key3", new Variant("value2"));

            Variant v4 = new Variant(Variant.EnumType.Bag);
            v4.Add("key1", new Variant("value2"));
            v4.Add("key2", new Variant("value3"));

            Assert.AreEqual(0, v1.CompareTo(v2));
            Assert.AreEqual(-1, v1.CompareTo(v3));
            Assert.AreEqual(1, v3.CompareTo(v1));
            Assert.AreEqual(-1, v1.CompareTo(v4));
            Assert.AreEqual(1, v4.CompareTo(v1));
        }
Ejemplo n.º 25
0
        private void MosaicNeed(UserNote note)
        {
            string goodsid = note.GetString(0);
            Goods g = GoodsAccess.Instance.GetGoodsByID(goodsid, note.PlayerID);
            if (g == null)
            {
                note.Call(MosaicCommand.MosaicNeedR, false, TipManager.GetMessage(MosaicReturn.MosaicEquipNo));
                return;
            }

            if (g.Value.GetIntOrDefault("IsChange") == 0)
            {
                note.Call(ExchangeCommand.ExchangNeedR, false, TipManager.GetMessage(MosaicReturn.MosaicNoChange));
                return;
            }

            Variant BaoShiInfo = g.Value.GetVariantOrDefault("BaoShiInfo");

            bool IsLet = true;
            foreach (string d in BaoShiInfo.Keys)
            {
                if (BaoShiInfo[d].ToString() != "-1")
                {
                    IsLet = false;
                    break;
                }
            }

            if (IsLet)
            {
                note.Call(MosaicCommand.MosaicNeedR, false, TipManager.GetMessage(MosaicReturn.MosaicNoLet));
                return;
            }

            List<GameConfig> mosaic = GameConfigAccess.Instance.Find("Mosaic");
            GameConfig gc = null;
            foreach (GameConfig gcg in mosaic)
            {
                if (gcg.Value.GetStringOrDefault("Type") == g.Value.GetStringOrDefault("GoodsType"))
                {
                    gc = gcg;
                    break;
                }
            }

            if (gc == null)
            {
                note.Call(MosaicCommand.MosaicNeedR, false, TipManager.GetMessage(MosaicReturn.MosaicNoLet));
                return;
            }

            string UpID = gc.Value.GetStringOrDefault("UpID");

            int UpCount = 0;

            PlayerEx b = note.Player.B0;
            foreach (Variant con in b.Value.GetValueOrDefault<IList>("C"))
            {
                if (con.GetStringOrDefault("G") == UpID)
                    UpCount += con.GetIntOrDefault("A");
            }
            //可以镶嵌的宝石
            IList MosaicNeed = gc.Value.GetValue<IList>("MosaicNeed");

            List<string> bs = new List<string>();
            foreach (string key in MosaicNeed)
            {
                GameConfig tmp = GameConfigAccess.Instance.FindOneById(key);
                if (tmp == null)
                    continue;
                if (g.Value.GetIntOrDefault("Level") >= tmp.Value.GetIntOrDefault("Level"))
                {
                    bs.Add(tmp.ID);
                }
            }

            if (bs.Count == 0)
            {
                note.Call(MosaicCommand.MosaicNeedR, false, TipManager.GetMessage(MosaicReturn.MosaicNoLet));
                return;
            }
            Variant v = new Variant();
            v.Add("BaoShiInfo", bs);
            v.Add("UpID", UpID);
            v.Add("UpCount", UpCount);
            note.Call(MosaicCommand.MosaicNeedR, true, v);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 邮件相关信息
        /// </summary>
        /// <param name="playerid">发件人</param>
        /// <param name="name">发件人名称</param>
        /// <param name="receiveid">接收人</param>
        /// <param name="receivename">接收者名称</param>
        /// <param name="d">邮件内容</param>
        /// <returns></returns>
        public static Variant CreateEmailValue(string playerid, string name, string receiveid, string receivename, Variant d)
        {
            Variant v = new Variant();
            v.Add("SendID", playerid);
            v.Add("SendName", name);
            v.Add("ReceiveID", receiveid);
            v.Add("ReceiveName", receivename);
            v.Add("Content", d.GetValue<object>("mailMess"));
            DateTime dt = DateTime.UtcNow;
            v.Add("UpdateDate", dt);
            //邮件有效天数
            int day = Convert.ToInt32(TipManager.GetMessage(EmailReturn.HameDay));
            v.Add("EndDate", dt.AddDays(day));

            int IsHave = 0;
            if (d.ContainsKey("moneyGoods"))
            {
                Variant money = d.GetVariantOrDefault("moneyGoods");
                if (money.ContainsKey("Coin"))
                {
                    v.Add("Coin", money.GetIntOrDefault("Coin"));
                    IsHave = money.GetIntOrDefault("Coin") > 0 ? 1 : 0;
                }
                else
                {
                    v.Add("Coin", 0);
                }
                if (money.ContainsKey("Score"))
                {
                    v.Add("Score", money.GetIntOrDefault("Score"));
                    IsHave = money.GetIntOrDefault("Score") > 0 ? 1 : 0;
                }
                else
                {
                    v.Add("Score", 0);
                }
            }
            else
            {
                v.Add("Coin", 0);
                v.Add("Score", 0);
            }

            if (d.ContainsKey("goodsList"))
            {
                List<Variant> list = new List<Variant>();
                IList goodsList = d.GetValue<IList>("goodsList");
                foreach (Variant msg in goodsList)
                {
                    GameConfig gc = GameConfigAccess.Instance.FindOneById(msg.GetStringOrDefault("E"));
                    string goodsType = string.Empty;
                    int sort = 0;
                    if (gc != null)
                    {
                        goodsType = gc.Value.GetStringOrDefault("GoodsType");
                        sort = gc.Value.GetIntOrDefault("Sort");
                    }
                    else
                    {
                        if (gc == null)
                        {
                            Goods g = GoodsAccess.Instance.FindOneById(msg.GetStringOrDefault("E"));
                            if (g != null)
                            {
                                goodsType = g.Value.GetStringOrDefault("GoodsType");
                                sort = g.Value.GetIntOrDefault("Sort");
                            }
                            else
                            {
                                if (g == null)
                                {
                                    //查询是否是宠物
                                    Pet pet = PetAccess.Instance.FindOneById(msg.GetStringOrDefault("E"));
                                    if (pet != null)
                                    {
                                        goodsType = "Pet";
                                        sort = pet.Value.GetIntOrDefault("Sort");
                                    }
                                }
                            }
                        }
                    }
                    if (goodsType == string.Empty)
                        continue;

                    Variant gs = new Variant();
                    gs.Add("SoleID", msg.GetStringOrDefault("E"));
                    gs.Add("GoodsID", msg.GetStringOrDefault("G"));
                    gs.Add("Number", msg.GetIntOrDefault("A"));
                    gs.Add("GoodsType", goodsType);
                    gs.Add("Sort", sort);

                    gs.Add("Coin", msg.GetIntOrDefault("Coin"));
                    gs.Add("Score", msg.GetIntOrDefault("Score"));

                    gs.Add("T", msg.GetVariantOrDefault("T"));
                    list.Add(gs);
                }
                v.Add("GoodsList", list);
                if (list.Count > 0)
                {
                    IsHave = 1;
                }
            }
            v.Add("IsHave", IsHave);
            return v;
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 熔炼,主要是将装备销除得到新的道具和取下镶嵌的宝石,只能够选择一颗宝石
        /// </summary>
        /// <param name="note"></param>
        private void Melt(UserNote note)
        {
            //熔练配置信息
            //string id = note.GetString(0);
            //熔炼的道具
            string goodsid = note.GetString(0);
            //选择宝石,-1表示没有选择
            string baoshi = note.GetString(1);

            //熔炼的道具信息
            Goods g = GoodsAccess.Instance.GetGoodsByID(goodsid, note.PlayerID);

            if (g == null)
            {
                note.Call(MeltCommand.MeltR, false, TipManager.GetMessage(MeltReturn.MeltEquipNo));
                return;
            }
            //熔炼物品的绑定状态
            int isBinding = g.Value.GetIntOrDefault("IsBinding");
            if (g.Value.GetIntOrDefault("IsChange") == 0)
            {
                note.Call(MeltCommand.MeltR, false, TipManager.GetMessage(MeltReturn.MeltNoChange));
                return;
            }

            if (g.Value.GetStringOrDefault("GoodsType").IndexOf("111") != 0)
            {
                note.Call(MeltCommand.MeltR, false, TipManager.GetMessage(MeltReturn.MeltEquipNo));
                return;
            }
            Variant Price = g.Value.GetValueOrDefault<Variant>("Price");
            Variant Buy = Price.GetValueOrDefault<Variant>("Buy");
            double Score = Math.Round(Buy.GetIntOrDefault("Score") * 0.5);
            if (Score > note.Player.Score)
            {
                note.Call(MeltCommand.MeltR, false, TipManager.GetMessage(MeltReturn.MeltNoScoreB));
                return;
            }
            string id = string.Empty;
            List<GameConfig> meltList = GameConfigAccess.Instance.Find("Split");
            foreach (GameConfig gcs in meltList)
            {
                if ((int)gcs.Value["Level"] == g.Value.GetIntOrDefault("Level"))
                {
                    //可以熔炼类型列表
                    IList ts = gcs.Value["Type"] as IList;
                    foreach (Variant m in ts)
                    {
                        if (m.GetStringOrDefault("GoodsType") == g.Value.GetStringOrDefault("GoodsType"))
                        {
                            id = gcs.ID;
                            break;
                        }
                    }
                }
            }

            //得到熔炼配置信息
            GameConfig gc = GameConfigAccess.Instance.FindOneById(id);
            if (gc == null)
            {
                note.Call(MeltCommand.MeltR, false, TipManager.GetMessage(MeltReturn.MeltConfigError));
                return;
            }
            //得到的道具
            IList v = gc.Value.GetValue<IList>("GetGoods");

            PlayerEx burden = note.Player.B0;
            IList c = burden.Value.GetValue<IList>("C");
            //包袱空格数
            int space = BurdenManager.BurdenSpace(c);
            //需要空格数
            int count = baoshi == "-1" ? v.Count : v.Count + 1;

            if (count > space)
            {
                //表示包袱不能存放可得到的物品
                note.Call(MeltCommand.MeltR, false, TipManager.GetMessage(MeltReturn.MeltBurdenFull));
                return;
            }
            List<Variant> list = new List<Variant>();

            Dictionary<string, PlayerEx> bus = new Dictionary<string, PlayerEx>();
            Dictionary<string, int> numberList = new Dictionary<string, int>();
            Dictionary<string, int> binds = new Dictionary<string, int>();
            Variant tmp;
            foreach (Variant m in v)
            {
                //得到的物品
                GameConfig getGoods = GameConfigAccess.Instance.FindOneById(m.GetStringOrDefault("GoodsID"));

                int a = BurdenManager.StactCount(getGoods);
                string name = "B0";
                if (a == 0)
                {
                    note.Call(MeltCommand.MeltR, false, TipManager.GetMessage(MeltReturn.MeltEquipError));
                    return;
                }
                PlayerEx b = note.Player.Value[name] as PlayerEx;
                if (!bus.ContainsKey(name)) bus.Add(name, b);

                if (!numberList.ContainsKey(getGoods.ID))
                    numberList.Add(getGoods.ID, m.GetIntOrDefault("Number"));
                else
                    numberList[getGoods.ID] += m.GetIntOrDefault("Number");

                if (!binds.ContainsKey(getGoods.ID)) binds.Add(getGoods.ID, isBinding);

                //TODO:得到的物品检查
                tmp = new Variant();
                tmp.Add("GoodsID", getGoods.ID);
                tmp.Add("Name", getGoods.Name);
                tmp.Add("Count", m.GetIntOrDefault("Number"));
                tmp.Add("IsGet", 1);
                list.Add(tmp);
            }
            if (baoshi != string.Empty)
            {
                GameConfig getBaoShi = GameConfigAccess.Instance.FindOneById(g.Value.GetVariantOrDefault("BaoShiInfo")[baoshi].ToString());
                if (getBaoShi != null)
                {
                    if (!bus.ContainsKey("B0"))
                    {
                        bus.Add("B0", note.Player.B0);
                    }
                    numberList.SetOrInc(getBaoShi.ID, 1);
                    if (!binds.ContainsKey(getBaoShi.ID))
                    {
                        binds.Add(getBaoShi.ID, isBinding);
                    }
                }
            }

            if (BurdenManager.BurdenIsFull(bus, numberList, binds))
            {
                note.Call(MeltCommand.MeltR, false, TipManager.GetMessage(MeltReturn.MeltBurdenFull));
                return;
            }

            BurdenManager.TaskGoodsInsert(bus, numberList, binds, note.PlayerID);

            #region 移除熔炼的装备
            foreach (Variant con in c)
            {
                if (con.GetStringOrDefault("E") == goodsid)
                {
                    tmp = new Variant();
                    tmp.Add("GoodsID", g.GoodsID);
                    tmp.Add("Name", g.Name);
                    tmp.Add("Count", con.GetIntOrDefault("A"));
                    tmp.Add("IsGet", 0);//0表示失去,1表示得到
                    list.Add(tmp);

                    //g.Mode = 1;
                    g.Save();

                    BurdenManager.BurdenClear(con);
                    break;
                }
            }
            #endregion

            burden.Save();
            note.Call(MeltCommand.MeltR, true, list);
            note.Player.UpdateBurden();
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 得到道具熔炼配置信息[完成]
        /// </summary>
        /// <param name="note"></param>
        private void MeltInfo(UserNote note)
        {
            string goodsid = note.GetString(0);
            Goods g = GoodsAccess.Instance.FindOneById(goodsid);
            if (g == null)
            {
                note.Call(MeltCommand.MeltInfoR, false, TipManager.GetMessage(MeltReturn.MeltEquipNo));
                return;
            }
            //不能改造
            if (g.Value.GetIntOrDefault("IsChange") == 0)
            {
                note.Call(MeltCommand.MeltInfoR, false, TipManager.GetMessage(MeltReturn.MeltNoChange));
                return;
            }
            //类型不正确
            if (g.Value["GoodsType"].ToString().IndexOf("111") != 0)
            {
                note.Call(MeltCommand.MeltInfoR, false, TipManager.GetMessage(MeltReturn.MeltEquipNo));
                return;
            }

            List<GameConfig> meltList = GameConfigAccess.Instance.Find("Split");

            foreach (GameConfig gc in meltList)
            {
                if ((int)gc.Value["Level"] == (int)g.Value["Level"])
                {
                    //可以熔炼类型列表
                    IList ts = gc.Value["Type"] as IList;
                    foreach (Variant m in ts)
                    {
                        if (m["GoodsType"].ToString() == g.Value["GoodsType"].ToString())
                        {
                            Variant v = new Variant();
                            v.Add("ID", gc.ID);
                            //得到当前装备宝石的信息-1表示没有打孔,0表示打孔没有镶嵌宝石,其它表示宝石ID
                            v.Add("BaoShiInfo", g.Value.GetVariantOrDefault("BaoShiInfo"));
                            //得到的可选道具列表
                            v.Add("GetGoods", gc.Value["GetGoods"]);
                            //熔炼需要币=买价*0.5,绑定游戏币
                            Variant Price = g.Value["Price"] as Variant;
                            Variant Buy = Price["Buy"] as Variant;

                            v.Add("Score", Math.Round(Convert.ToInt32(Buy["Score"]) * 0.5));
                            note.Call(MeltCommand.MeltInfoR, true, v);
                            return;
                        }
                    }
                }
            }

            note.Call(MeltCommand.MeltInfoR, false, TipManager.GetMessage(MeltReturn.MeltConfigError));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 得到社交用户列表信息
        /// </summary>
        /// <param name="note"></param>
        public static void SocialList(UserNote note)
        {
            string name = note.GetString(0);
            PlayerEx soc = note.Player.Social;
            List<PlayerSimple> list = new List<PlayerSimple>();
            if (soc != null && soc.Value != null)
            {
                IList ls = null;
                if (name == "Master" || name == "Apprentice")
                {
                    Variant d = soc.Value.GetVariantOrDefault("Mentor");
                    if (d != null) ls = d[name] as IList;
                }
                else
                {
                    ls = soc.Value[name] as IList;
                }

                if (ls != null && ls.Count != 0)
                {
                    list = SocialBusiness.SocialInfo(ls);
                }
            }

            Variant tmp = new Variant();
            tmp.Add(name, list);
            note.Call(SocialCommand.SocialListR, true, tmp);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 重置日常任务
        /// </summary>
        /// <param name="pb">当前在线</param>
        /// <param name="iscall"></param>
        public static void DayTask(PlayerBusiness pb, bool iscall = true)
        {
            string[] strs = TipManager.GetMessage(TaskReturn.DayTaskConfig).Split('|');

            if (strs.Length < 2)
                return;

            List<string> list = TaskAccess.Instance.Remove_1(pb.ID, 2);
            if (iscall)
            {
                foreach (string id in list)
                {
                    pb.Call(TaskCommand.GiveupR, true, id);
                }
            }

            int total = Convert.ToInt32(strs[0]);
            int max = Convert.ToInt32(strs[1]);

            PlayerEx ex;
            Variant v = null;

            if (pb.Value.ContainsKey("DayTask"))
            {
                ex = pb.Value["DayTask"] as PlayerEx;
                v = ex.Value;
                //表示时间到,更新日常任务的当前值
                if (v.GetLocalTimeOrDefault("NowData").Date != DateTime.Now.Date)
                {
                    v["Cur"] = 0;
                    v["Total"] = total;//
                    v["Max"] = max;//最大日常任务数量
                    v["NowData"] = DateTime.UtcNow;
                }
            }
            else
            {
                ex = new PlayerEx(pb.ID, "DayTask");
                v = new Variant();
                v.Add("Cur", 0);//当前完成数量
                v.Add("Total", total);//默认可以执行次数
                v.Add("Max", max);//每天最多允许执行次数
                v.Add("NowData", DateTime.UtcNow);//谋一天
                ex.Value = v;
                ex.Save();
                pb.Value.Add("DayTask", ex);
            }
            //更新一次,通知客户端
            if (v != null && v.GetIntOrDefault("Cur") < v.GetIntOrDefault("Total"))
            {
                if (!TaskAccess.Instance.IsDayTask(pb.ID,2))
                {
                    //表示当天日常任务已经完成
                    GameConfig gc = GameConfigAccess.Instance.GetDayTaskOne(pb.Level, 2);
                    if (gc != null)
                    {
                        Task t = TaskAccess.Instance.TaskBase(pb.ID, pb.RoleID, gc,0,0);
                        if (t != null)
                        {
                            v["Cur"] = v.GetIntOrDefault("Cur") + 1;
                            if (iscall)
                            {
                                pb.Call(TaskCommand.TaskActivationR, TaskAccess.Instance.GetTaskInfo(t));
                            }
                        }
                    }
                }
                else
                {
                    v["Cur"] = v.GetIntOrDefault("Cur") == 0 ? 1 : v.GetIntOrDefault("Cur");
                }
            }
            //如果成在变化测发送
            ex.Save();
            pb.Call(ClientCommand.UpdateActorR, new PlayerExDetail(ex));
        }