Skip to content

Commit 56d3729

Browse files
making region index instead
1 parent ae67bdb commit 56d3729

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ classifiers = [
2222
keywords=['helldivers2','api']
2323
requires-python = ">=3.8.1"
2424

25-
version = '0.0.1.20.15'
25+
version = '0.0.1.20.16'
2626
dependencies= [
2727
"pydantic>=2.9.2",
2828
"httpx>=0.27.2"

src/hd2api/models/Planet.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ def __sub__(self, other: "Planet") -> "Planet":
164164
new_regions = None
165165
if self.regions is not None and other.regions is not None:
166166
new_regions = []
167-
other_regions_dict = {region.id: region for region in other.regions}
167+
other_regions_dict = {region.regionIndex: region for region in other.regions}
168168
for region in self.regions:
169-
if region.id in other_regions_dict:
170-
new_regions.append(region - other_regions_dict[region.id])
169+
if region.regionIndex in other_regions_dict:
170+
new_regions.append(region - other_regions_dict[region.regionIndex])
171171
else:
172172
new_regions.append(region)
173173
elif self.regions is not None:
@@ -294,8 +294,10 @@ def estimate_remaining_lib_time(self, diff: "Planet") -> str:
294294
if timeval:
295295
rchange = region.calculate_change(rdiff)
296296
st = region.estimate_remaining_lib_time(rdiff)
297-
if st and "Stalemate" not in st:
298-
wo += "\n" + st
297+
if "Stalemate" in st:
298+
st = st.replace("Stalemate", ".")
299+
if st:
300+
wo += "\n *" + st
299301
if rchange < 0:
300302
timeoffset += timeval
301303

@@ -387,9 +389,9 @@ def average(planets_list: List["Planet"]) -> "Planet":
387389
for planet in planets_list:
388390
if planet.regions is not None:
389391
for region in planet.regions:
390-
if region.id not in regions_dict:
391-
regions_dict[region.id] = []
392-
regions_dict[region.id].append(region)
392+
if region.regionIndex not in regions_dict:
393+
regions_dict[region.regionIndex] = []
394+
regions_dict[region.regionIndex].append(region)
393395

394396
avg_regions = [Region.average(regions) for regions in regions_dict.values()]
395397

0 commit comments

Comments
 (0)