Skip to content

Commit 7e82483

Browse files
committed
Excess Consumption
1 parent db8f867 commit 7e82483

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
- [Sailors](./towns/tavern/sailors.md)
4242
- [Money Lender](./towns/money-lender.md)
4343
- [Bath House](./towns/bath-house.md)
44+
- [Excess Consumption](./towns/excess_consumption.md)
4445
- [Sieges](./towns/sieges.md)
4546
- [Initialization](./towns/sieges/initialization.md)
4647
- [Merchants](./ch05-00-merchants.md)

src/towns/excess_consumption.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Excess Consumption
2+
The `town_excess_consumption` function at `0x00528630` reduces excess wares which cannot be produced in the town.
3+
It is called in `town_tick` if the town is not under siege.
4+
5+
## Calculation
6+
```python
7+
def calculate_excess_consumption(
8+
daily_production: int,
9+
daily_consumption_citizens: int,
10+
daily_consumption_businesses: int,
11+
current_amount: int,
12+
t1: int,
13+
t3: int,
14+
) -> int:
15+
if daily_production:
16+
return 0
17+
if current_amount <= t1:
18+
return 0
19+
20+
above_t1 = current_amount - t1
21+
consumption = daily_consumption_citizens + daily_consumption_businesses
22+
removed_amount = above_t1
23+
* 16
24+
* consumption
25+
// 10
26+
// t3
27+
28+
return min(removed_amount, above_t1)
29+
```

0 commit comments

Comments
 (0)