コード例 #1
0
ファイル: TeamCaptainMediator.cs プロジェクト: abel/sinan
 /// <summary>
 /// 队长返回请求结果
 /// </summary>
 /// <param name="note"></param>
 private void ReplyApply(UserNote note, PlayerTeam team)
 {
     bool reply = note.GetBoolean(0);
     string memberID = note.GetString(1);
     int check = note.GetInt32(2);
     PlayerBusiness member;
     if (note.Player.Scene.TryGetPlayer(memberID, out member))
     {
         if (member.GetHashCode() == check)
         {
             if (reply)
             {
                 if (team.TryAddMember(member))
                 {
                     var members = team.AllPlayerDetail;
                     member.Call(TeamCommand.IntoTeamR, true, new object[] { team, members });
                     note.Player.CallAllExcludeOne(member, TeamCommand.NewMemberR, team.TeamID, new PlayerDetail(member));
                     return;
                 }
             }
             else //不同意
             {
                 //对方拒绝了你的入队请求
                 member.Call(TeamCommand.IntoTeamR, false, TipManager.GetMessage(ClientReturn.ReplyApply1));
             }
         }
     }
 }
コード例 #2
0
ファイル: PetMediator.cs プロジェクト: abel/sinan
        /// <summary>
        /// 放养
        /// </summary>
        /// <param name="note"></param>
        public void Stocking(UserNote note)
        {
            //宠物
            string id = note.GetString(0);
            bool isStocking = note.GetBoolean(1);
            if (note.Player.SceneID != SceneHome.DefaultID)
            {
                //不能在【{0}】场景{1}
                string str = string.Format(TipManager.GetMessage(PetsReturn.NoSceneID), note.Player.Scene.Name);
                note.Call(PetsCommand.StockingR, false, isStocking, str);
                return;
            }

            #region 家园驯化完成的宠物直接放养
            if (note.GetInt32(2) == 1)
            {
                PlayerEx home = note.Player.Home;
                Variant pk = home.Value["PetKeep"] as Variant;
                if (pk.GetIntOrDefault("PetsWild") != -1)
                {
                    note.Call(PetsCommand.StockingR, false, isStocking, TipManager.GetMessage(PetsReturn.NoExists));
                    //还不能放养
                    return;
                }
                if (pk.GetStringOrDefault("ID") != id)
                {
                    note.Call(PetsCommand.StockingR, false, isStocking, TipManager.GetMessage(PetsReturn.NoExists));
                    return;
                }
                Pet px = PetAccess.Instance.FindOneById(id);
                PlayerEx b2 = note.Player.B2;
                IList c2 = b2.Value.GetValue<IList>("C");
                Variant v2 = null;
                foreach (Variant v in c2)
                {
                    if (v.GetStringOrDefault("E") == string.Empty)
                    {
                        v2 = v;
                        break;
                    }
                }
                if (v2 == null)
                {
                    note.Call(PetsCommand.StockingR, false, isStocking, TipManager.GetMessage(PetsReturn.PetBurdenB2));
                    return;
                }

                v2["E"] = px.ID;
                v2["G"] = px.Value.GetStringOrDefault("PetsID");
                v2["S"] = px.Value.GetIntOrDefault("Sort");
                v2["H"] = px.Value.GetIntOrDefault("IsBinding");
                v2["A"] = 1;
                v2["D"] = 0;
                v2["R"] = px.Value.GetIntOrDefault("PetsRank");
                v2["I"] = 0;

                pk["ID"] = string.Empty;
                pk["PetID"] = string.Empty;
                pk["StartTime"] = string.Empty;
                pk["EndTime"] = string.Empty;
                pk["PetsWild"] = 0;
                pk["PetName"] = string.Empty;
                pk["PetsRank"] = 0;
                v2["T"] = PetAccess.Instance.CreateAward(note.Player.Level, id, note.PlayerID, note.Player.Pet);

                home.Save();
                b2.Save();

                note.Call(PetsCommand.StockingR, true, isStocking, PetAccess.Instance.GetPetModel(v2));
                Variant mn = new Variant();
                mn.Add("B2", note.Player.B2);
                note.Call(BurdenCommand.BurdenListR, mn);
                return;
            }
            #endregion

            #region 家园与宠物背包宠物交换
            //宠物所在位置
            PlayerEx burden0 = isStocking ? note.Player.B3 : note.Player.B2;

            //放入位置
            PlayerEx burden1 = isStocking ? note.Player.B2 : note.Player.B3;
            IList c0 = burden0.Value.GetValue<IList>("C");
            Variant v0 = null;
            foreach (Variant v in c0)
            {
                if (v.GetStringOrDefault("E") == id)
                {
                    v0 = v;
                    break;
                }
            }
            if (v0 == null)
            {
                note.Call(PetsCommand.StockingR, false, isStocking, TipManager.GetMessage(PetsReturn.NoExists));
                return;
            }

            IList c1 = burden1.Value.GetValue<IList>("C");

            Variant v1 = BurdenManager.GetBurdenSpace(c1);
            if (v1 == null)
            {
                string str = isStocking ? TipManager.GetMessage(PetsReturn.PetBurdenB2) : TipManager.GetMessage(PetsReturn.PetBurdenB3);
                note.Call(PetsCommand.StockingR, false, isStocking, str);
                return;
            }

            if (burden1.Name == "B2")
            {
                Variant ct = PetAccess.Instance.CreateAward(note.Player.Level, id, note.PlayerID, note.Player.Pet);
                //PetBusiness.CreateAward(note.Player, ct, id, note.PlayerID);

                Variant t = v0["T"] as Variant;
                if (t != null)
                {
                    if (t.ContainsKey("ProtectionTime"))
                    {
                        if (ct == null) ct = new Variant();
                        ct.Add("ProtectionTime", t.GetDateTimeOrDefault("ProtectionTime"));
                    }
                }
                v1["T"] = ct;
            }
            else
            {
                Variant t = v0.GetValueOrDefault<Variant>("T");
                Variant ct = new Variant();
                if (t != null)
                {
                    if (t.ContainsKey("ProtectionTime"))
                    {
                        ct.Add("ProtectionTime", t.GetDateTimeOrDefault("ProtectionTime"));
                    }
                }
                v1["T"] = ct;
            }
            v1["E"] = v0["E"];
            v1["G"] = v0["G"];
            v1["S"] = v0["S"];
            v1["H"] = v0["H"];
            v1["A"] = v0["A"];
            v1["D"] = v0["D"];
            v1["R"] = v0["R"];

            if (v0.GetIntOrDefault("I") == 1)
            {
                note.Player.ResetPet(null);
            }

            BurdenManager.BurdenClear(v0);
            burden0.Save();
            burden1.Save();

            //Variant ve = new Variant();
            //ve.Add("B2", note.Player.B2);
            //ve.Add("B3", note.Player.B3);
            //note.Call(BurdenCommand.BurdenListR, ve);
            note.Player.UpdateBurden("B2", "B3");
            if (isStocking)
            {
                note.Call(PetsCommand.StockingR, true, isStocking, PetAccess.Instance.GetPetModel(v1));
            }
            else
            {
                note.Call(PetsCommand.StockingR, true, isStocking, id);
            }

            bool isslip = false;
            if (isStocking)
            {
                if (v0.GetIntOrDefault("P") > 3)
                {
                    isslip = true;
                }
            }
            else
            {
                if (v1.GetIntOrDefault("P") > 3)
                {
                    isslip = true;
                }
            }

            if (isslip)
            {
                List<Variant> ps = PlayerExAccess.Instance.SlipPets(note.Player.B3);
                note.Player.GetSlipPets(ps);
            }
            #endregion
        }
