From 74ec0e98f37daa7e2a28cbab456da2e880f344c9 Mon Sep 17 00:00:00 2001 From: Adrien Rault Date: Thu, 31 Oct 2024 12:26:39 +0100 Subject: [PATCH 1/2] feat: make regexp for flavor text updater more generic --- .../flavor-text-updater/get-text-content.ts | 69 ++----------------- 1 file changed, 7 insertions(+), 62 deletions(-) diff --git a/scripts/data-gen-scripts/scripted-updaters/flavor-text-updater/get-text-content.ts b/scripts/data-gen-scripts/scripted-updaters/flavor-text-updater/get-text-content.ts index 981f3f2f79..bdb95787ff 100644 --- a/scripts/data-gen-scripts/scripted-updaters/flavor-text-updater/get-text-content.ts +++ b/scripts/data-gen-scripts/scripted-updaters/flavor-text-updater/get-text-content.ts @@ -23,10 +23,7 @@ export function getTextContent(bit1: string) { .replace(/'''Version 1\.0:''' .+1.2:''' (.+)/, '$1') .replace(/'''Version 1\.0:''' .+1\.1:''' (.+)/, '$1') .replace(/'''Version 1\.0:''' .+1\.2:''' (.+)/, '$1') - .replaceAll('{{tt|*|Pokédex entry only found in Pokémon HOME.}}', '') - .replaceAll('{{tt|*|Pokédex entry only found in Pokémon HOME}}', '') - .replaceAll('{{tt|*|In Ver 1.0, Tyranitar uses its entry from LeafGreen}}', '') - .replaceAll('{{tt|*|Used for both genders in-game}}', '') + .replaceAll(/\{\{tt\|\*\|(?:[\p{Letter}\d\p{Punctuation}\s]+?)\}\}/gu, '') .replaceAll('}}\t', '') .replaceAll('’', "'") .replaceAll('−', '-') @@ -34,63 +31,13 @@ export function getTextContent(bit1: string) { .replaceAll('”', '"') .replaceAll(' ', ' ') .replaceAll('', '.') - .replaceAll(`{{tt|–75 degrees Fahrenheit|−60 degrees Celsius}}`, '-75 degrees Fahrenheit') - .replaceAll(`{{tt|–75 degrees Fahrenheit|-60 degrees Celsius}}`, '-75 degrees Fahrenheit') - .replaceAll(`{{tt|–58 degrees Fahrenheit|−50 degrees Celsius}}`, '-58 degrees Fahrenheit') - .replaceAll(`{{tt|–58 degrees Fahrenheit|-50 degrees Celsius}}`, '-58 degrees Fahrenheit') - .replaceAll(`{{tt|–240 degrees Fahrenheit|−150 degrees Celsius}}`, '-240 degrees Fahrenheit') - .replaceAll(`{{tt|–240 degrees Fahrenheit|-150 degrees Celsius}}`, '-240 degrees Fahrenheit') + .replaceAll(/\{\{tt\|–(\d+) degrees Fahrenheit\|(?:-|−)\d+ degrees Celsius\}\}/g, '-$1 degrees Fahrenheit') .replaceAll(`{{tt|this|''the'' in Ruby v1.0}}`, 'this') .replaceAll(`{{tt|Bug/Grass Pokémon|''BUG POKéMON'' in R/S v1.0}}`, 'Bug/Grass Pokémon') - .replaceAll('{{tt|*|Unused entry}}', '') - .replaceAll('[[alien]]', 'alien') - .replaceAll('[[Alola]]', 'Alola') - .replaceAll('[[Apricorn]]', 'Apricorn') - .replaceAll('[[Berry|Berries]]', 'Berries') - .replaceAll('[[Black Augurite|extremely rare ore]]', 'extremely rare ore') - .replaceAll('[[Diamond Domain|kingdom of jewels]]', 'kingdom of jewels') - .replaceAll('[[Distortion World|world]]', 'world') - .replaceAll('[[Double Slap (move)|DoubleSlap]]', 'DoubleSlap') - .replaceAll('[[Dynamax]]', 'Dynamax') - .replaceAll('[[evolution]]', 'evolution') - .replaceAll('[[Evolution|becomes]]', 'becomes') - .replaceAll('[[Evolution|evolve]]', 'evolve') - .replaceAll('[[Evolution|evolved]]', 'evolved') - .replaceAll('[[Galar]]', 'Galar') - .replaceAll('[[Galar|homeland]]', 'homeland') - .replaceAll('[[Gladion|boy]]', 'boy') - .replaceAll('[[Gladion|the boy who evolved it into this form]]', 'the boy who evolved it into this form') - .replaceAll('[[Hisui]]', 'Hisui') - .replaceAll('[[Hisui|much harsher environments]]', 'much harsher environments') - .replaceAll('[[Kitakami|a new land]]', 'a new land') - .replaceAll('[[legendary Pokémon]]', 'legendary Pokémon') - .replaceAll('[[Mega Evolution|a phenomenon that occurs in a certain region]]', 'a phenomenon that occurs in a certain region') - .replaceAll('[[Moon Stone|moon stone]]', 'moon stone') - .replaceAll('[[move]]', 'move') - .replaceAll('[[Mr. Fuji|a certain scientist]]', 'a certain scientist') - .replaceAll('[[Old Amber|amber]]', 'amber') - .replaceAll('[[Paldea]]', 'Paldea') - .replaceAll('[[Poké Ball]]', 'Poké Ball') - .replaceAll('[[Pokégear]]', 'Pokégear') - .replaceAll('[[Pokégear|Pokégear]]', 'Pokégear') - .replaceAll('[[Pokégear|égear]]', 'Pokégear') - .replaceAll('[[Pokégear|Pokégear]]', 'Pokégear') - .replaceAll('[[Pokémon Trainer|Trainer]]', 'Trainer') - .replaceAll('[[Pokémon world|ours]]', 'ours') - .replaceAll('[[Professor Laventon|my]]', 'my') - .replaceAll('[[Pupitar (Pokémon)|a pupa]]', 'a pupa') - .replaceAll('[[region]]', 'region') - .replaceAll('[[regional form]]', 'regional form') - .replaceAll('[[Scarlet Book|an expedition journal]]', 'an expedition journal') - .replaceAll('[[Scarlet Book|old expedition journal]]', 'old expedition journal.') - .replaceAll('[[Sinnoh myths|mythology]]', 'mythology') - .replaceAll('[[Sinnoh myths|myths]]', 'myths') - .replaceAll('[[Sinnoh]]', 'Sinnoh') - .replaceAll('[[Time travel|travel at will through the past and future]]', 'travel at will through the past and future') - .replaceAll('[[type]]', 'type') - .replaceAll('[[Ultra Beast]]', 'Ultra Beast') - .replaceAll('[[Violet Book|certain expedition journal.]]', 'certain expedition journal.') - .replaceAll('[[Violet Book|old book]]', 'old book') + .replaceAll( + /(?:\[\[(?Pokégear)(?:\|[\p{Letter}\p{Other_Punctuation}\s()<>]+)?\]\])|(?:\[\[(?:[\p{Letter}\p{Other_Punctuation}\s()<>]+\|)?(?[\p{Letter}\p{Other_Punctuation}\s()<>]+)\]\])/gu, + '$$' + ) .replaceAll('{{OBP|Pokémon|species}}', 'Pokémon') .replaceAll('{{p|Type: Null}}', 'Type: Null') .replaceAll('{{ScBall}}', 'Poké Ball') @@ -98,7 +45,5 @@ export function getTextContent(bit1: string) { .replaceAll('{{sup/4|HG}}/Froslass{{sup/4|SS}}', '') .replaceAll('lower-back{{sup/4|HG}}/lower back{{sup/4|SS}}', 'lower-back') .replaceAll('the{{sup/3|R}}/this{{sup/3|S}}', 'this') - .replaceAll('a ', '') - .replaceAll('Berries', 'Berries') - .replaceAll("[[Dimension#Palkia's world|spatial dimension]]", 'spatial dimension'); + .replaceAll('a ', ''); } From fc85c3108ee7dd55a346010407574527f1576b4b Mon Sep 17 00:00:00 2001 From: Jeroen Claassens Date: Sat, 2 Nov 2024 16:00:07 +0100 Subject: [PATCH 2/2] fix: restore ursaring berries parsing --- .../scripted-updaters/flavor-text-updater/get-text-content.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/data-gen-scripts/scripted-updaters/flavor-text-updater/get-text-content.ts b/scripts/data-gen-scripts/scripted-updaters/flavor-text-updater/get-text-content.ts index bdb95787ff..92f959607f 100644 --- a/scripts/data-gen-scripts/scripted-updaters/flavor-text-updater/get-text-content.ts +++ b/scripts/data-gen-scripts/scripted-updaters/flavor-text-updater/get-text-content.ts @@ -45,5 +45,6 @@ export function getTextContent(bit1: string) { .replaceAll('{{sup/4|HG}}/Froslass{{sup/4|SS}}', '') .replaceAll('lower-back{{sup/4|HG}}/lower back{{sup/4|SS}}', 'lower-back') .replaceAll('the{{sup/3|R}}/this{{sup/3|S}}', 'this') - .replaceAll('a ', ''); + .replaceAll('a ', '') + .replaceAll('Berries', 'Berries'); }