Ejemplo n.º 1
0
 public override bool TakeAction()
 {
     if (string.IsNullOrEmpty(ContextUser.MercenariesID))
     {
         ErrorCode = LanguageManager.GetLang().ErrorCode;
         return false;
     }
     var cacheSet = new ShareCacheStruct<ServerFight>();
     FightCombat combat = new FightCombat();
     ServerFight fight = cacheSet.FindKey(combat.FastID, ContextUser.MercenariesID);
     if (fight != null)
     {
         if (!string.IsNullOrEmpty(fight.CombatMember))
         {
             fight.CombatMember = fight.CombatMember.Replace(ContextUser.UserID, "").Replace(",,", ",");
             if (fight.CombatMember == ",")
             {
                 fight.CombatMember = string.Empty;
             }
         }
         FightUser fightUser = GuildFightCombat._fightUserList.Find(m => m.UserId == ContextUser.UserID);
         if (fightUser != null)
         {
             GuildFightCombat._fightUserList.Remove(fightUser);
         }
         ContextUser.UserStatus = UserStatus.Normal;
     }
     else
     {
         ErrorCode = LanguageManager.GetLang().ErrorCode;
         ErrorInfo = LanguageManager.GetLang().St6411_FailedToExit;
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
        public override bool TakeAction()
        {
            if (string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }
            FightCombat fightCombat = new FightCombat();
            var cacheSet = new ShareCacheStruct<ServerFight>();
            ServerFight fight = cacheSet.FindKey(fightCombat.FastID, ContextUser.MercenariesID);
            if (fight != null)
            {
                if (GuildFightCombat.IsFightDate())
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St6412_FightWarDate;
                    return false;
                }

                var fightUser = GuildFightCombat._fightUserList.Find(m => !m.IsRemove && m.UserId == ContextUser.UserID);
                if (fightUser == null)
                {
                    fightUser = new FightUser();
                    fightUser.GuildID = fight.GuildID;
                    fightUser.UserId = ContextUser.UserID;
                    fightUser.UserName = ContextUser.NickName;
                    fightUser.WinCount = 0;
                    fightUser.CityID = fight.CityID;
                    fightUser.ObtainNum = 0;
                    fightUser.InspirePercent = 0;
                    fightUser.IsRemove = false;
                    fightUser.IsNotEnough = false;
                    GuildFightCombat._fightUserList.Add(fightUser);
                }
                if (!string.IsNullOrEmpty(fight.CombatMember) && !GuildFightCombat.IsFightWar(ContextUser.UserID, fight.CombatMember))
                {
                    fight.CombatMember = fight.CombatMember + ContextUser.UserID + ",";
                }
                else
                {
                    fight.CombatMember = ContextUser.UserID + ",";
                }
                ContextUser.UserStatus = UserStatus.FightCombat;
                ErrorCode = 0;
                ErrorInfo = LanguageManager.GetLang().St6412_FightWarSuccess;
            }
            else
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6412_HaveSignedUp;
                return false;
            }
            return true;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 公会争斗战冠军
 /// </summary>
 /// <param name="cityID"></param>
 /// <returns></returns>
 public static string FightChampion(int cityID)
 {
     FightCombat combat = new FightCombat();
     int fastID = MathUtils.Subtraction(combat.FastID, 1, 1);
     var applyList = new ShareCacheStruct<ServerFight>().FindAll(s => s.FastID == fastID && !s.IsRemove && s.CityID == cityID && s.RankID == 1);
     if (applyList.Count > 0)
     {
         return applyList[0].GuildID;
     }
     return string.Empty;
 }
Ejemplo n.º 4
0
 public override bool TakeAction()
 {
     if (cityID == 0)
     {
         var fightList = new ShareCacheStruct<GuildFightInfo>().FindAll();
         if (fightList.Count > 0)
         {
             cityID = fightList[0].CityID;
         }
     }
     var cityInfo = new ShareCacheStruct<CityInfo>().FindKey(cityID);
     if (cityInfo != null)
     {
         cityName = cityInfo.CityName;
     }
     FightCombat combat = new FightCombat();
     fightGroupList = new ShareCacheStruct<ServerFightGroup>().FindAll(s => s.FastID == combat.FastID && s.CityID == cityID && !s.IsRemove);
     if (fightGroupList.Count == 0)
     {
         int fastID = MathUtils.Subtraction(combat.FastID, 1, 1);
         fightGroupList = new ShareCacheStruct<ServerFightGroup>().FindAll(s => s.FastID == fastID && s.CityID == cityID && !s.IsRemove);
     }
     fightGroupList.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.NO.CompareTo(y.NO);
         if (result == 0)
         {
             var userGuildA = new ShareCacheStruct<UserGuild>().FindKey(x.GuildIDA);
             var userGuildB = new ShareCacheStruct<UserGuild>().FindKey(y.GuildIDA);
             if (userGuildA != null && userGuildB != null)
             {
                 result = userGuildB.GuildLv.CompareTo(userGuildA.GuildLv);
                 if (result == 0)
                 {
                     result = userGuildB.CurrExperience.CompareTo(userGuildA.CurrExperience);
                 }
             }
         }
         return result;
     });
     return true;
 }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
