示例#1
0
        public static bool CanChangeStyle(BaseRoom game, GSPacketIn pkg)
        {
            FightRateInfo[] infos = FightRateMgr.GetAllFightRateInfo();
            bool            result;

            try
            {
                FightRateInfo[] array = infos;
                for (int i = 0; i < array.Length; i++)
                {
                    FightRateInfo info = array[i];
                    if (info.BeginDay.Year <= DateTime.Now.Year && DateTime.Now.Year <= info.EndDay.Year)
                    {
                        if (info.BeginDay.DayOfYear <= DateTime.Now.DayOfYear && DateTime.Now.DayOfYear <= info.EndDay.DayOfYear)
                        {
                            if (info.BeginTime.TimeOfDay <= DateTime.Now.TimeOfDay && DateTime.Now.TimeOfDay <= info.EndTime.TimeOfDay)
                            {
                                if (FightRateMgr.random.Next(1000000) < info.Rate)
                                {
                                    result = true;
                                    return(result);
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }
            pkg.WriteBoolean(false);
            result = false;
            return(result);
        }
示例#2
0
 private static bool LoadFightRate(Dictionary <int, FightRateInfo> fighRate)
 {
     using (ServiceBussiness serviceBussiness = new ServiceBussiness())
     {
         FightRateInfo[] fightRate = serviceBussiness.GetFightRate(GameServer.Instance.Configuration.ServerID);
         FightRateInfo[] array     = fightRate;
         for (int i = 0; i < array.Length; i++)
         {
             FightRateInfo fightRateInfo = array[i];
             if (!fighRate.ContainsKey(fightRateInfo.ID))
             {
                 fighRate.Add(fightRateInfo.ID, fightRateInfo);
             }
         }
     }
     return(true);
 }
示例#3
0
 private static bool LoadFightRate(Dictionary <int, FightRateInfo> fighRate)
 {
     using (ServiceBussiness db = new ServiceBussiness())
     {
         FightRateInfo[] infos = db.GetFightRate(GameServer.Instance.Config.ServerID);
         FightRateInfo[] array = infos;
         for (int i = 0; i < array.Length; i++)
         {
             FightRateInfo info = array[i];
             if (!fighRate.ContainsKey(info.ID))
             {
                 fighRate.Add(info.ID, info);
             }
         }
     }
     return(true);
 }
        public FightRateInfo[] GetFightRate(int serverId)
        {
            SqlDataReader        reader = null;
            List <FightRateInfo> infos  = new List <FightRateInfo>();

            try
            {
                SqlParameter[] para = new SqlParameter[1];
                para[0] = new SqlParameter("@ServerID", serverId);

                db.GetReader(ref reader, "SP_Fight_Rate", para);
                if (reader.Read())
                {
                    FightRateInfo info = new FightRateInfo();
                    info.ID             = (int)reader["ID"];
                    info.ServerID       = (int)reader["ServerID"];
                    info.Rate           = (int)reader["Rate"];
                    info.BeginDay       = (DateTime)reader["BeginDay"];
                    info.EndDay         = (DateTime)reader["EndDay"];
                    info.BeginTime      = (DateTime)reader["BeginTime"];
                    info.EndTime        = (DateTime)reader["EndTime"];
                    info.SelfCue        = reader["SelfCue"] == null ? "" : reader["SelfCue"].ToString();
                    info.EnemyCue       = reader["EnemyCue"] == null ? "" : reader["EnemyCue"].ToString();
                    info.BoyTemplateID  = (int)reader["BoyTemplateID"];
                    info.GirlTemplateID = (int)reader["GirlTemplateID"];
                    info.Name           = reader["Name"] == null ? "" : reader["Name"].ToString();

                    infos.Add(info);
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("GetFightRate", e);
                }
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
            }
            return(infos.ToArray());
        }
示例#5
0
 public static bool CanChangeStyle(BaseRoom game, GSPacketIn pkg)
 {
     FightRateInfo[] allFightRateInfo = FightRateMgr.GetAllFightRateInfo();
     try
     {
         FightRateInfo[] array = allFightRateInfo;
         for (int i = 0; i < array.Length; i++)
         {
             FightRateInfo fightRateInfo = array[i];
             if (fightRateInfo.BeginDay.Year <= DateTime.Now.Year && DateTime.Now.Year <= fightRateInfo.EndDay.Year && fightRateInfo.BeginDay.DayOfYear <= DateTime.Now.DayOfYear && DateTime.Now.DayOfYear <= fightRateInfo.EndDay.DayOfYear && fightRateInfo.BeginTime.TimeOfDay <= DateTime.Now.TimeOfDay && DateTime.Now.TimeOfDay <= fightRateInfo.EndTime.TimeOfDay && ThreadSafeRandom.NextStatic(1000000) < fightRateInfo.Rate)
             {
                 return(true);
             }
         }
     }
     catch
     {
     }
     pkg.WriteBoolean(false);
     return(false);
 }