Beispiel #1
0
        public static int CurrCityID(short userlv)
        {
            int             cityID        = 0;
            List <CityInfo> cityInfosList = new ShareCacheStruct <CityInfo>().FindAll(m => m.CityType == 0 && m.MinLv <= userlv);

            cityInfosList.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                return(y.CityID.CompareTo(x.CityID));
            });
            if (cityInfosList.Count > 0)
            {
                cityID = cityInfosList[0].CityID;
            }
            return(cityID);
        }
Beispiel #2
0
        /// <summary>
        /// 佣兵武器开启的附魔格子
        /// </summary>
        /// <param name="itemLv"></param>
        /// <returns></returns>
        public static short EnchantOpenGridNum(short itemLv)
        {
            short gridNum     = 0;
            var   mosaicInfos = new ShareCacheStruct <MosaicInfo>().FindAll(m => m.DemandLv <= itemLv);

            mosaicInfos.QuickSort((x, y) =>
            {
                int result = 0;
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                result = y.DemandLv.CompareTo(x.DemandLv);
                return(result);
            });
            if (mosaicInfos.Count > 0)
            {
                gridNum = mosaicInfos[0].Position.ToShort();
            }
            return(gridNum);
        }
Beispiel #3
0
        public override bool TakeAction()
        {
            List <UserFriends> userFriendsesArray = new ShareCacheStruct <UserFriends>().FindAll(m => m.UserID == ContextUser.UserID && m.FriendType == _friendType);

            userFriendsesArray.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                //普通的玩家根据等级来排序 如果是仇敌的话需要用最后战斗时间来排序
                int result = 0;
                if (_friendType != FriendType.ChouDi)
                {
                    GameUser userx      = new GameDataCacheSet <GameUser>().FindKey(x.UserID);
                    GameUser usery      = new GameDataCacheSet <GameUser>().FindKey(y.UserID);
                    int userLvx         = userx == null ? 0 : userx.UserLv;
                    int userLvy         = usery == null ? 0 : usery.UserLv;
                    int currExperiencex = (UserGeneral.GetMainGeneral(x.UserID) ?? new UserGeneral()).CurrExperience;
                    int currExperiencey = (UserGeneral.GetMainGeneral(y.UserID) ?? new UserGeneral()).CurrExperience;
                    result = userLvy.CompareTo(userLvx);
                    if (result == 0)
                    {
                        result = currExperiencey.CompareTo(currExperiencex);
                    }
                }
                else
                {
                    result = x.FightTime.CompareTo(y.FightTime);
                    if (result == 0)
                    {
                        result = x.UserID.CompareTo(y.UserID);
                    }
                }
                return(result);
            });
            _userFriendList = userFriendsesArray.GetPaging(_pageIndex, _pageSize, out _pageCount);
            return(true);
        }
Beispiel #4
0
 /// <summary>
 /// 佣兵武器开启的附魔格子
 /// </summary>
 /// <param name="itemLv"></param>
 /// <returns></returns>
 public static short EnchantOpenGridNum(short itemLv)
 {
     short gridNum = 0;
     var mosaicInfos = new ShareCacheStruct<MosaicInfo>().FindAll(m => m.DemandLv <= itemLv);
     mosaicInfos.QuickSort((x, y) =>
     {
         int result = 0;
         if (x == null && y == null) return 0;
         if (x != null && y == null) return 1;
         if (x == null) return -1;
         result = y.DemandLv.CompareTo(x.DemandLv);
         return result;
     });
     if (mosaicInfos.Count > 0)
     {
         gridNum = mosaicInfos[0].Position.ToShort();
     }
     return gridNum;
 }
Beispiel #5
0
        public override bool TakeAction()
        {
            List <UserGuild> guildsArray = new ShareCacheStruct <UserGuild>().FindAll();

            guildsArray.QuickSort((x, y) =>
            {
                int result = 0;
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                result = y.GuildLv.CompareTo(x.GuildLv);
                if (result == 0)
                {
                    result = y.CurrExperience.CompareTo(x.CurrExperience);
                }
                return(result);
            });
            int ranking = 0;

            foreach (UserGuild guild in guildsArray)
            {
                ranking         = MathUtils.Addition(ranking, 1, int.MaxValue);
                guild.GuildRank = ranking;
                //guild.Update();
            }
            if (!string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                guildsArray = new ShareCacheStruct <UserGuild>().FindAll(u => u.GuildID != ContextUser.MercenariesID);
            }
            userGuildArray = guildsArray.GetPaging(pageIndex, pageSize, out pageCount);

            return(true);
        }