コード例 #3
0
ファイル: FriendsBusiness.cs プロジェクト: abel/sinan
        /// <summary>
        /// 得到申请回应
        /// </summary>
        /// <param name="note"></param>
        public static void FriendsBack(UserNote note)
        {
            string id = note.GetString(0);
            bool isagree = note.GetBoolean(1);
            PlayerBusiness pb = PlayersProxy.FindPlayerByID(id);
            if (!isagree)
            {
                pb.Call(SocialCommand.FriendsBackR, false, string.Format(TipManager.GetMessage(SocialReturn.FriendsBack1), note.Player.Name));
                //"【" + note.Player.Name + "】拒绝加你为好友", "");
                return;
            }

            if (!CheckFriends(note.Player, pb, SocialCommand.FriendsBackR, 1))
                return;

            Variant v = new Variant();
            v.Add("PlayerID", pb.ID);
            v.Add("Created", DateTime.UtcNow);

            PlayerEx social = note.Player.Social;
            IList enemy = social.Value.GetValue<IList>("Friends");
            int m = 0;
            int n = 0;
            if (enemy != null)
            {
                enemy.Add(v);
                m = enemy.Count;
            }
            else
            {
                social.Value["Friends"] = new List<Variant>() { v };
                m = 1;
            }

            Variant tmp = new Variant();
            tmp.Add("PlayerID", note.PlayerID);
            tmp.Add("Created", DateTime.UtcNow);

            PlayerEx social1 = pb.Social;
            IList enemy1 = social1.Value.GetValue<IList>("Friends");

            if (enemy1 != null)
            {
                enemy1.Add(tmp);
                n = enemy1.Count;
            }
            else
            {
                social1.Value["Friends"] = new List<Variant>() { tmp };
                n = 1;
            }
            social.Save();
            social1.Save();
            //"【" + note.Player.Name + "】与你成为好友,愿你们友谊在石器宝贝中长存"
            pb.Call(SocialCommand.FriendsBackR, true, string.Format(TipManager.GetMessage(SocialReturn.FriendsBack2), note.Player.Name), string.Empty);
            //"【" + user.Name + "】与你成为好友,愿你们友谊在石器宝贝中长存"
            note.Call(SocialCommand.FriendsBackR, true, string.Format(TipManager.GetMessage(SocialReturn.FriendsBack3), pb.Name), string.Empty);

            note.Player.FinishNote(FinishCommand.Friends, m);
            pb.FinishNote(FinishCommand.Friends, n);
        }
