コード例 #1
0
        public VoteServiceObject(List <Vote> _votes, string _urlOfGame, List <Player> _players, List <Replacement> _replacements, List <string> _moderatorNames, List <int> _dayStartPostNumbers, List <List <Player> > _nightkilledPlayers, List <DayviggedPlayer> _dayviggedPlayers, List <ResurrectedPlayer> _resurrectedPlayers, string _colorCode, int _priorVCNumber, string _flavorText, string _deadlineCode, List <Vote> _votesByOverride, bool _isRestCall, ProdTimer _prodTimer, string _fontOverride, bool _areaTagsOn, string _dividerOverride, bool _showLLevel, bool _showZeroCountWagons, bool _hardReset)
        {
            //System settings
            isRestCall = _isRestCall;

            //UserInput
            players             = _players;
            replacements        = _replacements;
            dayStartPostNumbers = _dayStartPostNumbers;
            nightkilledPlayers  = _nightkilledPlayers;
            flavorText          = _flavorText;
            deadlineCode        = "[countdown]" + _deadlineCode + "[/countdown]";
            priorVCNumber       = _priorVCNumber;
            colorCode           = _colorCode;
            fontOverride        = _fontOverride;
            areaTagsOn          = _areaTagsOn;
            dividerOverride     = _dividerOverride;
            showLLevel          = _showLLevel;
            showZeroCountWagons = _showZeroCountWagons;
            dayviggedPlayers    = _dayviggedPlayers;
            resurrectedPlayers  = _resurrectedPlayers;
            hardReset           = _hardReset;

            if (_prodTimer == null)
            {
                prodTimer = new ProdTimer(0, 48, 0, 0);
            }
            else
            {
                prodTimer = _prodTimer;
            }

            List <Vote> regularVotes = _votes;

            votes = new List <Vote>();

            List <Vote> overridesCompleted = new List <Vote>();

            foreach (Vote vote in regularVotes)
            {
                bool voteWasOverriden = false;
                foreach (Vote overrideVote in _votesByOverride)
                {
                    if (vote.PostNumber == overrideVote.PostNumber)
                    {
                        votes.Add(overrideVote);
                        overridesCompleted.Add(overrideVote);
                        voteWasOverriden = true;
                    }
                }

                if (!voteWasOverriden)
                {
                    votes.Add(vote);
                }
            }

            foreach (Vote vote in _votesByOverride)
            {
                if (!overridesCompleted.Contains(vote))
                {
                    votes.Add(vote);
                }
            }
        }
