Ejemplo n.º 1
0
 //对比玩家与名次是否相符
 public IEnumerator CompareRank(Coroutine coroutine, RankService _this, CompareRankInMessage msg)
 {
     msg.Response = ServerRankManager.CompareRank(msg.Request.ServerId, P1vP1.P1vP1RankTypeId,
                                                  msg.Request.CharacterId, msg.Request.Rank);
     msg.Reply();
     yield break;
 }
Ejemplo n.º 2
0
        public IEnumerator NodifyModifyPlayerName(Coroutine coroutine, RankService _this, NodifyModifyPlayerNameInMessage msg)
        {
            var name     = msg.Request.ModifyName;
            var ServerId = msg.Request.ServerId;

            ServerRankManager.ChangePlayerName(ServerId, name, msg.Request.Guid);
            yield break;
        }
Ejemplo n.º 3
0
 //修改等级
 public IEnumerator CharacterChangeLevel(Coroutine coroutine,
                                         RankService _this,
                                         CharacterChangeLevelInMessage msg)
 {
     ServerRankManager.ResetLevel(msg.Request.ServerId, msg.Request.Name, msg.Request.Guid,
                                  msg.Request.Level * Constants.RankLevelFactor + msg.Request.Exp);
     yield break;
 }
Ejemplo n.º 4
0
        public IEnumerator GetRankValue(Coroutine coroutine, RankService _this, GetRankValueInMessage msg)
        {
            var request  = msg.Request;
            var serverId = request.ServerId;
            var rankType = request.RankType;
            var idx      = request.Idx;

            msg.Response = ServerRankManager.GetRankData(serverId, rankType, idx);
            msg.Reply();
            yield break;
        }
Ejemplo n.º 5
0
        //玩家的排行榜数据修改
        public IEnumerator SSCharacterChangeDataList(Coroutine coroutine,
                                                     RankService _this,
                                                     SSCharacterChangeDataListInMessage msg)
        {
            var name     = msg.Request.Changes.Name;
            var ServerId = msg.Request.Changes.ServerId;

            foreach (var change in msg.Request.Changes.Changes)
            {
                switch (change.RankType)
                {
                case (int)RankType.FightValue:      //战斗力
                    ServerRankManager.ResetFightPoint(ServerId, name, msg.CharacterId, change.Value);
                    break;

                case (int)RankType.Level:      //等级
                    ServerRankManager.ResetLevel(ServerId, name, msg.CharacterId, change.Value);
                    break;

                case (int)RankType.Money:      //钱
                    ServerRankManager.ResetMoney(ServerId, name, msg.CharacterId, change.Value);
                    break;

                case (int)RankType.CityLevel:      //家园等级
                    ServerRankManager.ResetCityLevel(ServerId, name, msg.CharacterId, change.Value);
                    break;

                case (int)RankType.WingsFight:      //翅膀战力
                    ServerRankManager.ResetWingsFight(ServerId, name, msg.CharacterId, change.Value);
                    break;

                case (int)RankType.PetFight:      //精灵战力
                    ServerRankManager.ResetPetFight(ServerId, name, msg.CharacterId, change.Value);
                    break;

                case (int)RankType.RechargeTotal:                         //总充值
                    ServerRankManager.ResetTotalRecharge(ServerId, name, msg.CharacterId, change.Value);
                    break;

                case (int)RankType.DailyGift:
                case (int)RankType.WeeklyGift:
                case (int)RankType.TotalGift:
                    ServerRankManager.ResetGiftRank(change.RankType, ServerId, name, msg.CharacterId, change.Value);
                    break;

                case (int)RankType.Mount:      // 坐骑
                    ServerRankManager.ResetMountRank(ServerId, name, msg.CharacterId, change.Value);
                    break;
                }
            }
            yield break;
        }
