def spawn(self, all_sprites, mobs: pg.sprite.Group) -> int: """ Spawns enemies pseudo-randomly in an 8x8 tile area centered on the Spawner. Returns count of enemies spawned. """ max_count = randint( self.settings["gen"]["spawn_min"], self.settings["gen"]["spawn_max"], ) count = 0 for row in range(self.rows - 4, self.rows + 4): for col in range(self.cols - 4, self.cols + 4): if col <= self.settings["lvl"]["tiles_wide"]: if count >= max_count: break elif self.level_data[row][col] == "." and random() < 0.25: if random() < 0.5: mob = Mob( self.settings, self.img, "sleeper", col, row, ) else: mob = Mob( self.settings, self.img, "thrall", col, row, ) all_sprites.add(mob) mobs.add(mob) count += 1 self.kill() return count