Voting System (#31884)

* Voting System

The current voting system is very confusing and difficult to use or modify, so I updated it.

I also have added another voting method, described in #31803. Do not be alarmed, weighted voting is still used, but other methods will be available.

* Everything appears to work

Weighted and majority definitely work

* Update voting.dm

* admin can change from votable or nonvotable

* Revert "admin can change from votable or nonvotable"

This reverts commit 6d0c547958.

* done

* Update voting.js

* done done

* a

* Update voting.dm

* can change voting method

* Update voting.dm

* Update persistence_misc.dm

* a

* Update admin.dm
This commit is contained in:
adacovsk
2022-01-31 19:11:03 -05:00
committed by GitHub
parent 62f891ad21
commit 11953788f0
6 changed files with 247 additions and 201 deletions

View File

@@ -32,6 +32,8 @@
var/allow_admin_ooccolor = 0 // Allows admins with relevant permissions to have their own ooc colour
var/allow_vote_restart = 0 // allow votes to restart
var/allow_vote_mode = 0 // allow votes to change mode
var/toggle_maps = 0 // Change from votable maps = 0 to all compiled maps = 1
var/toggle_vote_method = 0 // Toggle voting methods: Weighted = 0, Majority = 1
var/allow_admin_jump = 1 // allows admin jumping
var/allow_admin_spawning = 1 // allows admin item spawning
var/allow_admin_rev = 1 // allows admin revives
@@ -203,9 +205,6 @@
var/discord_password
var/kill_phrase = "All your bases are belong to us."
// Weighted Votes
var/weighted_votes = 0
// Dynamic Mode
var/high_population_override = 1//If 1, what rulesets can or cannot be called depend on the threat level only
@@ -352,7 +351,6 @@
if ("allow_vote_mode")
config.allow_vote_mode = 1
if ("allow_admin_jump")
config.allow_admin_jump = 1
@@ -634,8 +632,6 @@
discord_url = value
if("discord_password")
discord_password = value
if("weighted_votes")
weighted_votes = TRUE
if ("kill_phrase")
kill_phrase = value

View File

@@ -110,12 +110,13 @@
if(!vote)
return
var/winner
if(vote.choices.len && alert(usr,"Pick existing choice?", "Rig", "Preexisting", "Add a new option") == "Preexisting")
winner = input(usr,"Choose a result.","Choose a result.", vote.choices[1]) as null|anything in vote.choices
if(!winner)
return
vote.choices[winner] = ARBITRARILY_LARGE_NUMBER
vote.tally[winner] = ARBITRARILY_LARGE_NUMBER
else
if(vote.ismapvote)
var/all_maps = get_all_maps()
@@ -129,6 +130,6 @@
winner = input(usr,"Add a result.","Add a result","") as text|null
if(!winner)
return
vote.choices[winner] = ARBITRARILY_LARGE_NUMBER
vote.tally[winner] = ARBITRARILY_LARGE_NUMBER
message_admins("Admin [key_name_admin(usr)] rigged the vote for [winner].")
log_admin("Admin [key_name(usr)] rigged the vote for [winner]. Choices were [vote.choices.Join(", ")]")
log_admin("Admin [key_name(usr)] rigged the vote for [winner].")

View File

@@ -208,6 +208,7 @@ var/datum/subsystem/persistence_misc/SSpersistence_misc
data = list()
fdel(file(file_path))
//Ape-related
/datum/persistence_task/ape_mode
execute = TRUE

View File

@@ -453,7 +453,7 @@ var/datum/controller/gameticker/ticker
gameend_time = world.time / 10
if(config.map_voting)
//testing("Vote picked [chosen_map]")
vote.initiate_vote("map","The Server", popup = 1, weighted_vote = config.weighted_votes)
vote.initiate_vote("map","The Server", popup = 1)
var/options = jointext(vote.choices, " ")
feedback_set("map vote choices", options)

View File

@@ -19,11 +19,11 @@ var/global/datum/controller/vote/vote = new()
/datum/html_interface/nanotrasen/vote/Topic(href, href_list[])
..()
if(href_list["html_interface_action"] == "onclose")
var/datum/html_interface_client/hclient = getClient(usr.client)
var/mob/user = usr
var/datum/html_interface_client/hclient = getClient(user.client)
if (istype(hclient))
src.hide(hclient)
vote.voting -= usr.client
vote.cancel_vote(user)
/datum/controller/vote
@@ -32,24 +32,23 @@ var/global/datum/controller/vote/vote = new()
var/time_remaining = 0
var/mode = null
var/question = null
var/list/choices = list()
var/list/voted = list()
var/list/voting = list()
var/list/current_votes = list()
var/list/discarded_choices = list()
var/list/ismapvote
var/chosen_map
name = "datum"
var/datum/html_interface/nanotrasen/vote/interface
var/list/data
//vote data
var/list/voters //assoc. list: user.ckey, choices
var/list/tally //assoc. list: choices, count
var/list/choices = list() //choices
var/choice
var/count
var/list/status_data
var/last_update = 0
var/initialized = 0
var/lastupdate = 0
var/total_votes = 0
var/vote_threshold = 0.15
var/discarded_votes = 0
var/weighted = TRUE // Whether to use weighted voting.
var/currently_voting = FALSE // If we are already voting, don't allow another one
// Jesus fuck some shitcode is breaking because it's sleeping and the SS doesn't like it.
@@ -57,8 +56,11 @@ var/global/datum/controller/vote/vote = new()
/datum/controller/vote/New()
. = ..()
src.data = list()
src.voters = list()
src.tally = list()
src.status_data = list()
src.choice = choice
src.count = count
spawn(5)
if(!src.interface)
src.interface = new/datum/html_interface/nanotrasen/vote(src, "Voting Panel", 400, 400, vote_head)
@@ -67,10 +69,7 @@ var/global/datum/controller/vote/vote = new()
if (vote != src)
if (istype(vote))
qdel(vote)
vote = src
//datum/controller/vote/proc/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
// return
/datum/controller/vote/proc/process() //called by master_controller
if (lock)
@@ -90,9 +89,9 @@ var/global/datum/controller/vote/vote = new()
if(time_remaining <= 0)
result()
for(var/client/C in voting)
for(var/ckey in voters) //hide voting interface using ckeys
var/client/C = directory[ckey]
if(C)
//nanomanager.close_user_uis(C.mob, src)
src.interface.hide(C)
src.reset()
else
@@ -101,64 +100,90 @@ var/global/datum/controller/vote/vote = new()
lock = FALSE
/datum/controller/vote/proc/reset()
currently_voting = FALSE
initiator = null
time_remaining = 0
mode = null
question = null
choices.len = 0
voted.len = 0
voting.len = 0
total_votes = 0
discarded_votes = 0
discarded_choices.len = 0
current_votes.len = 0
weighted = FALSE
voters.len = 0
tally.len = 0
update(1)
/datum/controller/vote/proc/get_result()
//get the highest number of votes
var/greatest_votes = 0
currently_voting = FALSE
for(var/option in choices)
var/votes = choices[option]
total_votes += votes
if(votes > greatest_votes)
greatest_votes = votes
//default-vote for everyone who didn't vote
var/non_voters = clients.len - get_total()
if(!config.vote_no_default && choices.len)
var/non_voters = (clients.len - total_votes)
//clients with voting initialized
if(non_voters > 0)
if(mode == "restart")
choices["Continue Playing"] += non_voters
if(choices["Continue Playing"] >= greatest_votes)
greatest_votes = choices["Continue Playing"]
else if(mode == "gamemode")
tally["Continue Playing"] += non_voters
if(mode == "gamemode")
if(master_mode in choices)
choices[master_mode] += non_voters
if(choices[master_mode] >= greatest_votes)
greatest_votes = choices[master_mode]
else if(mode == "crew_transfer")
var/factor = 0.5
switch(world.time / (10 * 60)) // minutes
if(0 to 60)
factor = 0.5
if(61 to 120)
factor = 0.8
if(121 to 240)
factor = 1
if(241 to 300)
factor = 1.2
else
factor = 1.4
choices["Initiate Crew Transfer"] = round(choices["Initiate Crew Transfer"] * factor)
tally[master_mode] += non_voters
if(mode == "crew_transfer")
var/factor = 0.0107*world.time**0.393 //magical factor between approx. 0.5 and 1.4
factor = max(factor,0.5)
tally["Initiate Crew Transfer"] = round(tally["Initiate Crew Transfer"] * factor)
to_chat(world, "<font color='purple'>Crew Transfer Factor: [factor]</font>")
greatest_votes = max(choices["Initiate Crew Transfer"], choices["Continue The Round"])
//choose the method for voting: "WEIGHTED" = 0, "MAJORITY" = 1
switch(config.toggle_vote_method)
if(0)
return weighted()
if(1)
return majority()
if(2)
if(mode == "map")
return majority()//return persistent()
else
return majority()
else
return majority()
/datum/controller/vote/proc/majority()
var/text
var/feedbackanswer
var/greatest_votes = 0
if (tally.len > 0)
if (tally[1])
var/list/winners = list()
sortTim(tally, /proc/cmp_numeric_dsc,1)
greatest_votes = tally[tally[1]]
for (var/c in tally)
if (tally[c] == greatest_votes)//must be true a least once
winners += c
if (winners.len > 1)
text = "<b>Vote Tied Between:</b><br>"
for(var/option in winners)
text += "\t[option]<br>"
feedbackanswer = jointext(winners, " ")
. = pick(winners)
if(mode == "map")
if(!feedbackanswer)
feedbackanswer = .
feedback_set("map vote winner", feedbackanswer)
else
feedback_set("map vote tie", "[feedbackanswer] chosen: [.]")
text += "<b>Vote Result: [.] won with [greatest_votes] vote\s.</b>"
for(var/c in tally)
if(. != c)
text += "<br>\t [c] had [tally[c] != null ? tally[c] : "0"]."
else
text += "<b>Vote Result: Inconclusive - No Votes!</b>"
return text
//get all options with that many votes and return them in a list
. = list()
if(weighted)
var/list/filteredchoices = choices.Copy()
/datum/controller/vote/proc/weighted()
var/vote_threshold = 0.15
var/list/discarded_choices = list()
var/discarded_votes = 0
var/total_votes = get_total()
var/text
var/list/filteredchoices = tally.Copy()
var/qualified_votes
if (total_votes > 0)
for(var/a in filteredchoices)
if(!filteredchoices[a])
filteredchoices -= a //Remove choices with 0 votes, as pickweight gives them 1 vote
@@ -168,50 +193,26 @@ var/global/datum/controller/vote/vote = new()
filteredchoices -= a
discarded_choices += a
if(filteredchoices.len)
. += pickweight(filteredchoices.Copy())
else
if(greatest_votes)
for(var/option in choices)
if(choices[option] == greatest_votes)
. += option
return .
/datum/controller/vote/proc/announce_result()
stack_trace("Fuck my shit up. Lock is \[[lock]]")
var/list/winners = get_result()
var/text
var/feedbackanswer
var/qualified_votes = total_votes - discarded_votes
currently_voting = FALSE
if(winners.len > 0)
if(winners.len > 1)
text = "<b>Vote Tied Between:</b><br>"
for(var/option in winners)
text += "\t[option]<br>"
feedbackanswer = jointext(winners, " ")
. = pick(winners)
if(mode == "map")
if(!feedbackanswer)
feedbackanswer = .
feedback_set("map vote winner", feedbackanswer)
else
feedback_set("map vote tie", "[feedbackanswer] chosen: [.]")
text += "<b>[weighted ? "Random Weighted " : ""]Vote Result: [.] won with [choices[.]] vote\s[weighted? " and a [round(100*choices[.]/qualified_votes)]% chance of winning" : null].</b>"
. = pickweight(filteredchoices.Copy())
qualified_votes = total_votes - discarded_votes
text += "<b>Random Weighted Vote Result: [.] won with [tally[.]] vote\s and a [round(100*tally[.]/qualified_votes)]% chance of winning.</b>"
for(var/choice in choices)
if(. == choice)
continue
text += "<br>\t [choice] had [choices[choice] != null ? choices[choice] : "0"] vote\s[(weighted&&choices[choice])? " and [(choice in discarded_choices) ? "did not get enough votes to qualify" : "a [round(100*choices[choice]/qualified_votes)]% chance of winning"]" : null]."
if(. != choice)
text += "<br>\t [choice] had [tally[choice] != null ? tally[choice] : "0"] vote\s[(tally[choice])? " and [(choice in discarded_choices) ? "did not get enough votes to qualify" : "a [round(100*tally[choice]/qualified_votes)]% chance of winning"]" : null]."
else
text += "<b>Vote Result: Inconclusive - No Votes!</b>"
log_vote(text)
to_chat(world, "<font color='purple'>[text]</font>")
return text
/datum/controller/vote/proc/announce_result()
currently_voting = FALSE
var/result = get_result()
log_vote(result)
to_chat(world, "<font color='purple'>[result]</font>")
/datum/controller/vote/proc/result()
. = announce_result()
var/restart = 0
currently_voting = FALSE
var/restart = 0
if(.)
switch(mode)
if("restart")
@@ -235,9 +236,6 @@ var/global/datum/controller/vote/vote = new()
chosen_map = "maps/voting/" + ismapvote[.] + "/vgstation13.dmb"
watchdog.chosen_map = ismapvote[.]
log_game("Players voted and chose.... [watchdog.chosen_map]!")
//testing("Vote picked [chosen_map]")
if(restart)
to_chat(world, "World restarting due to vote...")
feedback_set_details("end_error","restart vote")
@@ -249,12 +247,8 @@ var/global/datum/controller/vote/vote = new()
world.Reboot()
/datum/controller/vote/proc/submit_vote(var/mob/user, var/vote)
var/mob_ckey = user.ckey
if(mode)
if(config.vote_no_dead && usr.stat == DEAD && !usr.client.holder)
return 0
if (mob_ckey in voted)
to_chat(user, "<span class='warning'>You may only vote once.</span>")
if(config.vote_no_dead && user.stat == DEAD && !user.client.holder)
return 0
if (isnum(vote) && (1>vote) || (vote > choices.len))
to_chat(user, "<span class='warning'>Illegal vote.</span>")
@@ -262,23 +256,59 @@ var/global/datum/controller/vote/vote = new()
if(mode == "map")
if(!user.client.holder)
if(isnewplayer(user))
to_chat(usr, "<span class='warning'>Only players that have joined the round may vote for the next map.</span>")
to_chat(user, "<span class='warning'>Only players that have joined the round may vote for the next map.</span>")
return 0
if(isobserver(user))
var/mob/dead/observer/O = user
if(O.started_as_observer)
to_chat(usr, "<span class='warning'>Only players that have joined the round may vote for the next map.</span>")
to_chat(user, "<span class='warning'>Only players that have joined the round may vote for the next map.</span>")
return 0
if(current_votes[mob_ckey])
choices[choices[current_votes[mob_ckey]]]--
if(vote && vote != "cancel_vote")
voted += mob_ckey
choices[choices[vote]]++ //check this
current_votes[mob_ckey] = vote
return vote
//check vote then remove vote
if(vote && vote == "cancel_vote")
cancel_vote(user)
//add vote
else if(vote && vote != "cancel_vote")
add_vote(user, vote)
return vote //do we need this?
else
to_chat(user, "<span class='warning'>You may only vote once.</span>")
return 0
/datum/controller/vote/proc/initiate_vote(var/vote_type, var/initiator_key, var/popup = 0, var/weighted_vote = 0)
/datum/controller/vote/proc/get_vote(var/mob/user, var/num = FALSE)
var/mob_ckey = user.ckey
//returns voter's choice
if(mob_ckey)
if(voters[mob_ckey])
if(num)
return choices.Find(voters[mob_ckey])
else
return voters[mob_ckey]
return 0
/datum/controller/vote/proc/add_vote(var/mob/user, var/vote)
var/mob_ckey = user.ckey
//adds voter's choice and adds to tally. vote was passed as numbers
if(voters[mob_ckey])
cancel_vote(user)
tally[choices[vote]]++
voters[mob_ckey] += choices[vote]
/datum/controller/vote/proc/cancel_vote(var/mob/user)
var/mob_ckey = user.ckey
if (voters[mob_ckey])
tally[voters[mob_ckey]]--
voters -= mob_ckey
/datum/controller/vote/proc/get_total()
var/total = 0
//loop through choices in tally for count and add them up
for (var/c in tally)
if(c)
total += tally[c]
return total
/datum/controller/vote/proc/initiate_vote(var/vote_type, var/initiator_key, var/popup = 0)
var/mob/user = usr
if(currently_voting)
message_admins("<span class='info'>[initiator_key] attempted to begin a vote, however a vote is already in progress.</span>")
return
@@ -305,31 +335,36 @@ var/global/datum/controller/vote/vote = new()
question = "End the shift?"
choices.Add("Initiate Crew Transfer", "Continue The Round")
if("custom")
question = html_encode(input(usr,"What is the vote for?") as text|null)
question = html_encode(input(user,"What is the vote for?") as text|null)
if(!question)
return 0
for(var/i=1,i<=10,i++)
var/option = capitalize(html_encode(input(usr,"Please enter an option or hit cancel to finish") as text|null))
if(!option || mode || !usr.client)
for(var/i in 1 to 10)
var/option = capitalize(html_encode(input(user,"Please enter an option or hit cancel to finish") as text|null))
if(!option || mode || !user.client)
break
choices.Add(option)
if("map")
var/list/maps
question = "What should the next map be?"
var/list/maps = get_votable_maps()
for(var/key in maps)
choices.Add(key)
if (config.toggle_maps)
maps = get_all_maps()
else
maps = get_votable_maps()
if(!choices.len)
to_chat(world, "<span class='danger'>Failed to initiate map vote, no maps found.</span>")
return 0
ismapvote = maps
else
return 0
mode = vote_type
initiator = initiator_key
started_time = world.time
weighted = weighted_vote
var/text = "[capitalize(mode)] vote started by [initiator]."
choices = shuffle(choices)
//initialize tally
for (var/c in choices)
tally[c] = 0
if(mode == "custom")
text += "<br>[question]"
@@ -349,8 +384,8 @@ var/global/datum/controller/vote/vote = new()
continue
interact(C)
else
if(istype(usr) && usr.client)
interact(usr.client)
if(istype(user) && user.client)
interact(user.client)
to_chat(world, "<font color='purple'><b>[text]</b><br> <a href='?src=\ref[vote]'>Click here</a> or type 'vote' to place your votes.<br>You have [ismapvote && ismapvote.len ? "60" : config.vote_period/10] seconds to vote.</font>")
switch(vote_type)
@@ -362,16 +397,7 @@ var/global/datum/controller/vote/vote = new()
world << sound('sound/voice/Serithi/weneedvote.ogg')
if("map")
world << sound('sound/misc/rockthevote.ogg')
var/thisisstupid = 0
if(vote.choices.Find("Island Station"))
thisisstupid = 1
else if(vote.choices.Find("Island"))
thisisstupid = 2
if(thisisstupid)
if(thisisstupid == 2)
vote.choices["Island"] = -15
else
vote.choices["Island Station"] = -15
if(mode == "gamemode" && going)
going = 0
to_chat(world, "<span class='red'><b>Round start has been delayed.</b></span>")
@@ -386,11 +412,11 @@ var/global/datum/controller/vote/vote = new()
interface.callJavaScript("clearAll", new/list(), hclient_or_mob)
interface.callJavaScript("update_mode", status_data, hclient_or_mob)
if(data.len)
for (var/list/L in data)
if(tally.len)
for (var/i = 1; i <= tally.len; i++)
var/list/L = list(i, tally[i], tally[tally[i]])
interface.callJavaScript("update_choices", L, hclient_or_mob)
/datum/controller/vote/proc/interact(client/user)
set waitfor = FALSE // So we don't wait for each individual client's assets to be sent.
@@ -404,24 +430,23 @@ var/global/datum/controller/vote/vote = new()
else
CRASH("The user [M.name] of type [M.type] has been passed as a mob reference without a client to voting.interact()")
voting |= user
interface.show(user)
var/list/client_data = list()
var/admin = 0
var/currvote = 0
if(current_votes[user.ckey])
currvote = current_votes[user.ckey]
client_data[++client_data.len] = (currvote)
//interface.callJavascript("current_vote", current_votes[user.ckey])
//adds client data
if(get_vote(user))
client_data += list(get_vote(user,TRUE))
else
client_data += list(0)
if(user.holder)
admin = 1
if(user.holder.rights & R_ADMIN)
admin = 2
client_data[++client_data.len] = (admin)
client_data += list(admin)
interface.callJavaScript("client_data", client_data, user)
src.updateFor(user, interface)
/datum/controller/vote/proc/update(refresh = 0)
if(!interface)
interface = new/datum/html_interface/nanotrasen/vote(src, "Voting Panel", 400, 400, vote_head)
@@ -431,79 +456,89 @@ var/global/datum/controller/vote/vote = new()
return
last_update = world.time
status_data.len = 0
status_data[++status_data.len] = mode
status_data[++status_data.len] = question
status_data[++status_data.len] = time_remaining
status_data += list(mode)
status_data += list(question)
status_data += list(time_remaining)
if(config.allow_vote_restart)
status_data[++status_data.len] = 1
status_data += list(1)
else
status_data[++status_data.len] = 0
status_data += list(0)
if(config.allow_vote_mode)
status_data[++status_data.len] = 1
status_data += list(1)
else
status_data[++status_data.len] = 0
status_data += list(0)
if(config.toggle_maps)
status_data += list(1)
else
status_data += list(0)
if(config.toggle_vote_method)
status_data += list(1)
else
status_data += list(0)
var/list/choices_list = list()
if(mode)
for(var/i = 1; i <= choices.len; i++)
choices_list[++choices_list.len] = list(i, choices[i], (!isnull(choices[choices[i]]) ? choices[choices[i]] : 0))
data = choices_list
if(refresh && interface)
updateFor()
/datum/controller/vote/Topic(href,href_list[],hsrc)
if(!usr || !usr.client)
var/mob/user = usr
if(!user || !user.client)
return //not necessary but meh...just in-case somebody does something stupid
switch(href_list["vote"])
if ("cancel_vote")
var/mob_ckey = usr.ckey
if (!(mob_ckey in voted))
return
voted -= mob_ckey
choices[choices[current_votes[mob_ckey]]]--
current_votes[mob_ckey] = null
src.updateFor(usr.client)
cancel_vote(user)
src.updateFor(user.client)
return 0
if("cancel")
if(usr.client.holder)
if(user.client.holder)
if(alert("Are you sure you want to cancel this vote? This will not display the results, and for a map vote, re-use the current map.","Confirm","Yes","No") != "Yes")
return
log_admin("[key_name(usr)] has cancelled a vote currently taking place. Vote type: [mode], question, [question].")
message_admins("[key_name(usr)] has cancelled a vote currently taking place. Vote type: [mode], question, [question].")
log_admin("[user] has cancelled a vote currently taking place. Vote type: [mode], question, [question].")
message_admins("[user] has cancelled a vote currently taking place. Vote type: [mode], question, [question].")
reset()
update()
currently_voting = FALSE
if("toggle_restart")
if(usr.client.holder)
if(user.client.holder)
config.allow_vote_restart = !config.allow_vote_restart
update()
if("toggle_gamemode")
if(usr.client.holder)
if(user.client.holder)
config.allow_vote_mode = !config.allow_vote_mode
update()
if("restart")
if(config.allow_vote_restart || usr.client.holder)
initiate_vote("restart",usr.key)
if(config.allow_vote_restart || user.client.holder)
initiate_vote("restart",user)
if("gamemode")
if(config.allow_vote_mode || usr.client.holder)
initiate_vote("gamemode",usr.key)
if(config.allow_vote_mode || user.client.holder)
initiate_vote("gamemode",user)
if("crew_transfer")
if(config.allow_vote_restart || usr.client.holder)
initiate_vote("crew_transfer",usr.key)
if(config.allow_vote_restart || user.client.holder)
initiate_vote("crew_transfer",user)
if("custom")
if(usr.client.holder)
initiate_vote("custom",usr.key)
if(user.client.holder)
initiate_vote("custom",user)
if("map")
if(user.client.holder)
initiate_vote("map",user)
if("toggle_map")
if(user.client.holder)
config.toggle_maps = !config.toggle_maps
update()
if("toggle_vote_method")
if(user.client.holder)
config.toggle_vote_method = !config.toggle_vote_method
update()
else
submit_vote(usr, round(text2num(href_list["vote"])))
usr.vote()
submit_vote(user, round(text2num(href_list["vote"])))
user.vote()
/mob/verb/vote()
var/mob/user = usr
set category = "OOC"
set name = "Vote"
if(vote)
if(!vote.initialized)
to_chat(usr, "<span class='info'>The voting controller isn't fully initialized yet.</span>")
to_chat(user, "<span class='info'>The voting controller isn't fully initialized yet.</span>")
else
vote.interact(usr.client)
vote.interact(user.client)

View File

@@ -3,6 +3,8 @@ var question = null;
var time_left = 0;
var allow_restart = 0;
var allow_mode = 0 ;
var toggle_map = 0;
var toggle_vote_method = 0;
var selected_vote = 0;
var admin = 0;
var updates = 0;
@@ -28,11 +30,13 @@ function client_data(selection, privs){
admin = parseInt(privs) || 0;
}
function update_mode(newMode, newQuestion, newTimeleft, vrestart, vmode){
function update_mode(newMode, newQuestion, newTimeleft, vrestart, vmode, vmap, vmethod){
mode = newMode;
question = newQuestion;
allow_mode = parseInt(vmode) || 0;
allow_restart = parseInt(vrestart) || 0;
toggle_map = parseInt(vmap) || 0;
toggle_vote_method = parseInt(vmethod) || 0;
time_left = parseInt(newTimeleft) || 0;
$("#vote_choices").append($("<div class='item'></div>").append($("<div class='itemLabel'></div>").html("Time Left")).append($("<div class='itemContent'></div>").html(displayBar(time_left, 0, 60, (time_left >= 50) ? 'good' : (time_left >= 25) ? 'average' : 'bad', '<center>' + time_left + '</center>'))));
$("#vote_choices").append($("<div class='item'></div>").append($("<div class='itemLabel'></div>").html("<br />Question")).append($("<div class='itemContentMedium'></div>").append($("<div class='statusDisplay'></div>").text(question))));
@@ -44,12 +48,21 @@ function update_mode(newMode, newQuestion, newTimeleft, vrestart, vmode){
$("#vote_main").append($("<div class='item'></div>").append($("<div class='itemContent'></div>").html("<font color='grey'>Restart</font>")));
$("#vote_main").append($("<div class='item'></div>").append($("<div class='itemContent'></div>").html("<font color='grey'>Crew Transfer</font>")));
}
if(admin > 0 || allow_mode > 0){
$("#vote_main").append($("<div class='item'></div>").append($("<div class='itemContent'></div>").html("<a href='?src=" + hSrc + ";vote=gamemode'>GameMode</a>" + (admin == 2 ? "(<a href='?src=" + hSrc + ";vote=toggle_gamemode'>" + (allow_mode?"Allowed":"Disallowed") + "</a>)" : ""))));
}
if(admin > 0)
$("#vote_main").append($("<div class='item'></div>").append($("<div class='itemContent'></div>").html("<a href='?src=" + hSrc + ";vote=custom'>Custom</a>")));
if(admin > 0){
$("#vote_main").append($("<div class='item'></div>").append($("<div class='itemContent'></div>").html("<a href='?src=" + hSrc + ";vote=custom'>Custom Vote</a>")));
}
if(admin > 0){
$("#vote_main").append($("<div class='item'></div>").append($("<div class='itemContent'></div>").html("<a href='?src=" + hSrc + ";vote=map'>Map</a>" + (admin == 2 ? "(<a href='?src=" + hSrc + ";vote=toggle_map'>" + (toggle_map?"All Compiled":"Votable") + "</a>)" : ""))));
}
if(admin > 0){
$("#vote_main").append($("<div class='item'></div>").append($("<div class='itemContent'></div>").html("<a href='?src=" + hSrc + ";vote=toggle_vote_method'>" + (toggle_vote_method?"Majority":"Weighted") + "</a>)" )));
}
if(mode != null && mode != ""){
$("#vote_main").hide();