bastd.activity.dualteamscore
Functionality related to the end screen in dual-team mode.
1# Released under the MIT License. See LICENSE for details. 2# 3"""Functionality related to the end screen in dual-team mode.""" 4 5from __future__ import annotations 6 7from typing import TYPE_CHECKING 8 9import ba 10from bastd.activity.multiteamscore import MultiTeamScoreScreenActivity 11from bastd.actor.zoomtext import ZoomText 12 13if TYPE_CHECKING: 14 pass 15 16 17class TeamVictoryScoreScreenActivity(MultiTeamScoreScreenActivity): 18 """Scorescreen between rounds of a dual-team session.""" 19 20 def __init__(self, settings: dict): 21 super().__init__(settings=settings) 22 self._winner: ba.SessionTeam = settings['winner'] 23 assert isinstance(self._winner, ba.SessionTeam) 24 25 def on_begin(self) -> None: 26 ba.set_analytics_screen('Teams Score Screen') 27 super().on_begin() 28 29 height = 130 30 active_team_count = len(self.teams) 31 vval = (height * active_team_count) / 2 - height / 2 32 i = 0 33 shift_time = 2.5 34 35 # Usually we say 'Best of 7', but if the language prefers we can say 36 # 'First to 4'. 37 session = self.session 38 assert isinstance(session, ba.MultiTeamSession) 39 if ba.app.lang.get_resource('bestOfUseFirstToInstead'): 40 best_txt = ba.Lstr(resource='firstToSeriesText', 41 subs=[('${COUNT}', 42 str(session.get_series_length() / 2 + 1)) 43 ]) 44 else: 45 best_txt = ba.Lstr(resource='bestOfSeriesText', 46 subs=[('${COUNT}', 47 str(session.get_series_length()))]) 48 49 ZoomText(best_txt, 50 position=(0, 175), 51 shiftposition=(-250, 175), 52 shiftdelay=2.5, 53 flash=False, 54 trail=False, 55 h_align='center', 56 scale=0.25, 57 color=(0.5, 0.5, 0.5, 1.0), 58 jitter=3.0).autoretain() 59 for team in self.session.sessionteams: 60 ba.timer( 61 i * 0.15 + 0.15, 62 ba.WeakCall(self._show_team_name, vval - i * height, team, 63 i * 0.2, shift_time - (i * 0.150 + 0.150))) 64 ba.timer(i * 0.150 + 0.5, 65 ba.Call(ba.playsound, self._score_display_sound_small)) 66 scored = (team is self._winner) 67 delay = 0.2 68 if scored: 69 delay = 1.2 70 ba.timer( 71 i * 0.150 + 0.2, 72 ba.WeakCall(self._show_team_old_score, vval - i * height, 73 team, shift_time - (i * 0.15 + 0.2))) 74 ba.timer(i * 0.15 + 1.5, 75 ba.Call(ba.playsound, self._score_display_sound)) 76 77 ba.timer( 78 i * 0.150 + delay, 79 ba.WeakCall(self._show_team_score, vval - i * height, team, 80 scored, i * 0.2 + 0.1, 81 shift_time - (i * 0.15 + delay))) 82 i += 1 83 self.show_player_scores() 84 85 def _show_team_name(self, pos_v: float, team: ba.SessionTeam, 86 kill_delay: float, shiftdelay: float) -> None: 87 del kill_delay # Unused arg. 88 ZoomText(ba.Lstr(value='${A}:', subs=[('${A}', team.name)]), 89 position=(100, pos_v), 90 shiftposition=(-150, pos_v), 91 shiftdelay=shiftdelay, 92 flash=False, 93 trail=False, 94 h_align='right', 95 maxwidth=300, 96 color=team.color, 97 jitter=1.0).autoretain() 98 99 def _show_team_old_score(self, pos_v: float, sessionteam: ba.SessionTeam, 100 shiftdelay: float) -> None: 101 ZoomText(str(sessionteam.customdata['score'] - 1), 102 position=(150, pos_v), 103 maxwidth=100, 104 color=(0.6, 0.6, 0.7), 105 shiftposition=(-100, pos_v), 106 shiftdelay=shiftdelay, 107 flash=False, 108 trail=False, 109 lifespan=1.0, 110 h_align='left', 111 jitter=1.0).autoretain() 112 113 def _show_team_score(self, pos_v: float, sessionteam: ba.SessionTeam, 114 scored: bool, kill_delay: float, 115 shiftdelay: float) -> None: 116 del kill_delay # Unused arg. 117 ZoomText(str(sessionteam.customdata['score']), 118 position=(150, pos_v), 119 maxwidth=100, 120 color=(1.0, 0.9, 0.5) if scored else (0.6, 0.6, 0.7), 121 shiftposition=(-100, pos_v), 122 shiftdelay=shiftdelay, 123 flash=scored, 124 trail=scored, 125 h_align='left', 126 jitter=1.0, 127 trailcolor=(1, 0.8, 0.0, 0)).autoretain()
class
TeamVictoryScoreScreenActivity(ba._activity.Activity[ba._player.EmptyPlayer, ba._team.EmptyTeam]):
18class TeamVictoryScoreScreenActivity(MultiTeamScoreScreenActivity): 19 """Scorescreen between rounds of a dual-team session.""" 20 21 def __init__(self, settings: dict): 22 super().__init__(settings=settings) 23 self._winner: ba.SessionTeam = settings['winner'] 24 assert isinstance(self._winner, ba.SessionTeam) 25 26 def on_begin(self) -> None: 27 ba.set_analytics_screen('Teams Score Screen') 28 super().on_begin() 29 30 height = 130 31 active_team_count = len(self.teams) 32 vval = (height * active_team_count) / 2 - height / 2 33 i = 0 34 shift_time = 2.5 35 36 # Usually we say 'Best of 7', but if the language prefers we can say 37 # 'First to 4'. 38 session = self.session 39 assert isinstance(session, ba.MultiTeamSession) 40 if ba.app.lang.get_resource('bestOfUseFirstToInstead'): 41 best_txt = ba.Lstr(resource='firstToSeriesText', 42 subs=[('${COUNT}', 43 str(session.get_series_length() / 2 + 1)) 44 ]) 45 else: 46 best_txt = ba.Lstr(resource='bestOfSeriesText', 47 subs=[('${COUNT}', 48 str(session.get_series_length()))]) 49 50 ZoomText(best_txt, 51 position=(0, 175), 52 shiftposition=(-250, 175), 53 shiftdelay=2.5, 54 flash=False, 55 trail=False, 56 h_align='center', 57 scale=0.25, 58 color=(0.5, 0.5, 0.5, 1.0), 59 jitter=3.0).autoretain() 60 for team in self.session.sessionteams: 61 ba.timer( 62 i * 0.15 + 0.15, 63 ba.WeakCall(self._show_team_name, vval - i * height, team, 64 i * 0.2, shift_time - (i * 0.150 + 0.150))) 65 ba.timer(i * 0.150 + 0.5, 66 ba.Call(ba.playsound, self._score_display_sound_small)) 67 scored = (team is self._winner) 68 delay = 0.2 69 if scored: 70 delay = 1.2 71 ba.timer( 72 i * 0.150 + 0.2, 73 ba.WeakCall(self._show_team_old_score, vval - i * height, 74 team, shift_time - (i * 0.15 + 0.2))) 75 ba.timer(i * 0.15 + 1.5, 76 ba.Call(ba.playsound, self._score_display_sound)) 77 78 ba.timer( 79 i * 0.150 + delay, 80 ba.WeakCall(self._show_team_score, vval - i * height, team, 81 scored, i * 0.2 + 0.1, 82 shift_time - (i * 0.15 + delay))) 83 i += 1 84 self.show_player_scores() 85 86 def _show_team_name(self, pos_v: float, team: ba.SessionTeam, 87 kill_delay: float, shiftdelay: float) -> None: 88 del kill_delay # Unused arg. 89 ZoomText(ba.Lstr(value='${A}:', subs=[('${A}', team.name)]), 90 position=(100, pos_v), 91 shiftposition=(-150, pos_v), 92 shiftdelay=shiftdelay, 93 flash=False, 94 trail=False, 95 h_align='right', 96 maxwidth=300, 97 color=team.color, 98 jitter=1.0).autoretain() 99 100 def _show_team_old_score(self, pos_v: float, sessionteam: ba.SessionTeam, 101 shiftdelay: float) -> None: 102 ZoomText(str(sessionteam.customdata['score'] - 1), 103 position=(150, pos_v), 104 maxwidth=100, 105 color=(0.6, 0.6, 0.7), 106 shiftposition=(-100, pos_v), 107 shiftdelay=shiftdelay, 108 flash=False, 109 trail=False, 110 lifespan=1.0, 111 h_align='left', 112 jitter=1.0).autoretain() 113 114 def _show_team_score(self, pos_v: float, sessionteam: ba.SessionTeam, 115 scored: bool, kill_delay: float, 116 shiftdelay: float) -> None: 117 del kill_delay # Unused arg. 118 ZoomText(str(sessionteam.customdata['score']), 119 position=(150, pos_v), 120 maxwidth=100, 121 color=(1.0, 0.9, 0.5) if scored else (0.6, 0.6, 0.7), 122 shiftposition=(-100, pos_v), 123 shiftdelay=shiftdelay, 124 flash=scored, 125 trail=scored, 126 h_align='left', 127 jitter=1.0, 128 trailcolor=(1, 0.8, 0.0, 0)).autoretain()
Scorescreen between rounds of a dual-team session.
TeamVictoryScoreScreenActivity(settings: dict)
21 def __init__(self, settings: dict): 22 super().__init__(settings=settings) 23 self._winner: ba.SessionTeam = settings['winner'] 24 assert isinstance(self._winner, ba.SessionTeam)
Creates an Activity in the current ba.Session.
The activity will not be actually run until ba.Session.setactivity is called. 'settings' should be a dict of key/value pairs specific to the activity.
Activities should preload as much of their media/etc as possible in their constructor, but none of it should actually be used until they are transitioned in.
def
on_begin(self) -> None:
26 def on_begin(self) -> None: 27 ba.set_analytics_screen('Teams Score Screen') 28 super().on_begin() 29 30 height = 130 31 active_team_count = len(self.teams) 32 vval = (height * active_team_count) / 2 - height / 2 33 i = 0 34 shift_time = 2.5 35 36 # Usually we say 'Best of 7', but if the language prefers we can say 37 # 'First to 4'. 38 session = self.session 39 assert isinstance(session, ba.MultiTeamSession) 40 if ba.app.lang.get_resource('bestOfUseFirstToInstead'): 41 best_txt = ba.Lstr(resource='firstToSeriesText', 42 subs=[('${COUNT}', 43 str(session.get_series_length() / 2 + 1)) 44 ]) 45 else: 46 best_txt = ba.Lstr(resource='bestOfSeriesText', 47 subs=[('${COUNT}', 48 str(session.get_series_length()))]) 49 50 ZoomText(best_txt, 51 position=(0, 175), 52 shiftposition=(-250, 175), 53 shiftdelay=2.5, 54 flash=False, 55 trail=False, 56 h_align='center', 57 scale=0.25, 58 color=(0.5, 0.5, 0.5, 1.0), 59 jitter=3.0).autoretain() 60 for team in self.session.sessionteams: 61 ba.timer( 62 i * 0.15 + 0.15, 63 ba.WeakCall(self._show_team_name, vval - i * height, team, 64 i * 0.2, shift_time - (i * 0.150 + 0.150))) 65 ba.timer(i * 0.150 + 0.5, 66 ba.Call(ba.playsound, self._score_display_sound_small)) 67 scored = (team is self._winner) 68 delay = 0.2 69 if scored: 70 delay = 1.2 71 ba.timer( 72 i * 0.150 + 0.2, 73 ba.WeakCall(self._show_team_old_score, vval - i * height, 74 team, shift_time - (i * 0.15 + 0.2))) 75 ba.timer(i * 0.15 + 1.5, 76 ba.Call(ba.playsound, self._score_display_sound)) 77 78 ba.timer( 79 i * 0.150 + delay, 80 ba.WeakCall(self._show_team_score, vval - i * height, team, 81 scored, i * 0.2 + 0.1, 82 shift_time - (i * 0.15 + delay))) 83 i += 1 84 self.show_player_scores()
Called once the previous ba.Activity has finished transitioning out.
At this point the activity's initial players and teams are filled in and it should begin its actual game logic.
Inherited Members
- ba._activitytypes.ScoreScreenActivity
- transition_time
- inherits_tint
- inherits_vr_camera_offset
- use_fixed_vr_overlay
- default_music
- on_player_join
- on_transition_in
- ba._activity.Activity
- settings_raw
- teams
- players
- announce_player_deaths
- is_joining_activity
- allow_pausing
- allow_kick_idle_players
- slow_motion
- inherits_slow_motion
- inherits_music
- inherits_vr_overlay_center
- allow_mid_activity_joins
- can_show_ad_on_death
- globalsnode
- stats
- on_expire
- customdata
- expired
- playertype
- teamtype
- retain_actor
- add_actor_weak_ref
- session
- on_player_leave
- on_team_join
- on_team_leave
- on_transition_out
- handlemessage
- has_transitioned_in
- has_begun
- has_ended
- is_transitioning_out
- transition_out
- end
- create_player
- create_team
- ba._dependency.DependencyComponent
- dep_is_present
- get_dynamic_deps