Skip to content

Commit db493a2

Browse files
authored
Merge pull request #1429 from quietust/master
Fix logic for calculating petition age
2 parents 139ee17 + e7f1db0 commit db493a2

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Template for new versions:
3131
## New Features
3232

3333
## Fixes
34+
- `list-agreements`: fix logic for determining age of active petitions
3435

3536
## Misc Improvements
3637
- `fix/loyaltycascade`: now also breaks up brawls and other intra-fort conflicts that *look* like loyalty cascades

list-agreements.lua

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,14 @@ function get_petition_age(agr)
3535
local agr_year = agr.details[0].year
3636
local cur_year_tick = df.global.cur_year_tick
3737
local cur_year = df.global.cur_year
38-
local del_year, del_year_tick
39-
--delta, check to prevent off by 1 error, not validated
40-
if cur_year_tick > agr_year_tick then
41-
del_year = cur_year - agr_year
42-
del_year_tick = cur_year_tick - agr_year_tick
43-
else
44-
del_year = cur_year - agr_year - 1
45-
del_year_tick = agr_year_tick - cur_year_tick
38+
local del_year = cur_year - agr_year
39+
local del_year_tick = cur_year_tick - agr_year_tick
40+
if del_year_tick < 0 then
41+
del_year = del_year - 1
42+
del_year_tick = del_year_tick + 403200
4643
end
47-
local julian_day = math.floor(del_year_tick / 1200) + 1
44+
-- Round up to the nearest day, since we don't do fractions
45+
local julian_day = math.ceil(del_year_tick / 1200)
4846
local del_month = math.floor(julian_day / 28)
4947
local del_day = julian_day % 28
5048
return {del_year,del_month,del_day}

0 commit comments

Comments
 (0)