def award_local_achievement(self, achname: str) -> None: """For non-game-based achievements such as controller-connection.""" try: ach = self.get_achievement(achname) if not ach.complete: # Report new achievements to the game-service. _ba.report_achievement(achname) # And to our account. _ba.add_transaction({'type': 'ACHIEVEMENT', 'name': achname}) # Now attempt to show a banner. self.display_achievement_banner(achname) except Exception: print_exception()
def _award_achievement(self, achievement_name: str, sound: bool = True) -> None: """Award an achievement. Returns True if a banner will be shown; False otherwise """ from ba._achievement import get_achievement if achievement_name in self._achievements_awarded: return ach = get_achievement(achievement_name) # If we're in the easy campaign and this achievement is hard-mode-only, # ignore it. try: campaign = self.session.campaign assert campaign is not None if ach.hard_mode_only and campaign.name == 'Easy': return except Exception: from ba._error import print_exception print_exception() # If we haven't awarded this one, check to see if we've got it. # If not, set it through the game service *and* add a transaction # for it. if not ach.complete: self._achievements_awarded.add(achievement_name) # Report new achievements to the game-service. _ba.report_achievement(achievement_name) # ...and to our account. _ba.add_transaction({ 'type': 'ACHIEVEMENT', 'name': achievement_name }) # Now bring up a celebration banner. ach.announce_completion(sound=sound)