0
        public override bool TakeAction()
        {
            if (string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }
            FightCombat info = new FightCombat();
            UserGuild guild = new ShareCacheStruct<UserGuild>().FindKey(ContextUser.MercenariesID);
            if (guild == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }
            firstName = guild.GuildName.Substring(0, 1);
            GuildMember member = new ShareCacheStruct<GuildMember>().FindKey(ContextUser.MercenariesID,
                                                                             ContextUser.UserID);
            postType = member == null ? (short)0 : (short)member.PostType;
            ServerFight serverFight = new ShareCacheStruct<ServerFight>().FindKey(info.FastID, ContextUser.MercenariesID);
            if (serverFight != null)
            {
                isApply = 1;
            }
            fightList = new ConfigCacheSet<GuildFightInfo>().FindAll();
            if (cityID == 0 && fightList.Count > 0)
            {
                cityID = fightList[0].CityID;
            }
            var fightCity = new ConfigCacheSet<GuildFightInfo>().FindKey(cityID);
            if (fightCity != null)
            {
                rewardDesc = fightCity.CityDesc;
            }
            CityInfo cityInfo = new ConfigCacheSet<CityInfo>().FindKey(cityID);
            currCityName = cityInfo == null ? string.Empty : cityInfo.CityName;
            endData = (int)(GuildFightCombat.CurrFightDate() - DateTime.Now).TotalSeconds;

            int fastID = MathUtils.Subtraction(info.FastID, 1);
            var serverFightList = new ShareCacheStruct<ServerFight>().FindAll(s => s.FastID == fastID && !s.IsRemove && s.RankID == 1);
            foreach (var fight in serverFightList)
            {
                if (fight.CityID == cityID)
                {
                    guildName = GuildFightCombat.GuildName(fight.GuildID);
                }

                if (ContextUser.MercenariesID == fight.GuildID)
                {
                    isChampion = 1;
                }
            }

            return true;
        }
Ejemplo n.º 7
0
        public override bool TakeAction()
        {
            if (string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6203_GuildMemberNotEnough;
                return false;
            }
            GuildMember member = new ShareCacheStruct<GuildMember>().FindKey(ContextUser.MercenariesID, ContextUser.UserID);
            if (member == null || member.PostType == PostType.Member)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_OrdinaryMemberNotCompetence;
                return false;
            }
            UserGuild guild = new ShareCacheStruct<UserGuild>().FindKey(ContextUser.MercenariesID);
            if (guild == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }

            FightCombat fightCombat = new FightCombat();
            var cacheSet = new ShareCacheStruct<ServerFight>();
            ServerFight fight = cacheSet.FindKey(fightCombat.FastID, ContextUser.MercenariesID);
            if (fight != null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_HaveSignedUp;
                return false;
            }

            DateTime nextDate;
            FightStage stage = GuildFightCombat.GetStage(out nextDate);
            if (GuildFightCombat.IsFightDate())
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_CityABattleTime;
                return false;
            }

            if (stage != FightStage.Apply)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_CityABattleTime;
                return false;
            }

            //if (DateTime.Now > fightCombat.GuildEndTime && DateTime.Now < fightCombat.GuildStartTime)
            //{
            //    ErrorCode = LanguageManager.GetLang().ErrorCode;
            //    ErrorInfo = LanguageManager.GetLang().St6404_OutRegistrationTime;
            //    return false;
            //}

            GuildFightInfo fightInfo = new ConfigCacheSet<GuildFightInfo>().FindKey(cityID);
            if (fightInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }
            if (guild.GuildLv < fightInfo.GuildLv)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_GuildLvNotEnough;
                return false;
            }
            if (guild.CurrDonateNum < fightInfo.SkillNum)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_CurrDonateNumNotEnough;
                return false;
            }
            guild.CurrDonateNum = MathUtils.Subtraction(guild.CurrDonateNum, fightInfo.SkillNum);

            fight = new ServerFight(fightCombat.FastID, ContextUser.MercenariesID);
            fight.GuildBanner = string.Empty;
            fight.CityID = cityID;
            fight.RankID = 0;
            fight.ApplyDate = DateTime.Now;
            fight.IsRemove = false;
            fight.IsBanner = false;
            cacheSet.Add(fight, GameEnvironment.CacheGlobalPeriod);
            ErrorCode = 0;
            ErrorInfo = LanguageManager.GetLang().St6401_SuccessfulRegistration;
            return true;
        }