コード例 #4
0
ファイル: MasterBusiness.cs プロジェクト: abel/sinan
        /// <summary>
        /// 拜师或收徒
        /// </summary>
        /// <param name="note"></param>
        public static void MasterApply(UserNote note)
        {
            //true拜师,false表示收徒
            bool IsMaster = note.GetBoolean(0);
            string name = note.GetString(1);

            if (note.Player.Name == name)
            {
                note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.NoSelf));
                return;
            }

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

            if (!masterBase.Online)
            {
                //判断被申请者是否在线,如果不在线不能成功
                note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.NoOnLine));
                return;
            }

            if (MasterList.ContainsKey(note.PlayerID))
            {
                List<Variant> list = MasterList[note.PlayerID];
                int Number = 0;
                for (int i = 0; i < list.Count; i++)
                {
                    Variant k = list[i];
                    DateTime EndDate;
                    if (!DateTime.TryParse(k.GetStringOrDefault("EndDate"), out EndDate))
                        continue;
                    if (EndDate < DateTime.UtcNow)
                    {
                        //过期
                        list.Remove(k);
                    }
                    else if (k.GetBooleanOrDefault("IsMaster") == IsMaster)
                    {
                        if (k.GetStringOrDefault("PlayerID") == masterBase.ID)
                        {
                            note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(IsMaster ? SocialReturn.IsMaster : SocialReturn.IsApprentice));
                            return;
                        }
                        Number += 1;
                    }
                }
                if (Number >= 10)
                {
                    note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.AppNumber));
                    return;
                }
            }

            //师傅信息
            PlayerEx MasterSocial = IsMaster ? masterBase.Social : note.Player.Social;
            //徒弟信息
            PlayerEx AppSocial = IsMaster ? note.Player.Social : masterBase.Social;

            if (MasterSocial == null || AppSocial == null)
            {
                note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.UserInfoError));
                return;
            }

            int MasterLevel = 0;//师傅等级
            int AppLevel = 0;//徒弟等级
            if (IsMaster)
            {
                MasterLevel = masterBase.Level;
                AppLevel = note.Player.Level;
            }
            else
            {
                MasterLevel = note.Player.Level;
                AppLevel = masterBase.Level;
            }

            if (AppLevel > 39)
            {
                //徒弟必须小于或等于39级
                note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.MasterNoLevel));
                return;
            }

            if (MasterLevel < 40)
            {
                //师傅发须大于39级
                note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.MasterLevelGap));
                return;
            }

            Variant MasterMentor = MasterSocial.Value.GetValueOrDefault<Variant>("Mentor");
            Variant AppMentor = AppSocial.Value.GetValueOrDefault<Variant>("Mentor");
            if (FreezeDate(MasterMentor))
            {
                //你申请的师傅正处在冷冻期
                note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.MasterApply3));
                return;
            }
            if (FreezeDate(AppMentor))
            {
                //徒弟是否是在冻结期
                note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.MasterApply4));
                return;
            }

            //判断师傅中是否已经是仇人,师傅和徒弟
            if (SocialBusiness.IsLet(MasterSocial, AppSocial.PlayerID, new List<string> { "Enemy" }))
            {
                note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.Enemy));
                return;
            }
            if (SocialBusiness.IsLet(MasterSocial, AppSocial.PlayerID, new List<string> { "Master" }))
            {
                note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.Master));
                return;
            }
            if (SocialBusiness.IsLet(MasterSocial, AppSocial.PlayerID, new List<string> { "Apprentice" }))
            {
                note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.Apprentice));
                return;
            }

            if (SocialBusiness.IsLet(AppSocial, MasterSocial.PlayerID, new List<string> { "Enemy" }))
            {
                note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.Enemy));
                return;
            }
            if (SocialBusiness.IsLet(AppSocial, MasterSocial.PlayerID, new List<string> { "Master" }))
            {
                note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.Master));
                return;
            }
            if (SocialBusiness.IsLet(AppSocial, MasterSocial.PlayerID, new List<string> { "Apprentice" }))
            {
                note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.Apprentice));
                return;
            }

            //徒弟师傅数量
            IList AppMaster = AppMentor.GetValue<IList>("Master");

            if (AppMaster != null)
            {
                if (AppMaster.Count >= 1)
                {
                    note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.MasterCount));
                    return;
                }
            }

            //师傅徒弟数量
            IList MasterApp = MasterMentor.GetValue<IList>("Apprentice");
            if (MasterApp != null)
            {
                if (!CheckApp(MasterApp))
                {
                    note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.ApprenticeCount));
                    return;
                }
                //if (MasterApp.Count >= 4)
                //{
                //    note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.ApprenticeCount));
                //    return;
                //}
            }

            Variant p = new Variant();
            p.Add("ID", note.PlayerID);
            p.Add("IsMaster", IsMaster);
            //发布时间
            p.Add("EndDate", DateTime.UtcNow.AddHours(72));
            p.Add("PlayerID", masterBase.ID);

            if (!MasterList.ContainsKey(note.PlayerID))
            {
                MasterList.Add(note.PlayerID, new List<Variant> { p });
            }
            else
            {
                List<Variant> list = MasterList[note.PlayerID];
                list.Add(p);
            }
            string str = note.PlayerID + "," + masterBase.ID;
            Variant v = new Variant();
            v.Add("ID", str);
            if (IsMaster)
            {
                v.Add("Message", string.Format(TipManager.GetMessage(SocialReturn.MasterApply1), note.Player.Name));
            }
            else
            {
                v.Add("Message", string.Format(TipManager.GetMessage(SocialReturn.MasterApply2), note.Player.Name));
            }
            masterBase.Call(SocialCommand.MasterApplyR, true, IsMaster, v);
        }