Ejemplo n.º 6
0
        //修改数据
        public IEnumerator CharacterChangeData(Coroutine coroutine, RankService _this, CharacterChangeDataInMessage msg)
        {
            switch (msg.Request.RankType)
            {
            case (int)RankType.FightValue:      //战斗力
                ServerRankManager.ResetFightPoint(msg.Request.ServerId, msg.Request.Name, msg.Request.Guid,
                                                  msg.Request.Value);
                break;

            case (int)RankType.Money:      //钱
                ServerRankManager.ResetMoney(msg.Request.ServerId, msg.Request.Name, msg.Request.Guid,
                                             msg.Request.Value);
                break;

            case (int)RankType.CityLevel:      //家园等级
                ServerRankManager.ResetCityLevel(msg.Request.ServerId, msg.Request.Name, msg.Request.Guid,
                                                 msg.Request.Value);
                break;

            case (int)RankType.WingsFight:      //翅膀战力
                ServerRankManager.ResetWingsFight(msg.Request.ServerId, msg.Request.Name, msg.Request.Guid,
                                                  msg.Request.Value);
                break;

            case (int)RankType.PetFight:      //精灵战力
                ServerRankManager.ResetPetFight(msg.Request.ServerId, msg.Request.Name, msg.Request.Guid,
                                                msg.Request.Value);
                break;

            case (int)RankType.RechargeTotal:                     //精灵战力
                ServerRankManager.ResetTotalRecharge(msg.Request.ServerId, msg.Request.Name, msg.Request.Guid,
                                                     msg.Request.Value);
                break;

            case (int)RankType.DailyGift:
            case (int)RankType.WeeklyGift:
            case (int)RankType.TotalGift:
                ServerRankManager.ResetGiftRank(msg.Request.RankType, msg.Request.ServerId,
                                                msg.Request.Name, msg.Request.Guid, msg.Request.Value);
                break;

            case (int)RankType.Mount:       // 坐骑
                ServerRankManager.ResetMountRank(msg.Request.ServerId, msg.Request.Name, msg.Request.Guid, msg.Request.Value);
                break;
            }
            yield break;
        }
Ejemplo n.º 7
0
        public void FightRankListBackUp(RankManager _this)
        {
            _this.FightRankServerToRnak.Clear();


            DataTable.Table.ForeachServerName(record =>
            {
                int serverId = record.LogicID;
                if (record.LogicID == record.Id)
                {
                    var data = ServerRankManager.GetRankDataByServerId(serverId, 0, 1, 20);

                    if (null != data)
                    {
                        _this.FightRankServerToRnak.Add(serverId, data);
                    }
                }
                return(true);
            });
        }
Ejemplo n.º 8
0
        //获取排行榜列表
        public IEnumerator GetRankList(Coroutine coroutine, RankCharacterProxy charProxy, GetRankListInMessage msg)
        {
            var proxy = charProxy;

            var serverId = SceneExtension.GetServerLogicId(msg.Request.ServerId);
            var type     = msg.Request.RankType;

            PlayerLog.WriteLog(proxy.CharacterId, "----------Rank----------GetRankList----------{0},{1}", serverId, type);

            var needServerName         = false;
            List <DBRank_One> tempList = null;

            if (type == (int)RankType.DailyGift || type == (int)RankType.WeeklyGift ||
                type == (int)RankType.TotalGift)
            {
                needServerName = true;
                tempList       = ServerRankManager.GetTotalRankData(type, 1, 100);
            }
            else
            {
                tempList = ServerRankManager.GetRankDataByServerId(serverId, type, 1, 100);
            }

            if (tempList == null)
            {
                msg.Reply();
                yield break;
            }
            msg.Response.RankType = type;
            foreach (var one in tempList)
            {
                if (one == null)
                {
                    Logger.Error("GetRankList serverId={0},type={1}", serverId, type);
                    continue;
                }
                var rankMessage = new RankOne
                {
                    Id   = one.Guid,
                    Name = one.Name //ServerRankManager.GetName(serverId, one.Guid),
                };
                if (type == (int)RankType.Level)
                {
                    rankMessage.Value = (int)(one.Value / Constants.RankLevelFactor);
                }
                else if (type == (int)RankType.CityLevel)
                {
                    rankMessage.Value = (int)(one.Value / Constants.RankLevelFactor);
                }
                else if (type == (int)RankType.Arena)
                {
                    rankMessage.Value = one.FightPoint;
                }
                else
                {
                    rankMessage.Value = (int)one.Value;
                }

                if (needServerName && one.ServerId > 0)
                {
                    var tbServerName = Table.GetServerName(one.ServerId);
                    if (tbServerName != null)
                    {
                        rankMessage.ServerName = tbServerName.Name;
                    }
                }

                if (rankMessage.Name == "")
                {
                    var dbSceneSimple = RankServer.Instance.SceneAgent.GetSceneSimpleData(rankMessage.Id, 0);
                    yield return(dbSceneSimple.SendAndWaitUntilDone(coroutine));

                    if (dbSceneSimple.State == MessageState.Reply)
                    {
                        rankMessage.Name = dbSceneSimple.Response.Name;
                        one.Name         = dbSceneSimple.Response.Name;
                    }
                    else
                    {
                        //未找到
                        rankMessage.Name = "^301036";
                        one.Name         = "^301036";
                    }
                }
                msg.Response.RankData.Add(rankMessage);
            }
            msg.Reply();
        }
