Skip to content

Commit 553a19d

Browse files
committed
Fix TypeError in cadence ability editing in Content Manager GUI
1 parent 77c98f3 commit 553a19d

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

modules/contentManager/app.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,15 @@ def edit_cadence_abilities(abilities_list, key_prefix):
145145
with st.container(border=True):
146146
col1, col2, col3 = st.columns([3, 2, 1])
147147
with col1:
148-
# The nested structure is {"Ability": {"Name": "...", "Description": "..."}, "Requirements": [...], "PrimaryStat": "..."}
149-
current_ab_name = ab_entry["Ability"]["Name"]
148+
# The structure in JSON is {"Ability": "Name", "Requirements": [...], "PrimaryStat": "..."}
149+
current_ab_name = ab_entry["Ability"]
150150
new_ab_name = st.selectbox(f"Ability {i}", all_ability_names, index=all_ability_names.index(current_ab_name) if current_ab_name in all_ability_names else 0, key=f"{key_prefix}_ab_{i}")
151151

152152
if new_ab_name != current_ab_name:
153-
source_ab = next(a for a in manager.unified_data["abilities"] if a["Name"] == new_ab_name)
154-
ab_entry["Ability"]["Name"] = source_ab["Name"]
155-
ab_entry["Ability"]["Description"] = source_ab["Description"]
153+
ab_entry["Ability"] = new_ab_name
156154

157155
with col2:
158-
ab_entry["PrimaryStat"] = st.selectbox(f"Stat {i}", stat_names, index=stat_names.index(ab_entry["PrimaryStat"]) if ab_entry["PrimaryStat"] in stat_names else 0, key=f"{key_prefix}_stat_{i}")
156+
ab_entry["PrimaryStat"] = st.selectbox(f"Stat {i}", stat_names, index=stat_names.index(ab_entry["PrimaryStat"]) if ab_entry.get("PrimaryStat") in stat_names else 0, key=f"{key_prefix}_stat_{i}")
159157

160158
with col3:
161159
if st.button("🗑️ Remove Ability", key=f"{key_prefix}_del_{i}"):
@@ -171,7 +169,7 @@ def edit_cadence_abilities(abilities_list, key_prefix):
171169
if st.button("➕ Add Ability to Cadence", key=f"{key_prefix}_add"):
172170
source_ab = manager.unified_data["abilities"][0]
173171
abilities_list.append({
174-
"Ability": {"Name": source_ab["Name"], "Description": source_ab["Description"]},
172+
"Ability": source_ab["Name"],
175173
"Requirements": [],
176174
"PrimaryStat": "Magic"
177175
})

0 commit comments

Comments
 (0)