-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed commute-sentence to justice with command option pardon
- Loading branch information
1 parent
978aa41
commit d1081ea
Showing
4 changed files
with
65 additions
and
35 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
justice | ||
======= | ||
|
||
.. dfhack-tool:: | ||
:summary: Commands related to the justice system | ||
:tags: fort armok units | ||
|
||
This tool allows control over aspects of the justice system, such as the | ||
ability to pardon criminals. | ||
|
||
usage | ||
----- | ||
|
||
:: | ||
justice pardon [--unit <id>] | ||
|
||
Pardon the selected unit or the one specified by unit id if provided. Currently | ||
only applies to prison time and doesn't cancel beatings or hammerings. | ||
|
||
|
||
options | ||
------- | ||
|
||
``-u``, ``--unit <id>`` | ||
Specifies the unit id of the target of the command. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
local argparse = require('argparse') | ||
|
||
local function pardon_unit(unit) | ||
for _,punishment in ipairs(df.global.plotinfo.punishments) do | ||
if punishment.criminal == unit.id then | ||
punishment.prison_counter = 0 | ||
return | ||
end | ||
end | ||
qerror('Unit is not currently serving a sentence!') | ||
end | ||
|
||
local function command_pardon(unit_id) | ||
local unit = nil | ||
if not unit_id then | ||
unit = dfhack.gui.getSelectedUnit() | ||
if not unit then qerror("No unit selected!") end | ||
else | ||
unit = df.unit.find(unit_id) | ||
if not unit then qerror(("No unit with id %i"):format(unit_id)) end | ||
end | ||
if unit then pardon_unit(unit) end | ||
end | ||
|
||
local unit_id = nil | ||
|
||
local args = {...} | ||
|
||
local positionals = argparse.processArgsGetopt(args, | ||
{'u', 'unit', hasArg=true, handler=function(optarg) unit_id = optarg end} | ||
) | ||
|
||
local command = positionals[1] | ||
|
||
if command == "pardon" then | ||
command_pardon(unit_id) | ||
end | ||
|
||
qerror(("Unrecognised command: %s"):format(command)) |