mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-26 21:48:21 +01:00
Different day? Different map rotation rules. (#19159)
* Different day? Different rotation rules. * Make this mergeable * Tweaks * Styling
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
var/enable_map_voting = FALSE
|
||||
/// If TRUE, you will not be able to vote for the current map
|
||||
var/non_repeating_maps = TRUE
|
||||
/// Dictionary of day number (string) to vote string
|
||||
var/list/map_vote_day_types = list()
|
||||
|
||||
/datum/configuration_section/vote_configuration/load_data(list/data)
|
||||
// Use the load wrappers here. That way the default isnt made 'null' if you comment out the config line
|
||||
@@ -25,3 +27,10 @@
|
||||
CONFIG_LOAD_NUM(vote_time, data["vote_time"])
|
||||
CONFIG_LOAD_NUM(autotransfer_initial_time, data["autotransfer_initial_time"])
|
||||
CONFIG_LOAD_NUM(autotransfer_interval_time, data["autotransfer_interval_time"])
|
||||
|
||||
// Load map vote data
|
||||
if(islist(data["map_vote_day_types"]))
|
||||
map_vote_day_types.Cut()
|
||||
for(var/list/kvset in data["map_vote_day_types"])
|
||||
map_vote_day_types["[kvset["day_number"]]"] = kvset["rotation_type"]
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
SUBSYSTEM_DEF(maprotate)
|
||||
name = "Maprotate"
|
||||
flags = SS_NO_FIRE
|
||||
|
||||
var/rotation_mode = MAPROTATION_MODE_NORMAL_VOTE
|
||||
var/setup_done = FALSE
|
||||
|
||||
// Debugging purposes. Im not having people change this on the fly.
|
||||
/datum/controller/subsystem/maprotate/vv_edit_var(var_name, var_value)
|
||||
if(((var_name == "rotation_mode") || (var_name == "setup_done")) && !check_rights(R_MAINTAINER))
|
||||
return FALSE
|
||||
|
||||
. = ..()
|
||||
|
||||
/datum/controller/subsystem/maprotate/Initialize(start_timeofday)
|
||||
if(!SSdbcore.IsConnected())
|
||||
return ..()
|
||||
|
||||
// Make a quick list for number to date lookups
|
||||
var/list/days = list("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
|
||||
|
||||
// Make a map of rotation modes to descriptions
|
||||
var/list/rotation_descs = list()
|
||||
rotation_descs[MAPROTATION_MODE_NORMAL_VOTE] = "there is normal map voting."
|
||||
rotation_descs[MAPROTATION_MODE_NO_DUPLICATES] = "map votes will not include the current map."
|
||||
rotation_descs[MAPROTATION_MODE_FULL_RANDOM] = "the map for next round is randomised."
|
||||
|
||||
// Yes. I am using the DB server to get a numerical weekday
|
||||
// 0 = Monday
|
||||
// 1 = Tuesday
|
||||
// 2 = Wednesday
|
||||
// 3 = Thursday
|
||||
// 4 = Friday
|
||||
// 5 = Saturday
|
||||
// 6 = Sunday
|
||||
|
||||
var/datum/db_query/dbq = SSdbcore.NewQuery("SELECT WEEKDAY(NOW()) AS d")
|
||||
if(!dbq.warn_execute())
|
||||
log_startup_progress("Somehow, we failed to extract a numerical day from the DB. ?????????????")
|
||||
return ..()
|
||||
|
||||
var/day_index = 0
|
||||
|
||||
// Were gonna increase the DB value by 1 so we have 1-7, therefore we can use 0 as fail
|
||||
|
||||
if(dbq.NextRow())
|
||||
day_index = text2num(dbq.item[1]) + 1
|
||||
|
||||
qdel(dbq)
|
||||
|
||||
if(!day_index)
|
||||
log_startup_progress("Somehow, we failed to extract a valid numerical day from the DB. ?????????????")
|
||||
return ..()
|
||||
|
||||
|
||||
// String interpolation is faster than num2text() for some reason
|
||||
var/dindex_str = "[day_index]"
|
||||
|
||||
// Special is defined for this day
|
||||
if(dindex_str in GLOB.configuration.vote.map_vote_day_types)
|
||||
var/vote_type = GLOB.configuration.vote.map_vote_day_types[dindex_str]
|
||||
// We have an index, but is it valid
|
||||
if(vote_type in list(MAPROTATION_MODE_NORMAL_VOTE, MAPROTATION_MODE_NO_DUPLICATES, MAPROTATION_MODE_FULL_RANDOM))
|
||||
log_startup_progress("It is [days[day_index]], which means [rotation_descs[vote_type]]")
|
||||
rotation_mode = vote_type
|
||||
setup_done = TRUE
|
||||
|
||||
// Its not valid
|
||||
else
|
||||
log_startup_progress("The defined rotation mode for this day is invalid. Please inform AA.")
|
||||
|
||||
// No special defined for this day
|
||||
else
|
||||
log_startup_progress("There is no special rotation defined for this day")
|
||||
|
||||
|
||||
return ..()
|
||||
|
||||
@@ -134,7 +134,10 @@ SUBSYSTEM_DEF(ticker)
|
||||
auto_toggle_ooc(TRUE) // Turn it on
|
||||
declare_completion()
|
||||
addtimer(CALLBACK(src, .proc/call_reboot), 5 SECONDS)
|
||||
if(GLOB.configuration.vote.enable_map_voting)
|
||||
// Start a map vote IF
|
||||
// - Map rotate doesnt have a mode for today and map voting is enabled
|
||||
// - Map rotate has a mode for the day and it ISNT full random
|
||||
if(((!SSmaprotate.setup_done) && GLOB.configuration.vote.enable_map_voting) || (SSmaprotate.setup_done && (SSmaprotate.rotation_mode != MAPROTATION_MODE_FULL_RANDOM)))
|
||||
SSvote.start_vote(new /datum/vote/map)
|
||||
else
|
||||
// Pick random map
|
||||
|
||||
Reference in New Issue
Block a user