From 803ea1313265cdf7a882336e51955640a07b689d Mon Sep 17 00:00:00 2001 From: That0nePerson <63219222+That0nePerson@users.noreply.github.com> Date: Fri, 18 Feb 2022 14:58:16 -0500 Subject: [PATCH] Custom ipc shackle laws (#7) * Compiling Version 0.1 of Custom Shackle * Custom Shackles 1.0 * Fixed the fucking Management Panel Co-authored-by: Tim --- code/datums/shackle_law_sets.dm | 13 ++++++++ .../client/preference_setup/laws/laws_pref.dm | 30 +++++++++++++++---- code/modules/nano/modules/law_manager.dm | 15 +++++----- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/code/datums/shackle_law_sets.dm b/code/datums/shackle_law_sets.dm index b802581b78f..4e12ac75737 100644 --- a/code/datums/shackle_law_sets.dm +++ b/code/datums/shackle_law_sets.dm @@ -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) diff --git a/code/modules/client/preference_setup/laws/laws_pref.dm b/code/modules/client/preference_setup/laws/laws_pref.dm index ed8f72108ae..cecab0df1a6 100644 --- a/code/modules/client/preference_setup/laws/laws_pref.dm +++ b/code/modules/client/preference_setup/laws/laws_pref.dm @@ -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 ..() diff --git a/code/modules/nano/modules/law_manager.dm b/code/modules/nano/modules/law_manager.dm index e146e6b5d04..fb54d793089 100644 --- a/code/modules/nano/modules/law_manager.dm +++ b/code/modules/nano/modules/law_manager.dm @@ -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 @@ -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 @@ -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