def attempt_spawn(self, players): players = Location.attempt_spawn(self, players) if not self.building.can_spawn_unit(): return players if self.spawn_timer > 0: self.spawn_timer -= 1 elif self.unit_in_loc is None and players[self.owner].gold >= util.UNIT_COST: self.unit_in_loc = Unit(self.building.unit_type, self.owner, self.exit_direction[self.owner]) self.spawn_timer = util.SPAWN_DELAY players[self.owner].gold -= util.UNIT_COST return players