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

Fix issue in upgrade view #160

Merged
merged 2 commits into from
Mar 2, 2025
Merged
Changes from 1 commit
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
22 changes: 21 additions & 1 deletion python/base_computer/upgrade_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,27 @@ def process_resource(key, resource_text):
original = float(parts[original_index])

return f"{format_number(damaged)} (orig: {format_number(original)})"

def process_range(text):
parts = text.split('/')

damaged_index = 0
original_index = 0

if len(parts) == 2:
damaged_index = 0
original_index = 1
elif len(parts) == 3:
damaged_index = 1
original_index = 2
else:
return text

damaged = int(parts[damaged_index])/1000
original = int(parts[original_index])/1000

return f"{format_number(damaged)} (orig: {format_number(original)})"

# We process a line to find the tag <key> or <key=value>
# <key> we convert to unit[key] and replace the tag with it.
# <key=value> we again convert and check if equal to value.
Expand Down Expand Up @@ -273,7 +293,7 @@ def get_upgrade_info(unit_stats):

# Radar range in km not meters
if 'Radar_Range' in unit:
unit['Radar_Range'] = format_number(int(unit['Radar_Range'])/ 1000)
unit['Radar_Range'] = process_range(unit['Radar_Range'])

text = ''

Expand Down
Loading