コード例 #5
0
ファイル: MasterBusiness.cs プロジェクト: abel/sinan
        /// <summary>
        /// 拜师或收徒回复
        /// </summary>
        /// <param name="note"></param>
        public static void MasterBack(UserNote note)
        {
            //true表示拜师,false表示收徒
            bool IsMaster = note.GetBoolean(0);
            string[] strs = note.GetString(1).Split(',');
            string plasyerid = strs[0];

            PlayerBusiness OnLineBusiness = PlayersProxy.FindPlayerByID(plasyerid);
            if (OnLineBusiness == null || (!OnLineBusiness.Online))
            {
                //判断被申请者是否在线,如果不在线不能成功
                note.Call(SocialCommand.MasterBackR, false, IsMaster, TipManager.GetMessage(SocialReturn.NoOnLine));
                return;
            }

            //师傅信息
            PlayerEx MasterSocial = IsMaster ? note.Player.Social : OnLineBusiness.Social;
            //徒弟信息
            PlayerEx AppSocial = IsMaster ? OnLineBusiness.Social : note.Player.Social;

            if (MasterSocial == null || AppSocial == null)
            {
                note.Call(SocialCommand.MasterBackR, false, IsMaster, TipManager.GetMessage(SocialReturn.UserInfoError));
                return;
            }

            int MasterLevel = 0;//师傅等级
            int AppLevel = 0;//徒弟等级
            if (IsMaster)
            {
                MasterLevel = note.Player.Level;
                AppLevel = OnLineBusiness.Level;
            }
            else
            {
                MasterLevel = OnLineBusiness.Level;
                AppLevel = note.Player.Level;
            }

            if (AppLevel > 39)
            {
                note.Call(SocialCommand.MasterBackR, false, IsMaster, TipManager.GetMessage(SocialReturn.MasterNoLevel));
                return;
            }

            if (MasterLevel < 40)
            {
                note.Call(SocialCommand.MasterBackR, false, IsMaster, TipManager.GetMessage(SocialReturn.MasterLevelGap));
                return;
            }

            Variant MasterMentor = MasterSocial.Value.GetValueOrDefault<Variant>("Mentor"); ;
            Variant AppMentor = AppSocial.Value.GetValueOrDefault<Variant>("Mentor");
            if (FreezeDate(MasterMentor))
            {
                //师傅正处在冷冻期
                note.Call(SocialCommand.MasterBackR, false, IsMaster, TipManager.GetMessage(SocialReturn.MasterApply3));
                return;
            }
            if (FreezeDate(AppMentor))
            {
                //徒弟正处在冷冻期
                note.Call(SocialCommand.MasterBackR, false, IsMaster, TipManager.GetMessage(SocialReturn.MasterApply4));
                return;
            }

            //判断师傅中是否已经是仇人,师傅和徒弟
            if (SocialBusiness.IsLet(MasterSocial, AppSocial.PlayerID, new List<string> { "Enemy" }))
            {
                note.Call(SocialCommand.MasterBackR, false, IsMaster, TipManager.GetMessage(SocialReturn.Enemy));
                return;
            }
            if (SocialBusiness.IsLet(MasterSocial, AppSocial.PlayerID, new List<string> { "Master" }))
            {
                note.Call(SocialCommand.MasterBackR, false, IsMaster, TipManager.GetMessage(SocialReturn.Master));
                return;
            }
            if (SocialBusiness.IsLet(MasterSocial, AppSocial.PlayerID, new List<string> { "Apprentice" }))
            {
                note.Call(SocialCommand.MasterBackR, false, IsMaster, TipManager.GetMessage(SocialReturn.Apprentice));
                return;
            }

            if (SocialBusiness.IsLet(AppSocial, MasterSocial.PlayerID, new List<string> { "Enemy" }))
            {
                note.Call(SocialCommand.MasterBackR, false, IsMaster, TipManager.GetMessage(SocialReturn.Enemy));
                return;
            }
            if (SocialBusiness.IsLet(AppSocial, MasterSocial.PlayerID, new List<string> { "Master" }))
            {
                note.Call(SocialCommand.MasterBackR, false, IsMaster, TipManager.GetMessage(SocialReturn.Master));
                return;
            }
            if (SocialBusiness.IsLet(AppSocial, MasterSocial.PlayerID, new List<string> { "Apprentice" }))
            {
                note.Call(SocialCommand.MasterBackR, false, IsMaster, TipManager.GetMessage(SocialReturn.Apprentice));
                return;
            }

            //徒弟师傅数量
            IList AppMaster = AppMentor.GetValue<IList>("Master");

            if (AppMaster != null)
            {
                if (AppMaster.Count >= 1)
                {
                    note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.MasterCount));
                    return;
                }
            }

            //师傅徒弟数量
            IList MasterApp = MasterMentor.GetValue<IList>("Apprentice");
            if (MasterApp != null)
            {
                if (!CheckApp(MasterApp))
                {
                    note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.ApprenticeCount));
                    return;
                }
                //if (MasterApp.Count >= 4)
                //{
                //    note.Call(SocialCommand.MasterApplyR, false, IsMaster, TipManager.GetMessage(SocialReturn.MasterCount));
                //    return;
                //}
            }

            DateTime dt = DateTime.UtcNow;
            Variant v = new Variant();
            v.Add("PlayerID", MasterSocial.PlayerID);
            v.Add("Created", dt);
            if (AppMaster == null)
            {
                AppMentor["Master"] = new List<Variant> { v };
            }
            else
            {
                AppMaster.Add(v);
            }

            Variant app = new Variant();
            app.Add("PlayerID", AppSocial.PlayerID);
            app.Add("Created", dt);

            IList MasterApprentice = MasterMentor.GetValue<IList>("Apprentice");
            if (MasterApprentice == null)
            {
                MasterMentor["Apprentice"] = new List<Variant>() { app };
            }
            else
            {
                MasterApprentice.Add(app);
            }

            MasterSocial.Save();
            AppSocial.Save();

            if (IsMaster)
            {
                string MasterStr = string.Format(TipManager.GetMessage(SocialReturn.MasterBack1), OnLineBusiness.Name);
                // "你已经收【" + OnLineBusiness.Name + "】为徒!";
                Variant mt = new Variant();
                mt.Add("Message", MasterStr);
                mt.Add("Member", new PlayerSimple(OnLineBusiness, 3));

                note.Call(SocialCommand.MasterBackR, true, true, mt);

                string AppStr = string.Format(TipManager.GetMessage(SocialReturn.MasterBack2), note.Player.Name);
                // "你已经拜【" + note.Player.Name + "】为师!";
                Variant at = new Variant();
                at.Add("Message", AppStr);
                at.Add("Member", new PlayerSimple(note.Player, 3));
                OnLineBusiness.Call(SocialCommand.MasterBackR, true, false, at);
            }
            else
            {
                string MasterStr = string.Format(TipManager.GetMessage(SocialReturn.MasterBack3), note.Player.Name);
                //"你已经收【" + note.Player.Name + "】为徒!";
                Variant mt = new Variant();
                mt.Add("Message", MasterStr);
                mt.Add("Member", new PlayerSimple(note.Player, 3));
                OnLineBusiness.Call(SocialCommand.MasterBackR, true, true, mt);

                string AppStr = string.Format(TipManager.GetMessage(SocialReturn.MasterBack2), OnLineBusiness.Name);
                //"你已经拜【" + OnLineBusiness.Name+ "】为师!";
                Variant at = new Variant();
                at.Add("Message", AppStr);
                at.Add("Member", new PlayerSimple(OnLineBusiness, 3));
                note.Call(SocialCommand.MasterBackR, true, false, at);
            }
        }
