From e0a877be9b85ef81bc7844158d49879f97a51fcf Mon Sep 17 00:00:00 2001 From: Robert Williams Date: Fri, 2 Feb 2024 15:16:58 -0600 Subject: [PATCH 1/7] Updating MoveDetailSerializer to change $effect_chance to actual number --- data/v2/csv/move_effect_prose.csv | 4 +--- pokemon_v2/serializers.py | 7 ++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/data/v2/csv/move_effect_prose.csv b/data/v2/csv/move_effect_prose.csv index 958ddbdf4..3ad875593 100644 --- a/data/v2/csv/move_effect_prose.csv +++ b/data/v2/csv/move_effect_prose.csv @@ -153,9 +153,7 @@ This move cannot be copied by []{move:mimic} or []{move:mirror-move}, nor select The user takes damage instead of being healed if the target has []{ability:liquid-ooze}. []{move:rapid-spin} will remove this effect. - -This effect is passed on by []{move:baton-pass}." -86,9,Does nothing.,"Does nothing. +7,9,Has a $e. This move cannot be used while []{move:gravity} is in effect." 87,9,Disables the target's last used move for 1-8 turns.,"Disables the target's last used move, preventing its use for 4–7 turns, selected at random, or until the target leaves the [field]{mechanic:field}. If the target hasn't used a move since entering the [field]{mechanic:field}, if it tried to use a move this turn and [failed]{mechanic:failed}, if its last used move has 0 PP remaining, or if it already has a move disabled, this move will fail." diff --git a/pokemon_v2/serializers.py b/pokemon_v2/serializers.py index b1acff77c..b6367bc8f 100644 --- a/pokemon_v2/serializers.py +++ b/pokemon_v2/serializers.py @@ -2343,7 +2343,12 @@ def get_effect_text(self, obj): data = MoveEffectEffectTextSerializer( effect_texts, many=True, context=self.context ).data - + effect_entries = data[0] + for i, k in enumerate(effect_entries): + print(i, k) + if '$effect_chance%' in effect_entries[k]: + data[0][k] = effect_entries[k].replace('$effect_chance', f'{obj.move_effect_chance}') + return data def get_effect_change_text(self, obj): From ccd44796c48c756f99d82e83a030d92b4b11a731 Mon Sep 17 00:00:00 2001 From: Robert Williams Date: Fri, 2 Feb 2024 17:06:36 -0600 Subject: [PATCH 2/7] fixing a debugging print line --- pokemon_v2/serializers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pokemon_v2/serializers.py b/pokemon_v2/serializers.py index b6367bc8f..7c45acdef 100644 --- a/pokemon_v2/serializers.py +++ b/pokemon_v2/serializers.py @@ -2345,7 +2345,6 @@ def get_effect_text(self, obj): ).data effect_entries = data[0] for i, k in enumerate(effect_entries): - print(i, k) if '$effect_chance%' in effect_entries[k]: data[0][k] = effect_entries[k].replace('$effect_chance', f'{obj.move_effect_chance}') From 77b974161e500d2c6ed94b4491ca3222fb1db1b5 Mon Sep 17 00:00:00 2001 From: Robert Williams Date: Fri, 2 Feb 2024 17:24:03 -0600 Subject: [PATCH 3/7] replacing move_effect_prose.csv with original --- data/v2/csv/move_effect_prose.csv | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/data/v2/csv/move_effect_prose.csv b/data/v2/csv/move_effect_prose.csv index 3ad875593..958ddbdf4 100644 --- a/data/v2/csv/move_effect_prose.csv +++ b/data/v2/csv/move_effect_prose.csv @@ -153,7 +153,9 @@ This move cannot be copied by []{move:mimic} or []{move:mirror-move}, nor select The user takes damage instead of being healed if the target has []{ability:liquid-ooze}. []{move:rapid-spin} will remove this effect. -7,9,Has a $e. + +This effect is passed on by []{move:baton-pass}." +86,9,Does nothing.,"Does nothing. This move cannot be used while []{move:gravity} is in effect." 87,9,Disables the target's last used move for 1-8 turns.,"Disables the target's last used move, preventing its use for 4–7 turns, selected at random, or until the target leaves the [field]{mechanic:field}. If the target hasn't used a move since entering the [field]{mechanic:field}, if it tried to use a move this turn and [failed]{mechanic:failed}, if its last used move has 0 PP remaining, or if it already has a move disabled, this move will fail." From 8f9fd71aa65b3b5d331a36489584164140fd8202 Mon Sep 17 00:00:00 2001 From: Robert Williams Date: Sat, 3 Feb 2024 21:56:25 -0600 Subject: [PATCH 4/7] removing unnecessary line --- pokemon_v2/serializers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pokemon_v2/serializers.py b/pokemon_v2/serializers.py index 7c45acdef..ddd80eb92 100644 --- a/pokemon_v2/serializers.py +++ b/pokemon_v2/serializers.py @@ -2343,10 +2343,10 @@ def get_effect_text(self, obj): 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}') + data[0][k] = effect_entries[k].replace('$effect_chance', f'{obj.move_effect_chance}') return data From 12db174d1e2c6cbd0daec10a6fc91e17a4da8246 Mon Sep 17 00:00:00 2001 From: Robert Williams Date: Sat, 3 Feb 2024 22:02:23 -0600 Subject: [PATCH 5/7] that line was needed after all --- pokemon_v2/serializers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pokemon_v2/serializers.py b/pokemon_v2/serializers.py index ddd80eb92..7c45acdef 100644 --- a/pokemon_v2/serializers.py +++ b/pokemon_v2/serializers.py @@ -2343,10 +2343,10 @@ def get_effect_text(self, obj): data = MoveEffectEffectTextSerializer( effect_texts, many=True, context=self.context ).data - effect_entries = data[0] for i, k in enumerate(effect_entries): - data[0][k] = effect_entries[k].replace('$effect_chance', f'{obj.move_effect_chance}') + if '$effect_chance%' in effect_entries[k]: + data[0][k] = effect_entries[k].replace('$effect_chance', f'{obj.move_effect_chance}') return data From c843a67a00dbc744530cd6dd5c528e8889b9ce7c Mon Sep 17 00:00:00 2001 From: Robert Williams Date: Fri, 9 Feb 2024 23:30:52 -0600 Subject: [PATCH 6/7] fixing linter issue --- pokemon_v2/serializers.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pokemon_v2/serializers.py b/pokemon_v2/serializers.py index 7c45acdef..d79e6cd69 100644 --- a/pokemon_v2/serializers.py +++ b/pokemon_v2/serializers.py @@ -2344,10 +2344,12 @@ def get_effect_text(self, obj): 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}') - + 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}" + ) + return data def get_effect_change_text(self, obj): From 99f2131424ad3328465e4dba7d5b9b70e3e9a831 Mon Sep 17 00:00:00 2001 From: Robert Williams Date: Sat, 10 Feb 2024 19:56:30 -0600 Subject: [PATCH 7/7] making simonorono's suggest changes --- pokemon_v2/serializers.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pokemon_v2/serializers.py b/pokemon_v2/serializers.py index 67e181a2c..cef6f6b13 100644 --- a/pokemon_v2/serializers.py +++ b/pokemon_v2/serializers.py @@ -2343,12 +2343,12 @@ def get_effect_text(self, obj): 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