示例#1
0
        public override bool TakeAction()
        {
            UserGuild guild = new ShareCacheStruct <UserGuild>().FindKey(ContextUser.MercenariesID);

            if (guild != null)
            {
                GuildMember member = new ShareCacheStruct <GuildMember>().FindKey(ContextUser.MercenariesID, ContextUser.UserID);
                if (member == null || member.PostType != PostType.Chairman)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St6008_NotChairman;
                    return(false);
                }
                GameActive      active        = new ShareCacheStruct <GameActive>().FindKey(UserGuild.ActiveID);
                List <BossDate> bossDateList  = UserHelper.GetBossDate().FindAll(u => u.EnableWeek == dateType);
                GuildBossInfo   guildBossInfo = guild.GuildBossInfo;
                if (bossDateList.Count > 0)
                {
                    BossDate bossDate = bossDateList[0];

                    if (guildBossInfo != null)
                    {
                        if (guildBossInfo.RefreshDate != MathUtils.SqlMinDate)
                        {
                            if (UserHelper.IsCurrentWeek(guild.GuildBossInfo.RefreshDate))
                            {
                                ErrorCode = LanguageManager.GetLang().ErrorCode;
                                ErrorInfo = LanguageManager.GetLang().St6109_GuildBossTime;
                                return(false);
                            }
                        }

                        if (guildBossInfo.BossLv == 0)
                        {
                            guildBossInfo.BossLv = (short)active.BossLv;
                        }
                        guildBossInfo.IsKill       = false;
                        guildBossInfo.EnablePeriod = bossDate.EnablePeriod;
                        guildBossInfo.EnableWeek   = (int)dateType;
                        guildBossInfo.RefreshDate  = DateTime.Now;
                        guild.GuildBossInfo        = guildBossInfo;
                        //guild.Update();
                    }
                    else
                    {
                        guildBossInfo              = new GuildBossInfo();
                        guildBossInfo.IsKill       = false;
                        guildBossInfo.BossLv       = (short)active.BossLv;
                        guildBossInfo.EnablePeriod = bossDate.EnablePeriod;
                        guildBossInfo.EnableWeek   = (int)dateType;
                        guildBossInfo.RefreshDate  = DateTime.Now;
                        guild.GuildBossInfo        = guildBossInfo;
                        //guild.Update();
                    }
                }
            }
            return(true);
        }
示例#2
0
        public static int IsSelect(string guildID, BossDate bossDate)
        {
            DateTime   priod      = new DateTime();
            DateTime   endPriod   = new DateTime();
            int        isSelect   = 0;
            GameActive gameActive = new ShareCacheStruct <GameActive>().FindKey(UserGuild.ActiveID);

            UserGuild guild = new ShareCacheStruct <UserGuild>().FindKey(guildID);

            if (guild != null && guild.GuildBossInfo != null)
            {
                if (UserHelper.IsCurrentWeek(guild.GuildBossInfo.RefreshDate))
                {
                    priod    = UserHelper.GuildBossDate(guild.GuildBossInfo);
                    endPriod = priod.AddMinutes(gameActive.Minutes);

                    if (guild.GuildBossInfo.EnableWeek == (int)bossDate.EnableWeek)
                    {
                        isSelect = 1;
                    }
                    else if (DateTime.Now > endPriod)
                    {
                        isSelect = 2;
                    }
                    else if ((priod - DateTime.Now).TotalSeconds > 3600)
                    {
                        isSelect = 0;
                    }
                }
                else
                {
                    priod    = UserHelper.GuildEnableWeek(bossDate.EnableWeek);
                    endPriod = priod.AddMinutes(gameActive.Minutes);
                    if ((priod - DateTime.Now).TotalSeconds > 3600)
                    {
                        isSelect = 0;
                    }
                    else if (DateTime.Now > endPriod)
                    {
                        isSelect = 2;
                    }
                }
            }
            else
            {
                priod    = UserHelper.GuildEnableWeek(bossDate.EnableWeek);
                endPriod = priod.AddMinutes(gameActive.Minutes);
                if (DateTime.Now > endPriod)
                {
                    isSelect = 2;
                }
                else if ((priod - DateTime.Now).TotalSeconds > 3600)
                {
                    isSelect = 0;
                }
                else
                {
                    isSelect = 2;
                }
            }

            return(isSelect);
        }