コード例 #6
0
ファイル: AuctionBusiness.cs プロジェクト: abel/sinan
        /// <summary>
        /// 购买列表
        /// </summary>
        /// <param name="note"></param>
        public static void AuctionBuyList(UserNote note)
        {
            string soleid = note.PlayerID + string.Empty + note.Name;
            if (!m_dic.TryAdd(soleid, soleid))
                return;
            try
            {
                int pageSize = note.GetInt32(0);
                int pageIndex = note.GetInt32(1);
                string goodsType = note.GetString(2);
                bool isName = note.GetBoolean(3);

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

                int total = 0;
                int currIndex = 0;
                List<Auction> list = AuctionAccess.Instance.AuctionBuyList(note.PlayerID, goodsType, isName, pageSize, pageIndex, out total, out currIndex);
                List<Variant> msg = new List<Variant>();
                if (list != null)
                {
                    foreach (Auction a in list)
                    {
                        Variant v = new Variant();
                        v.Add("ID", a.ID);
                        v.Add("Name", a.Name);
                        foreach (var k in a.Value)
                        {
                            v.Add(k.Key, k.Value);
                        }
                        msg.Add(v);
                    }
                }
                note.Call(AuctionCommand.AuctionBuyListR, total, currIndex, msg);
            }
            finally
            {
                m_dic.TryRemove(soleid, out soleid);
            }
        }
