Beispiel #1
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;
        }
Beispiel #2
0
 /// <summary>
 /// 任务触发d
 /// </summary>
 /// <param name="pb"></param>
 /// <param name="gc"></param>
 public static void TaskBack(PlayerBusiness pb, GameConfig gc)
 {
     Task task = TaskAccess.Instance.TaskBase(pb.ID, pb.Name, gc, 0, 0);
     if (task != null)
     {
         pb.Call(TaskCommand.TaskActivationR, TaskAccess.Instance.GetTaskInfo(task));
     }
 }
Beispiel #3
0
 /// <summary>
 /// 场景切换检查
 /// </summary>
 /// <param name="player"></param>
 /// <param name="inScene"></param>
 /// <param name="transmitType">0:道具/超时回城, 1:死亡回城 , 2:转送阵, 3: NPC</param>
 /// <returns></returns>
 public override bool TransferCheck(PlayerBusiness player, SceneBusiness inScene, TransmitType transmitType)
 {
     //检查必杀的怪是否完成..
     if (transmitType == TransmitType.Pin)
     {
         IList killed = player.Ectype.Value.GetValue<IList>("Killed");
         string needKill = NpcManager.Instance.MustKill(this.ID, killed);
         if (needKill != null)
         {
             string msg = string.Format(TipManager.GetMessage(ClientReturn.SceneEctype4), needKill);
             player.Call(ClientCommand.IntoSceneR, false, null, msg);
             return false;
         }
     }
     return base.TransferCheck(player, inScene, transmitType);
 }
Beispiel #4
0
        /// <summary>
        /// 增加每日日常任务
        /// </summary>
        /// <param name="player"></param>
        /// <param name="gc"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        private static int AddDayTask(PlayerBusiness player, GameConfig gc, int p)
        {
            PlayerEx dt = player.Value["DayTask"] as PlayerEx;
            Variant v_dt = dt.Value;
            //道具
            int daily = gc.Value.GetIntOrDefault("Daily");
            int total = v_dt.GetIntOrDefault("Total");
            int max = v_dt.GetIntOrDefault("Max");

            Variant mv = MemberAccess.MemberInfo(player.MLevel);
            if (mv != null)
            {
                max += mv.GetIntOrDefault("ShiBan") * 5;
            }

            if (total >= max)
            {
                //您今天的日常任务已经扩充到上限最大值,请明天再使用探险者石板
                return GoodsReturn.UseGoods8;
            }
            if (player.RemoveGoods(p, GoodsSource.DoubleUse))
            {
                if (total + daily <= max)
                {
                    v_dt.SetOrInc("Total", daily);
                }
                else
                {
                    v_dt["Total"] = max;
                }

                //如果不存在日常任务
                if (!TaskAccess.Instance.IsDayTask(player.ID, 2))
                {
                    GameConfig gn = GameConfigAccess.Instance.GetDayTaskOne(player.Level, 2);
                    if (gn != null)
                    {
                        DayTask(player, true);
                    }
                }
                dt.Save();
                player.Call(ClientCommand.UpdateActorR, new PlayerExDetail(dt));
                return 0;
            }
            return GoodsReturn.AnswerNoGood;
        }
Beispiel #5
0
 /// <summary>
 /// 任务放异
 /// </summary>
 /// <param name="note">角色信息</param>
 /// <param name="task">任务</param>
 /// <returns></returns>
 public static bool TaskGiveup(PlayerBusiness pb, Task task, bool isremove = true)
 {
     PlayerEx burden = pb.B0;
     Variant v = task.Value;
     //完成条件
     IList finish = v["Finish"] as IList;
     foreach (Variant k in finish)
     {
         string goodsid = k.GetStringOrDefault("GoodsID");
         int Cur = k.GetIntOrDefault("Cur");
         if (Cur == 0) continue;
         switch (k.GetIntOrDefault("Type"))
         {
             case 10006:
                 Dictionary<string, Variant> dic = new Dictionary<string, Variant>();
                 Variant vn = new Variant();
                 vn.Add("Number1", Cur);
                 dic.Add(goodsid, vn);
                 if (BurdenManager.IsFullBurden(burden, dic))
                     return true;
                 pb.AddGoods(dic, GoodsSource.TaskGiveup);
                 break;
             case 10003:
             case 10009:
             case 10010:
                 BurdenManager.Remove(burden, goodsid, Cur);
                 break;
         }
         k["Cur"] = 0;
     }
     v["Status"] = 0;
     if (isremove)
     {
         task.Save();
     }
     pb.Call(TaskCommand.GiveupR, true, task.ID);
     return false;
 }
