Auto-translated
I don't really want to dig through the code, but what do the lines of code that explicitly specify the creature level look like?
If (let's say) the answer to my question is "true," then I can suggest the following: if there is a fixed line indicating the level, then you can create a Ruby program (in my opinion, it's convenient for this; if someone hasn't heard of it, it's similar to Python) that will look at the line, (roughly speaking) determine the level, and replace it with a line that specifies the same level but a random creature.
The most straightforward implementation (since it will take time ~(n^2+n)) seems to me to be the following: let's assume that we have a line in the file - "level 1 - assassin." We read the entire file into an array (if the language allows, it's better to use a string) text. By iterating through the file, we make a line-by-line comparison with the array arr. In the array arr, we have seven reference lines ["level 1 - (regular expression)"..."level 7 - (regular expression)"]. And if (a[0] == text[a certain interval containing the line from the file]), then (text[a certain interval containing the line from the file] = "level 1 - (random creature)") and so on.