Ejemplo n.º 8
0
        public override bool TakeAction()
        {
            if (string.IsNullOrEmpty(name))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6405_GuildBannerNotEnough;
                return false;
            }
            UserGuild guild = new ShareCacheStruct<UserGuild>().FindKey(ContextUser.MercenariesID);
            if (guild == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }
            if (string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6011_GuildMemberNotMember;
                return false;
            }
            GuildMember member = new ShareCacheStruct<GuildMember>().FindKey(ContextUser.MercenariesID, ContextUser.UserID);
            if (member == null || member.PostType == PostType.Member)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_OrdinaryMemberNotCompetence;
                return false;
            }
            FightCombat fightCombat = new FightCombat();
            int fastID = MathUtils.Subtraction(fightCombat.FastID, 1);
            ServerFight fight = new ShareCacheStruct<ServerFight>().FindKey(fastID, ContextUser.MercenariesID);
            if (fight != null && fight.IsBanner)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6413_HaveBeenModified;
                return false;
            }

            if (fight == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6405_GuildNotEnterName;
                return false;
            }

            if (name.Length > 1)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6405_FillInACharacter;
                return false;
            }

            if (fight.FastID == fastID && fight.RankID == 1 && !fight.IsRemove)
            {
                if (fight.IsBanner)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St6413_HaveBeenModified;
                    return false;
                }
                fight.IsBanner = true;
            }
            fight.GuildBanner = name.Substring(0, 1);
            ErrorCode = 0;
            ErrorInfo = LanguageManager.GetLang().St6405_SettingTheBannerSuccess;
            return true;
        }
Ejemplo n.º 9
0
 public static bool GuildFightBroadcast(string userID, int fightcount, string guildiD)
 {
     DateTime endDate;
     DateTime begintime = GuildFightCombat.FightCombatStartDate(out endDate);
     DateTime applyEnd = begintime.AddMinutes(-GameConfigSet.BattleBroadcast);
     if (DateTime.Now > applyEnd && DateTime.Now < begintime && fightcount <= 3)
     {
         FightCombat combat = new FightCombat();
         var fightList = new ShareCacheStruct<ServerFight>().FindAll(s => s.FastID == combat.FastID && s.Stage > 0);
         var serverFight = new ShareCacheStruct<ServerFight>().FindKey(combat.FastID, guildiD);
         if (serverFight != null)
         {
             var cityfightList = new ShareCacheStruct<ServerFight>().FindAll(s => s.FastID == combat.FastID && s.CityID == serverFight.CityID);
             if (cityfightList.Count == 1)
             {
                 return false;
             }
         }
         foreach (var fight in fightList)
         {
             var member = new ShareCacheStruct<GuildMember>().FindKey(fight.GuildID, userID);
             if (member != null)
             {
                 TraceLog.ReleaseWriteDebug("公会城市争斗战参战成员{0}", userID);
                 fightcount++;
                 return true;
             }
         }
     }
     return false;
 }