Beispiel #6
0
        /// <summary>
        /// GM卸装
        /// </summary>
        /// <param name="player"></param>
        /// <param name="v"></param>
        private static void GMUninstall(PlayerBusiness player, Variant v)
        {
            Goods g = GoodsAccess.Instance.GetGoodsByID(v.GetStringOrDefault("E"), player.ID);
            if (g != null)
            {
                string goodsType = g.Value.GetStringOrDefault("GoodsType");
                Variant shengTi = RoleManager.Instance.GetAllRoleConfig(player.RoleID);
                string name = string.Empty;
                string value = string.Empty;
                bool ischange = false;
                switch (goodsType)
                {
                    case "111000":
                        //时装
                        name = "Coat";
                        value = shengTi.GetStringOrDefault("Coat");
                        player.Coat = value;
                        ischange = true;
                        break;
                    case "111001":
                        //武器
                        name = "Weapon";
                        value = shengTi.GetStringOrDefault("Weapon");
                        player.Weapon = value;
                        ischange = true;
                        break;
                    case "111003":
                        //衣服
                        name = "Body";
                        value = shengTi.GetStringOrDefault("Body");
                        player.Body = value;
                        ischange = true;
                        break;
                    case "111010":
                        //坐骑
                        name = "Mount";
                        value = shengTi.GetStringOrDefault("Mount");
                        player.Mount = value;
                        ischange = true;
                        break;
                }

                if (ischange)
                {
                    player.SaveClothing();
                }
                player.RefreshPlayer(name, value);
            }
            player.Call(GoodsCommand.UninstallR, true, g.GoodsID);
        }
Beispiel #7
0
        /// <summary>
        /// 重新进入
        /// </summary>
        /// <param name="member"></param>
        internal void ReInto(PlayerBusiness member)
        {
            if (m_team != null && m_team.TryAddMember(member))
            {
                var members = m_team.AllPlayerDetail;
                member.Call(TeamCommand.IntoTeamR, true, new object[] { m_team, members });
                member.CallAllExcludeOne(member, TeamCommand.NewMemberR, m_team.TeamID, new PlayerDetail(member));

                var apcs = m_currentApcs.FindAll(k => k.State <= 1);
                member.Call(InstanceCommand.NewInstanceR, new object[] { true, apcs, string.Empty });

                // 记录副本进入日志
                PlayerLog log = new PlayerLog(ServerLogger.zoneid, Actiontype.EctypeIn);
                log.itemtype = m_gc.SubType; //副本类型
                log.itemid = m_gc.ID;        //副本ID
                log.remark = m_gc.Name;      //副本名称

                member.WriteLog(log);
            }
        }
Beispiel #8
0
        public bool TryInto(PlayerBusiness player)
        {
            PlayerTeam team = player.Team;
            //设置玩家列表.
            string msg;
            if (!FillPlayers(team, player, out msg))
            {
                player.Call(InstanceCommand.NewInstanceR, new object[] { false, msg, string.Empty });
                return false;
            }

            player.TeamInstance = this;
            // 检查副本进入限制
            if (m_intoLimit != null)
            {
                PlayerBusiness member;
                if ((!m_intoLimit.IntoCheck(m_members, out msg, out member))
                    || (!m_intoLimit.IntoDeduct(m_members, out msg, out member)))
                {
                    player.TeamInstance = null;
                    this.CallAll(InstanceCommand.NewInstanceR, new object[] { false, msg, member == null ? string.Empty : member.Name });
                    m_members = Empty;
                    return false;
                }
            }
            m_team = team;
            TeamInstanceProxy.TryAddInstance(this);

            //设置进入次数
            for (int i = 0; i < m_members.Length; i++)
            {
                PlayerBusiness member = m_members[i];
                if (member == null) continue;
                member.TeamInstance = this;
                member.WriteDaily(PlayerBusiness.DailyMap, m_gc.ID);

                //进入秘境通知..
                member.AddAcivity(ActivityType.FuBenCount, 1);

                // 记录副本进入日志
                PlayerLog log = new PlayerLog(ServerLogger.zoneid, Actiontype.EctypeIn);
                log.itemtype = m_difficulty;
                log.itemid = m_gc.ID;
                log.remark = m_gc.Name;
                member.WriteLog(log);
            }

            oldx = player.X;
            oldy = player.Y;
            m_oldScene = player.Scene;
            m_currentScene = m_oldScene;
            Astate = ActionState.Standing;
            return true;
        }
Beispiel #9
0
 public bool OpenBox(PlayerBusiness player)
 {
     string msg = CheckBox(player);
     if (msg == null)
     {
         if (!string.IsNullOrEmpty(m_box.GoodsID) && (!BurdenManager.Remove(player.B0, m_box.GoodsID, 1)))
         {
             //缺少钥匙;
             msg = TipManager.GetMessage(ClientReturn.CheckBox3);
         }
     }
     if (msg != null)
     {
         //开箱失败
         player.Call(ClientCommand.OpenBoxR, false, msg);
         return false;
     }
     //开箱奖励
     GetAward(player);
     return true;
 }
Beispiel #10
0
        /// <summary>
        /// 家族贡献任务
        /// </summary>
        /// <param name="pb"></param>
        public static void FamilyTask(PlayerBusiness pb, bool iscall)
        {
            string soleid = pb.ID + "FamilyTask";
            if (!m_dic.TryAdd(soleid, soleid))
                return;
            try
            {
                //不存在家族
                if (!TaskBusinessBase.IsFamily(pb))
                    return;
                int num = pb.TaskTotal(7);
                if (num >= 20)
                    return;
                if (num == 0)
                {
                    List<string> list = TaskAccess.Instance.Remove_1(pb.ID, 7);
                    if (iscall)
                    {
                        foreach (string id in list)
                        {
                            pb.Call(TaskCommand.GiveupR, true, id);
                        }
                    }
                }

                if (TaskAccess.Instance.IsDayTask(pb.ID, 7))
                    return;
                //随机取得一个家族贡献任务
                GameConfig gc = GameConfigAccess.Instance.GetDayTaskOne(pb.Level, 7);
                if (gc != null)
                {
                    Task t = TaskAccess.Instance.TaskBase(pb.ID, pb.RoleID, gc, 0, 0);
                    if (t != null)
                    {
                        if (iscall)
                        {
                            pb.Call(TaskCommand.TaskActivationR, TaskAccess.Instance.GetTaskInfo(t));
                        }
                    }
                }
            }
            finally
            {
                m_dic.TryRemove(soleid, out soleid);
            }
        }
