From d05c2426a813993a5df913a3527ff71cac1c415c Mon Sep 17 00:00:00 2001 From: Putnam Date: Thu, 6 Feb 2020 15:47:04 -0800 Subject: [PATCH 1/8] Added a config for map voting types. --- code/controllers/configuration/entries/general.dm | 3 +++ code/controllers/subsystem/ticker.dm | 10 +++++++++- config/config.txt | 9 +++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/code/controllers/configuration/entries/general.dm b/code/controllers/configuration/entries/general.dm index c3ae90cc1b..2e5b8a1852 100644 --- a/code/controllers/configuration/entries/general.dm +++ b/code/controllers/configuration/entries/general.dm @@ -267,6 +267,9 @@ /datum/config_entry/flag/tgstyle_maprotation +/datum/config_entry/string/map_vote_type + config_entry_value = "SCORE" + /datum/config_entry/number/maprotatechancedelta config_entry_value = 0.75 min_val = 0 diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index ceb003210e..f0c9e3499c 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -477,7 +477,15 @@ SUBSYSTEM_DEF(ticker) if(CONFIG_GET(flag/tgstyle_maprotation)) INVOKE_ASYNC(SSmapping, /datum/controller/subsystem/mapping/.proc/maprotate) else - SSvote.initiate_vote("map","server",TRUE) + switch(CONFIG_GET(string/map_vote_type)) + if("PLURALITY") + SSvote.initiate_vote("map","server",TRUE) + else if("APPROVAL") + SSvote.initiate_vote("map","server",TRUE,votesystem = APPROVAL_VOTING) + else if("IRV") + SSvote.initiate_vote("map","server",TRUE,votesystem = INSTANT_RUNOFF_VOTING) + else if("SCORE") + SSvote.initiate_vote("map","server",TRUE,votesystem = MAJORITY_JUDGEMENT_VOTING) /datum/controller/subsystem/ticker/proc/HasRoundStarted() return current_state >= GAME_STATE_PLAYING diff --git a/config/config.txt b/config/config.txt index 6d302a5512..4d8dcfb00c 100644 --- a/config/config.txt +++ b/config/config.txt @@ -384,6 +384,15 @@ MAPROTATION ## When it's set to zero, the map will be randomly picked each round ALLOW_MAP_VOTING 1 +## Map voting type +## Determines what kind of vote the map vote is +## Options are: +## PLURALITY (default, only vote for one option) +## APPROVAL (can vote for as many as you want), I +## IRV (vote by ranked choice, winner determined by instant runoff algorithm) +## SCORE (give individual rankings of each choice, winner determined by majority judgement algorithm) +MAP_VOTE_TYPE SCORE + ## Map rotate chance delta ## This is the chance of map rotation factored to the round length. ## A value of 1 would mean the map rotation chance is the round length in minutes (hour long round == 60% rotation chance) From e6d353dd016ca3b0c7ddc3810dd1706948cc8788 Mon Sep 17 00:00:00 2001 From: Putnam Date: Thu, 6 Feb 2020 15:56:58 -0800 Subject: [PATCH 2/8] that's not how switch works... --- code/controllers/subsystem/ticker.dm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index f0c9e3499c..d73bde6763 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -480,12 +480,14 @@ SUBSYSTEM_DEF(ticker) switch(CONFIG_GET(string/map_vote_type)) if("PLURALITY") SSvote.initiate_vote("map","server",TRUE) - else if("APPROVAL") + if("APPROVAL") SSvote.initiate_vote("map","server",TRUE,votesystem = APPROVAL_VOTING) - else if("IRV") + if("IRV") SSvote.initiate_vote("map","server",TRUE,votesystem = INSTANT_RUNOFF_VOTING) - else if("SCORE") + if("SCORE") SSvote.initiate_vote("map","server",TRUE,votesystem = MAJORITY_JUDGEMENT_VOTING) + // fallback + SSvote.initiate_vote("map","server",TRUE) /datum/controller/subsystem/ticker/proc/HasRoundStarted() return current_state >= GAME_STATE_PLAYING From edcdb531cccf3fcd08e8dfd1399ab607627cdfe0 Mon Sep 17 00:00:00 2001 From: Putnam Date: Thu, 6 Feb 2020 15:57:42 -0800 Subject: [PATCH 3/8] kwargs --- code/controllers/subsystem/ticker.dm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index d73bde6763..716773b3b4 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -479,15 +479,15 @@ SUBSYSTEM_DEF(ticker) else switch(CONFIG_GET(string/map_vote_type)) if("PLURALITY") - SSvote.initiate_vote("map","server",TRUE) + SSvote.initiate_vote("map","server",hideresults=TRUE) if("APPROVAL") - SSvote.initiate_vote("map","server",TRUE,votesystem = APPROVAL_VOTING) + SSvote.initiate_vote("map","server",hideresults=TRUE,votesystem = APPROVAL_VOTING) if("IRV") - SSvote.initiate_vote("map","server",TRUE,votesystem = INSTANT_RUNOFF_VOTING) + SSvote.initiate_vote("map","server",hideresults=TRUE,votesystem = INSTANT_RUNOFF_VOTING) if("SCORE") - SSvote.initiate_vote("map","server",TRUE,votesystem = MAJORITY_JUDGEMENT_VOTING) + SSvote.initiate_vote("map","server",hideresults=TRUE,votesystem = MAJORITY_JUDGEMENT_VOTING) // fallback - SSvote.initiate_vote("map","server",TRUE) + SSvote.initiate_vote("map","server",hideresults=TRUE) /datum/controller/subsystem/ticker/proc/HasRoundStarted() return current_state >= GAME_STATE_PLAYING From 0ebd2a814fa26b67ee98c3a7b106c5d95716ba75 Mon Sep 17 00:00:00 2001 From: Putnam Date: Thu, 6 Feb 2020 16:11:14 -0800 Subject: [PATCH 4/8] fixed spurious divide-by-zero --- code/controllers/subsystem/vote.dm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 2a7c4401f3..0b80f6253a 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -201,7 +201,10 @@ SUBSYSTEM_DEF(vote) max_score=max(max_score,scores[score_name]) min_score=min(min_score,scores[score_name]) for(var/score_name in scores) - scores[score_name] = (scores[score_name]-min_score)/(max_score-min_score) + if(max_score == min_score) + scores[score_name] = 1 + else + scores[score_name] = (scores[score_name]-min_score)/(max_score-min_score) SSblackbox.record_feedback("nested tally","voting",scores[score_name],list(blackbox_text,"Total scores",score_name)) /datum/controller/subsystem/vote/proc/get_runoff_results(var/blackbox_text) From 7f0a3698700e76db72c502f1d70e7020fa47dc16 Mon Sep 17 00:00:00 2001 From: Putnam Date: Fri, 7 Feb 2020 04:29:53 -0800 Subject: [PATCH 5/8] Also added options for custom votes --- code/__DEFINES/vote.dm | 9 +++++++++ code/controllers/subsystem/vote.dm | 2 ++ 2 files changed, 11 insertions(+) diff --git a/code/__DEFINES/vote.dm b/code/__DEFINES/vote.dm index b83ea7b8f6..12e802383e 100644 --- a/code/__DEFINES/vote.dm +++ b/code/__DEFINES/vote.dm @@ -6,3 +6,12 @@ #define INSTANT_RUNOFF_VOTING 5 GLOBAL_LIST_INIT(vote_score_options,list("Bad","Poor","Acceptable","Good","Great")) + +GLOBAL_LIST_INIT(vote_type_names,list(\ +"Plurality (default)" = PLURALITY_VOTING,\ +"Approval" = APPROVAL_VOTING,\ +"IRV (single winner ranked choice)" = INSTANT_RUNOFF_VOTING,\ +"Schulze (ranked choice, higher result=better)" = SCHULZE_VOTING,\ +"Raw Score (returns results from 0 to 1, winner is 1)" = SCORE_VOTING,\ +"Majority Judgement (single-winner score voting)" = MAJORITY_JUDGEMENT_VOTING,\ +)) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 0b80f6253a..730f688723 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -487,6 +487,8 @@ SUBSYSTEM_DEF(vote) question = stripped_input(usr,"What is the vote for?") if(!question) return 0 + var/system_string = input(usr,"Which voting type?",GLOB.vote_type_names[1]) in GLOB.vote_type_names + vote_system = GLOB.vote_type_names[system_string] for(var/i=1,i<=10,i++) var/option = capitalize(stripped_input(usr,"Please enter an option or hit cancel to finish")) if(!option || mode || !usr.client) From 27efd5427485851c8a15792d33edd338d52a007f Mon Sep 17 00:00:00 2001 From: Putnam Date: Fri, 7 Feb 2020 04:38:39 -0800 Subject: [PATCH 6/8] why was that else there. why --- code/controllers/subsystem/vote.dm | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 730f688723..086167fc48 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -255,14 +255,13 @@ SUBSYSTEM_DEF(vote) text += "\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!" if(vote_system == MAJORITY_JUDGEMENT_VOTING) text += "\nIt should be noted that this is not a raw tally of votes but the number of runoffs done by majority judgement!" - else - for(var/i=1,i<=choices.len,i++) - var/votes = choices[choices[i]] - if(!votes) - votes = 0 - if(was_roundtype_vote) - stored_gamemode_votes[choices[i]] = votes - text += "\n[choices[i]]: [obfuscated ? "???" : votes]" //CIT CHANGE - adds obfuscated votes + for(var/i=1,i<=choices.len,i++) + var/votes = choices[choices[i]] + if(!votes) + votes = 0 + if(was_roundtype_vote) + stored_gamemode_votes[choices[i]] = votes + text += "\n[choices[i]]: [obfuscated ? "???" : votes]" //CIT CHANGE - adds obfuscated votes if(mode != "custom") if(winners.len > 1 && !obfuscated) //CIT CHANGE - adds obfuscated votes text = "\nVote Tied Between:" From 84a9f2f058ea5e6e45a0c68f00800b799f1f8e64 Mon Sep 17 00:00:00 2001 From: Putnam Date: Fri, 7 Feb 2020 19:54:15 -0800 Subject: [PATCH 7/8] make the fallback majority judgement --- 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 716773b3b4..998ae835a7 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -487,7 +487,7 @@ SUBSYSTEM_DEF(ticker) if("SCORE") SSvote.initiate_vote("map","server",hideresults=TRUE,votesystem = MAJORITY_JUDGEMENT_VOTING) // fallback - SSvote.initiate_vote("map","server",hideresults=TRUE) + SSvote.initiate_vote("map","server",hideresults=TRUE,votesystem = MAJORITY_JUDGEMENT_VOTING) /datum/controller/subsystem/ticker/proc/HasRoundStarted() return current_state >= GAME_STATE_PLAYING From c45dab8ebd33e9c96ef6ee6db113802f1abdbc8f Mon Sep 17 00:00:00 2001 From: Putnam Date: Fri, 7 Feb 2020 20:37:22 -0800 Subject: [PATCH 8/8] uhh? --- code/controllers/subsystem/ticker.dm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index 998ae835a7..748cdc1dbd 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -477,7 +477,8 @@ SUBSYSTEM_DEF(ticker) if(CONFIG_GET(flag/tgstyle_maprotation)) INVOKE_ASYNC(SSmapping, /datum/controller/subsystem/mapping/.proc/maprotate) else - switch(CONFIG_GET(string/map_vote_type)) + var/vote_type = CONFIG_GET(string/map_vote_type) + switch(vote_type) if("PLURALITY") SSvote.initiate_vote("map","server",hideresults=TRUE) if("APPROVAL")