Voting Overhaul

Transfer vote delay is counted from vote end, so it doesn't conflict with invalid or cancelled votes. Or other votes.

TRANSFER_TIMEOUT added as a config option, default value is 2 hours. No transfer votes before 2 hours.

Transfer votes before 3 hour mark require 2/3rds majority to pass again. Credit to SoundScopes for the original snippet.
This commit is contained in:
skull132
2016-03-25 16:09:03 +02:00
parent 8d1de33271
commit 5b147ac05b
4 changed files with 37 additions and 12 deletions

View File

@@ -34,6 +34,7 @@ var/list/gamemode_cache = list()
var/vote_autotransfer_initial = 108000 // Length of time before the first autotransfer vote is called
var/vote_autotransfer_interval = 36000 // length of time before next sequential autotransfer vote
var/vote_autogamemode_timeleft = 100 //Length of time before round start when autogamemode vote is called (in seconds, default 100).
var/transfer_timeout = 72000 // timeout before a transfer vote can be called (deciseconds, 120 minute default)
var/vote_no_default = 0 // vote does not default to nochange/norestart (tbi)
var/vote_no_dead = 0 // dead people can't vote (tbi)
// var/enable_authentication = 0 // goon authentication
@@ -363,6 +364,9 @@ var/list/gamemode_cache = list()
if ("vote_autogamemode_timeleft")
config.vote_autogamemode_timeleft = text2num(value)
if ("transfer_timeout")
config.transfer_timeout = text2num(value)
if("ert_admin_only")
config.ert_admin_call_only = 1

View File

@@ -15,6 +15,7 @@ datum/controller/vote
var/list/current_votes = list()
var/list/additional_text = list()
var/auto_muted = 0
var/last_transfer_vote = null
New()
if(vote != src)
@@ -106,6 +107,12 @@ datum/controller/vote
world << "<font color='purple'>Crew Transfer Factor: [factor]</font>"
greatest_votes = max(choices["Initiate Crew Transfer"], choices["Continue The Round"])
if(mode == "crew_transfer")
if(round(world.time / 36000)+12 <= 14)
// Credit to Scopes @ oldcode.
world << "<font color='purple'><b>Majority voting rule in effect. 2/3rds majority needed to initiate transfer.</b></font>"
choices["Initiate Crew Transfer"] = round(choices["Initiate Crew Transfer"] - round(total_votes / 3))
greatest_votes = max(choices["Initiate Crew Transfer"], choices["Continue The Round"])
//get all options with that many votes and return them in a list
. = list()
@@ -163,6 +170,7 @@ datum/controller/vote
if("crew_transfer")
if(. == "Initiate Crew Transfer")
init_shift_change(null, 1)
last_transfer_vote = world.time
if("add_antagonist")
if(isnull(.) || . == "None")
antag_add_failed = 1
@@ -199,8 +207,17 @@ datum/controller/vote
proc/initiate_vote(var/vote_type, var/initiator_key, var/automatic = 0)
if(!mode)
if(started_time != null && !(check_rights(R_ADMIN) || automatic))
var/next_allowed_time = (started_time + config.vote_delay)
if(started_time != null && !(check_rights(R_ADMIN|R_MOD) || automatic))
// Transfer votes are their own little special snowflake
var/next_allowed_time = 0
if (vote_type == "crew_transfer")
if (last_transfer_vote)
next_allowed_time = (last_transfer_vote + config.vote_delay)
else
next_allowed_time = config.transfer_timeout
else
next_allowed_time = (started_time + config.vote_delay)
if(next_allowed_time > world.time)
return 0