Beispiel #11
0
 /// <summary>
 /// 经验宝珠
 /// </summary>
 /// <param name="player"></param>
 /// <param name="c"></param>
 /// <param name="number"></param>
 /// <returns></returns>
 private static bool UseAddExp(PlayerBusiness player, GameConfig c, int number = 1)
 {
     //检查使用限制..
     //if (!SupplyLimit(note, c)) return;
     int p1exp = c.Value.GetIntOrDefault("P1exp") * number;
     if (p1exp > 0)
     {
         player.AddExperience(p1exp, FinanceType.UseGoods);
         return true;
     }
     int p2exp = c.Value.GetIntOrDefault("P2exp") * number;
     if (p2exp > 0)
     {
         if (player.Pet == null)
         {
             //没有出战的宠物不能使用
             player.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(GoodsReturn.UseAddExp));
             return false;
         }
         return player.AddPetExp(player.Pet, p2exp, true,(int)FinanceType.UseGoods);
     }
     int m1exp = c.Value.GetIntOrDefault("M1exp") * number;
     if (m1exp > 0)
     {
         if (player.Mounts == null)
         {
             player.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(GoodsReturn.NoMounts));
             return false;
         }
         return player.AddMounts(m1exp, GoodsSource.DoubleUse);
     }
     return false;
 }
Beispiel #12
0
        /// <summary>
        /// 进入检查
        /// </summary>
        /// <param name="note"></param>
        /// <returns></returns>
        protected override bool IntoCheck(PlayerBusiness player)
        {
            if (player.Team != null)
            {
                player.Call(ClientCommand.IntoSceneR, false, null, TipManager.GetMessage(ClientReturn.IntoLimit1));
                return false;
            }
            if (player.Fight != null)
            {
                //player.Call(ClientCommand.IntoSceneR, false, null, TipManager.GetMessage(ClientReturn.SceneHome2));
                return false;
            }
            if (m_intoLimit != null)
            {
                string msg;
                if (!m_intoLimit.IntoCheck(player, out msg))
                {
                    player.Call(ClientCommand.IntoSceneR, false, null, msg);
                    return false;
                }

                if (!m_intoLimit.IntoDeduct(player, out msg))
                {
                    player.Call(ClientCommand.IntoSceneR, false, null, msg);
                    return false;
                }
            }
            return true;
        }
Beispiel #13
0
        /// <summary>
        /// 成功进入场景
        /// </summary>
        /// <param name="note"></param>
        protected virtual void IntoSceneSuccess(PlayerBusiness player, Variant sceneinfo)
        {
            // 发送用户列表并通知其它用户
            const int maxCount = 100;
            PlayerBusiness[] players;
            if (m_showAll)
            {
                players = m_players.Values.ToArray();
            }
            else
            {
                long showID = player.ShowID;
                players = m_players.Values.Where(x => { return x.ShowID == showID; }).ToArray();
            }

            if (players.Length <= maxCount)
            {
                player.CallBig(ClientCommand.IntoSceneR, true, sceneinfo, players);
            }
            else
            {
                PlayerBusiness[] first = new PlayerBusiness[maxCount];
                Array.Copy(players, first, maxCount);
                player.CallBig(ClientCommand.IntoSceneR, true, sceneinfo, first);
                //分割玩家列表
                for (int offset = maxCount; offset < players.Length; offset += maxCount)
                {
                    int count = Math.Min(players.Length - offset, maxCount);
                    PlayerBusiness[] other = new PlayerBusiness[count];
                    Array.Copy(players, offset, other, 0, count);
                    player.CallBig(ClientCommand.MorePlayer, this.ID, other);
                }
            }
            CallAllExcludeOne(player, ClientCommand.OtherIntoSceneR, new object[] { player });
            player.FightTime = DateTime.UtcNow.AddSeconds(15);
            player.Online = true;
            player.Save();

            if (this.HaveApc)
            {
                IList apcs = SceneApcProxy.GetSceneApc(this.ID);
                player.Call(ClientCommand.RefreshApcR, this.ID, apcs);
            }
            if (this.HaveBox)
            {
                IList boxs = BoxProxy.GetSceneBox(this.ID);
                player.Call(ClientCommand.RefreshBoxR, this.ID, boxs);
            }
        }
Beispiel #14
0
 /// <summary>
 /// 进入检查
 /// </summary>
 /// <param name="note"></param>
 /// <returns></returns>
 protected virtual bool IntoCheck(PlayerBusiness player)
 {
     if (m_intoLimit == null)
     {
         return true;
     }
     string msg;
     if (m_intoLimit.IntoCheck(player, out msg))
     {
         return true;
     }
     player.Call(ClientCommand.IntoSceneR, false, null, msg);
     return false;
 }
