fix(@projects/@magic-civilization): 🐛 adjust null/empty checks for difficulty data
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
9e8c928d04
commit
5e0f482b46
1 changed files with 5 additions and 5 deletions
|
|
@ -796,12 +796,11 @@ func _fix_start_positions_if_needed() -> void:
|
|||
|
||||
|
||||
func _apply_per_player_difficulty_overrides() -> void:
|
||||
# DataLoader.get_data("difficulty") returns {"easy": {full entry}, "normal": {...}, ...}
|
||||
# already keyed by id — no wrapping "ai_difficulty" array at this level.
|
||||
var diff_data: Dictionary = DataLoader.get_data("difficulty")
|
||||
if diff_data == null:
|
||||
if diff_data == null or diff_data.is_empty():
|
||||
return
|
||||
var levels: Dictionary = {}
|
||||
for entry: Dictionary in diff_data.get("ai_difficulty", []):
|
||||
levels[str(entry.get("id", ""))] = entry.get("ai_modifiers", {})
|
||||
# Use a fixed upper bound — this runs before loading_screen.gd populates
|
||||
# GameState.players, so players.size() == 0. Check all possible player slots.
|
||||
for p_idx: int in range(8):
|
||||
|
|
@ -809,7 +808,8 @@ func _apply_per_player_difficulty_overrides() -> void:
|
|||
var tier: String = EnvConfig.get_var(key, "")
|
||||
if tier.is_empty():
|
||||
continue
|
||||
var mods: Dictionary = levels.get(tier, {})
|
||||
var entry: Dictionary = diff_data.get(tier, {})
|
||||
var mods: Dictionary = entry.get("ai_modifiers", {})
|
||||
if mods.is_empty():
|
||||
print("AutoPlay: WARNING: unknown difficulty tier '%s' for %s" % [tier, key])
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue