Exemplo n.º 1
0
        public static void AddLog(ClientPlayerInfo FromPlayer, string Command, string Results)
        {
            if (logCount == 0)
            {
                return;
            }
            if (Regex.Match(Command, @"^(?:\[[^\]]*\])*([\!\%])\1?log").Success) //checks for `!log` preceded by 0 or more tags.
            {
                return;                                                          // don't log the !log command. makes things too confusing and hard to use.
            }
            // finds the number of color tags and closing tags, then adds to the beginning/end to make sure they match
            string logName = MessageUtilities.closeTags(FromPlayer.GetChatName());

            Logs.Insert(0, new CmdLog(logName, Command, Results));
            while (Logs.Count > logCount)
            {
                Logs.RemoveAt(Logs.Count - 1);
            }
        }
Exemplo n.º 2
0
        public override void use(ClientPlayerInfo p, string message)
        {
            if (message == "")
            {
                help(p);
                return;
            }

            if (useVote && !p.IsLocal_)  // host can always force play, never uses vote.
            {
                Cmd.all.getCommand <VoteHandler.VoteCMD>("vote").forceNextUse();
                Cmd.all.getCommand <VoteHandler.VoteCMD>("vote").use(p, "y play " + message);
                return;
            }

            if (G.Sys.GameManager_.ModeID_ == GameModeID.Trackmogrify)
            {
                MessageUtilities.sendMessage(p, "You can't manage the playlist in trackmogrify.");
                return;
            }

            FilteredPlaylist filterer = new FilteredPlaylist(GeneralUtilities.getAllLevelsAndModes());

            if (!p.IsLocal_)
            {
                filterer.AddFiltersFromString(playFilter);
            }

            MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(p));
            GeneralUtilities.sendFailures(GeneralUtilities.addFiltersToPlaylist(filterer, p, message, true), 4);
            MessageUtilities.popMessageOptions();

            var list = filterer.Calculate().levelList;

            if (list.Count == 0)
            {
                MessageUtilities.sendMessage(p, "Can't find a level with the filter '" + message + "'.");
                return;
            }

            LevelPlaylist playlist = new LevelPlaylist();

            playlist.CopyFrom(G.Sys.GameManager_.LevelPlaylist_);

            var     currentPlaylist = playlist.Playlist_;
            AutoCmd autoCmd         = Cmd.all.getCommand <AutoCmd>("auto");
            int     origIndex       = G.Sys.GameManager_.LevelPlaylist_.Index_;
            int     index           = autoCmd.getInsertIndex();

            var maxPerRoundLocal = 0;

            if (p.IsLocal_ || maxPerRound <= 0)
            {
                maxPerRoundLocal = int.MaxValue;
            }
            else
            {
                maxPerRoundLocal = maxPerRound;
            }

            var maxPerCmdLocal = 0;

            if (p.IsLocal_ || maxPerCmd <= 0)
            {
                maxPerCmdLocal = int.MaxValue;
            }
            else
            {
                maxPerCmdLocal = maxPerCmd;
            }

            var countCmd = 0;

            var countRound = 0;

            playerVotesThisRound.TryGetValue(GeneralUtilities.getUniquePlayerString(p), out countRound);

            string lvlsStr = "";

            foreach (var lvl in list)
            {
                if (countRound + 1 > maxPerRoundLocal)
                {
                    MessageUtilities.sendMessage(p, $"You have reached the maximum amount of maps you can add per round ({maxPerRound})");
                    break;
                }
                if (countCmd + 1 > maxPerCmdLocal)
                {
                    MessageUtilities.sendMessage(p, "You have reached the maximum amount of maps you can add per " + GeneralUtilities.formatCmd("!play") + $" ({maxPerCmd})");
                    break;
                }
                countRound++;
                countCmd++;
                if (countCmd <= 10)
                {
                    lvlsStr += lvl.levelNameAndPath_.levelName_ + ", ";
                }
                currentPlaylist.Insert(index + countCmd - 1, lvl);
            }
            playerVotesThisRound[GeneralUtilities.getUniquePlayerString(p)] = countRound;

            if (countCmd > 0)
            {
                G.Sys.GameManager_.LevelPlaylist_.Clear();

                foreach (var lvl in currentPlaylist)
                {
                    G.Sys.GameManager_.LevelPlaylist_.Add(lvl);
                }
                G.Sys.GameManager_.LevelPlaylist_.SetIndex(origIndex);

                lvlsStr = lvlsStr.Substring(0, lvlsStr.Count() - 2);
                if (countCmd > 10)
                {
                    lvlsStr = lvlsStr + $" and {countCmd - 10} more";
                }

                if (p.IsLocal_)
                {
                    MessageUtilities.sendMessage(p, "Level(s) " + lvlsStr + " added to the playlist !");
                }
                else
                {
                    MessageUtilities.sendMessage("Level(s) " + lvlsStr + " added to the playlist by " + p.GetChatName() + "!");
                }
            }
        }