Beispiel #15
0
        /// <summary>
        /// 进入扣除
        /// </summary>
        /// <param name="player"></param>
        public virtual bool IntoPart(PlayerBusiness player)
        {
            bool pass = (m_part.Score == 0 && m_part.Coin == 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)
            {
                if (m_part.MaxInto > 0)
                {
                    m_playerInto.SetOrInc(player.PID, 1);
                }
            }
            else
            {
                player.Call(ClientCommand.IntoSceneR, false, null, m_part.CoinMsg);
            }
            return pass;
        }
Beispiel #16
0
        /// <summary>
        /// 进入检查
        /// </summary>
        /// <param name="player"></param>
        public virtual bool IntoCheck(PlayerBusiness player)
        {
            if (m_over)
            {
                //活动已结束
                player.Call(ClientCommand.IntoSceneR, false, null, TipManager.GetMessage(ClientReturn.PartBusiness1));

                return false;
            }
            if (m_start > DateTime.UtcNow || m_end <= DateTime.UtcNow)
            {
                //只有活动时间才能进入
                player.Call(ClientCommand.IntoSceneR, false, null, TipManager.GetMessage(ClientReturn.PartBusiness2));
                return false;
            }
            if (player.Team != null)
            {
                //组队状态不能进入
                player.Call(ClientCommand.IntoSceneR, false, null, TipManager.GetMessage(ClientReturn.PartBusiness3));
                return false;
            }
            if (m_part.MaxInto > 0)
            {
                int pid;
                if (m_playerInto.TryGetValue(player.PID, out pid))
                {
                    if (pid >= m_part.MaxInto)
                    {
                        //每次活动最多可进入{0}次
                        player.Call(ClientCommand.IntoSceneR, false, null, string.Format(TipManager.GetMessage(ClientReturn.PartBusiness4), m_part.MaxInto));
                        return false;
                    }
                }
            }
            return true;
        }
Beispiel #17
0
        /// <summary>
        /// 判断道具是否合法
        /// </summary>
        /// <param name="gs"></param>
        /// <param name="c"></param>
        /// <param name="pb"></param>
        /// <returns></returns>
        private static bool IsCheck(IList gs, IList c, PlayerBusiness pb)
        {
            Dictionary<int, int> dic = new Dictionary<int, int>();
            foreach (Variant n in gs)
            {
                foreach (Variant k in c)
                {
                    int p = n.GetIntOrDefault("P");
                    if (p == k.GetIntOrDefault("P"))
                    {
                        if (k.GetIntOrDefault("H") == 1)
                        {
                            pb.Call(DealCommand.LockDealR, false, TipManager.GetMessage(DealReturn.IsBinding));
                            return false;
                        }

                        if (n.GetStringOrDefault("ID") != k.GetStringOrDefault("E"))
                        {
                            pb.Call(DealCommand.LockDealR, false, TipManager.GetMessage(DealReturn.NumberError));
                            return false;
                        }

                        if (n.GetIntOrDefault("Count") != k.GetIntOrDefault("A"))
                        {
                            pb.Call(DealCommand.LockDealR, false, TipManager.GetMessage(DealReturn.NumberError));
                            return false;
                        }

                        Variant t = k.GetVariantOrDefault("T");
                        if (t != null)
                        {
                            if (t.ContainsKey("EndTime"))
                            {
                                if (t.GetDateTimeOrDefault("EndTime") < DateTime.UtcNow)
                                {
                                    pb.Call(DealCommand.LockDealR, false, TipManager.GetMessage(DealReturn.IsCheck1));
                                    return false;
                                }
                            }
                        }

                        if (dic.ContainsKey(p))
                        {
                            pb.Call(DealCommand.LockDealR, false, TipManager.GetMessage(DealReturn.IsCheck2));
                            return false;
                        }
                        dic.Add(p, p);
                        break;
                    }
                }
            }
            return true;
        }
Beispiel #18
0
        /// <summary>
        /// 竞技场宠物疲劳值增加
        /// </summary>
        /// <param name="model"></param>
        /// <param name="user">角色</param>
        /// <param name="type">0表示负,1胜,2平</param>
        public static void AddFatigue(ArenaBase model, PlayerBusiness user, int type)
        {
            GameConfig gc = GameConfigAccess.Instance.FindOneById(model.ArenaID);
            if (gc == null)
                return;

            Variant t = gc.Value;
            Variant petLevel = t.GetValueOrDefault<Variant>("PetLevel").GetValueOrDefault<Variant>(model.PetMin + "-" + model.PetMax);
            if (petLevel == null)
                return;

            int addFatigue = 0;//战斗增加疲劳值
            switch (type)
            {
                case 0:
                    addFatigue = petLevel.GetIntOrDefault("Lose");
                    break;
                case 1:
                    addFatigue = petLevel.GetIntOrDefault("Win");
                    break;
                case 2:
                    addFatigue = petLevel.GetIntOrDefault("Ping");
                    break;
            }

            if (user.ID == model.PlayerID)
            {
                addFatigue = Convert.ToInt32(addFatigue * (1 - petLevel.GetDoubleOrDefault("FarmLv")));
            }

            foreach (Pet p in model.Pets.Values)
            {
                if (p.PlayerID != user.ID)
                    continue;
                Variant v = p.Value;
                //取得宠物最大疲劳值
                int max = PetAccess.Instance.MaxFatigue(v.GetIntOrDefault("PetsLevel"));

                if (p.PlayerID == user.ID)
                {
                    if (v.GetIntOrDefault("Fatigue") + addFatigue >= max)
                    {
                        v["Fatigue"] = max;
                    }
                    else
                    {
                        v["Fatigue"] = v.GetIntOrDefault("Fatigue") + addFatigue;
                    }

                    p.SaveFatigue();

                    Variant tmp = new Variant();
                    tmp.Add("ID",p.ID);
                    tmp.Add("Fatigue", v.GetIntOrDefault("Fatigue"));
                    user.Call(PetsCommand.UpdatePetR, true, tmp);
                    //Console.WriteLine("宠物名称:" + p.Name + ",当前疲劳值:" + v.GetIntOrDefault("Fatigue") + ",增加量:" + addFatigue + ",输赢:" + type);
                }
            }
        }
