mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-22 05:25:15 +01:00
[MIRROR] End Of Creating Map Votes with One/Zero Options. [MDB IGNORE] (#16977)
* End Of Creating Map Votes with One/Zero Options. (#70340) Makes it so you can't call a map vote when there is less than two maps to choose from Co-authored-by: VexingRaven <msgerbs@ users.noreply.github.com> Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> * End Of Creating Map Votes with One/Zero Options. Co-authored-by: san7890 <the@san7890.com> Co-authored-by: VexingRaven <msgerbs@ users.noreply.github.com> Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>
This commit is contained in:
@@ -18,16 +18,14 @@
|
||||
|
||||
/datum/vote/map_vote/create_vote()
|
||||
. = ..()
|
||||
|
||||
// Before we create a vote, remove all maps from our choices that are outside of our population range.
|
||||
// Note that this can result in zero remaining choices for our vote, which is not ideal (but technically fine).
|
||||
for(var/map in choices)
|
||||
var/datum/map_config/possible_config = config.maplist[map]
|
||||
if(possible_config.config_min_users > 0 && GLOB.clients.len < possible_config.config_min_users)
|
||||
choices -= map
|
||||
|
||||
else if(possible_config.config_max_users > 0 && GLOB.clients.len > possible_config.config_max_users)
|
||||
choices -= map
|
||||
check_population(should_key_choices = FALSE)
|
||||
if((length(choices) == 1) && EMERGENCY_ESCAPED_OR_ENDGAMED) // Only one choice, no need to vote. Let's just auto-rotate it to the only remaining map because it would just happen anyways.
|
||||
var/de_facto_winner = choices[1]
|
||||
var/datum/map_config/change_me_out = global.config.maplist[de_facto_winner]
|
||||
SSmapping.changemap(change_me_out)
|
||||
to_chat(world, span_boldannounce("The map vote has been skipped because there is only one map left to vote for. The map has been changed to [change_me_out.map_name]."))
|
||||
SSmapping.map_voted = TRUE // voted by not voting, very sad.
|
||||
return FALSE
|
||||
|
||||
/datum/vote/map_vote/toggle_votable(mob/toggler)
|
||||
if(!toggler)
|
||||
@@ -49,6 +47,11 @@
|
||||
if(forced)
|
||||
return TRUE
|
||||
|
||||
var/number_of_choices = length(check_population())
|
||||
if(number_of_choices < 2)
|
||||
message = "There [number_of_choices == 1 ? "is only one map" : "are no maps"] to choose from."
|
||||
return FALSE
|
||||
|
||||
if(SSmapping.map_vote_rocked)
|
||||
return TRUE
|
||||
|
||||
@@ -63,6 +66,23 @@
|
||||
message = initial(message)
|
||||
return TRUE
|
||||
|
||||
/// Before we create a vote, remove all maps from our choices that are outside of our population range. Note that this can result in zero remaining choices for our vote, which is not ideal (but ultimately okay).
|
||||
/// Argument should_key_choices is TRUE, pass as FALSE in a context where choices are already keyed in a list.
|
||||
/datum/vote/map_vote/proc/check_population(should_key_choices = TRUE)
|
||||
if(should_key_choices)
|
||||
for(var/key in default_choices)
|
||||
choices[key] = 0
|
||||
|
||||
for(var/map in choices)
|
||||
var/datum/map_config/possible_config = config.maplist[map]
|
||||
if(possible_config.config_min_users > 0 && GLOB.clients.len < possible_config.config_min_users)
|
||||
choices -= map
|
||||
|
||||
else if(possible_config.config_max_users > 0 && GLOB.clients.len > possible_config.config_max_users)
|
||||
choices -= map
|
||||
|
||||
return choices
|
||||
|
||||
/datum/vote/map_vote/get_vote_result(list/non_voters)
|
||||
// Even if we have default no vote off,
|
||||
// if our default map is null for some reason, we shouldn't continue
|
||||
|
||||
@@ -56,6 +56,10 @@
|
||||
message = "Rocking the vote is disabled because an admin has forcibly set the map!"
|
||||
return FALSE
|
||||
|
||||
if(EMERGENCY_ESCAPED_OR_ENDGAMED && SSmapping.map_voted)
|
||||
message = "The emergency shuttle has already left the station and the next map has already been chosen!"
|
||||
return FALSE
|
||||
|
||||
message = initial(message)
|
||||
return TRUE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user