コード例 #7
0
ファイル: MountsBussiness.cs プロジェクト: abel/sinan
        /// <summary>
        /// 坐骑技能更换
        /// </summary>
        /// <param name="note"></param>
        public static void MountsSkillChange(UserNote note)
        {
            string oldid = note.GetString(0);
            string newid = note.GetString(1);
            bool ischange = note.GetBoolean(2);
            Mounts m = note.Player.Mounts;
            if (m == null)
            {
                //没有坐骑
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts2));
                return;
            }
            Variant mv = m.Value;
            if (mv == null)
            {
                //被更换的技能不存在
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts3));
                return;
            }
            Variant skill = mv.GetVariantOrDefault("Skill");
            if (skill == null)
            {
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts3));
                return;
            }
            Variant o = skill.GetVariantOrDefault(oldid);
            if (o == null)
            {
                //被更换的技能不存在
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts3));
                return;
            }

            if (skill.ContainsKey(newid))
            {
                //你想更换的技能已经存在
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts4));
                return;
            }

            GameConfig gc = GameConfigAccess.Instance.FindOneById(m.MountsID);
            if (gc == null)
            {
                //坐骑配置问题
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts5));
                return;
            }
            Variant v = gc.Value;
            if (v == null)
            {
                //坐骑配置问题
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts5));
                return;
            }

            Variant skills = v.GetVariantOrDefault("Skills");
            if (skills == null)
            {
                //技能不存在
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts6));
                return;
            }

            int level = 0;//新技能等级
            if (!skills.TryGetValueT(newid, out level))
            {
                //技能不存在
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts6));
                return;
            }

            //选择的新技能类型
            GameConfig gck = GameConfigAccess.Instance.FindOneById(newid);
            if (gck == null)
            {
                //技能配置有问题
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts7));
                return;
            }

            if (!gck.Value.ContainsKey(level.ToString()))
            {
                //坐骑技能等级配置有问题
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts8));
                return;
            }

            if (gck.SubType != "MountAddition")
            {
                //坐骑类型不正确
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts9));
                return;
            }

            int score = v.GetIntOrDefault("ChangeScore");
            if (score < 0)
            {
                //石币不足
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts10));
                return;
            }

            if (note.Player.Score < score)
            {
                //石币不足
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts10));
                return;
            }

            if (ischange)
            {
                string goodsid = "G_d000689";
                if (!note.Player.RemoveGoods(goodsid, GoodsSource.MountsSkillChange))
                {
                    note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts15));
                    return;
                }
            }

            if (!note.Player.AddScore(-score, FinanceType.MountsSkillChange))
            {
                //石币不足
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts10));
                return;
            }

            Variant info = new Variant();
            info.Add("P", o.GetIntOrDefault("P"));
            if (ischange)
            {
                info.Add("Cur", o.GetIntOrDefault("Cur"));
                info.Add("Level", o.GetIntOrDefault("Level"));
            }
            else
            {
                info.Add("Cur", 0);
                info.Add("Level", 1);
            }
            //添加新技能
            skill.Add(newid, info);
            //移除旧的技能
            skill.Remove(oldid);

            if (m.Save())
            {
                PetAccess.PetReset(note.Player.Pet, note.Player.Skill, false, m);
                note.Call(PetsCommand.UpdatePetR, true, note.Player.Pet);
                note.Player.MountsUpdate(m, new List<string>() { "Skill" });
                note.Call(MountsCommand.MountsSkillChangeR, true, "");
            }
            else
            {
                //操作失败
                note.Call(MountsCommand.MountsSkillChangeR, false, TipManager.GetMessage(MountsReturn.Mounts1));
            }
        }
