Allows players to call for restart or map vote (if everyone is dead and no admins online) (#32883)

* rock the vote

* tweaks

* Update voting.dm

* should work

* Update voting.js

* Update voting.js

* Update voting.dm
This commit is contained in:
adacovsk
2022-07-10 12:34:53 -04:00
committed by GitHub
parent 52a7355c72
commit 3474e39817
6 changed files with 46 additions and 67 deletions

View File

@@ -347,11 +347,6 @@
if("allow_admin_ooccolor")
config.allow_admin_ooccolor = 1
if ("allow_vote_restart")
config.allow_vote_restart = 1
if ("allow_vote_mode")
config.allow_vote_mode = 1
if ("allow_admin_jump")
config.allow_admin_jump = 1

View File

@@ -662,7 +662,7 @@ var/stacking_limit = 90
if(living_players.len) //if anybody is around and alive in the current round
last_time_of_population = world.time
else if(last_time_of_population && world.time - last_time_of_population > 5 MINUTES && world.time > 15 MINUTES) //if enough time has passed without it
else if(last_time_of_population && world.time - last_time_of_population > 1 HOURS) //if enough time has passed without it
ticker.station_nolife_cinematic()
if(world.time > (7 HOURS + 40 MINUTES) && world.time - last_time_of_late_shuttle_call > 1 HOURS && emergency_shuttle.direction == 0) // 8 hour work shift, with time for shuttle to arrive and leave. If recalled, do every hour
shuttle_autocall("Shift due to end")

View File

@@ -21,6 +21,6 @@
. = ..()
if(player_list.len) //if anybody is in the current round
last_time_of_players = world.time
if(last_time_of_players && world.time - last_time_of_players > 5 MINUTES && world.time > 15 MINUTES) //if enough time has passed without them
if(last_time_of_players && world.time - last_time_of_players > 1 HOURS) //if enough time has passed without them
CallHook("Reboot",list())
world.Reboot()

View File

@@ -71,6 +71,7 @@ var/global/datum/controller/vote/vote = new()
/datum/controller/vote/proc/reset()
currently_voting = FALSE
lock = FALSE
initiator = null
time_remaining = 0
mode = null
@@ -326,13 +327,12 @@ var/global/datum/controller/vote/vote = new()
if(currently_voting)
message_admins("<span class='info'>[initiator_key] attempted to begin a vote, however a vote is already in progress.</span>")
return
currently_voting = TRUE
if(!mode)
if(started_time != null && !check_rights(R_ADMIN))
var/next_allowed_time = (started_time + config.vote_delay)
if(next_allowed_time > world.time)
to_chat(user, "You must wait [(next_allowed_time - world.time)/10] seconds to call another vote.")
return 0
reset()
switch(vote_type)
if("restart")
@@ -377,6 +377,7 @@ var/global/datum/controller/vote/vote = new()
else
return 0
currently_voting = TRUE
mode = vote_type
initiator = initiator_key
started_time = world.time
@@ -490,14 +491,6 @@ var/global/datum/controller/vote/vote = new()
status_data += list(mode)
status_data += list(question)
status_data += list(time_remaining)
if(config.allow_vote_restart)
status_data += list(1)
else
status_data += list(0)
if(config.allow_vote_mode)
status_data += list(1)
else
status_data += list(0)
if(config.toggle_maps)
status_data += list(1)
else
@@ -511,6 +504,12 @@ var/global/datum/controller/vote/vote = new()
var/mob/user = usr
if(!user || !user.client)
return //not necessary but meh...just in-case somebody does something stupid
var/living_players = 0
for(var/client/C in clients)
if(C && C.mob && C.mob.stat == CONSCIOUS)
living_players++
break
switch(href_list["vote"])
if ("cancel_vote")
cancel_vote(user)
@@ -524,46 +523,56 @@ var/global/datum/controller/vote/vote = new()
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()
else
to_chat(user, "<span class='notice'> You can't do that!")
if("rig")
if(user.client.holder)
rigvote()
update()
if("toggle_restart")
if(user.client.holder)
config.allow_vote_restart = !config.allow_vote_restart
update()
if("toggle_gamemode")
if(user.client.holder)
config.allow_vote_mode = !config.allow_vote_mode
update()
else
to_chat(user, "<span class='notice'> You can't do that!")
if("restart")
if(config.allow_vote_restart || user.client.holder)
if(user.client.holder)
initiate_vote("restart",user)
else if(!length(admins) && !living_players)
initiate_vote("restart",user)
else
to_chat(user, "<span class='notice'> An admin is currently online. Ask them for a restart.")
if("gamemode")
if(config.allow_vote_mode || user.client.holder)
if(user.client.holder)
initiate_vote("gamemode",user)
else
to_chat(user, "<span class='notice'> You can't do that! This doesn't work anyway.")
if("crew_transfer")
if(config.allow_vote_restart || user.client.holder)
if(user.client.holder)
initiate_vote("crew_transfer",user)
else
to_chat(user, "<span class='notice'> You can't do that!")
if("custom")
if(user.client.holder)
initiate_vote("custom",user)
else
to_chat(user, "<span class='notice'> You can't do that!")
if("map")
if(user.client.holder)
initiate_vote("map",user)
update()
else if(!length(admins) && !living_players)
initiate_vote("restart",user)
else
to_chat(user, "<span class='notice'> An admin is currently online. Ask them for a map vote.")
if("toggle_map")
if(user.client.holder)
config.toggle_maps = !config.toggle_maps
update()
else
to_chat(user, "<span class='notice'> You can't do that!")
if("toggle_vote_method")
if(user.client.holder)
config.toggle_vote_method = config.toggle_vote_method % 4 + 1
update()
else
to_chat(user, "<span class='notice'> You can't do that!")
//If not calling a vote, submit a vote
else
submit_vote(user, round(text2num(href_list["vote"])))
update()
user.vote()
/mob/verb/vote()

View File

@@ -1,8 +1,6 @@
var mode = null;
var question = null;
var time_left = 0;
var allow_restart = 0;
var allow_mode = 0 ;
var toggle_map = 0;
var toggle_vote_method = 1;
var selected_vote = 0;
@@ -10,7 +8,6 @@ var admin = 0;
var updates = 0;
var clearallup = 0;
function clearAll(){
clearallup += 1;
$("#vote_main").empty();
@@ -29,42 +26,24 @@ function client_data(selection, privs){
admin = parseInt(privs) || 0;
}
function update_mode(newMode, newQuestion, newTimeleft, vrestart, vmode, vmap, vmethod){
function update_mode(newMode, newQuestion, newTimeleft, vmap, vmethod){
mode = newMode;
question = newQuestion;
allow_mode = parseInt(vmode) || 0;
allow_restart = parseInt(vrestart) || 0;
time_left = parseInt(newTimeleft) || 0;
toggle_map = parseInt(vmap) || 0;
toggle_vote_method = parseInt(vmethod) || 1;
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))));
if(admin > 0 || allow_restart > 0){
$("#vote_main").append($("<div class='item'></div>").append($("<div class='itemContent'></div>").html("<a href='?src=" + hSrc + ";vote=restart'>Restart</a>" + (admin == 2 ? "(<a href='?src=" + hSrc + ";vote=toggle_restart'>" + (allow_restart?"Allowed":"Disallowed") + "</a>)" : ""))));
$("#vote_main").append($("<div class='item'></div>").append($("<div class='itemContent'></div>").html("<a href='?src=" + hSrc + ";vote=crew_transfer'>Crew Transfer</a>")));
}
else{
$("#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 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=restart'>Call Restart Vote</a>")));
$("#vote_main").append($("<div class='item'></div>").append($("<div class='itemContent'></div>").html("<a href='?src=" + hSrc + ";vote=gamemode'>Call Gamemode Vote</a>")));
$("#vote_main").append($("<div class='item'></div>").append($("<div class='itemContent'></div>").html("<a href='?src=" + hSrc + ";vote=crew_transfer'>Call Crew Transfer Vote</a>")));
$("#vote_main").append($("<div class='item'></div>").append($("<div class='itemContent'></div>").html("<a href='?src=" + hSrc + ";vote=custom'>Call Custom Vote</a>")));
$("#vote_main").append($("<div class='item'></div>").append($("<div class='itemContent'></div>").html("<a href='?src=" + hSrc + ";vote=map'>Call Map Vote</a>" + (admin == 2 ? "(<a href='?src=" + hSrc + ";vote=toggle_map'>" + (toggle_map?"All Compiled":"Votable") + "</a>)" : ""))));
if(admin > 0) {
var a = ((toggle_vote_method == 1) ? "Weighted" : (toggle_vote_method == 2) ? "Majority" : (toggle_vote_method == 3) ? "Persistent" : (toggle_vote_method == 4) ? "Random" : "Null");
$("#vote_main").append($("<div class='item'></div>").append($("<div class='itemContent'></div>").html("<a href='?src=" + hSrc + ";vote=toggle_vote_method'>" + a + "</a>")));
}
if(mode != null && mode != ""){
$("#vote_main").hide();
if(admin > 0){

View File

@@ -151,7 +151,6 @@ var/auxtools_path
s["mode"] = master_mode
s["respawn"] = config ? abandon_allowed : 0
s["enter"] = enter_allowed
s["vote"] = config.allow_vote_mode
s["ai"] = config.allow_ai
s["host"] = host ? host : null
s["players"] = list()
@@ -330,9 +329,6 @@ var/auxtools_path
features += abandon_allowed ? "respawn" : "no respawn"
if (config && config.allow_vote_mode)
features += "vote"
if (config && config.allow_ai)
features += "AI allowed"