def generate_level(character: Character): # Build the tiles level = Level( name="The Beginning", depth=1, tiles=""" .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... """, character=character, ) level.save() # Add the character to this level character.current_level = level character.x = 5 character.y = 5 character.save() # Create a creature ctype = random.choice([c for c in CreatureType.objects.all()]) c = Creature( current_level=level, x=0, y=0, type=ctype, current_hp=ctype.base_hp ) c.save() return level