コード例 #8
0
ファイル: TeamsMediator.cs プロジェクト: abel/sinan
 /// <summary>
 /// 玩家回复是否同意
 /// </summary>
 /// <param name="note"></param>
 private void ReplyInvite(UserNote note)
 {
     string teamID = note.GetString(0);
     bool a = note.GetBoolean(1);
     if (!a) return;
     PlayerTeam team;
     if (m_teams.TryGetValue(teamID, out team))
     {
         if (!team.Available)
         {
             //队伍已满
             note.Call(TeamCommand.IntoTeamR, false, TipManager.GetMessage(ClientReturn.TeamsMediator2));
             return;
         }
         PlayerBusiness member = note.Player;
         if (team.TryAddMember(member))
         {
             var members = team.AllPlayerDetail;
             note.Call(TeamCommand.IntoTeamR, true, new object[] { team, members });
             member.CallAllExcludeOne(member, TeamCommand.NewMemberR, teamID, new PlayerDetail(member));
         }
     }
 }
コード例 #9
0
ファイル: SceneBusiness_Fight.cs プロジェクト: abel/sinan
 /// <summary>
 /// 回复切磋
 /// </summary>
 /// <param name="note"></param>
 protected void FightReplyCC(UserNote note)
 {
     PlayerBusiness player = note.Player;
     if (player.AState == ActionState.Fight || player.TeamJob == TeamJob.Member)
     {
         return;
     }
     string pkID = note.GetString(1);
     PlayerBusiness b;
     if (m_players.TryGetValue(pkID, out b))
     {
         bool a = note.GetBoolean(0);
         if (!a)
         {
             //不同意切磋
             b.Call(FightCommand.FightReplyCCR, false, note.PlayerID);
             return;
         }
         player.FightTime = DateTime.UtcNow;
         UserNote note2 = new UserNote(note, FightCommand.IntoBattlePK, new object[] { FightType.CC, b });
         Notifier.Instance.Publish(note2);
     }
 }
コード例 #10
0
ファイル: FightBase.cs プロジェクト: abel/sinan
        private void AutoFight(UserNote note)
        {
            PlayerBusiness player = note.Player;
            bool auto = note.GetBoolean(0);
            int count = 0;
            if (auto)
            {
                count = player.StartAutoFight();
            }
            else
            {
                player.EndAutoFight();
            }

            FightObject[] team;
            FightObject f = m_teamA.FirstOrDefault(x => x.ID == player.ID);
            if (f != null)
            {
                team = m_teamA;
            }
            else
            {
                f = m_teamB.FirstOrDefault(x => x.ID == player.ID);
                team = m_teamB;
            }

            if (f != null)
            {
                var buffer = AmfCodec.Encode(FightCommand.AutoFightR, new object[] { player.ID, count });
                foreach (var p in team)
                {
                    if (p.FType == FighterType.Player)
                    {
                        p.Player.Call(buffer);
                    }
                }
            }
        }