diff --git a/code/controllers/configuration/configuration.dm b/code/controllers/configuration/configuration.dm index 14954524fa..730a3f17f4 100644 --- a/code/controllers/configuration/configuration.dm +++ b/code/controllers/configuration/configuration.dm @@ -236,7 +236,6 @@ if(!(M.config_tag in modes)) // ensure each mode is added only once modes += M.config_tag mode_names[M.config_tag] = M.name - probabilities[M.config_tag] = M.probability mode_reports[M.config_tag] = M.generate_report() if(probabilities[M.config_tag]>0) mode_false_report_weight[M.config_tag] = M.false_report_weight @@ -342,6 +341,9 @@ if(probabilities[M.config_tag]<=0) qdel(M) continue + if(M.config_tag in SSvote.stored_modetier_results && SSvote.stored_modetier_results[M.config_tag] < Get(/datum/config_entry/number/dropped_modes)) + qdel(M) + continue if(min_pop[M.config_tag]) M.required_players = min_pop[M.config_tag] if(max_pop[M.config_tag]) diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index b95ef43d37..eea5789a0e 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -394,3 +394,9 @@ /datum/config_entry/flag/allow_clockwork_marauder_on_station config_entry_value = TRUE + +/datum/config_entry/flag/modetier_voting + config_entry_value = TRUE + +/datum/config_entry/number/dropped_modes + config_entry_value = 3 diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index 45c8e3c8fe..0948e428ff 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -221,6 +221,12 @@ SUBSYSTEM_DEF(ticker) var/init_start = world.timeofday //Create and announce mode var/list/datum/game_mode/runnable_modes + if(SSvote.mode && (SSvote.mode == "roundtype" || SSvote.mode == "dynamic" || SSvote.mode == "mode tiers")) + SSvote.result() + SSpersistence.SaveSavedVotes() + for(var/client/C in SSvote.voting) + C << browse(null, "window=vote;can_close=0") + SSvote.reset() if(GLOB.master_mode == "random" || GLOB.master_mode == "secret") runnable_modes = config.get_runnable_modes() @@ -484,9 +490,10 @@ SUBSYSTEM_DEF(ticker) SSticker.modevoted = TRUE var/dynamic = CONFIG_GET(flag/dynamic_voting) if(dynamic) - SSvote.initiate_vote("dynamic","server",hideresults=TRUE,votesystem=SCORE_VOTING,forced=TRUE,vote_time = 2 MINUTES) + SSvote.initiate_vote("dynamic","server",hideresults=TRUE,votesystem=SCORE_VOTING,forced=TRUE,vote_time = 20 MINUTES) else - SSvote.initiate_vote("roundtype","server",hideresults=TRUE,votesystem=PLURALITY_VOTING,forced=TRUE, vote_time = 2 MINUTES) + SSvote.initiate_vote("roundtype","server",hideresults=TRUE,votesystem=PLURALITY_VOTING,forced=TRUE, \ + vote_time = (CONFIG_GET(flag/modetier_voting) ? 1 MINUTES : 20 MINUTES)) /datum/controller/subsystem/ticker/Recover() current_state = SSticker.current_state diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 573c89a5af..f82954276e 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -15,6 +15,7 @@ SUBSYSTEM_DEF(vote) var/vote_system = PLURALITY_VOTING var/question = null var/list/choices = list() + var/list/scores = list() var/list/choice_descs = list() // optional descriptions var/list/voted = list() var/list/voting = list() @@ -26,6 +27,8 @@ SUBSYSTEM_DEF(vote) var/list/stored_gamemode_votes = list() //Basically the last voted gamemode is stored here for end-of-round use. + var/list/stored_modetier_results = list() // The aggregated tier list of the modes available in secret. + /datum/controller/subsystem/vote/fire() //called by master_controller if(mode) if(end_time < world.time) @@ -33,7 +36,8 @@ SUBSYSTEM_DEF(vote) SSpersistence.SaveSavedVotes() for(var/client/C in voting) C << browse(null, "window=vote;can_close=0") - reset() + if(end_time < world.time) // result() can change this + reset() else if(next_pop < world.time) var/datum/browser/client_popup for(var/client/C in voting) @@ -54,6 +58,7 @@ SUBSYSTEM_DEF(vote) choice_descs.Cut() voted.Cut() voting.Cut() + scores.Cut() obfuscated = FALSE //CIT CHANGE - obfuscated votes remove_action_buttons() @@ -116,10 +121,8 @@ SUBSYSTEM_DEF(vote) var/opposite_pref = d[j][i] if(pref_number>opposite_pref) p[i][j] = d[i][j] - p[j][i] = 0 else p[i][j] = 0 - p[j][i] = d[i][j] for(var/i in 1 to choices.len) for(var/j in 1 to choices.len) if(i != j) @@ -180,6 +183,22 @@ SUBSYSTEM_DEF(vote) score.Cut(median_pos,median_pos+1) choices[score_name]++ +/datum/controller/subsystem/vote/proc/calculate_scores(var/blackbox_text) + var/list/scores_by_choice = list() + for(var/choice in choices) + scores_by_choice[choice] = list() + for(var/ckey in voted) + var/list/this_vote = voted[ckey] + for(var/choice in this_vote) + sorted_insert(scores_by_choice[choice],this_vote[choice],/proc/cmp_numeric_asc) + var/middle_score = round(GLOB.vote_score_options.len/2,1) + for(var/score_name in scores_by_choice) + var/list/score = scores_by_choice[score_name] + for(var/S in score) + scores[score_name] += S-middle_score + SSblackbox.record_feedback("nested tally","voting",scores[score_name],list(blackbox_text,"Total scores",score_name)) + + /datum/controller/subsystem/vote/proc/announce_result() var/vote_title_text var/text @@ -234,6 +253,8 @@ SUBSYSTEM_DEF(vote) var/admintext = "Obfuscated results" if(vote_system == RANKED_CHOICE_VOTING) admintext += "\nIt should be noted that this is not a raw tally of votes (impossible in ranked choice) but the score determined by the schulze method of voting, so the numbers will look weird!" + else if(vote_system == SCORE_VOTING) + admintext += "\nIt should be noted that this is not a raw tally of votes but the number of runoffs done by majority judgement!" for(var/i=1,i<=choices.len,i++) var/votes = choices[choices[i]] admintext += "\n[choices[i]]: [votes]" @@ -252,6 +273,12 @@ SUBSYSTEM_DEF(vote) SSticker.save_mode(.) message_admins("The gamemode has been voted for, and has been changed to: [GLOB.master_mode]") log_admin("Gamemode has been voted for and switched to: [GLOB.master_mode].") + if(CONFIG_GET(flag/modetier_voting)) + reset() + started_time = 0 + initiate_vote("mode tiers","server",hideresults=FALSE,votesystem=RANKED_CHOICE_VOTING,forced=TRUE, vote_time = 30 MINUTES) + to_chat(world,"The vote will end right as the round starts.") + return . if("restart") if(. == "Restart Round") restart = 1 @@ -262,6 +289,8 @@ SUBSYSTEM_DEF(vote) restart = 1 else GLOB.master_mode = . + if("mode tiers") + stored_modetier_results = choices.Copy() if("dynamic") if(SSticker.current_state > GAME_STATE_PREGAME)//Don't change the mode if the round already started. return message_admins("A vote has tried to change the gamemode, but the game has already started. Aborting.") @@ -382,6 +411,13 @@ SUBSYSTEM_DEF(vote) choices |= M if("roundtype") //CIT CHANGE - adds the roundstart secret/extended vote choices.Add("secret", "extended") + if("mode tiers") + var/list/modes_to_add = config.votable_modes + var/list/probabilities = CONFIG_GET(keyed_list/probability) + for(var/tag in modes_to_add) + if(probabilities[tag] <= 0) + modes_to_add -= tag + choices.Add(modes_to_add) if("dynamic") for(var/T in config.storyteller_cache) var/datum/dynamic_storyteller/S = T diff --git a/config/game_options.txt b/config/game_options.txt index 34c8ca48fd..ef9296cd3b 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -578,4 +578,10 @@ DYNAMIC_VOTING ## Choose which Engine to start the round with, comment to remove an Engine from the rotation BOX_RANDOM_ENGINE Engine SM BOX_RANDOM_ENGINE Engine Tesla -BOX_RANDOM_ENGINE Engine Singulo \ No newline at end of file +BOX_RANDOM_ENGINE Engine Singulo + +## Whether or not there's a mode tier list vote after the secret/extended vote. +MODETIER_VOTING + +## Number of modes dropped by the modetier vote during mode selection, after vote. +DROPPED_MODES 3