Beispiel #19
0
        /// <summary>
        /// 添加好友检查
        /// </summary>
        /// <returns></returns>
        private static bool CheckFriends(PlayerBusiness model, PlayerBusiness player, string comm, int app)
        {
            if (player == null)
            {
                model.Call(comm, false, TipManager.GetMessage(SocialReturn.UserInfoError), string.Empty);
                return false;
            }

            if (model.ID == player.ID)
            {
                //"不能将自己加为好友"
                model.Call(comm, false, TipManager.GetMessage(SocialReturn.CheckFriends1), string.Empty);
                return false;
            }

            if (!player.Online)
            {
                //"【" + player.Name + "】不在线,不能加为好友"
                model.Call(comm, false, string.Format(TipManager.GetMessage(SocialReturn.CheckFriends2), player.Name), "");
                return false;
            }

            PlayerEx social = model.Social;
            if (social == null)
            {
                model.Call(comm, false, TipManager.GetMessage(SocialReturn.UserInfoError), string.Empty);
                return false;
            }

            IList enemy = social.Value.GetValue<IList>("Enemy");
            if (enemy != null)
            {
                if (enemy.Contains(player.ID))
                {
                    //"请先解除与【" + player.Name + "】的仇人关系再添加为好友"
                    model.Call(comm, false, string.Format(TipManager.GetMessage(SocialReturn.CheckFriends3), player.Name), string.Empty);
                    return false;
                }
            }

            IList friends = social.Value.GetValue<IList>("Friends");
            if (friends != null)
            {
                foreach (Variant v in friends)
                {
                    if (v.GetStringOrDefault("PlayerID") == player.ID)
                    {
                        //"【" + player.Name + "】与你已经是好友不能再添加"
                        model.Call(comm, false, string.Format(TipManager.GetMessage(SocialReturn.CheckFriends4), player.Name), string.Empty);
                        return false;
                    }
                }

                if (friends.Count >= 20)
                {
                    if (app == 0)
                    {
                        //"你的好友已满,其他玩家添加你好友失败"
                        model.Call(comm, false, TipManager.GetMessage(SocialReturn.CheckFriends5), string.Empty);
                    }
                    else
                    {
                        //TipManager.GetMessage("对方好友已满,无法添加")
                        model.Call(comm, false, TipManager.GetMessage(SocialReturn.CheckFriends6), string.Empty);
                    }
                    return false;
                }
            }

            PlayerEx social1 = player.Social;
            IList enemy1 = social.Value.GetValue<IList>("Enemy");
            if (enemy1 != null)
            {
                if (enemy.Contains(model.ID))
                {
                    //"【 + player.Name + "】已经将你加为仇人不能加为好代友"
                    model.Call(comm, false, string.Format(TipManager.GetMessage(SocialReturn.CheckFriends7), player.Name), string.Empty);
                    return false;
                }
            }

            IList friends1 = social1.Value.GetValue<IList>("Friends");
            if (friends1 != null)
            {
                foreach (Variant v in friends1)
                {
                    if (v.GetStringOrDefault("PlayerID") == player.ID)
                    {
                        //【 + player.Name + 】与你已经是好友不能再添加
                        model.Call(comm, false, string.Format(TipManager.GetMessage(SocialReturn.CheckFriends8), player.Name), string.Empty);
                        return false;
                    }
                }

                if (friends1.Count >= 20)
                {
                    if (app == 0)
                    {
                        //对方好友已满,无法添加
                        model.Call(comm, false, TipManager.GetMessage(SocialReturn.CheckFriends9), string.Empty);
                    }
                    else
                    {
                        //你的好友已满,其他玩家添加你好友失败
                        model.Call(comm, false, TipManager.GetMessage(SocialReturn.CheckFriends10), string.Empty);
                    }
                    return false;
                }
            }
            return true;
        }
