Newer
Older
from enemies import *
from map import *
import random
# dictionary to ensure no ID collision
id_tracker = {}
# someone may want to improve the way enemies are populated
def populate_enemies():
for enemy in enemy_classes:
id_tracker[enemy.__name__.lower()] = 1
for room_id in rooms:
room = rooms[room_id]
if room.cleared == False:
random_monster = random.choice(enemy_classes)
# enemy level increases with room difficulty
level = random.randint(
room.difficulty * 3 - 2,
room.difficulty * 3
)
# get id
monster_id = random_monster.__name__.lower() + "_" + str(id_tracker[random_monster.__name__.lower()])
id_tracker[random_monster.__name__.lower()] += 1
room.enemies.append(
random_monster(monster_id, level)
)