Ejemplo n.º 9
0
        //获取主城战力排行榜数据
        public IEnumerator GetFightRankList(Coroutine coroutine, RankCharacterProxy charProxy, GetFightRankListInMessage msg)
        {
            var proxy = charProxy;

            var serverId = SceneExtension.GetServerLogicId(msg.Request.ServerId);
            var type     = msg.Request.RankType;

            PlayerLog.WriteLog(proxy.CharacterId, "----------Rank----------GetFightRankList----------{0},{1}", serverId, type);

            var timeNow = System.DateTime.Now;
            var record  = DataTable.Table.GetServerName(serverId);

            if (null != record)
            {
                var             startTime = System.DateTime.Parse(record.OpenTime);
                System.TimeSpan span      = (timeNow - startTime);
                if (startTime.Date.Equals(timeNow.Date))
                {
                    if (timeNow.Day == startTime.Day)
                    {
                        msg.Reply();
                        yield break;
                    }
                }
            }

            var needServerName         = false;
            List <DBRank_One> tempList = null;

            tempList = ServerRankManager.GetFightRankList(serverId, type);

            if (tempList == null)
            {
                msg.Reply();
                yield break;
            }
            msg.Response.RankType = type;
            List <int> professCount = new List <int>();

            foreach (var one in tempList)
            {
                if (professCount.Count >= 3)
                {
                    break;
                }
                if (one == null)
                {
                    Logger.Error("GetRankList serverId={0},type={1}", serverId, type);
                    continue;
                }
                var rankMessage = new RankOne
                {
                    Id   = one.Guid,
                    Name = one.Name //ServerRankManager.GetName(serverId, one.Guid),
                };
                if (type == (int)RankType.Level)
                {
                    rankMessage.Value = (int)(one.Value / Constants.RankLevelFactor);
                }
                else if (type == (int)RankType.CityLevel)
                {
                    rankMessage.Value = (int)(one.Value / Constants.RankLevelFactor);
                }
                else if (type == (int)RankType.Arena)
                {
                    rankMessage.Value = one.FightPoint;
                }
                else
                {
                    rankMessage.Value = (int)one.Value;
                }

                if (needServerName && one.ServerId > 0)
                {
                    var tbServerName = Table.GetServerName(one.ServerId);
                    if (tbServerName != null)
                    {
                        rankMessage.ServerName = tbServerName.Name;
                    }
                }

                var dbSceneSimple = RankServer.Instance.SceneAgent.GetSceneSimpleData(rankMessage.Id, 0);
                yield return(dbSceneSimple.SendAndWaitUntilDone(coroutine));

                if (dbSceneSimple.State == MessageState.Reply)
                {
                    if (dbSceneSimple.ErrorCode == (int)ErrorCodes.OK)
                    {
                        if (rankMessage.Name == "")
                        {
                            rankMessage.Name = dbSceneSimple.Response.Name;
                            one.Name         = dbSceneSimple.Response.Name;
                        }

                        int typeId = dbSceneSimple.Response.TypeId;
                        if (!professCount.Contains(typeId))
                        {
                            professCount.Add(typeId);
                            msg.Response.RankData.Add(rankMessage);
                        }
                    }
                }
                else
                {
                    if (rankMessage.Name == "")
                    {
                        //未找到
                        rankMessage.Name = "^301036";
                        one.Name         = "^301036";
                    }
                }
            }

            msg.Reply();
        }
Ejemplo n.º 10
0
 public void LookRank()
 {
     ServerRankManager.ShowLog();
 }
