mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 03:02:54 +00:00
Conflict Resolution
This commit is contained in:
@@ -1,378 +1,3 @@
|
|||||||
<<<<<<< HEAD
|
|
||||||
SUBSYSTEM_DEF(vote)
|
|
||||||
|
|
||||||
name = "Vote"
|
|
||||||
|
|
||||||
wait = 10
|
|
||||||
|
|
||||||
priority = FIRE_PRIORITY_VOTE
|
|
||||||
|
|
||||||
runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT
|
|
||||||
|
|
||||||
flags = SS_KEEP_TIMING | SS_NO_INIT
|
|
||||||
|
|
||||||
var/list/round_voters = list()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Current vote
|
|
||||||
|
|
||||||
var/initiator
|
|
||||||
|
|
||||||
var/started_time
|
|
||||||
|
|
||||||
var/time_remaining
|
|
||||||
|
|
||||||
var/duration
|
|
||||||
|
|
||||||
var/mode
|
|
||||||
|
|
||||||
var/question
|
|
||||||
|
|
||||||
var/list/choices = list()
|
|
||||||
|
|
||||||
var/list/gamemode_names = list()
|
|
||||||
|
|
||||||
var/list/voted = list()
|
|
||||||
|
|
||||||
var/list/current_votes = list()
|
|
||||||
|
|
||||||
var/list/additional_text = list()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/datum/controller/subsystem/vote/fire(resumed)
|
|
||||||
|
|
||||||
if(mode)
|
|
||||||
|
|
||||||
time_remaining = round((started_time + duration - world.time)/10)
|
|
||||||
|
|
||||||
if(mode == VOTE_GAMEMODE && ticker.current_state >= GAME_STATE_SETTING_UP)
|
|
||||||
|
|
||||||
to_chat(world, "<b>Gamemode vote aborted: Game has already started.</b>")
|
|
||||||
|
|
||||||
reset()
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
if(time_remaining <= 0)
|
|
||||||
|
|
||||||
result()
|
|
||||||
|
|
||||||
reset()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/datum/controller/subsystem/vote/proc/autotransfer()
|
|
||||||
|
|
||||||
initiate_vote(VOTE_CREW_TRANSFER, "the server", 1)
|
|
||||||
|
|
||||||
log_debug("The server has called a crew transfer vote.")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/datum/controller/subsystem/vote/proc/autogamemode()
|
|
||||||
|
|
||||||
initiate_vote(VOTE_GAMEMODE, "the server", 1)
|
|
||||||
|
|
||||||
log_debug("The server has called a gamemode vote.")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/datum/controller/subsystem/vote/proc/reset()
|
|
||||||
|
|
||||||
initiator = null
|
|
||||||
|
|
||||||
started_time = null
|
|
||||||
|
|
||||||
duration = null
|
|
||||||
|
|
||||||
time_remaining = null
|
|
||||||
|
|
||||||
mode = null
|
|
||||||
|
|
||||||
question = null
|
|
||||||
|
|
||||||
choices.Cut()
|
|
||||||
|
|
||||||
voted.Cut()
|
|
||||||
|
|
||||||
current_votes.Cut()
|
|
||||||
|
|
||||||
additional_text.Cut()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/datum/controller/subsystem/vote/proc/get_result() // Get the highest number of votes
|
|
||||||
|
|
||||||
var/greatest_votes = 0
|
|
||||||
|
|
||||||
var/total_votes = 0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(var/option in choices)
|
|
||||||
|
|
||||||
var/votes = choices[option]
|
|
||||||
|
|
||||||
total_votes += votes
|
|
||||||
|
|
||||||
if(votes > greatest_votes)
|
|
||||||
|
|
||||||
greatest_votes = votes
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(!config.vote_no_default && choices.len) // Default-vote for everyone who didn't vote
|
|
||||||
|
|
||||||
var/non_voters = (GLOB.clients.len - total_votes)
|
|
||||||
|
|
||||||
if(non_voters > 0)
|
|
||||||
|
|
||||||
if(mode == VOTE_RESTART)
|
|
||||||
|
|
||||||
choices["Continue Playing"] += non_voters
|
|
||||||
|
|
||||||
if(choices["Continue Playing"] >= greatest_votes)
|
|
||||||
|
|
||||||
greatest_votes = choices["Continue Playing"]
|
|
||||||
|
|
||||||
else if(mode == VOTE_GAMEMODE)
|
|
||||||
|
|
||||||
if(master_mode in choices)
|
|
||||||
|
|
||||||
choices[master_mode] += non_voters
|
|
||||||
|
|
||||||
if(choices[master_mode] >= greatest_votes)
|
|
||||||
|
|
||||||
greatest_votes = choices[master_mode]
|
|
||||||
|
|
||||||
else if(mode == VOTE_CREW_TRANSFER)
|
|
||||||
|
|
||||||
var/factor = 0.5
|
|
||||||
|
|
||||||
switch(world.time / (10 * 60)) // minutes
|
|
||||||
|
|
||||||
if(0 to 60)
|
|
||||||
|
|
||||||
factor = 0.5
|
|
||||||
|
|
||||||
if(61 to 120)
|
|
||||||
|
|
||||||
factor = 0.8
|
|
||||||
|
|
||||||
if(121 to 240)
|
|
||||||
|
|
||||||
factor = 1
|
|
||||||
|
|
||||||
if(241 to 300)
|
|
||||||
|
|
||||||
factor = 1.2
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
factor = 1.4
|
|
||||||
|
|
||||||
choices["Initiate Crew Transfer"] = round(choices["Initiate Crew Transfer"] * factor)
|
|
||||||
|
|
||||||
world << "<font color='purple'>Crew Transfer Factor: [factor]</font>"
|
|
||||||
|
|
||||||
greatest_votes = max(choices["Initiate Crew Transfer"], choices["Continue The Round"])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
. = list() // Get all options with that many votes and return them in a list
|
|
||||||
|
|
||||||
if(greatest_votes)
|
|
||||||
|
|
||||||
for(var/option in choices)
|
|
||||||
|
|
||||||
if(choices[option] == greatest_votes)
|
|
||||||
|
|
||||||
. += option
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/datum/controller/subsystem/vote/proc/announce_result()
|
|
||||||
|
|
||||||
var/list/winners = get_result()
|
|
||||||
|
|
||||||
var/text
|
|
||||||
|
|
||||||
if(winners.len > 0)
|
|
||||||
|
|
||||||
if(winners.len > 1)
|
|
||||||
|
|
||||||
if(mode != VOTE_GAMEMODE || ticker.hide_mode == 0) // Here we are making sure we don't announce potential game modes
|
|
||||||
|
|
||||||
text = "<b>Vote Tied Between:</b>\n"
|
|
||||||
|
|
||||||
for(var/option in winners)
|
|
||||||
|
|
||||||
text += "\t[option]\n"
|
|
||||||
|
|
||||||
. = pick(winners)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(var/key in current_votes)
|
|
||||||
|
|
||||||
if(choices[current_votes[key]] == .)
|
|
||||||
|
|
||||||
round_voters += key // Keep track of who voted for the winning round.
|
|
||||||
|
|
||||||
if(mode != VOTE_GAMEMODE || . == "Extended" || ticker.hide_mode == 0) // Announce Extended gamemode, but not other gamemodes
|
|
||||||
|
|
||||||
text += "<b>Vote Result: [mode == VOTE_GAMEMODE ? gamemode_names[.] : .]</b>"
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
text += "<b>The vote has ended.</b>"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
text += "<b>Vote Result: Inconclusive - No Votes!</b>"
|
|
||||||
|
|
||||||
if(mode == VOTE_ADD_ANTAGONIST)
|
|
||||||
|
|
||||||
antag_add_failed = 1
|
|
||||||
|
|
||||||
log_vote(text)
|
|
||||||
|
|
||||||
to_chat(world, "<font color='purple'>[text]</font>")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/datum/controller/subsystem/vote/proc/result()
|
|
||||||
|
|
||||||
. = announce_result()
|
|
||||||
|
|
||||||
var/restart = 0
|
|
||||||
|
|
||||||
if(.)
|
|
||||||
|
|
||||||
switch(mode)
|
|
||||||
|
|
||||||
if(VOTE_RESTART)
|
|
||||||
|
|
||||||
if(. == "Restart Round")
|
|
||||||
|
|
||||||
restart = 1
|
|
||||||
|
|
||||||
if(VOTE_GAMEMODE)
|
|
||||||
|
|
||||||
if(master_mode != .)
|
|
||||||
|
|
||||||
world.save_mode(.)
|
|
||||||
|
|
||||||
if(ticker && ticker.mode)
|
|
||||||
|
|
||||||
restart = 1
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
master_mode = .
|
|
||||||
|
|
||||||
if(VOTE_CREW_TRANSFER)
|
|
||||||
|
|
||||||
if(. == "Initiate Crew Transfer")
|
|
||||||
|
|
||||||
init_shift_change(null, 1)
|
|
||||||
|
|
||||||
if(VOTE_ADD_ANTAGONIST)
|
|
||||||
|
|
||||||
if(isnull(.) || . == "None")
|
|
||||||
|
|
||||||
antag_add_failed = 1
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
additional_antag_types |= antag_names_to_ids[.]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(mode == VOTE_GAMEMODE) //fire this even if the vote fails.
|
|
||||||
|
|
||||||
if(!round_progressing)
|
|
||||||
|
|
||||||
round_progressing = 1
|
|
||||||
|
|
||||||
world << "<font color='red'><b>The round will start soon.</b></font>"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(restart)
|
|
||||||
|
|
||||||
world << "World restarting due to vote..."
|
|
||||||
|
|
||||||
feedback_set_details("end_error", "restart vote")
|
|
||||||
|
|
||||||
if(blackbox)
|
|
||||||
|
|
||||||
blackbox.save_all_data_to_sql()
|
|
||||||
|
|
||||||
sleep(50)
|
|
||||||
|
|
||||||
log_game("Rebooting due to restart vote")
|
|
||||||
|
|
||||||
world.Reboot()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/datum/controller/subsystem/vote/proc/submit_vote(ckey, newVote)
|
|
||||||
|
|
||||||
if(mode)
|
|
||||||
|
|
||||||
if(config.vote_no_dead && usr.stat == DEAD && !usr.client.holder)
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
if(current_votes[ckey])
|
|
||||||
|
|
||||||
choices[choices[current_votes[ckey]]]--
|
|
||||||
|
|
||||||
if(newVote && newVote >= 1 && newVote <= choices.len)
|
|
||||||
|
|
||||||
choices[choices[newVote]]++
|
|
||||||
|
|
||||||
current_votes[ckey] = newVote
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
current_votes[ckey] = null
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/datum/controller/subsystem/vote/proc/initiate_vote(vote_type, initiator_key, automatic = FALSE, time = config.vote_period)
|
|
||||||
|
|
||||||
if(!mode)
|
|
||||||
|
|
||||||
if(started_time != null && !(check_rights(R_ADMIN) || automatic))
|
|
||||||
|
|
||||||
var/next_allowed_time = (started_time + config.vote_delay)
|
|
||||||
|
|
||||||
if(next_allowed_time > world.time)
|
|
||||||
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
reset()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch(vote_type)
|
|
||||||
|
|
||||||
if(VOTE_RESTART)
|
|
||||||
|
|
||||||
choices.Add("Restart Round", "Continue Playing")
|
|
||||||
|
|
||||||
if(VOTE_GAMEMODE)
|
|
||||||
|
|
||||||
if(ticker.current_state >= GAME_STATE_SETTING_UP)
|
|
||||||
|
|
||||||
SUBSYSTEM_DEF(vote)
|
SUBSYSTEM_DEF(vote)
|
||||||
name = "Vote"
|
name = "Vote"
|
||||||
wait = 10
|
wait = 10
|
||||||
@@ -764,4 +389,3 @@ SUBSYSTEM_DEF(vote)
|
|||||||
|
|
||||||
if(SSvote)
|
if(SSvote)
|
||||||
src << browse(SSvote.interface(src), "window=vote;size=500x[300 + SSvote.choices.len * 25]")
|
src << browse(SSvote.interface(src), "window=vote;size=500x[300 + SSvote.choices.len * 25]")
|
||||||
var/list/current_votes = list()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user