Breeding
Spawning Process Summary
The spawn_monster event action manages the breeding of two "Tuxemons" (monsters) to create a new offspring. This process involves determining the genetic "seed" parent, inheriting tastes with a chance of mutation, and generating a unique name for the new monster.
---
Determining the Genetic Seed Parent (_determine_seed)
The _determine_seed function decides which of the two parent monsters (mother or father) will contribute its species (slug) as the basis for the offspring. The selection follows a hierarchical set of rules, prioritizing biological fitness:
- Evolution Stage: The monster at a higher evolutionary stage is preferred. The stages are prioritized as
stage2>stage1>standalone. - Total Stats: If evolution stages are the same, the monster with higher total base stats (sum of all
StatTypevalues) is chosen. - Vitality Ratio (HP Ratio): If total stats are also equal, the monster with a greater vitality ratio (current HP divided by max HP) is selected.
- Type Effectiveness: If all the above are equal, the function considers type effectiveness. The parent whose types are more effective against the other parent's types is chosen.
- Random Selection: If all previous criteria are tied, the seed parent is chosen randomly between the mother and the father.
---
Determining the Offspring's Name (_determine_name)
The _determine_name function generates a new name for the offspring by combining parts of the mother's and father's names. The process aims to create a blended name while avoiding awkward combinations:
- Vowel-Based Combination (Preferred):
- If both parent names contain at least one vowel (a, e, i, o, u, y), the function finds the vowel closest to the midpoint of each name.
- The new name is formed by taking the first part of the first parent's name up to and including its closest midpoint vowel, and combining it with the second part of the second parent's name starting from its closest midpoint vowel.
- Midpoint Split (Fallback):
- If either parent's name lacks a vowel, the function defaults to splitting each name at its midpoint.
- The first half of the first parent's name is combined with the second half of the second parent's name.
- Duplicate Character Removal: After combining the name parts, any consecutive duplicate characters are removed (e.g., "Aarron" becomes "Aaron").
- Capitalization: The final generated name is capitalized.
---
Move Selection
The offspring inherits one move directly from the father:
- A random move is selected from the father's current moves.
- This randomly selected move replaces one of the child's initial moves (specifically, at index 0 or 1, chosen randomly).