Skip to content

Commit 55e68d1

Browse files
committed
minor fixes
1 parent 4cc3f5c commit 55e68d1

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

src/towns/population.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
# Population
22
All things related to the population are handled during the town's tick call.
33
The following subsections explain the identified functions.
4+
5+
The game uses the following enum to represent the 4 population types:
6+
```c
7+
enum population_type : __int32
8+
{
9+
pt_rich = 0x0,
10+
pt_wealthy = 0x1,
11+
pt_poor = 0x2,
12+
pt_beggar = 0x3,
13+
};
14+
```

src/towns/population/levels.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@ def __init__(
4242
dwellings_capacity_poor,
4343
]
4444

45-
def get_divisor(self, level):
46-
if level == 0:
47-
return 213 if self.has_mint else 320
48-
elif level == 1:
49-
return 160
50-
raise Exception()
51-
5245
def update_population_levels(self):
5346
self.update_population_level(0)
5447
self.update_population_level(1)
@@ -63,7 +56,7 @@ def update_population_level(self, level: int):
6356
LOGGER.debug(f"{level} target: {target} stock: {self.citizens[level]}")
6457
if target < self.citizens[level]:
6558
# Current stock exceeds target
66-
demoted = 2 * self.citizens[level] / target + 1
59+
demoted = 2 * self.citizens[level] // target + 1
6760
if demoted > self.citizens[level]:
6861
demoted = self.citizens[level] - 1
6962
self.citizens[2] += demoted
@@ -79,6 +72,13 @@ def update_population_level(self, level: int):
7972
self.citizens[2] -= promoted
8073
self.citizens[level] += promoted
8174

75+
def get_divisor(self, level):
76+
if level == 0:
77+
return 213 if self.has_mint else 320
78+
elif level == 1:
79+
return 160
80+
raise Exception()
81+
8282

8383
def plot_example1():
8484
plt.clf()

src/towns/population/levels1.png

-1.04 KB
Loading

0 commit comments

Comments
 (0)