Beispiel #6
0
        public override bool TakeAction()
        {
            FightCombat combat          = new FightCombat();
            var         serverFightList = new ShareCacheStruct <ServerFight>().FindAll(s => s.FastID == combat.FastID && !s.IsRemove);

            serverFightList.QuickSort((x, y) =>
            {
                int result;
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                result = x.CityID.CompareTo(y.CityID);
                if (result == 0)
                {
                    var userGuildA = new ShareCacheStruct <UserGuild>().FindKey(x.GuildID);
                    var userGuildB = new ShareCacheStruct <UserGuild>().FindKey(y.GuildID);
                    if (userGuildA != null && userGuildB != null)
                    {
                        result = userGuildB.GuildLv.CompareTo(userGuildA.GuildLv);
                        if (result == 0)
                        {
                            result = userGuildB.CurrExperience.CompareTo(userGuildA.CurrExperience);
                        }
                    }
                }
                return(result);
            });
            fightList = serverFightList.GetPaging(pageIndex, pageSize, out pageCount);
            rankID    = (short)(MathUtils.Subtraction(pageIndex, 1) * 5);
            return(true);
        }
Beispiel #7
0
 public GameNotice[] GetNotices(int pageIndex, int pageSize, out int recordCount)
 {
     recordCount = 0;
     try
     {
         List <GameNotice> list = new ShareCacheStruct <GameNotice>().FindAll();
         list.QuickSort((x, y) =>
         {
             int result = y.IsTop.CompareTo(x.IsTop);
             if (result == 0)
             {
                 return(y.CreateDate.CompareTo(x.CreateDate));
             }
             return(result);
         });
         var tempList = list.GetPaging(pageIndex, pageSize, out recordCount);
         return(tempList.ToArray());
     }
     catch (Exception ex)
     {
         new BaseLog().SaveLog("取公告出错:", ex);
         throw;
     }
 }
Beispiel #8
0
 public GameNotice[] GetNotices(int pageIndex, int pageSize, out int recordCount)
 {
     recordCount = 0;
     try
     {
         List<GameNotice> list = new ShareCacheStruct<GameNotice>().FindAll();
         list.QuickSort((x, y) =>
         {
             int result = y.IsTop.CompareTo(x.IsTop);
             if (result == 0)
             {
                 return y.CreateDate.CompareTo(x.CreateDate);
             }
             return result;
         });
         var tempList = list.GetPaging(pageIndex, pageSize, out recordCount);
         return tempList.ToArray();
     }
     catch (Exception ex)
     {
         new BaseLog().SaveLog("取公告出错:", ex);
         throw;
     }
 }
Beispiel #9
0
        public override bool TakeAction()
        {
            List<UserGuild> guildsArray = new ShareCacheStruct<UserGuild>().FindAll();
            guildsArray.QuickSort((x, y) =>
            {
                int result = 0;
                if (x == null && y == null) return 0;
                if (x != null && y == null) return 1;
                if (x == null) return -1;
                result = y.GuildLv.CompareTo(x.GuildLv);
                if (result == 0)
                {
                    result = y.CurrExperience.CompareTo(x.CurrExperience);
                }
                return result;
            });
            int ranking = 0;
            foreach (UserGuild guild in guildsArray)
            {
                ranking = MathUtils.Addition(ranking, 1, int.MaxValue);
                guild.GuildRank = ranking;
                //guild.Update();
            }
            if (!string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                guildsArray = new ShareCacheStruct<UserGuild>().FindAll(u => u.GuildID != ContextUser.MercenariesID);
            }
            userGuildArray = guildsArray.GetPaging(pageIndex, pageSize, out pageCount);

            return true;
        }
