shithub: pokecrystal

Download patch

ref: a6efb7f0fbc5dd791feebb21c497caa328125224
parent: a17ef09e100c5a570adbc7a55e84d69e55370af6
author: Bryan Bishop <[email protected]>
date: Fri May 18 17:31:51 EDT 2012

extract trainer group id and trainer id from TrainerFragment objects

--- a/extras/crystal.py
+++ b/extras/crystal.py
@@ -3313,6 +3313,7 @@
         global_dependencies.add(self.itemfrag)
         return self.dependencies
 
+trainer_group_maximums = {}
 class TrainerFragment(Command):
     """used by TrainerFragmentParam and PeopleEvent for trainer data
     
@@ -3375,6 +3376,20 @@
         deps.extend(self.params[6].get_dependencies(recompute=recompute, global_dependencies=global_dependencies))
         self.dependencies = deps
         return deps
+
+    def parse(self):
+        Command.parse(self)
+
+        # get the trainer group id
+        trainer_group = self.params[1].byte
+
+        # get the trainer id
+        trainer_id = self.params[2].byte
+
+        if not trainer_group in trainer_group_maximums.keys():
+            trainer_group_maximums[trainer_group] = trainer_id
+        elif trainer_group_maximums[trainer_group] < trainer_id:
+            trainer_group_maximums[trainer_group] = trainer_id
 
     def to_asm(self):
         xspacing = ""