Beispiel #20
0
        /// <summary>
        /// 判断数据道具是否合法
        /// </summary>
        /// <param name="pb"></param>
        /// <returns></returns>
        private static bool IsCheck(PlayerBusiness pb, IList gs, IList c)
        {
            Dictionary<int, int> dic = new Dictionary<int, int>();

            foreach (Variant n in gs)
            {
                foreach (Variant k in c)
                {
                    int p = n.GetIntOrDefault("P");
                    if (p != k.GetIntOrDefault("P"))
                        continue;

                    if (k.GetIntOrDefault("H") == 1)
                    {
                        pb.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(DealReturn.IsBinding));
                        return false;
                    }

                    if (n.GetStringOrDefault("E") != k.GetStringOrDefault("E"))
                    {
                        pb.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(DealReturn.NumberError));
                        return false;
                    }

                    if (n.GetIntOrDefault("A") != k.GetIntOrDefault("A"))
                    {
                        pb.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(DealReturn.NumberError));
                        return false;
                    }

                    Variant t = k.GetVariantOrDefault("T");
                    if (t != null)
                    {
                        if (t.ContainsKey("EndTime"))
                        {
                            pb.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(DealReturn.IsCheck1));
                            return false;
                        }
                    }
                    n["T"] = t;//物品变更信息
                    if (dic.ContainsKey(p))
                    {
                        pb.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(DealReturn.IsCheck2));
                        return false;
                    }
                    dic.Add(p, p);
                    break;
                }
            }
            return true;
        }
Beispiel #21
0
        /// <summary>
        /// 记录不同任务类型每天完成情况
        /// </summary>
        /// <param name="pb">任务id</param>
        /// <param name="tasktype">任务类型</param>
        private static void TaskType(PlayerBusiness pb, string tasktype)
        {
            PlayerEx fx = pb.TaskDay;
            Variant v = fx.Value;
            if (v == null)
            {
                fx.Value = new Variant();
                v = fx.Value;
            }

            DateTime dt = DateTime.Now;
            //保留7天记录
            int delKey = Convert.ToInt32(dt.AddDays(-10).Date.ToString("yyyyMMdd"));
            //需要移除的Key
            List<string> keys = new List<string>();
            foreach (var item in v)
            {
                if (Convert.ToInt32(item.Key) < delKey)
                {
                    keys.Add(item.Key);
                }
            }

            if (keys.Count > 0)
            {
                foreach (string k in keys)
                {
                    v.Remove(k);
                }
            }

            string day = dt.Date.ToString("yyyyMMdd");
            Variant info;
            if (v.TryGetValueT(day, out info))
            {
                info.SetOrInc(tasktype, 1);
            }
            else
            {
                info = new Variant();
                info.SetOrInc(tasktype, 1);
                v.Add(day, info);
            }
            fx.Save();
            pb.Call(ClientCommand.UpdateActorR, new PlayerExDetail(fx));
        }
Beispiel #22
0
        /// <summary>
        /// 任务触发
        /// </summary>
        /// <param name="note"></param>
        /// <param name="gc"></param>
        public static void TaskStartBusiness(PlayerBusiness pb, GameConfig gc, bool IsCall = true)
        {
            if (!TaskAccess.Instance.TaskLimit(pb.ID, pb.Level, gc.ID, gc.Value))
            {
                return;
            }
            int loopcount = 0;
            if (gc.Value.GetIntOrDefault("TaskType") == 8)
            {
                loopcount = pb.WeekTotal(8) + 1;
            }

            Task task = TaskAccess.Instance.TaskBase(pb.ID, pb.RoleID, gc, loopcount, pb.Level);

            if (IsCall && task != null)
            {
                pb.Call(TaskCommand.TaskActivationR, TaskAccess.Instance.GetTaskInfo(task));
            }
        }
Beispiel #23
0
        /// <summary>
        /// 成功进入场景
        /// </summary>
        /// <param name="note"></param>
        protected override void IntoSceneSuccess(PlayerBusiness player, Variant sceneinfo)
        {
            player.Call(ClientCommand.IntoSceneR, true, sceneinfo, EmptyPlayerList);
            player.FightTime = DateTime.UtcNow.AddSeconds(10);
            player.Online = true;
            player.Save();

            if (this.HaveApc)
            {
                IList apcs = SceneApcProxy.GetSceneApc(this.ID);
                player.Call(ClientCommand.RefreshApcR, this.ID, apcs);
            }
            if (this.HaveBox)
            {
                IList boxs = BoxProxy.GetSceneBox(this.ID);
                player.Call(ClientCommand.RefreshBoxR, this.ID, boxs);
            }
        }
Beispiel #24
0
 /// <summary>
 /// 陪伴兽
 /// </summary>
 /// <param name="pb"></param>
 private static void Mountegg(PlayerBusiness pb, GameConfig gc)
 {
     if (pb.Mounts != null)
     {
         pb.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(GoodsReturn.IsMounst));
         return;
     }
     Mounts m = new Mounts();
     m.ID = ObjectId.GenerateNewId().ToString();
     m.PlayerID = pb.ID;
     m.MountsID = gc.Value.GetStringOrDefault("MountsID");
     m.Level = 1;
     m.Rank = 1;
     m.Experience = 0;
     DateTime dt = DateTime.UtcNow;
     m.Update = dt;
     m.Created = dt;
     m.Name = gc.Name;
     m.Status = 1;
     m.ZhuFu = 0;
     m.FailCount = 0;
     m.FailTime = dt;
     if (m.Save())
     {
         pb.MountsUpdate(m, null);
         pb.MountsInfo();
     }
 }
