From be98704abecb77fe5b40af464546acf7ce861393 Mon Sep 17 00:00:00 2001 From: Putnam Date: Sun, 5 Jan 2020 04:19:21 -0800 Subject: [PATCH 1/4] weird super secret vote --- code/controllers/configuration/configuration.dm | 4 +++- .../configuration/entries/game_options.dm | 3 +++ code/controllers/subsystem/ticker.dm | 2 +- code/controllers/subsystem/vote.dm | 12 ++++++++++-- config/game_options.txt | 5 ++++- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/code/controllers/configuration/configuration.dm b/code/controllers/configuration/configuration.dm index 14954524fa..25f05af55b 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_gamemode_votes && SSvote.stored_gamemode_votes[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 61b5788ef8..d045a92c83 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -392,3 +392,6 @@ /datum/config_entry/flag/allow_clockwork_marauder_on_station 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..76ebfb6765 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -486,7 +486,7 @@ SUBSYSTEM_DEF(ticker) if(dynamic) SSvote.initiate_vote("dynamic","server",hideresults=TRUE,votesystem=SCORE_VOTING,forced=TRUE,vote_time = 2 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=RANKED_CHOICE_VOTING,forced=TRUE, vote_time = 2 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..2563aadf71 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -116,10 +116,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) @@ -248,6 +246,10 @@ SUBSYSTEM_DEF(vote) if("roundtype") //CIT CHANGE - adds the roundstart extended/secret vote 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.") + if(choices["secret"] > choices["extended"]) + . = "secret" + else + . = "extended" GLOB.master_mode = . SSticker.save_mode(.) message_admins("The gamemode has been voted for, and has been changed to: [GLOB.master_mode]") @@ -382,6 +384,12 @@ SUBSYSTEM_DEF(vote) choices |= M if("roundtype") //CIT CHANGE - adds the roundstart secret/extended vote choices.Add("secret", "extended") + 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..99d6b143f8 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -578,4 +578,7 @@ 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 + +## Number of modes dropped by the secret vote during mode selection, after vote. +DROPPED_MODES 3 From da830d3449c1b932af73b7c62788bd3c5a391356 Mon Sep 17 00:00:00 2001 From: Putnam Date: Sun, 5 Jan 2020 19:49:54 -0800 Subject: [PATCH 2/4] Added scores for my own dastardly reasons --- code/controllers/subsystem/vote.dm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 2563aadf71..cb1a13541e 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() @@ -54,6 +55,7 @@ SUBSYSTEM_DEF(vote) choice_descs.Cut() voted.Cut() voting.Cut() + scores.Cut() obfuscated = FALSE //CIT CHANGE - obfuscated votes remove_action_buttons() @@ -178,6 +180,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 @@ -191,6 +209,7 @@ SUBSYSTEM_DEF(vote) calculate_condorcet_votes(vote_title_text) if(vote_system == SCORE_VOTING) calculate_majority_judgement_vote(vote_title_text) + calculate_scores(vote_title_text) var/list/winners = get_result() var/was_roundtype_vote = mode == "roundtype" || mode == "dynamic" if(winners.len > 0) From 70a1a0a9c1530e4c603403aec1ddea578f9cb564 Mon Sep 17 00:00:00 2001 From: Putnam Date: Tue, 7 Jan 2020 00:39:14 -0800 Subject: [PATCH 3/4] better way to do it tbh --- .../configuration/configuration.dm | 2 +- .../configuration/entries/game_options.dm | 3 +++ code/controllers/subsystem/ticker.dm | 11 ++++++++-- code/controllers/subsystem/vote.dm | 21 +++++++++++++------ config/game_options.txt | 5 ++++- 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/code/controllers/configuration/configuration.dm b/code/controllers/configuration/configuration.dm index 25f05af55b..730a3f17f4 100644 --- a/code/controllers/configuration/configuration.dm +++ b/code/controllers/configuration/configuration.dm @@ -341,7 +341,7 @@ if(probabilities[M.config_tag]<=0) qdel(M) continue - if(M.config_tag in SSvote.stored_gamemode_votes && SSvote.stored_gamemode_votes[M.config_tag] < Get(/datum/config_entry/number/dropped_modes)) + 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]) diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index d045a92c83..d67027b93d 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -393,5 +393,8 @@ /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 76ebfb6765..cf8affdc7a 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 == "modetiers")) + 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=RANKED_CHOICE_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 cb1a13541e..f82954276e 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -27,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) @@ -34,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) @@ -209,7 +212,6 @@ SUBSYSTEM_DEF(vote) calculate_condorcet_votes(vote_title_text) if(vote_system == SCORE_VOTING) calculate_majority_judgement_vote(vote_title_text) - calculate_scores(vote_title_text) var/list/winners = get_result() var/was_roundtype_vote = mode == "roundtype" || mode == "dynamic" if(winners.len > 0) @@ -251,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]" @@ -265,14 +269,16 @@ SUBSYSTEM_DEF(vote) if("roundtype") //CIT CHANGE - adds the roundstart extended/secret vote 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.") - if(choices["secret"] > choices["extended"]) - . = "secret" - else - . = "extended" GLOB.master_mode = . 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 @@ -283,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.") @@ -403,6 +411,7 @@ 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) diff --git a/config/game_options.txt b/config/game_options.txt index 99d6b143f8..ef9296cd3b 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -580,5 +580,8 @@ BOX_RANDOM_ENGINE Engine SM BOX_RANDOM_ENGINE Engine Tesla BOX_RANDOM_ENGINE Engine Singulo -## Number of modes dropped by the secret vote during mode selection, after vote. +## 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 From fdce8e2b6904b6e4c65353070b0fc09ddf8c384b Mon Sep 17 00:00:00 2001 From: Putnam Date: Wed, 8 Jan 2020 03:55:23 -0800 Subject: [PATCH 4/4] dang --- code/controllers/subsystem/ticker.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index cf8affdc7a..0948e428ff 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -221,7 +221,7 @@ 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 == "modetiers")) + if(SSvote.mode && (SSvote.mode == "roundtype" || SSvote.mode == "dynamic" || SSvote.mode == "mode tiers")) SSvote.result() SSpersistence.SaveSavedVotes() for(var/client/C in SSvote.voting)