示例#1
0
        public void Update()
        {
            var names  = new List <string>();
            var scores = new List <int>();

            MovieService.GetTopMovies(RoomId, MOVIE_COUNT, ref names, ref scores);

            var topMovies = "";

            for (var i = 0; i < names.Count; i++)
            {
                topMovies += (topMovies == "" ? "" : "\n")
                             + string.Format("[{0:D2}] #{1}-{2}", i + 1, names[i], scores[i]);
            }

            if (_topMovies != topMovies)
            {
                File.WriteAllText(TopMoviesFile, topMovies);
                _topMovies = topMovies;
            }
        }
示例#2
0
 void StartPlay()
 {
     btnStartPlay.Enabled = false;
     btnStopPlay.Enabled  = true;
     MovieService.StartPlay();
 }
示例#3
0
        void ProcessChatCommand_PlayMovie(string movieName, string scoreInCommand, ChatMessage message)
        {
            // 检查系统里面是否有这部电影
            if (!MovieService.HasMovie(message.RoomId, movieName))
            {
                var officialName = MovieService.GetOfficialMovieName(message.RoomId, movieName);   // 用的是别名?
                if (officialName == "" || !MovieService.HasMovie(message.RoomId, officialName))
                {
                    Obs.MovieMessage.AddMessage("{0} : 没有找到电影【{1}】!", message.UserName, movieName);
                    return;
                }
                movieName = officialName;
            }

            // 检查是否是禁播的电影
            if (MovieService.IsMovieOnBlacklist(message.RoomId, movieName))
            {
                Obs.MovieMessage.AddMessage("{0} : 【{1}】已经禁播!", message.UserName, movieName);
                return;
            }

            // 检查点播电影是否是当前正在播放的电影
            var currentMovie = MovieService.GetCurrentMovie(message.RoomId);

            if (currentMovie != null && currentMovie.Equals(movieName, StringComparison.OrdinalIgnoreCase))
            {
                Obs.MovieMessage.AddMessage("{0} : 正在播放【{1}】, 请不要重复点播!", message.UserName, movieName);
                return;
            }

            // 电影冷却完成了?
            var movieCooldown = AppSettings.MovieCooldown;
            var lastPlayTime  = MovieService.GetLastPlayTime(message.RoomId, movieName);

            if ((DateTime.Now - lastPlayTime).TotalMinutes < movieCooldown)
            {
                Obs.MovieMessage.AddMessage("{0} : 点播【{1}】失败, 还有 {2} 分钟才能点播!",
                                            message.UserName, movieName,
                                            movieCooldown - (DateTime.Now - lastPlayTime).TotalMinutes);
                return;
            }

            // 检查积分是否溢出
            var movieScore = 0;

            if (!int.TryParse(scoreInCommand, out movieScore))
            {
                Obs.MovieMessage.AddMessage("{0} : 点播【{1}】失败, 积分无效!", message.UserName, movieName);
                return;
            }
            movieScore = Math.Abs(movieScore);

            // 用户积分够吗?
            var userScore = UserService.GetScore(message.RoomId, message.UserId);

            if (userScore < movieScore)
            {
                Obs.MovieMessage.AddMessage("{0} : 点播【{1}】失败, 积分不够, 当前积分 {2}",
                                            message.UserName, movieName, userScore);
                return;
            }

            // 更新积分
            MovieService.AddScore(message.RoomId, movieName, movieScore);
            UserService.AddScore(message.RoomId, message.UserId, message.UserName, movieScore * (-1));

            // 显示成功点播信息
            Obs.MovieMessage.AddMessage("{0} :【{1}】+ {2}", message.UserName, movieName, movieScore);
            return;
        }