Dynamic configuration file.

Signed-off-by: TheChosenEvilOne <tceo-email@protonmail.com>
This commit is contained in:
TheChosenEvilOne
2019-08-25 19:22:18 +03:00
parent 2aa0a3ea63
commit ab78f63ddf
7 changed files with 64 additions and 3 deletions
@@ -378,3 +378,8 @@
/datum/config_entry/number/monkeycap
config_entry_value = 64
min_val = 0
/datum/config_entry/flag/dynamic_config_enabled
/datum/config_entry/string/dynamic_config_file
config_entry_value = "config/dynamic.json"
+17
View File
@@ -107,6 +107,8 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
var/highlander_executed = FALSE
/// If a only ruleset has been executed.
var/only_ruleset_executed = FALSE
/// Dynamic configuration, loaded on pre_setup
var/list/configuration = null
/datum/game_mode/dynamic/admin_panel()
var/list/dat = list("<html><head><title>Game Mode Panel</title></head><body><h1><B>Game Mode Panel</B></h1>")
@@ -287,6 +289,10 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
return TRUE
/datum/game_mode/dynamic/pre_setup()
if(CONFIG_GET(flag/dynamic_config_enabled))
var/json_file = file(CONFIG_GET(string/dynamic_config_file))
if(fexists(json_file))
configuration = json_decode(file2text(json_file))
for (var/rule in subtypesof(/datum/dynamic_ruleset))
var/datum/dynamic_ruleset/ruleset = new rule()
// Simple check if the ruleset should be added to the lists.
@@ -300,6 +306,17 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
if ("Midround")
if (ruleset.weight)
midround_rules += ruleset
if(configuration)
if(!configuration[ruleset.ruletype])
continue
if(!configuration[ruleset.ruletype][ruleset.name])
continue
var/rule_conf = configuration[ruleset.ruletype][ruleset.name]
for(var/variable in rule_conf)
if(!ruleset.vars[variable])
stack_trace("Invalid dynamic configuration variable [variable] in [ruleset.ruletype] [ruleset.name]")
ruleset.vars[variable] = rule_conf[variable]
for(var/mob/dead/new_player/player in GLOB.player_list)
if(player.ready == PLAYER_READY_TO_PLAY && player.mind)
roundstart_pop_ready++
@@ -168,7 +168,7 @@
candidates.Remove(P)
continue
else
if(!antag_flag in P.client.prefs.be_special || is_banned_from(P.ckey, list(antag_flag, ROLE_SYNDICATE)))
if(!(antag_flag in P.client.prefs.be_special) || is_banned_from(P.ckey, list(antag_flag, ROLE_SYNDICATE)))
candidates.Remove(P)
continue
@@ -17,7 +17,7 @@
candidates.Remove(P)
continue
else
if(!antag_flag in P.client.prefs.be_special || is_banned_from(P.ckey, list(antag_flag, ROLE_SYNDICATE)))
if(!(antag_flag in P.client.prefs.be_special) || is_banned_from(P.ckey, list(antag_flag, ROLE_SYNDICATE)))
candidates.Remove(P)
continue
if (P.mind.assigned_role in restricted_roles) // Does their job allow for it?
@@ -44,7 +44,7 @@
candidates.Remove(M)
continue
else
if(!antag_flag in M.client.prefs.be_special || is_banned_from(M.ckey, list(antag_flag, ROLE_SYNDICATE)))
if(!(antag_flag in M.client.prefs.be_special) || is_banned_from(M.ckey, list(antag_flag, ROLE_SYNDICATE)))
candidates.Remove(M)
continue
if (M.mind)
+36
View File
@@ -0,0 +1,36 @@
{
"Roundstart": {
"Traitors": {
"cost": 10,
"weight": 5,
"required_candidates": 1,
"high_population_requirement": 10,
"minimum_required_aged": 0,
"requirements": [
10,
10,
10,
10,
10,
10,
10,
10,
10,
10
],
"protected_roles": [
"Security Officer",
"Warden",
"Detective",
"Head of Security",
"Captain"
],
"restricted_roles": [
"Cyborg"
],
"autotraitor_cooldown": 450
}
},
"Midround": {},
"Latejoin": {}
}
+3
View File
@@ -254,6 +254,9 @@ MAX_TICKETS_PER_ROLL 100
## Uncomment to allow players to see the set odds of different rounds in secret/random in the get server revision screen. This will NOT tell the current roundtype.
#SHOW_GAME_TYPE_ODDS
DYNAMIC_CONFIG_ENABLED
DYNAMIC_CONFIG_FILE "config/dynamic.json"
## RANDOM EVENTS ###
## Comment this out to disable random events during the round.
ALLOW_RANDOM_EVENTS