Beispiel #10
0
        public override bool TakeAction()
        {

            List<UserFriends> userFriendsesArray = new ShareCacheStruct<UserFriends>().FindAll(m => m.UserID == ContextUser.UserID && m.FriendType == _friendType);
            userFriendsesArray.QuickSort((x, y) =>
            {
                if (x == null && y == null) return 0;
                if (x != null && y == null) return 1;
                if (x == null) return -1;
                //普通的玩家根据等级来排序 如果是仇敌的话需要用最后战斗时间来排序
                int result = 0;
                if (_friendType != FriendType.ChouDi)
                {
                    GameUser userx = new PersonalCacheStruct<GameUser>().FindKey(x.UserID);
                    GameUser usery = new PersonalCacheStruct<GameUser>().FindKey(y.UserID);
                    int userLvx = userx == null ? 0 : userx.UserLv;
                    int userLvy = usery == null ? 0 : usery.UserLv;
                    int currExperiencex = (UserGeneral.GetMainGeneral(x.UserID) ?? new UserGeneral()).CurrExperience;
                    int currExperiencey = (UserGeneral.GetMainGeneral(y.UserID) ?? new UserGeneral()).CurrExperience;
                    result = userLvy.CompareTo(userLvx);
                    if (result == 0)
                    {
                        result = currExperiencey.CompareTo(currExperiencex);
                    }

                }
                else
                {
                    result = x.FightTime.CompareTo(y.FightTime);
                    if (result == 0)
                    {
                        result = x.UserID.CompareTo(y.UserID);
                    }
                }
                return result;
            });
            _userFriendList = userFriendsesArray.GetPaging(_pageIndex, _pageSize, out _pageCount);
            return true;
        }
