Skip to content

Commit

Permalink
Upgrades policy config + policy verb. (#44296)
Browse files Browse the repository at this point in the history
* Upgrades policy config + policy verb.

* Better example and proper default value.

* hr on top

* Cleanup
  • Loading branch information
AnturK authored and ExcessiveUseOfCobblestone committed Jun 10, 2019
1 parent c9afd3e commit 69ac935
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 11 deletions.
6 changes: 5 additions & 1 deletion code/__DEFINES/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,8 @@
#define SPAM_TRIGGER_AUTOMUTE 10 //Number of identical messages required before the spam-prevention will automute you

#define STICKYBAN_DB_CACHE_TIME 10 SECONDS
#define STICKYBAN_ROGUE_CHECK_TIME 5
#define STICKYBAN_ROGUE_CHECK_TIME 5


#define POLICY_POLYMORPH "polymorph" //Shown to vicitm of staff of change and related effects.
#define POLICY_VERB_HEADER "policy_verb_header" //Shown on top of policy verb window
2 changes: 2 additions & 0 deletions code/__HELPERS/config.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/proc/get_policy(keyword)
return global.config.policy[keyword]
30 changes: 30 additions & 0 deletions code/controllers/configuration/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
var/list/mode_false_report_weight

var/motd
var/policy

/datum/controller/configuration/proc/admin_reload()
if(IsAdminAdvancedProcCall())
Expand Down Expand Up @@ -47,6 +48,7 @@
break
loadmaplist(CONFIG_MAPS_FILE)
LoadMOTD()
LoadPolicy()

/datum/controller/configuration/proc/full_wipe()
if(IsAdminAdvancedProcCall())
Expand Down Expand Up @@ -243,6 +245,34 @@
var/tm_info = GLOB.revdata.GetTestMergeInfo()
if(motd || tm_info)
motd = motd ? "[motd]<br>[tm_info]" : tm_info
/*
Policy file should be a json file with a single object.
Value is raw html.
Possible keywords :
Job titles / Assigned roles (ghost spawners for example) : Assistant , Captain , Ash Walker
Mob types : /mob/living/simple_animal/hostile/carp
Antagonist types : /datum/antagonist/highlander
Species types : /datum/species/lizard
special keywords defined in _DEFINES/admin.dm
Example config:
{
"Assistant" : "Don't kill everyone",
"/datum/antagonist/highlander" : "<b>Kill everyone</b>",
"Ash Walker" : "Kill all spacemans"
}
*/
/datum/controller/configuration/proc/LoadPolicy()
policy = list()
var/rawpolicy = file2text("[directory]/policy.json")
if(rawpolicy)
var/parsed = json_decode(rawpolicy)
if(!parsed)
log_config("JSON parsing failure for policy.json")
else
policy = parsed

/datum/controller/configuration/proc/loadmaplist(filename)
log_config("Loading config file [filename]...")
Expand Down
4 changes: 0 additions & 4 deletions code/controllers/configuration/entries/game_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
/datum/config_entry/keyed_list/midround_antag/ValidateListEntry(key_name, key_value)
return key_name in config.modes

/datum/config_entry/keyed_list/policy
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_TEXT

/datum/config_entry/number/damage_multiplier
config_entry_value = 1
integer = FALSE
Expand Down
22 changes: 22 additions & 0 deletions code/modules/client/verbs/ooc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,25 @@ GLOBAL_VAR_INIT(normal_ooc_colour, "#002eb8")

pct += delta
winset(src, "mainwindow.split", "splitter=[pct]")


/client/verb/policy()
set name = "Show Policy"
set desc = "Show special server rules related to your current character."
set category = "OOC"

//Collect keywords
var/list/keywords = mob.get_policy_keywords()
var/header = get_policy(POLICY_VERB_HEADER)
var/list/policytext = list(header,"<hr>")
var/anything = FALSE
for(var/keyword in keywords)
var/p = get_policy(keyword)
if(p)
policytext += p
policytext += "<hr>"
anything = TRUE
if(!anything)
policytext += "No related rules found."

usr << browse(policytext.Join(""),"window=policy")
4 changes: 4 additions & 0 deletions code/modules/mob/living/carbon/human/human_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,7 @@
return account

return FALSE

/mob/living/carbon/human/get_policy_keywords()
. = ..()
. += "[dna.species.type]"
9 changes: 9 additions & 0 deletions code/modules/mob/mob_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,12 @@ It's fairly easy to fix if dealing with single letters but not so much with comp

if(HAS_TRAIT(src, TRAIT_DISSECTED))
. += "<span class='notice'>This body has been dissected and analyzed. It is no longer worth experimenting on.</span><br>"

/mob/proc/get_policy_keywords()
. = list()
. += "[type]"
if(mind)
. += mind.assigned_role
. += mind.special_role //In case there's something special leftover, try to avoid
for(var/datum/antagonist/A in mind.antag_datums)
. += "[A.type]"
2 changes: 1 addition & 1 deletion code/modules/projectiles/projectile/magic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@

to_chat(new_mob, "<span class='warning'>Your form morphs into that of a [randomize].</span>")

var/poly_msg = CONFIG_GET(keyed_list/policy)["polymorph"]
var/poly_msg = get_policy(POLICY_POLYMORPH)
if(poly_msg)
to_chat(new_mob, poly_msg)

Expand Down
5 changes: 0 additions & 5 deletions config/policies.txt

This file was deleted.

1 change: 1 addition & 0 deletions config/policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
#include "code\__HELPERS\areas.dm"
#include "code\__HELPERS\AStar.dm"
#include "code\__HELPERS\cmp.dm"
#include "code\__HELPERS\config.dm"
#include "code\__HELPERS\dates.dm"
#include "code\__HELPERS\dna.dm"
#include "code\__HELPERS\files.dm"
Expand Down

0 comments on commit 69ac935

Please sign in to comment.