Ejemplo n.º 11
0
        //获取某排行榜数据
        public IEnumerator SSGetServerRankData(Coroutine coroutine, RankService _this, SSGetServerRankDataInMessage msg)
        {
            var serverId = msg.Request.ServerId;
            var type     = msg.Request.Ranktype;
            var tempList = ServerRankManager.GetRankDataByServerId(serverId, type, 1, 100);

            if (tempList == null)
            {
                msg.Reply();
                yield break;
            }
            foreach (var one in tempList)
            {
                if (one == null)
                {
                    Logger.Error("GetRankList serverId={0},type={1}", serverId, type);
                    continue;
                }
                msg.Response.RankType = type;
                var rankMessage = new RankOne
                {
                    Id   = one.Guid,
                    Name = one.Name //ServerRankManager.GetName(serverId, one.Guid),
                };
                if (type == (int)RankType.Level)
                {
                    rankMessage.Value = (int)(one.Value / Constants.RankLevelFactor);
                }
                else if (type == (int)RankType.CityLevel)
                {
                    rankMessage.Value = (int)(one.Value / Constants.RankLevelFactor);
                }
                else if (type == (int)RankType.Arena)
                {
                    rankMessage.Value = one.FightPoint;
                }
                else
                {
                    rankMessage.Value = (int)one.Value;
                }
                if (rankMessage.Name == "")
                {
                    var dbSceneSimple = RankServer.Instance.SceneAgent.GetSceneSimpleData(rankMessage.Id, 0);
                    yield return(dbSceneSimple.SendAndWaitUntilDone(coroutine));

                    if (dbSceneSimple.State == MessageState.Reply)
                    {
                        rankMessage.Name = dbSceneSimple.Response.Name;
                        one.Name         = dbSceneSimple.Response.Name;
                    }
                    else
                    {
                        //未找到
                        rankMessage.Name = "^301036";
                        one.Name         = "^301036";
                    }
                }
                msg.Response.RankData.Add(rankMessage);
            }
            msg.Reply();
        }
Ejemplo n.º 12
0
        public IEnumerator RankP1vP1FightOver(Coroutine coroutine, RankService _this, RankP1vP1FightOverInMessage msg)
        {
            var selfId = msg.Request.CharacterId;
            var pvpId  = msg.Request.PvpCharacterId;

            var ranking = ServerRankManager.GetRankByType(msg.Request.ServerId, P1vP1.P1vP1RankTypeId);

            if (null == ranking)
            {
                Logger.Error("RankP1vP1FightOver not find ranking serverid={0},type={1}", msg.Request.ServerId, P1vP1.P1vP1RankTypeId);
                yield break;
            }

            var self = ranking.GetPlayerData(selfId);
            var pvp  = ranking.GetPlayerData(pvpId);

            if (self == null)
            {
                self      = new DBRank_One();
                self.Rank = ranking.GetRankCount() + 1;
                Logger.Error("RankP1vP1FightOver not find selfId={0}", selfId);
                yield break;
            }
            if (pvp == null)
            {
                Logger.Error("RankP1vP1FightOver not find pvpId={0}", pvpId);
                yield break;
            }
            var selfIndex = self.Rank;
            var pvpIndex  = pvp.Rank;
            var result    = msg.Request.Result;

            if (result != 1)
            {
                var selfMessage = RankServer.Instance.LogicAgent.PushP1vP1LadderChange(selfId, 0, msg.Request.PvpName,
                                                                                       result, selfIndex, selfIndex);
                yield return(selfMessage.SendAndWaitUntilDone(coroutine));

                if (!StaticData.IsRobot(pvpId))
                //if (pvpId > 999999)
                {
                    var pvpMessage = RankServer.Instance.LogicAgent.PushP1vP1LadderChange(pvpId, 1, msg.Request.Name,
                                                                                          result, pvpIndex, pvpIndex);
                    yield return(pvpMessage.SendAndWaitUntilDone(coroutine));
                }
                yield break;
            }

            if (selfIndex > pvpIndex)
            {
                ranking.SwapIndex(self, pvp);
                var selfMessage = RankServer.Instance.LogicAgent.PushP1vP1LadderChange(selfId, 0, msg.Request.PvpName,
                                                                                       result, selfIndex, pvpIndex);
                yield return(selfMessage.SendAndWaitUntilDone(coroutine));

                if (!StaticData.IsRobot(pvpId))
                //if (pvpId > 999999)
                {
                    var pvpMessage = RankServer.Instance.LogicAgent.PushP1vP1LadderChange(pvpId, 1, msg.Request.Name,
                                                                                          result, pvpIndex, selfIndex);
                    yield return(pvpMessage.SendAndWaitUntilDone(coroutine));

                    {//邮件通知对方
                        var item = new ItemBaseData();
                        item.ItemId = -1;
                        var args = new StringArray();
                        args.Items.Add(msg.Request.Name);
                        args.Items.Add(selfIndex.ToString());
                        var msgMail = RankServer.Instance.LogicAgent.SendMailToCharacterByItems(pvpId, 95, item, args);
                        yield return(msgMail.SendAndWaitUntilDone(coroutine));
                    }
                }
            }
            else
            {
                //selfOverIndex = -1;//-1代表打的人名次比我要差
                var selfMessage = RankServer.Instance.LogicAgent.PushP1vP1LadderChange(selfId, 0, msg.Request.PvpName,
                                                                                       result, selfIndex, -1);
                yield return(selfMessage.SendAndWaitUntilDone(coroutine));

                if (!StaticData.IsRobot(pvpId))
                //if (pvpId > 999999)
                {
                    var pvpMessage = RankServer.Instance.LogicAgent.PushP1vP1LadderChange(pvpId, 1, msg.Request.Name,
                                                                                          result, pvpIndex, -1);
                    yield return(pvpMessage.SendAndWaitUntilDone(coroutine));
                }
            }
        }