コード例 #2
0
        public void buildLatest(int dayNumber, int priorVCNumber, string flavorBBCode, string deadlineCode, int playersKilledOvernight, string colorCode, int firstPostOfDay, int lastPostOfDay, ProdTimer prodTimer, string fontOverride, bool areaTagsOn, string dividerOverride, bool showLLevel, bool showZeroCountWagons)
        {
            string displayString = ((fontOverride != null) ? "[font=" + fontOverride + "]" : "") + (areaTagsOn ? "[area]" : "") + "[b][u][size=150][color=" + colorCode + "]" + "Votecount " + dayNumber + "." + (priorVCNumber + 1) + "[/color][/size][/u][/b]" + History.NEW_LINE_HERE;

            wagons.Sort((a, b) => - 1 * a.CompareTo(b));
            bool  firstOne          = true;
            bool  AWagonWasHammered = false;
            Wagon leadWagon         = null;

            foreach (Wagon wagon in wagons)
            {
                if ((wagon.PlayersVoting.Count > 0) || (showZeroCountWagons && wagon.PlayerBeingVoted != null && wagon.PlayerBeingVoted.IsAlive && !wagon.PlayerBeingVoted.IsTreestumped && !wagon.PlayerBeingVoted.IsGunner))
                {
                    if (firstOne == true)
                    {
                        displayString = displayString + "[i]";
                        leadWagon     = wagon;
                    }
                    displayString = displayString + "[b]" + wagon.PlayerBeingVoted.Name + "(" + wagon.PlayersVotingAndNotTreestumpedCount + ")[/b]" + ((dividerOverride != null) ? " " + dividerOverride + " " : " ~ ") + wagon.playersVotingCommaDelimitedList(firstPostOfDay, lastPostOfDay);
                    if (firstOne == true)
                    {
                        displayString = displayString + "[/i]" + ((wagon.IsHammered ? " -- HAMMER " : (showLLevel ? " L - " + wagon.L_Level : ""))) + History.NEW_LINE_HERE;
                    }
                    else
                    {
                        displayString = displayString + (showLLevel ? " L - " + wagon.L_Level : "") + History.NEW_LINE_HERE;
                    }
                    firstOne = false;
                }
                if (!AWagonWasHammered)
                {
                    AWagonWasHammered = wagon.IsHammered;
                }
            }

            int alivePlayersAtVoteCountStart = playersAliveNoTreestumpsNoGunners() + ((AWagonWasHammered == true) ? 1 : 0);

            /* displayString = displayString + History.NEW_LINE_HERE;
             * List<string> playersDead = new List<string>();
             * foreach(Player player in playersInVoteCount)
             * {
             *   if (player.IsDead)
             *   {
             *       playersDead.Add(player.Name);
             *   }
             * }
             * displayString = displayString + "Players dead: " + String.Join(",", playersDead.ToArray());*/

            displayString = displayString + History.NEW_LINE_HERE;
            displayString = displayString + History.NEW_LINE_HERE;
            string playersNotVotingString = getPlayersNotVotingString(firstPostOfDay, lastPostOfDay);

            //Not voting failsafe.
            string[]      playersNotVotingStringArray = playersNotVotingString.Length > 0 ? playersNotVotingString.Split(',') : null;
            List <string> playersNotVotingList        = playersNotVotingStringArray != null ? new List <string>(playersNotVotingStringArray) : new List <string>();

            if (AWagonWasHammered == true && leadWagon != null)
            {
                Player playerHammered = leadWagon.PlayerBeingVoted;
                if (playerHammered.PlayerCurrentlyVoting == null)
                {
                    bool addPlayerToList = true;
                    foreach (string playerName in playersNotVotingStringArray)
                    {
                        if (playerName.Equals(playerHammered.Name))
                        {
                            addPlayerToList = false;
                            break;
                        }
                    }

                    if (addPlayerToList)
                    {
                        playersNotVotingList.Add(" " + playerHammered.Name + "(" + playerHammered.getNumberOfPostsInDay(firstPostOfDay, lastPostOfDay) + ")");
                        playersNotVotingStringArray = playersNotVotingList.ToArray();
                        playersNotVotingString      = String.Join(",", playersNotVotingStringArray);
                    }
                }
            }

            string countNotVotingString = playersNotVotingStringArray != null ? playersNotVotingStringArray.Length + "" : "0";

            displayString = displayString + "Not Voting (" + countNotVotingString + "): " + playersNotVotingString;
            displayString = displayString + History.NEW_LINE_HERE;
            displayString = displayString + History.NEW_LINE_HERE;
            displayString = displayString + "With " + alivePlayersAtVoteCountStart + " alive it takes " + maxThreshold + " to lynch." + History.NEW_LINE_HERE;


            displayString = displayString + History.NEW_LINE_HERE;
            displayString = displayString + "Day " + dayNumber + " deadline is in " + deadlineCode + (areaTagsOn ? "[/area]" : "") + (fontOverride != null ? "[/font]" : "") + History.NEW_LINE_HERE + History.NEW_LINE_HERE;



            displayString = displayString + "[area=MOD REMINDERS]" + History.NEW_LINE_HERE;

            DateTime now           = DateTime.UtcNow.AddHours(-6);
            bool     aProdIsNeeded = false;

            DateTime timeToCountBackFrom = now;

            if (AWagonWasHammered)
            {
                timeToCountBackFrom = leadWagon.TimeOfLastVote;
            }

            if (timeToCountBackFrom - days[days.Count - 1].FirstPostTime > new TimeSpan(prodTimer.Days, prodTimer.Hours, prodTimer.Minutes, prodTimer.Seconds))
            {
                foreach (Player player in playersInVoteCount)
                {
                    if (player.IsAlive && player.TimeOfLastPost != null && player.TimeOfLastPost.Year > 1986)
                    {
                        DateTime lastPostPlusProd = player.TimeOfLastPost.AddDays(prodTimer.Days).AddHours(prodTimer.Hours).AddMinutes(prodTimer.Minutes).AddSeconds(prodTimer.Seconds);
                        if (player.IsAlive && lastPostPlusProd < timeToCountBackFrom)
                        {
                            TimeSpan timeSinceLastPost = (timeToCountBackFrom - player.TimeOfLastPost);
                            displayString = displayString + player.Name + " needs a prod. The last post was at: " + player.TimeOfLastPost.ToString() + " which was " + timeSinceLastPost.Days + " days " + timeSinceLastPost.Hours + " hours " + timeSinceLastPost.Minutes + " minutes " + timeSinceLastPost.Seconds + " seconds ago." + History.NEW_LINE_HERE;
                            aProdIsNeeded = true;
                        }
                    }
                    else if (player.TimeOfLastPost.Year == 1986)
                    {
                        displayString = displayString + player.Name + " has never posted. Please verify player interest. " + History.NEW_LINE_HERE;
                        aProdIsNeeded = true;
                    }
                }
            }
            if (!aProdIsNeeded)
            {
                displayString = displayString + "NONE" + History.NEW_LINE_HERE;
            }


            displayString = displayString + "[/area]" + History.NEW_LINE_HERE;

            displayString = displayString + "[area=FLAVOR]" + flavorBBCode + "[/area]";

            latestVCOutput = displayString.Replace(History.NEW_LINE_HERE, System.Environment.NewLine + ((isRestCall) ? "" : ""));
        }
