/obj/machinery/computer/sentencing
name = "criminal sentencing console"
desc = "A console that allows registered security personnel to create incident reports for various on-station crimes. It produces an encrypted report that can be used to automatically set a brig timer."
icon_state = "computerw"
icon_screen = "securityw"
light_color = LIGHT_COLOR_ORANGE
req_one_access = list( access_brig, access_heads )
circuit = "/obj/item/circuitboard/sentencing"
density = 0
var/datum/crime_incident/incident
var/menu_screen = "main_menu"
var/datum/browser/menu = new( null, "crim_sentence", "Criminal Sentencing", 710, 725 )
var/console_tag
/obj/machinery/computer/sentencing/New()
..()
if( console_tag )
tag = console_tag
/obj/machinery/computer/sentencing/attack_hand(mob/user as mob)
if(..())
return
if(stat & (NOPOWER|BROKEN))
return
ui_interact(user)
/obj/machinery/computer/sentencing/attackby(obj/item/O as obj, user as mob)
if( istype( O, /obj/item/paper/incident ) && menu_screen == "import_incident" )
usr.drop_from_inventory(O,src)
if( import( O ))
ping( "\The [src] pings, \"Successfully imported incident report!\"" )
menu_screen = "incident_report"
else
to_chat(user, "Could not import incident report.")
qdel( O )
else if( istype( O, /obj/item/paper ) && menu_screen == "import_incident" )
to_chat(user, "This console only accepts authentic incident reports. Copies are invalid.")
..()
/obj/machinery/computer/sentencing/proc/import( var/obj/item/paper/incident/I )
incident = null
if( istype( I ) && I.incident )
incident = I.incident
return incident
/obj/machinery/computer/sentencing/ui_interact( mob/user as mob )
. = ""
switch( menu_screen )
if( "import_incident" )
. += import_incident()
if( "incident_report" )
. += incident_report()
/*if( "process_judiciary_report" )
. += process_judiciary_report()*/
if( "low_severity" )
. += add_charges()
if( "med_severity" )
. += add_charges()
if( "high_severity" )
. += add_charges()
else
. += main_menu()
menu.set_user( user )
menu.set_content( . )
menu.open()
onclose(user, "crim_sentence")
return
/obj/machinery/computer/sentencing/proc/main_menu()
. = "
Welcome! Please select an option!
"
. += "Import Incident New Report"
return .
/obj/machinery/computer/sentencing/proc/import_incident()
. = "Incident Import
"
. += "Insert an existing Securty Incident Report paper."
. += "
"
. += "Cancel"
return .
/obj/machinery/computer/sentencing/proc/incident_report()
. = ""
if( !istype( incident ))
. += "There was an error loading the incident, please Try Again"
return .
// Criminal and sentence
. += ""
. += "
"
. += list_witnesses()
. += list_evidence()
. += list_notes()
. += "
"
// Charges list
. += list_charges( 1 )
. += "
"
. += ""
. += "Render Guilty"
. += "Render Guilty - Fine"
. += ""
return .
/obj/machinery/computer/sentencing/proc/list_charges( var/buttons = 0 )
. += ""
. += ""
if( buttons )
. += "| Charges Add | "
else
. += "Charges | "
. += "
"
for( var/datum/law/L in incident.charges )
. += ""
. += "| [L.name] | "
. += "[L.desc] | "
if( buttons )
. += "Remove | "
. += "
"
. += "
"
/obj/machinery/computer/sentencing/proc/list_sentence()
. = ""
. += ""
. += "| Convict |
"
. += "| "
if( istype(incident.card) )
var/obj/item/card/id/card = incident.card.resolve()
. += "[card]"
else
. += "None"
. += " |
"
. += ""
. += "| Sentence | "
. += "
"
. += "| Brig | "
. += ""
if( incident.brig_sentence )
if( incident.brig_sentence < PERMABRIG_SENTENCE )
. += "[incident.brig_sentence] MINUTES"
else
. += "HOLDING UNTIL TRANSFER"
else
. += "None"
. += " | "
. += "
"
. += "
"
return .
/obj/machinery/computer/sentencing/proc/list_witnesses()
. = ""
var/list/witnesses = incident.arbiters["Witness"]
. += ""
. += ""
. += "| Witnesses Add | "
. += "
"
for( var/witness in witnesses )
. += ""
if( witnesses[witness] )
. += "| "
. += "[witness]: "
. += " | "
. += "[witnesses[witness]]"
else
. += " | "
. += "[witness]"
. += " | "
. += "Notes "
. += "Remove"
. += " |
"
. += "
"
return .
/obj/machinery/computer/sentencing/proc/list_evidence()
. = ""
var/list/evidence = incident.evidence
. += ""
. += ""
. += "| EvidenceAdd | "
. += "
"
for( var/item in evidence )
. += ""
if( evidence[item] )
. += "| "
. += "[item]: "
. += " | "
. += "[evidence[item]]"
else
. += " | "
. += "[item]"
. += " | "
. += "Notes "
. += "Remove"
. += " |
"
. += "
"
return .
/obj/machinery/computer/sentencing/proc/list_notes()
. = ""
// Incident notes table
. += ""
. += ""
. += "| Incident Summary Change | "
. += "
"
if( incident.notes )
. += ""
. += "| [incident.notes] | "
. += "
"
. += "
"
return .
/obj/machinery/computer/sentencing/proc/add_charges()
. = ""
if( !istype( incident ))
. += "There was an error loading the incident, please Try Again"
return .
if( !istype( SSlaw ))
. += "There was an error loading corporate regulations, please Try Again"
return .
. += charges_header()
. += "
"
switch( menu_screen )
if( "low_severity" )
. += get_law_table(SSlaw.low_severity, header="Misdemeanors")
if( "med_severity" )
. += get_law_table(SSlaw.med_severity, header="Indictable Offences")
if( "high_severity" )
. += get_law_table(SSlaw.high_severity, header="Capital Offences")
. += "
"
. += "Return"
/obj/machinery/computer/sentencing/proc/charges_header()
. = ""
if( menu_screen == "low_severity" )
. += "Low Severity"
else
. += "Low Severity"
. += " - "
if( menu_screen == "med_severity" )
. += "Medium Severity"
else
. += "Medium Severity"
. += " - "
if( menu_screen == "high_severity" )
. += "High Severity"
else
. += "High Severity"
. += " - Return"
. += ""
return .
/obj/machinery/computer/sentencing/proc/get_law_table(list/laws, header = "Misdemeanors")
. = ""
. += ""
. += ""
. += "| [header] | "
. += "
"
. += ""
. += "| Name | "
. += "Description | "
. += "Brig Sentence | "
. += "Fine | "
. += "Button | "
. += "
"
for(var/datum/law/L in laws)
. += ""
. += "| [L.name] | "
. += "[L.desc] | "
. += "[L.get_brig_time_string()] | "
. += "[L.get_fine_string()] | "
. += "Charge | "
. += "
"
. += "
"
return .
/obj/machinery/computer/sentencing/proc/render_innocent( var/mob/user )
var/obj/item/card/id/card = incident.card.resolve()
ping( "\The [src] pings, \"[card] has been found innocent of the accused crimes!\"" )
qdel( incident )
incident = null
menu_screen = "main_menu"
/obj/machinery/computer/sentencing/proc/render_guilty( var/mob/living/user )
if( !incident )
to_chat(user, "There is no active case!")
return
if( !istype( user ))
return
var/error = print_incident_report()
if( error )
to_chat(user, "[error]")
return
print_incident_overview(incident.renderGuilty(user, 0))
var/obj/item/card/id/card = incident.card.resolve()
if( incident.brig_sentence < PERMABRIG_SENTENCE)
ping( "\The [src] pings, \"[card.registered_name] has been found guilty of their crimes!\"" )
else
pingx3( "\The [src] pings, \"[card.registered_name] has been found guilty of their crimes and earned a HuT Sentence\"" )
incident = null
menu_screen = "main_menu"
/obj/machinery/computer/sentencing/proc/render_guilty_fine( var/mob/living/user )
if(!incident)
to_chat(user, "There is no active case!")
return
if(!istype(user))
return
if(incident.fine <= 0)
buzz("\The [src] buzzes, \"No fine has been entered!\"")
return
//Lets check if there is a felony amongst the crimes
for(var/datum/law/L in incident.charges)
if(L.felony)
buzz("\The [src] buzzes, \"The crimes are too severe to apply a fine!\"")
if(!L.can_fine())
buzz("\The [src] buzzes, \"It is not possible to fine for [L.name]\"")
return
//Try to resole the security account first
var/datum/money_account/security_account = SSeconomy.get_department_account("Security")
if(!security_account)
buzz("\The [src] buzzes, \"Could not get security account!\"")
return
var/obj/item/card/id/card = incident.card.resolve()
//Let´s get the account of the suspect and verify they have enough money
var/datum/money_account/suspect_account = SSeconomy.get_account(card.associated_account_number)
if(!suspect_account)
buzz("\The [src] buzzes, \"Could not get suspect account!\"")
return
if(suspect_account.money < incident.fine)
buzz("\The [src] buzzes, \"There is not enough money in the account to pay the fine!\"")
return
SSeconomy.charge_to_account(suspect_account.account_number,security_account.owner_name,"Incident: [incident.UID]","Sentencing Console",-incident.fine)
SSeconomy.charge_to_account(security_account.account_number,suspect_account.owner_name,"Incident: [incident.UID]Fine","Sentencing Console",incident.fine)
print_incident_overview(incident.renderGuilty(user,1))
ping("\The [src] pings, \"[card.registered_name] has been fined for their crimes!\"")
incident = null
menu_screen = "main_menu"
/obj/machinery/computer/sentencing/proc/print_incident_overview(var/text)
var/obj/item/paper/P = new /obj/item/paper
P.set_content_unsafe("Incident Summary",text)
print(P)
/obj/machinery/computer/sentencing/proc/print_incident_report( var/sentence = 1 )
var/error = incident.missingSentenceReq()
if( error )
return error
if( printing )
return "The machine is already printing something!"
var/obj/item/paper/incident/I = new /obj/item/paper/incident
I.incident = incident
I.sentence = sentence
I.name = "Encoded Incident Report"
print( I )
return 0
/obj/machinery/computer/sentencing/Topic(href, href_list)
if(..())
return
if(stat & (NOPOWER|BROKEN))
return 0 // don't update UIs attached to this object
usr.set_machine(src)
switch(href_list["button"])
if( "import_incident" )
menu_screen = "import_incident"
if( "new_incident" )
incident = new()
menu_screen = "incident_report"
if( "change_menu" )
menu_screen = href_list["choice"]
if( "change_criminal" )
var/obj/item/card/id/C = usr.get_active_hand()
if( istype( C ))
if( incident && C.mob )
incident.criminal = C.mob
incident.card = WEAKREF(C)
ping( "\The [src] pings, \"Convict [C] verified.\"" )
else if( incident.criminal )
ping( "\The [src] pings, \"Convict cleared.\"" )
incident.criminal = null
incident.card = null
if( "change_brig" )
if( !incident )
return
var/number = input( usr, "Enter a number between [incident.getMinBrigSentence()] and [incident.getMaxBrigSentence()] minutes", "Brig Sentence", 0) as num
if( number < incident.getMinBrigSentence() )
to_chat(usr, "The entered sentence was less than the minimum sentence!")
else if( number > incident.getMaxBrigSentence() )
to_chat(usr, "The entered sentence was greater than the maximum sentence!")
else
incident.brig_sentence = number
if( "change_fine" )
if( !incident )
return
var/number = input( usr, "Enter a number between [incident.getMinFine()] and [incident.getMaxFine()] credits", "Fine", 0) as num
if( number < incident.getMinFine() )
to_chat(usr, "The entered sentence was less than the minimum sentence!")
else if( number > incident.getMaxFine() )
to_chat(usr, "The entered sentence was greater than the maximum sentence!")
else
incident.fine = number
if( "print_encoded_form" )
var/error = print_incident_report( 0 )
if( error )
to_chat(usr, "[error]")
else
incident = null
menu_screen = "main_menu"
if( "add_arbiter" )
var/title = href_list["title"]
var/obj/item/card/id/C = usr.get_active_hand()
if( istype( C ))
if( incident && C.mob )
var/error = incident.addArbiter( C, title )
if( !error )
ping( "\The [src] pings, \"[title] [C.mob] verified.\"" )
else
to_chat(usr, "\The [src] buzzes, \"[error]\"")
else
ping( "\The [src] pings, \"[title] cleared.\"" )
incident.arbiters[title] = null
if( "add_evidence" )
var/obj/O = usr.get_active_hand()
if( istype( O ))
var/list/L = incident.evidence
L += O
incident.evidence = L
if( "add_charge" )
incident.charges += locate( href_list["law"] )
incident.refreshSentences()
ping( "\The [src] pings, \"Successfully added charge\"" )
if( "remove_charge" )
incident.charges -= locate( href_list["law"] )
incident.refreshSentences()
ping( "\The [src] pings, \"Successfully removed charge\"" )
if( "remove_witness" )
var/list/L = incident.arbiters["Witness"]
L -= locate( href_list["choice"] )
incident.arbiters["Witness"] = L
if( "remove_evidence" )
var/list/L = incident.evidence
L -= locate( href_list["choice"] )
incident.evidence = L
if( "add_witness_notes" )
var/list/L = incident.arbiters["Witness"]
var/W = locate( href_list["choice"] )
var/notes = sanitize( input( usr,"Summarize what the witness said:","Witness Report", html_decode( L[W] )) as message, MAX_PAPER_MESSAGE_LEN, extra = 0)
if( notes != null )
L[W] = notes
incident.arbiters["Witness"] = L
if( "add_evidence_notes" )
var/list/L = incident.evidence
var/E = locate( href_list["choice"] )
var/notes = sanitize( input( usr,"Describe the relevance of this evidence:","Evidence Report", html_decode( L[E] )) as message, MAX_PAPER_MESSAGE_LEN, extra = 0)
if( notes != null )
L[E] = notes
incident.evidence = L
if( "add_notes" )
if( !incident )
return
var/incident_notes = sanitize( input( usr,"Describe the incident here:","Incident Report", html_decode( incident.notes )) as message, MAX_PAPER_MESSAGE_LEN, extra = 0)
if( incident_notes != null )
incident.notes = incident_notes
if( "render_guilty" )
if( !incident )
return
if( !incident.notes )
if( alert("No incident notes were added. Adding a short description of the incident is highly recommended. Do you still want to continue with the print?",,"Yes","No") == "No" )
return
render_guilty( usr )
if( "render_guilty_fine" )
//Check for the notes
if( !incident.notes )
if( alert("No incident notes were added. Adding a short description of the incident is highly recommended. Do you still want to continue with the print?",,"Yes","No") == "No" )
return
//Get the ID Card
render_guilty_fine( usr )
add_fingerprint(usr)
updateUsrDialog()
/obj/machinery/computer/sentencing/courtroom
console_tag = "sentencing_courtroom"