Skip to content

Commit

Permalink
equipment: ruff format and comment
Browse files Browse the repository at this point in the history
  • Loading branch information
juk0de committed Nov 15, 2024
1 parent db836c6 commit d22b725
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mtf2json/equipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ def get_name_and_size(value: str) -> tuple[str, str]:
# now split the string
res = re.split(":size:", value, flags=re.IGNORECASE)
# convert to float and then to int if it's a whole number, otherwise keep as float
size = str(int(float(res[1]))) if float(res[1]).is_integer() else str(float(res[1]))
size = (
str(int(float(res[1])))
if float(res[1]).is_integer()
else str(float(res[1]))
)
return (res[0].strip(), f"{size}t")

def add_sized_equipment(
Expand Down Expand Up @@ -97,6 +101,7 @@ def add_sized_equipment(
if slot_value and ":size:" in slot_value.lower():
slot_name, size = get_name_and_size(slot_value)
# overwrite the old slot name
# FIXME: add tags like 'omnipod' and 'armored' if available
mech_data["critical_slots"][location][key] = slot_name
# add the equipment to the list (if not yet done)
add_sized_equipment(mech_data, location, slot_name, size)

0 comments on commit d22b725

Please sign in to comment.