Skip to content

Commit 4275a45

Browse files
authored
Merge pull request #61 from Jah-yee/fix/null-check-comp-fields
fix: check for None before dividing completion times by 3600
2 parents cf792c0 + d134528 commit 4275a45

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎howlongtobeatpy/howlongtobeatpy/JSONResultParser.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@ def parse_json_element(self, input_game_element):
7373
current_entry.json_content = input_game_element
7474
# Add a few times elements as help for the user
7575
# Calculate only if value is not None
76-
if "comp_main" in input_game_element:
76+
if "comp_main" in input_game_element and input_game_element.get("comp_main") is not None:
7777
current_entry.main_story = round(input_game_element.get("comp_main") / 3600, 2)
78-
if "comp_plus" in input_game_element:
78+
if "comp_plus" in input_game_element and input_game_element.get("comp_plus") is not None:
7979
current_entry.main_extra = round(input_game_element.get("comp_plus") / 3600, 2)
80-
if "comp_100" in input_game_element:
80+
if "comp_100" in input_game_element and input_game_element.get("comp_100") is not None:
8181
current_entry.completionist = round(input_game_element.get("comp_100") / 3600, 2)
82-
if "comp_all" in input_game_element:
82+
if "comp_all" in input_game_element and input_game_element.get("comp_all") is not None:
8383
current_entry.all_styles = round(input_game_element.get("comp_all") / 3600, 2)
84-
if "invested_co" in input_game_element:
84+
if "invested_co" in input_game_element and input_game_element.get("invested_co") is not None:
8585
current_entry.coop_time = round(input_game_element.get("invested_co") / 3600, 2)
86-
if "invested_mp" in input_game_element:
86+
if "invested_mp" in input_game_element and input_game_element.get("invested_mp") is not None:
8787
current_entry.mp_time = round(input_game_element.get("invested_mp") / 3600, 2)
8888
# Add complexity booleans
8989
current_entry.complexity_lvl_combine = bool(input_game_element.get("comp_lvl_combine", 0))

0 commit comments

Comments
 (0)