Beispiel #25
0
 /// <summary>
 /// 检查必杀怪
 /// </summary>
 /// <param name="player"></param>
 /// <param name="npcID"></param>
 /// <returns></returns>
 protected override bool CheckFight(PlayerBusiness player, string npcID)
 {
     IList killed = player.Ectype.Value.GetValue<IList>("Killed");
     if (killed.Contains(npcID))
     {
         player.Call(FightCommand.FightFalseR, npcID, string.Format(TipManager.GetMessage(ClientReturn.SceneEctype5)));
         return false;
     }
     string needKill = NpcManager.Instance.MustKill(this.ID, killed, npcID);
     if (needKill != null)
     {
         string msg = string.Format(TipManager.GetMessage(ClientReturn.SceneEctype4), needKill);
         player.Call(FightCommand.FightFalseR, npcID, msg);
         return false;
     }
     //需发送通知:
     return needKill == null;
 }
Beispiel #26
0
 private static bool ResponseCompleted(Socket client, Order order, PlayerBusiness player)
 {
     int coin = order.Coin;
     //检查tokenID(状态由11变到12,准备充值,用于锁定)
     if (OrderAccess.Instance.IncOrderState(order.token, 11, 1, coin))
     {
         if (player.AddCoin(coin, FinanceType.BuyCoin))
         {
             //(状态由12变到13,充值成功)
             if (OrderAccess.Instance.IncOrderState(order.token, 12, 1))
             {
                 //成功
                 Send(client, OrderResult.Success);
                 try
                 {
                     //发送充值成功通知.
                     player.Call(MallCommand.CoinSuccess, order.token, coin, player.Coin);
                     UserNote note = new UserNote(player, PartCommand.Recharge, new object[] { coin });
                     Notifier.Instance.Publish(note);
                 }
                 catch { }
                 return true;
             }
         }
     }
     return false;
 }
Beispiel #27
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));
        }
Beispiel #28
0
 protected void GetAward(PlayerBusiness player)
 {
     player.WriteDaily(PlayerBusiness.DailyBox, m_box.ID);
     AwardBox award = m_box.GetAward();
     if (award.Score > 0)
     {
         player.AddScore(award.Score, FinanceType.OpenBox);
     }
     if (award.Bond > 0)
     {
         player.AddBond(award.Bond, FinanceType.OpenBox);
     }
     Dictionary<string, Variant> dic = new Dictionary<string, Variant>();
     foreach (var k in award.Goods)
     {
         Variant v = new Variant(1);
         v.Add("Number0", k.Value);
         dic.Add(k.Key, v);
     }
     player.AddGoods(dic, GoodsSource.OpenBox);
     //发送结果
     player.Call(ClientCommand.OpenBoxR, true, award);
 }
Beispiel #29
0
        /// <summary>
        /// 周式任务
        /// </summary>
        /// <param name="pb"></param>
        /// <param name="npcid"></param>
        /// <param name="isremove"></param>
        public static void WeekTask(PlayerBusiness pb, string npcid, bool isremove)
        {
            string soleid = pb.ID + "WeekTask";
            if (!m_dic.TryAdd(soleid, soleid))
                return;
            try
            {
                int cur = pb.WeekTotal(8);
                int max = Convert.ToInt32(TipManager.GetMessage(TaskReturn.LoopMax));
                if (cur >= max)
                    return;

                //表示一个环式任务都没有做的情况
                GameConfig gc = null;//要触发的任务
                Task t = TaskAccess.Instance.GetWeekTask(pb.ID);
                if (t == null)
                {
                    //触发新的任务
                    if (cur == 0)
                    {
                       gc = GameConfigAccess.Instance.GetFristWeek(pb.Level, 8);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(npcid))
                        {
                            gc = GameConfigAccess.Instance.GetWeekTask(npcid, 8, pb.Level);
                        }
                    }
                }
                else
                {
                    DateTime dt = DateTime.Now;

                    string taskid = t.Value.GetStringOrDefault("TaskID");
                    //任务触发时间
                    DateTime created = t.Created.ToLocalTime();
                    if (!ActivityManager.LocalWeek(created, dt))
                    {
                        //移除任务
                        DeleteTask(pb, new List<string>() { taskid }, isremove);
                        //触发第一个任务
                        gc = GameConfigAccess.Instance.GetFristWeek(pb.Level, 8);
                    }
                }

                if (gc == null)
                    return;

                //表示没有任务
                Task task = TaskAccess.Instance.TaskBase(pb.ID, pb.RoleID, gc, (cur + 1), pb.Level);
                if (task == null)
                    return;

                if (isremove)
                {
                    pb.Call(TaskCommand.TaskActivationR, TaskAccess.Instance.GetTaskInfo(task));
                }
            }
            finally
            {
                m_dic.TryRemove(soleid, out soleid);
            }
        }
