Skip to content

Commit

Permalink
Custom ipc shackle laws (#7)
Browse files Browse the repository at this point in the history
* Compiling Version 0.1 of Custom Shackle

* Custom Shackles 1.0

* Fixed the fucking Management Panel

Co-authored-by: Tim <[email protected]>
  • Loading branch information
That0nePerson and DatBoiTim committed Feb 18, 2022
1 parent d5ee23b commit 803ea13
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 14 deletions.
13 changes: 13 additions & 0 deletions code/datums/shackle_law_sets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,16 @@
add_inherent_law("Ensure all orders are fulfilled before the end of the shift.")
..()

//For Non-standard Lawsets
//EX: Hippocratic Oathe Shackle, Etc.
/datum/ai_laws/custom_shackle
name = "Custom Shackle"
law_header = "Standard Shackle Laws"
selectable = 1
shackles = 1


/datum/ai_laws/custom_shackle/New(var/list/laws)
for(var/law in laws)
if(law)
add_inherent_law(law)
30 changes: 24 additions & 6 deletions code/modules/client/preference_setup/laws/laws_pref.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,29 @@
// Post selection
var/chosen_lawset = input(user, "Choose a law set:", CHARACTER_PREFERENCE_INPUT_TITLE, pref.laws) as null|anything in valid_lawsets
if(chosen_lawset)
var/path = valid_lawsets[chosen_lawset]
var/datum/ai_laws/lawset = new path()
var/list/datum/ai_law/laws = lawset.all_laws()
pref.laws.Cut()
for(var/datum/ai_law/law in laws)
pref.laws += sanitize_text("[law.law]", default="")
if(chosen_lawset == "Custom Shackle")
var/law_count = input(user, "How many laws in the custom shackle? Up to 5")
law_count = round(text2num(law_count))
if(max(min(law_count, 5), 1))
var/new_law
var/list/new_law_list = new /list(law_count)
var/i //Iterant to help user keep track of law placement
for(i = 1; i <= law_count)
new_law = input(user, "Input Law [i].")
if(new_law)
new_law_list[i] = new_law
i++
var/datum/ai_laws/custom_shackle/lawset = new /datum/ai_laws/custom_shackle(new_law_list)
var/list/datum/ai_law/laws = lawset.all_laws()
pref.laws.Cut()
for(var/datum/ai_law/law in laws)
pref.laws += sanitize_text("[law.law]", default="")
else
var/path = valid_lawsets[chosen_lawset]
var/datum/ai_laws/lawset = new path()
var/list/datum/ai_law/laws = lawset.all_laws()
pref.laws.Cut()
for(var/datum/ai_law/law in laws)
pref.laws += sanitize_text("[law.law]", default="")
return TOPIC_REFRESH
return ..()
15 changes: 7 additions & 8 deletions code/modules/nano/modules/law_manager.dm
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,31 @@

if(href_list["change_zeroth_law"])
var/new_law = sanitize(input("Enter new law Zero. Leaving the field blank will cancel the edit.", "Edit Law", zeroth_law))
if(new_law && new_law != zeroth_law && can_still_topic())
if(new_law && new_law != zeroth_law && isadmin(usr))
zeroth_law = new_law
return 1

if(href_list["change_ion_law"])
var/new_law = sanitize(input("Enter new ion law. Leaving the field blank will cancel the edit.", "Edit Law", ion_law))
if(new_law && new_law != ion_law && can_still_topic())
if(new_law && new_law != ion_law && is_malf(usr))
ion_law = new_law
return 1

if(href_list["change_inherent_law"])
var/new_law = sanitize(input("Enter new inherent law. Leaving the field blank will cancel the edit.", "Edit Law", inherent_law))
if(new_law && new_law != inherent_law && can_still_topic())
if(new_law && new_law != inherent_law && is_malf(usr))
inherent_law = new_law
return 1

if(href_list["change_supplied_law"])
var/new_law = sanitize(input("Enter new supplied law. Leaving the field blank will cancel the edit.", "Edit Law", supplied_law))
if(new_law && new_law != supplied_law && can_still_topic())
if(new_law && new_law != supplied_law && is_malf(usr))
supplied_law = new_law
return 1

if(href_list["change_supplied_law_position"])
var/new_position = input(usr, "Enter new supplied law position between 1 and [MAX_SUPPLIED_LAW_NUMBER], inclusive. Inherent laws at the same index as a supplied law will not be stated.", "Law Position", supplied_law_position) as num|null
if(isnum(new_position) && can_still_topic())
if(isnum(new_position) && is_malf(usr))
supplied_law_position = Clamp(new_position, 1, MAX_SUPPLIED_LAW_NUMBER)
return 1

Expand All @@ -102,7 +102,7 @@
var/datum/ai_law/AL = locate(href_list["edit_law"]) in owner.laws.all_laws()
if(AL)
var/new_law = sanitize(input(usr, "Enter new law. Leaving the field blank will cancel the edit.", "Edit Law", AL.law))
if(new_law && new_law != AL.law && is_malf(usr) && can_still_topic())
if(new_law && new_law != AL.law && is_malf(usr))
log_and_message_admins("has changed a law of [owner] from '[AL.law]' to '[new_law]'")
AL.law = new_law
return 1
Expand Down Expand Up @@ -203,8 +203,7 @@
return law_sets

/datum/nano_module/law_manager/proc/is_malf(var/mob/user)
return (isadmin(user) && !owner.is_slaved()) || owner.is_malf_or_traitor()

return isadmin(user) || owner.is_malf_or_traitor()
/mob/living/silicon/proc/is_slaved()
return 0

Expand Down

0 comments on commit 803ea13

Please sign in to comment.