Beispiel #11
0
        /// <summary>
        /// 决赛对阵
        /// </summary>
        public static void Grouping(int FastID, FightStage Stage, int cityID)
        {
            int gstage = (int)Stage - 1;
            FightStage Rstage = (FightStage)gstage;
            if (Stage == FightStage.semi_Wait)
            {
                Rstage = FightStage.quarter_final;
            }
            else if (Stage == FightStage.final_Wait)
            {
                Rstage = FightStage.semi_final;
            }
            var againstList = new ShareCacheStruct<ServerFightGroup>().FindAll(s => s.FastID == FastID && s.Stage == Rstage && s.CityID == cityID);
            againstList.QuickSort((x, y) =>
            {
                return x.NO.CompareTo(y.NO);
            });
            if (againstList.Count < 4 && Stage == FightStage.semi_Wait)
            {
                if (againstList.Count == 2)
                {
                    AppendServerFightGroup(1, againstList[0].WinGuildID, string.Empty, againstList[0].CityID);
                    AppendServerFightGroup(2, againstList[1].WinGuildID, string.Empty, againstList[1].CityID);
                }
                else if (againstList.Count == 3)
                {
                    AppendServerFightGroup(1, againstList[0].WinGuildID, againstList[1].WinGuildID, againstList[0].CityID);
                    AppendServerFightGroup(2, againstList[2].WinGuildID, string.Empty, againstList[2].CityID);
                }
            }
            else
            {
                for (int i = 0; i < againstList.Count / 2; i++)
                {
                    ServerFightGroup againstA = againstList[i * 2];
                    ServerFightGroup againstB = againstList[(i * 2) + 1];
                    ServerFightGroup against = new ServerFightGroup(Guid.NewGuid().ToString());
                    against.NO = i + 1;
                    against.Stage = Rstage;
                    if (Stage == FightStage.semi_Wait)
                    {
                        against.Stage = FightStage.semi_final;
                    }
                    else if (Stage == FightStage.final_Wait)
                    {
                        against.Stage = FightStage.final;
                    }
                    against.Round = 1;
                    against.FastID = FastID;
                    against.CityID = cityID;
                    if (againstA.Result == 1)
                    {
                        against.GuildIDA = againstA.GuildIDA;
                    }
                    else
                    {
                        against.GuildIDA = againstA.GuildIDB;
                    }

                    if (againstB.Result == 1)
                    {
                        against.GuildIDB = againstB.GuildIDA;
                    }
                    else
                    {
                        against.GuildIDB = againstB.GuildIDB;
                    }
                    against.IsRemove = false;
                    new ShareCacheStruct<ServerFightGroup>().Add(against, GameEnvironment.CacheGlobalPeriod);
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// 晋级公会
        /// </summary>
        /// <returns></returns>
        public static ServerFight[] GetApply(FightStage stage, int cityID)
        {
            int fastID = info.FastID;
            FightStage fightStage = FightStage.Ready;
            if (stage == FightStage.Apply && info.FastID > 1)
            {
                fastID = MathUtils.Subtraction(fastID, 1);
                fightStage = FightStage.final;
            }
            if (stage == FightStage.semi_Wait)
            {
                fightStage = FightStage.quarter_final;
            }
            else if (stage == FightStage.final_Wait)
            {
                fightStage = FightStage.semi_final;
            }
            var fightGroupList = new ShareCacheStruct<ServerFightGroup>().FindAll(s => s.FastID == fastID && s.Stage == fightStage);
            foreach (var fightgroup in fightGroupList)
            {
                if (string.IsNullOrEmpty(fightgroup.WinGuildID))
                {
                    ServerFightGroupWinGuildID(fightgroup, fastID);
                }
            }

            var applyList = new ShareCacheStruct<ServerFight>().FindAll(s => s.FastID == info.FastID && s.Stage == stage && s.CityID == cityID);
            applyList.QuickSort((x, y) =>
            {
                int result;
                if (x == null && y == null) return 0;
                if (x != null && y == null) return 1;
                if (x == null) return -1;
                result = (int)y.GetResult(stage).CompareTo(x.GetResult(stage));
                if (result == 0)
                {
                    var userGuildA = new ShareCacheStruct<UserGuild>().FindKey(x.GuildID);
                    var userGuildB = new ShareCacheStruct<UserGuild>().FindKey(y.GuildID);
                    if (userGuildA != null && userGuildB != null)
                    {
                        result = userGuildB.GuildLv.CompareTo(userGuildA.GuildLv);
                        if (result == 0)
                        {
                            result = userGuildB.CurrExperience.CompareTo(userGuildA.CurrExperience);
                        }
                    }
                }
                return result;
            });

            var apply = new CacheList<ServerFight>();
            for (int i = 0; i < info.Lenght && i < applyList.Count; i++)
            {
                apply.Add(applyList[i]);
            }
            return apply.ToArray();
        }
Beispiel #13
0
 public override bool TakeAction()
 {
     FightCombat combat = new FightCombat();
     var serverFightList = new ShareCacheStruct<ServerFight>().FindAll(s => s.FastID == combat.FastID && !s.IsRemove);
     serverFightList.QuickSort((x, y) =>
     {
         int result;
         if (x == null && y == null) return 0;
         if (x != null && y == null) return 1;
         if (x == null) return -1;
         result = x.CityID.CompareTo(y.CityID);
         if (result == 0)
         {
             var userGuildA = new ShareCacheStruct<UserGuild>().FindKey(x.GuildID);
             var userGuildB = new ShareCacheStruct<UserGuild>().FindKey(y.GuildID);
             if (userGuildA != null && userGuildB != null)
             {
                 result = userGuildB.GuildLv.CompareTo(userGuildA.GuildLv);
                 if (result == 0)
                 {
                     result = userGuildB.CurrExperience.CompareTo(userGuildA.CurrExperience);
                 }
             }
         }
         return result;
     });
     fightList = serverFightList.GetPaging(pageIndex, pageSize, out pageCount);
     rankID = (short)(MathUtils.Subtraction(pageIndex, 1) * 5);
     return true;
 }
Beispiel #14
0
 public static int CurrCityID(short userlv)
 {
     int cityID = 0;
     List<CityInfo> cityInfosList = new ShareCacheStruct<CityInfo>().FindAll(m => m.CityType == 0 && m.MinLv <= userlv);
     cityInfosList.QuickSort((x, y) =>
     {
         if (x == null && y == null) return 0;
         if (x != null && y == null) return 1;
         if (x == null) return -1;
         return y.CityID.CompareTo(x.CityID);
     });
     if (cityInfosList.Count > 0)
     {
         cityID = cityInfosList[0].CityID;
     }
     return cityID;
 }