Ejemplo n.º 13
0
        public IEnumerator GetPvPList(Coroutine coroutine,
                                      int serverId,
                                      ulong guid,
                                      string name,
                                      List<ulong> targetList,
                                      List<int> rankList)

        {
            P1vP1.DBRank_One = null;
            var rank = ServerRankManager.GetRankByType(serverId, P1vP1.P1vP1RankTypeId);
            if (rank == null)
            {
                yield break;
            }
            //获得我的名次
            int myLadder;
            P1vP1.DBRank_One = rank.GetPlayerData(guid);
            if (P1vP1.DBRank_One == null)
            {
                var dbSceneSimple = RankServer.Instance.SceneAgent.GetSceneSimpleData(guid, 0);
                yield return dbSceneSimple.SendAndWaitUntilDone(coroutine);
                if (dbSceneSimple.State != MessageState.Reply)
                {
                    yield break;
                }
                if (dbSceneSimple.ErrorCode != (int) ErrorCodes.OK)
                {
                    yield break;
                }
                rank.AddRanking(serverId, guid, 0, name, dbSceneSimple.Response.FightPoint);
                P1vP1.DBRank_One = rank.GetPlayerData(guid);
                myLadder = 1000;
            }
            else
            {
                myLadder = P1vP1.DBRank_One.Rank;
            }
            //int myLadder = rank.GetPlayerLadder(guid);
            //if (myLadder == -1)
            //{
            //    myLadder = 9999;
            //}
            var rankCount = rank.GetRankListCount();
            if (myLadder > rankCount)
            {
                myLadder = rankCount;
            }
            //计算应该取得名次
            if (myLadder < 4)
            {
                for (var i = 0; i < 4; i++)
                {
                    if (i != myLadder - 1)
                    {
                        var rankOne = rank.GetRankOneByIndex(i);
                        if (rankOne != null)
                        {
                            targetList.Add(rankOne.Guid);
                            rankList.Add(rankOne.Rank);                            
                        }
                    }
                }
                //DBRank_One = null;
                yield break;
            }
            //随机3个阶段
            for (var i = 0; i != 3; ++i)
            {
                var minRank = myLadder*(i*2 + 4)/10;
                var maxRank = myLadder*(i*2 + 6)/10;
                if (myLadder < 100)
                {
                    if (i == 2)
                    {                       
                        maxRank = myLadder * i;
                    }
                }
                var thisRank = MyRandom.Random(minRank, maxRank - 1) - 1;
                var one = rank.GetRankOneByIndex(thisRank);
                
                if (one == null)
                {
                    targetList.Add(rank.GetRankOneByIndex(0).Guid);
                    rankList.Add(0);
                    continue;
                }
                while (one.Guid == guid)
                {
                    thisRank = MyRandom.Random(minRank, maxRank - 1) - 1;
                    one = rank.GetRankOneByIndex(thisRank);
                }

                targetList.Add(one.Guid);
                rankList.Add(thisRank + 1);
            }
            //targetList.Add(rank.GetRankOneByIndex(MyRandom.Random(myLadder * 4 / 10, myLadder * 6 / 10)).Guid);
            //targetList.Add(rank.GetRankOneByIndex(MyRandom.Random(myLadder * 6 / 10, myLadder * 8 / 10)).Guid);
            //targetList.Add(rank.GetRankOneByIndex(MyRandom.Random(myLadder * 8 / 10, myLadder)).Guid);
        }