Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Station Police view has tabs: 1. crime records, + new: 2. rules & regulations #5863

Merged
merged 4 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions data/lang/ui-core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,17 @@
"description": "",
"message": "Crew Roster"
},
"CRIME": {
"description": "Heading introducing a single crime name or list of crime names",
"message": "Crime"
},
"CRIMINAL": {
"description": "Legal status of player",
"message": "Criminal"
},
"CRIMINAL_RECORD": {
"description": "Past crimes / crime history of character",
"message": "Criminal record"
"description": "Heading for past crimes / crime history of character, proper noun",
"message": "Criminal Record"
},
"CURRENT_FUEL": {
"description": "For hyperjump planner",
Expand Down Expand Up @@ -639,6 +643,10 @@
"description": "Financial statement of player, e.g. cash",
"message": "Finance"
},
"FINE": {
"description": "Cost of a criminal action",
"message": "Fine"
},
"FLIGHTLOG_DOCKING": {
"description": "Used in Flight Log, to indicate player's position. 'primary_info' is a station name",
"message": "Docking at {primary_info}"
Expand Down Expand Up @@ -1207,6 +1215,10 @@
"description": "An illegal action or commodity",
"message": "Illegal in System"
},
"ILLEGAL_COMMODITIES": {
"description": "Commodities illegal in the current system or polity",
"message": "Illegal Commodities"
},
"ILLEGAL_JUMP": {
"description": "A finable crime",
"message": "Reckless hyperjump registered"
Expand Down Expand Up @@ -1331,6 +1343,14 @@
"description": "",
"message": "Legal status"
},
"LEGAL_RULES": {
"description": "Refers to laws, rules and regulations",
"message": "Legal rules applicable in station controlled space. Laws are sensor enforced within a distance of: {distance}"
},
"LEGAL_RULES_AND_REGULATIONS": {
"description": "Heading on a tab, keep it short",
"message": "Rules and Regulations"
},
"LIGHT_CARGO_SHUTTLE": {
"description": "",
"message": "Light cargo shuttle"
Expand Down Expand Up @@ -1733,7 +1753,7 @@
},
"OUTSTANDING_FINES": {
"description": "Unpaid fines for crimes committed",
"message": "Outstanding fines"
"message": "Outstanding Fines"
},
"OUT_OF_RANGE": {
"description": "Ship jump status",
Expand Down Expand Up @@ -1843,6 +1863,10 @@
"description": "Player combat rating",
"message": "Poor"
},
"POSESSION_OF_COMMODITIES_ILLEGAL": {
"description": "",
"message": "Possession of certain commodities is illegal in this system."
},
"POSITION": {
"description": "The job title/position of crew memeber",
"message": "Position"
Expand Down Expand Up @@ -2307,6 +2331,10 @@
"description": "Message when restoring savegame",
"message": "There were errors in recovery:"
},
"THESE_ITEMS_ARE_PUNISHABLE_BY_FINE": {
"description": "",
"message": "Purchase, sale, and transportation of these items is punishable by a fine and possible confiscation"
},
"THE_SHIP_IS_UNDER_STATION_CONTROL_COMMANDER": {
"description": "",
"message": "The ship is under station control, Commander."
Expand Down
7 changes: 6 additions & 1 deletion data/libs/Legal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ Legal.CrimeType["TRADING_ILLEGAL_GOODS"] = {basefine = 5e3, name = l.TRADING_ILL
Legal.CrimeType["WEAPONS_DISCHARGE"] = {basefine = 5e2, name = l.UNLAWFUL_WEAPONS_DISCHARGE}
Legal.CrimeType["CONTRACT_FRAUD"] = {basefine = 5e2, name = l.CONTRACT_FRAUD}


function Legal:fine (crime, lawlessness)
return math.max(1, 1+math.floor(self.CrimeType[crime].basefine * (1.0-lawlessness)))
end

function Legal:notifyOfCrime (ship, crime)
if not ship:IsPlayer() then return end
-- TODO: can this be called in hyperpace?
Expand All @@ -63,7 +68,7 @@ function Legal:notifyOfCrime (ship, crime)

local lawlessness = Game.system.lawlessness
local _, outstandingfines = Game.player:GetCrimeOutstanding()
local newFine = math.max(1, 1+math.floor(self.CrimeType[crime].basefine * (1.0-lawlessness)))
local newFine = self:fine(crime, lawlessness)

-- don't keep compounding fines, except for murder
if crime ~= "MURDER" and newFine < outstandingfines then newFine = 0 end
Expand Down
133 changes: 67 additions & 66 deletions data/libs/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ local utils = {}
-- > for i, v in numbered_keys(pairs(table)) do ... end
--
function utils.numbered_keys(step, context, position)
local k = position
local f = function(s, i)
local v
k,v = step(s, k)
if k ~= nil then
return (i+1), v
local k = position
local f = function(s, i)
local v
k,v = step(s, k)
if k ~= nil then
return (i+1), v
end
end
end
return f, context, 0
return f, context, 0
end

--
Expand All @@ -40,12 +40,12 @@ end
-- > for k,v in filter(function (k,v) ... return true end, pairs(table))
--
function utils.filter(predicate, step, context, position)
local f = function (s, k)
local v
repeat k,v = step(s,k); until (k == nil) or predicate(k,v)
return k,v
end
return f, context, position
local f = function (s, k)
local v
repeat k,v = step(s,k); until (k == nil) or predicate(k,v)
return k,v
end
return f, context, position
end

--
Expand All @@ -57,14 +57,15 @@ end
-- > for k,v in map(function (k,v) ... return newk, newv end, pairs(table))
--
function utils.map(transformer, step, context, position)
local f = function (s, k)
local v
k, v = step(s, k)
if k ~= nil then
return transformer(k,v)
-- fully wrap the iterator so that transformed keys don't feed back into the step function
local f = function ()
local v
position, v = step(context, position)
if position ~= nil then
return transformer(position, v)
end
end
end
return f, context, position
return f, context, position
end

--
Expand All @@ -76,14 +77,14 @@ end
-- > array = build_array(pairs(table))
--
function utils.build_array(f, s, k)
local v
local t = {}
while true do
local v
local t = {}
while true do
k, v = f(s, k)
if k == nil then break end
table.insert(t, v)
end
return t
end
return t
end

--
Expand All @@ -95,14 +96,14 @@ end
-- > filtered = build_table(filter(function () ... end, pairs(table)))
--
function utils.build_table(f, s, k)
local v
local t = {}
while true do
local v
local t = {}
while true do
k, v = f(s, k)
if k == nil then break end
t[k] = v
end
return t
end
return t
end

--
Expand Down Expand Up @@ -246,47 +247,47 @@ function utils.stable_sort(values, cmp)
end

local split = function (values)
local a = {}
local b = {}
local len = #values
local mid = math.floor(len/2)
for i = 1, mid do
a[i] = values[i]
end
for i = mid+1, len do
b[i-mid] = values[i]
end
return a,b
local a = {}
local b = {}
local len = #values
local mid = math.floor(len/2)
for i = 1, mid do
a[i] = values[i]
end
for i = mid+1, len do
b[i-mid] = values[i]
end
return a,b
end

local merge = function (a,b)
local result = {}
local a_len = #(a)
local b_len = #(b)
local i1 = 1
local i2 = 1
for j = 1, a_len+b_len do
if i2 > b_len
or (i1 <= a_len and cmp(a[i1], b[i2]))
then
result[j] = a[i1]
i1 = i1 + 1
else
result[j] = b[i2]
i2 = i2 + 1
end
end
return result
local result = {}
local a_len = #(a)
local b_len = #(b)
local i1 = 1
local i2 = 1
for j = 1, a_len+b_len do
if i2 > b_len
or (i1 <= a_len and cmp(a[i1], b[i2]))
then
result[j] = a[i1]
i1 = i1 + 1
else
result[j] = b[i2]
i2 = i2 + 1
end
end
return result
end

local function merge_sort (values)
if #values > 1 then
local a, b = split(values)
a = merge_sort(a)
b = merge_sort(b)
values = merge(a, b)
end
return values
if #values > 1 then
local a, b = split(values)
a = merge_sort(a)
b = merge_sort(b)
values = merge(a, b)
end
return values
end

return merge_sort(values)
Expand Down
Loading