diff --git a/pokemon_v2/serializers.py b/pokemon_v2/serializers.py index 67e181a2..cef6f6b1 100644 --- a/pokemon_v2/serializers.py +++ b/pokemon_v2/serializers.py @@ -2343,12 +2343,12 @@ class MoveDetailSerializer(serializers.ModelSerializer): data = MoveEffectEffectTextSerializer( effect_texts, many=True, context=self.context ).data - effect_entries = data[0] - for _i, k in enumerate(effect_entries): - if "$effect_chance%" in effect_entries[k]: - data[0][k] = effect_entries[k].replace( - "$effect_chance", f"{obj.move_effect_chance}" - ) + if len(data) > 0: + for key, value in data[0].items(): + if "$effect_chance%" in value: + data[0][key] = value.replace( + "$effect_chance", f"{obj.move_effect_chance}" + ) return data