def update_scores(self) -> None: """ update scoreboard and check for winners """ # FIXME: tidy this up # pylint: disable=too-many-nested-blocks have_scoring_team = False win_score = self._score_to_win for team in [self.teams[0], self._bot_team]: assert team is not None assert self._scoreboard is not None self._scoreboard.set_team_value(team, team.gamedata['score'], win_score) if team.gamedata['score'] >= win_score: if not have_scoring_team: self.scoring_team = team if team is self._bot_team: self.continue_or_end_game() else: ba.setmusic(ba.MusicType.VICTORY) # Completion achievements. assert self._bot_team is not None if self._preset in ['rookie', 'rookie_easy']: self._award_achievement('Rookie Football Victory', sound=False) if self._bot_team.gamedata['score'] == 0: self._award_achievement( 'Rookie Football Shutout', sound=False) elif self._preset in ['pro', 'pro_easy']: self._award_achievement('Pro Football Victory', sound=False) if self._bot_team.gamedata['score'] == 0: self._award_achievement('Pro Football Shutout', sound=False) elif self._preset in ['uber', 'uber_easy']: self._award_achievement('Uber Football Victory', sound=False) if self._bot_team.gamedata['score'] == 0: self._award_achievement( 'Uber Football Shutout', sound=False) if (not self._player_has_dropped_bomb and not self._player_has_punched): self._award_achievement('Got the Moves', sound=False) self._bots.stop_moving() self.show_zoom_message(ba.Lstr(resource='victoryText'), scale=1.0, duration=4.0) self.celebrate(10.0) assert self._starttime_ms is not None self._final_time_ms = int( ba.time(timeformat=ba.TimeFormat.MILLISECONDS) - self._starttime_ms) self._time_text_timer = None assert (self._time_text_input is not None and self._time_text_input.node) self._time_text_input.node.timemax = ( self._final_time_ms) # FIXME: Does this still need to be deferred? ba.pushcall(ba.Call(self.do_end, 'victory'))
def _start_preloads(self) -> None: # FIXME: The func that calls us back doesn't save/restore state # or check for a dead activity so we have to do that ourself. if self.expired: return with ba.Context(self): _preload1() ba.timer(0.5, lambda: ba.setmusic(ba.MusicType.MENU))
def _play_victory_music(self) -> None: # Make sure we don't stomp on the next activity's music choice. if not self.is_transitioning_out(): ba.setmusic(ba.MusicType.VICTORY)
def _update_waves(self) -> None: # pylint: disable=too-many-branches # If we have no living bots, go to the next wave. if (self._can_end_wave and not self._bots.have_living_bots() and not self._game_over and self._lives > 0): self._can_end_wave = False self._time_bonus_timer = None self._time_bonus_text = None if self._preset in {Preset.ENDLESS, Preset.ENDLESS_TOURNAMENT}: won = False else: assert self._waves is not None won = (self._wavenum == len(self._waves)) # Reward time bonus. base_delay = 4.0 if won else 0 if self._time_bonus > 0: ba.timer(0, ba.Call(ba.playsound, self._cashregistersound)) ba.timer(base_delay, ba.Call(self._award_time_bonus, self._time_bonus)) base_delay += 1.0 # Reward flawless bonus. if self._wavenum > 0 and self._flawless: ba.timer(base_delay, self._award_flawless_bonus) base_delay += 1.0 self._flawless = True # reset if won: # Completion achievements: if self._preset in {Preset.PRO, Preset.PRO_EASY}: self._award_achievement('Pro Runaround Victory', sound=False) if self._lives == self._start_lives: self._award_achievement('The Wall', sound=False) if not self._player_has_picked_up_powerup: self._award_achievement('Precision Bombing', sound=False) elif self._preset in {Preset.UBER, Preset.UBER_EASY}: self._award_achievement('Uber Runaround Victory', sound=False) if self._lives == self._start_lives: self._award_achievement('The Great Wall', sound=False) if not self._a_player_has_been_killed: self._award_achievement('Stayin\' Alive', sound=False) # Give remaining players some points and have them celebrate. self.show_zoom_message(ba.Lstr(resource='victoryText'), scale=1.0, duration=4.0) self.celebrate(10.0) ba.timer(base_delay, self._award_lives_bonus) base_delay += 1.0 ba.timer(base_delay, self._award_completion_bonus) base_delay += 0.85 ba.playsound(self._winsound) ba.cameraflash() ba.setmusic(ba.MusicType.VICTORY) self._game_over = True ba.timer(base_delay, ba.Call(self.do_end, 'victory')) return self._wavenum += 1 # Short celebration after waves. if self._wavenum > 1: self.celebrate(0.5) ba.timer(base_delay, self._start_next_wave)
def end_game(self) -> None: ba.pushcall(ba.Call(self.do_end, 'defeat')) ba.setmusic(None) ba.playsound(self._player_death_sound)
def end_game(self) -> None: # Tell our bots to celebrate just to rub it in. self._bots.final_celebrate() ba.setmusic(None) ba.pushcall(ba.WeakCall(self.do_end, 'defeat'))
def end_game(self) -> None: ba.setmusic(None) self._bots.final_celebrate() ba.timer(0.001, ba.Call(self.do_end, 'defeat'))