public void Stop() { voteTimer.Stop(); ongoingVotes.Remove(this); IEnumerable <OptionInfo> mostVotedOptions = options.Where(a => a.votes == options.Max(a2 => a2.votes)); if (mostVotedOptions.Count() > 1) { TShock.Utils.Broadcast("The vote has tied.", Color.Teal); return; } OptionInfo winningOption = mostVotedOptions.First(); string resultsFormatted = ""; foreach (OptionInfo optionInfo in options) { resultsFormatted += string.Format("{0} - {1} vote{2}\n", optionInfo.option, optionInfo.votes, optionInfo.votes == 1 ? "" : "s"); } resultsFormatted = resultsFormatted.Trim(); TShock.Utils.Broadcast(resultsFormatted, Color.Aqua); TShock.Utils.Broadcast(string.Format("The winning option was \"{0}\" with {1} vote{2}!", winningOption.option, winningOption.votes, winningOption.votes == 1 ? "" : "s"), Color.Orange); if (winningOption.methodUponWin == null) { return; } winningOption.methodUponWin(); }
public void ForceStop(OptionInfo winningOption) { voteTimer.Stop(); ongoingVotes.Remove(this); TShock.Utils.Broadcast(string.Format("The winning option was \"{0}\"", winningOption.option), Color.Orange); if (winningOption.methodUponWin == null) { return; } winningOption.methodUponWin(); }