forked from DizzyEggg/pokeemerald
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved Frontier teams into battle_frontier_trainers.h
- Loading branch information
Showing
3 changed files
with
351 additions
and
1,806 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
migration_scripts/1.10/convert_battle_frontier_trainers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import glob | ||
import re | ||
import os | ||
|
||
if not os.path.exists("Makefile"): | ||
print("Please run this script from your root folder.") | ||
quit() | ||
|
||
# Read battle_frontier_trainer_mons.h and extract the party information | ||
for file in glob.glob('./src/data/battle_frontier/battle_frontier_trainer_mons.h'): | ||
with open(file, 'r') as f: | ||
source_content = f.read() | ||
|
||
# Extract party info from battle_frontier_trainer_mons.h | ||
source_pattern = re.compile(r'gBattleFrontierTrainerMons_(.*)\[\]\s*=\s*\n\{\n\s*(FRONTIER.*)') | ||
source_data = {} | ||
for match in source_pattern.findall(source_content): | ||
if len(match) == 2: | ||
trainer_name, party_group = match | ||
source_data[trainer_name] = (party_group) | ||
|
||
# Read battle_frontier_trainers.h content | ||
for file in glob.glob('./src/data/battle_frontier/battle_frontier_trainers.h'): | ||
with open(file, 'r') as f: | ||
destination_content = f.read() | ||
|
||
# Modify battle_frontier_trainers.h content | ||
def add_party_data(match): | ||
trainer_name = match.group(1) | ||
if trainer_name in source_data: | ||
party_group = source_data[trainer_name] | ||
print(f"Updating {trainer_name}: adding {party_group}") | ||
return f'(const u16[]){{{party_group}}}' | ||
else: | ||
return match.group(0) | ||
|
||
destination_pattern = re.compile(r'gBattleFrontierTrainerMons_(.*)') | ||
modified_content = destination_pattern.sub(add_party_data, destination_content) | ||
|
||
# Write the modified content back to battle_frontier_trainers.h | ||
#(const u16[]){FRONTIER_MONS_PARASOL_LADY_1} | ||
for file in glob.glob('./src/data/battle_frontier/battle_frontier_trainers.h'): | ||
with open(file, 'w') as f: | ||
f.write(modified_content) | ||
print("battle_frontier_trainers.h has been updated") |
Oops, something went wrong.