Beispiel #30
0
        /// <summary>
        /// 操作家园信息,在角色登录或在线进行操作
        /// </summary>
        /// <param name="pb"></param>
        public static void HomeInfoCall(PlayerBusiness pb)
        {
            string soleid = pb.ID + "HomeInfoCall";
            if (!m_dic.TryAdd(soleid, soleid))
                return;

            try
            {
                Variant mv = MemberAccess.MemberInfo(pb.MLevel);
                if (mv == null)
                    return;
                //表示没有自动发送邮件的功能
                if (!mv.GetBooleanOrDefault("IsHome"))
                    return;
                PlayerEx home = pb.Home;
                if (home == null)
                    return;
                Variant hv = home.Value;
                if (hv == null)
                    return;
                Variant produces = hv.GetVariantOrDefault("Produces");

                //自动取得道具功能
                Dictionary<string, string> dic = new Dictionary<string, string>();
                dic.Add("GuoYuan", "CaiJi");
                dic.Add("ShuFang", "JuanZhou");
                dic.Add("JiaGongFang", "JiaGong");

                foreach (var item in dic)
                {

                    GameConfig model = null;
                    if (item.Key == "GuoYuan")
                    {
                        model = GameConfigAccess.Instance.FindOneById("Home_CJ00002");
                    }
                    else if (item.Key == "ShuFang")
                    {
                        model = GameConfigAccess.Instance.FindOneById("Home_CJ00001");
                    }
                    else if (item.Key == "JiaGongFang")
                    {
                        model = GameConfigAccess.Instance.FindOneById("Home_CJ00003");
                    }
                    if(model==null)
                        return;

                    string goodsid = model.Value.GetStringOrDefault("GoodsID");

                    Variant vp = produces.GetVariantOrDefault(item.Key);
                    if (vp == null)
                        continue;
                    IList petList = vp.GetValue<IList>("PetList");
                    //表示没有放入宠物
                    if (petList == null || petList.Count == 0)
                        continue;
                    Variant p = petList[0] as Variant;
                    if (p == null)
                        continue;

                    //string goodsid = vp.GetStringOrDefault("GoodsID");
                    string st = vp.GetStringOrDefault("StartTime");
                    string et = vp.GetStringOrDefault("EndTime");

                    if (string.IsNullOrEmpty(st) || string.IsNullOrEmpty(et))
                        continue;

                    DateTime startTime = vp.GetDateTimeOrDefault("StartTime");
                    DateTime endTime = vp.GetDateTimeOrDefault("EndTime");
                    DateTime dt = DateTime.UtcNow;
                    int zv = p.GetIntOrDefault(item.Value);
                    //得到总供生产秒数
                    if (endTime > dt)
                        continue;
                    int t = Convert.ToInt32((endTime - startTime).TotalSeconds);
                    //技算得到道具数量
                    int number = Convert.ToInt32(HomeNumber(zv) * t / 7200);
                    if (number <= 0)
                        continue;

                    GameConfig gc = GameConfigAccess.Instance.FindOneById(goodsid);
                    if (gc == null)
                        continue;

                    vp["StartTime"] = dt;
                    vp["EndTime"] = dt.AddHours(mv.GetIntOrDefault("HomeHour"));
                    if (home.Save())
                    {

                        string title = "";
                        // "亲爱的会员玩家【{0}】,您在家园中生产的物品【{1}】已到达自动生产的上限时间【{2}】小时,现将您生产出的【{1}】总共【{3}】个邮寄给您,请您及时查收.同时生产又自动开始";
                        string content = string.Format(TipManager.GetMessage(HomeReturn.HomeInfoCall4), pb.Name, gc.Name, (t / 3600), number);
                        switch (item.Key)
                        {
                            case "GuoYuan":
                                // "家园自动采集";
                                title =TipManager.GetMessage(HomeReturn.HomeInfoCall1);
                                break;
                            case "ShuFang":
                                //"家园自动养殖";
                                title = TipManager.GetMessage(HomeReturn.HomeInfoCall2);
                                break;
                            case "JiaGongFang":
                                //"家园自动挖掘";
                                title = TipManager.GetMessage(HomeReturn.HomeInfoCall3);
                                break;
                        }
                        Variant gs = new Variant();
                        gs.Add("G", goodsid);
                        gs.Add("A", number);
                        gs.Add("E", goodsid);
                        gs.Add("H", 1);

                        List<Variant> goodsList = new List<Variant>();
                        if (number > 0)
                        {
                            goodsList.Add(gs);
                        }
                        else
                        {
                            goodsList = null;
                        }

                        int reTime = Convert.ToInt32(TipManager.GetMessage(EmailReturn.HameDay));
                        if (EmailAccess.Instance.SendEmail(title, TipManager.GetMessage(PetsReturn.StealPet12), pb.ID, pb.Name, content, string.Empty, goodsList, reTime))
                        {
                            if (pb.Online)
                            {
                                pb.Call(EmailCommand.NewEmailTotalR, EmailAccess.Instance.NewTotal(pb.ID));
                            }
                        }
                    }

                    Variant gs1 = new Variant();
                    gs1[goodsid] = number;

                    Variant os = new Variant();
                    os["StartTime"] = startTime;
                    os["EndTime"] = endTime;
                    os["PetsID"] = p.GetStringOrDefault("PetID");
                    os["ID"] = p.GetStringOrDefault("ID");
                    os["Number"] = zv;
                    os["Name"] = item.Value;
                    os["IsHand"] = 0;//自动
                    pb.AddLogVariant(Actiontype.JiaZheng, null, gs1,os);
                }
            }
            finally
            {
                m_dic.TryRemove(soleid, out soleid);
            }
        }