Skip to content

Commit 7b85a77

Browse files
committed
changed commute-sentence to justice with command option pardon
1 parent 978aa41 commit 7b85a77

4 files changed

Lines changed: 65 additions & 35 deletions

File tree

commute-sentence.lua

Lines changed: 0 additions & 19 deletions
This file was deleted.

docs/commute-sentence.rst

Lines changed: 0 additions & 16 deletions
This file was deleted.

docs/justice.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
justice
2+
=======
3+
4+
.. dfhack-tool::
5+
:summary: Commands related to the justice system
6+
:tags: fort armok units
7+
8+
This tool allows control over aspects of the justice system, such as the
9+
ability to pardon criminals.
10+
11+
usage
12+
-----
13+
14+
::
15+
justice pardon [--unit <id>]
16+
17+
Pardon the selected unit or the one specified by unit id if provided. Currently
18+
only applies to prison time and doesn't cancel beatings or hammerings.
19+
20+
21+
options
22+
-------
23+
24+
``-u``, ``--unit <id>``
25+
Specifies the unit id of the target of the command.

justice.lua

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
local argparse = require('argparse')
3+
4+
local function pardon_unit(unit)
5+
for _,punishment in ipairs(df.global.plotinfo.punishments) do
6+
if punishment.criminal == unit.id then
7+
punishment.prison_counter = 0
8+
return
9+
end
10+
end
11+
qerror('Unit is not currently serving a sentence!')
12+
end
13+
14+
local function command_pardon(unit_id)
15+
local unit = nil
16+
if not unit_id then
17+
unit = dfhack.gui.getSelectedUnit()
18+
if not unit then qerror("No unit selected!") end
19+
else
20+
unit = df.unit.find(unit_id)
21+
if not unit then qerror(("No unit with id %i"):format(unit_id)) end
22+
end
23+
if unit then pardon_unit(unit) end
24+
end
25+
26+
local unit_id = nil
27+
28+
local args = {...}
29+
30+
local positionals = argparse.processArgsGetopt(args,
31+
{'u', 'unit', hasArg=true, handler=function(optarg) unit_id = optarg end}
32+
)
33+
34+
local command = positionals[1]
35+
36+
if command == "pardon" then
37+
command_pardon(unit_id)
38+
end
39+
40+
qerror(("Unrecognised command: %s"):format(command))

0 commit comments

Comments
 (0)