コード例 #3
0
        public VoteServiceObject(string _urlOfGame, List <Player> _players, List <Replacement> _replacements, List <string> _moderatorNames, List <int> _dayStartPostNumbers, List <List <Player> > _nightkilledPlayers, List <DayviggedPlayer> _dayviggedPlayers, List <ResurrectedPlayer> _resurrectedPlayers, string _colorCode, int _priorVCNumber, string _flavorText, string _deadlineCode, List <Vote> _votesByOverride, bool _isRestCall, ProdTimer _prodTimer, string _fontOverride, bool _areaTagsOn, string _dividerOverride, bool _showLLevel, bool _showZeroCountWagons, bool _hardReset)
        {
            //System settings
            isRestCall = _isRestCall;

            if (_prodTimer == null)
            {
                prodTimer = new ProdTimer(0, 48, 0, 0);
            }
            else
            {
                prodTimer = _prodTimer;
            }

            //User data input
            votes = new List <Vote>();
            //List<Vote> regularVotes = new List<Vote>();
            players             = _players;
            replacements        = _replacements;
            dayStartPostNumbers = _dayStartPostNumbers;
            nightkilledPlayers  = _nightkilledPlayers;
            flavorText          = _flavorText;
            deadlineCode        = "[countdown]" + _deadlineCode + "[/countdown]";
            priorVCNumber       = _priorVCNumber;
            colorCode           = _colorCode;
            fontOverride        = _fontOverride;
            areaTagsOn          = _areaTagsOn;
            dividerOverride     = _dividerOverride;
            showLLevel          = _showLLevel;
            showZeroCountWagons = _showZeroCountWagons;
            dayviggedPlayers    = _dayviggedPlayers;
            resurrectedPlayers  = _resurrectedPlayers;
            hardReset           = _hardReset;



            Posts = RunScrubLogic.RunScrubLogic.BuildPosts(_urlOfGame, players, _moderatorNames, replacements);

            //Handle replacements in core player object
            foreach (Replacement replacement in replacements)
            {
                replacement.performReplacement("", players);
            }

            List <Vote> regularVotes = new List <Vote>();

            string debugString = "";

            //Refresh post player connection. Because of rewrite this is needed.
            foreach (Post post in Posts)
            {
                //This is necessary because the reference to Players doesn't get updated because of the new ECS system.
                if (post.PlayerPosting != null)
                {
                    foreach (Player player in players)
                    {
                        if (player.Name.Equals(post.PlayerPosting.Name))
                        {
                            player.addPostNumber(post.PostNumber);
                            if (player.TimeOfLastPost < post.TimeOfPost)
                            {
                                player.TimeOfLastPost = post.TimeOfPost;
                            }

                            if (post.VoteInThisPost != null)
                            {
                                post.VoteInThisPost.updatePlayerReference(player);
                                regularVotes.Add(post.VoteInThisPost);
                            }

                            if (player.Name.Equals("Nauci"))
                            {
                                debugString = String.Join(",", player.PostNumbers.ToArray());
                            }
                        }
                    }
                }
                else
                {
                    UnityEngine.Debug.Log("Could not find player for post: " + post.PostNumber);
                }
            }



            List <Vote> overridesCompleted = new List <Vote>();

            foreach (Vote vote in regularVotes)
            {
                bool voteWasOverriden = false;
                foreach (Vote overrideVote in _votesByOverride)
                {
                    if (vote.PostNumber == overrideVote.PostNumber)
                    {
                        votes.Add(overrideVote);
                        overridesCompleted.Add(overrideVote);
                        voteWasOverriden = true;
                    }
                }

                if (!voteWasOverriden)
                {
                    votes.Add(vote);
                }
            }

            foreach (Vote vote in _votesByOverride)
            {
                if (!overridesCompleted.Contains(vote))
                {
                    votes.Add(vote);
                }
            }
        }