示例#1
0
        public static void StartGame(CommandArgs args)
        {
            TSPlayer tSPlayer = args.Player;

            HubEvent hubEvent = HubEvent.GetEventPlayerIn(tSPlayer.Name);

            if (hubEvent == null)
            {
                tSPlayer.SendErrorMessage("You are not in an event!");
                return;
            }

            tSPlayer.SendSuccessMessage("You successfully started a vote to start the event!");

            VotingSystem votingSystem = new VotingSystem("Should the game start?",
                                                         60000,
                                                         hubEvent,
                                                         new OptionInfo("Yes", hubEvent.StartEventCountdown),
                                                         new OptionInfo("No"));

            votingSystem.Start();
        }
示例#2
0
        public static void OnGameUpdate(EventArgs _)
        {
            // Teleport spectating players to their targets.
            foreach (TSPlayer tSPlayer in Util.spectatingPlayersToTargets.Keys)
            {
                TSPlayer target   = Util.spectatingPlayersToTargets[tSPlayer];
                Vector2  position = target.TPlayer.position;
                tSPlayer.TeleportNoDust(position);
            }

            // Check if an event has already started.
            HubEvent startedEvent = HubEvent.GetOngoingEvent();

            if (startedEvent != null)
            {
                startedEvent.GameUpdate();
                return;
            }

            // Check if there is already an ongoing vote.
            if (VotingSystem.ongoingVotes.Count > 0)
            {
                return;
            }

            // Start the event countdown vote if there are enough players.
            foreach (HubEvent hubEvent in HubConfig.config.HubEvents)
            {
                if (hubEvent.tSPlayers.Count >= hubEvent.minPlayersForStart)
                {
                    VotingSystem votingSystem = new VotingSystem("Should the game start?",
                                                                 60000,
                                                                 hubEvent,
                                                                 new OptionInfo("Yes", hubEvent.StartEventCountdown),
                                                                 new OptionInfo("No", hubEvent.DeclineStart));
                    votingSystem.Start();
                }
            }
        }
示例#3
0
        public static void CreateVote(CommandArgs args)
        {
            TSPlayer tSPlayer = args.Player;

            if (args.Parameters.Count < 4)
            {
                tSPlayer.SendErrorMessage("Invalid syntax! Proper syntax: /createvote <Question> <Vote Length in MS> <Option 1> <Option 2> <Optional/More Options...>");
                return;
            }

            string question = args.Parameters[0];

            if (!int.TryParse(args.Parameters[1], out int voteLengthMS))
            {
                tSPlayer.SendErrorMessage("The vote length must be a number!");
                return;
            }

            IEnumerable <string> options = args.Parameters.Skip(2);

            List <OptionInfo> optionInfos = new List <OptionInfo>();

            foreach (string option in options)
            {
                optionInfos.Add(new OptionInfo(option));
            }

            VotingSystem votingSystem = new VotingSystem(question,
                                                         voteLengthMS,
                                                         null,
                                                         optionInfos.ToArray());

            tSPlayer.SendSuccessMessage("The vote was successfully created!");

            votingSystem.Start();
        }