Merge pull request #10942 from Putnam3145/map-vote-options

Added a config for map voting types
This commit is contained in:
Ghom
2020-02-08 23:31:33 +01:00
committed by GitHub
5 changed files with 46 additions and 10 deletions
+9
View File
@@ -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,\
))
@@ -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
+12 -1
View File
@@ -477,7 +477,18 @@ 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)
var/vote_type = CONFIG_GET(string/map_vote_type)
switch(vote_type)
if("PLURALITY")
SSvote.initiate_vote("map","server",hideresults=TRUE)
if("APPROVAL")
SSvote.initiate_vote("map","server",hideresults=TRUE,votesystem = APPROVAL_VOTING)
if("IRV")
SSvote.initiate_vote("map","server",hideresults=TRUE,votesystem = INSTANT_RUNOFF_VOTING)
if("SCORE")
SSvote.initiate_vote("map","server",hideresults=TRUE,votesystem = MAJORITY_JUDGEMENT_VOTING)
// fallback
SSvote.initiate_vote("map","server",hideresults=TRUE,votesystem = MAJORITY_JUDGEMENT_VOTING)
/datum/controller/subsystem/ticker/proc/HasRoundStarted()
return current_state >= GAME_STATE_PLAYING
+13 -9
View File
@@ -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)
@@ -252,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<b>[choices[i]]:</b> [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<b>[choices[i]]:</b> [obfuscated ? "???" : votes]" //CIT CHANGE - adds obfuscated votes
if(mode != "custom")
if(winners.len > 1 && !obfuscated) //CIT CHANGE - adds obfuscated votes
text = "\n<b>Vote Tied Between:</b>"
@@ -484,6 +486,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)
+9
View File
@@ -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)