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( 41 resource='firstToSeriesText', 42 subs=[('${COUNT}', str(session.get_series_length() / 2 + 1))], 43 ) 44 else: 45 best_txt = ba.Lstr( 46 resource='bestOfSeriesText', 47 subs=[('${COUNT}', str(session.get_series_length()))], 48 ) 49 50 ZoomText( 51 best_txt, 52 position=(0, 175), 53 shiftposition=(-250, 175), 54 shiftdelay=2.5, 55 flash=False, 56 trail=False, 57 h_align='center', 58 scale=0.25, 59 color=(0.5, 0.5, 0.5, 1.0), 60 jitter=3.0, 61 ).autoretain() 62 for team in self.session.sessionteams: 63 ba.timer( 64 i * 0.15 + 0.15, 65 ba.WeakCall( 66 self._show_team_name, 67 vval - i * height, 68 team, 69 i * 0.2, 70 shift_time - (i * 0.150 + 0.150), 71 ), 72 ) 73 ba.timer( 74 i * 0.150 + 0.5, 75 ba.Call(ba.playsound, self._score_display_sound_small), 76 ) 77 scored = team is self._winner 78 delay = 0.2 79 if scored: 80 delay = 1.2 81 ba.timer( 82 i * 0.150 + 0.2, 83 ba.WeakCall( 84 self._show_team_old_score, 85 vval - i * height, 86 team, 87 shift_time - (i * 0.15 + 0.2), 88 ), 89 ) 90 ba.timer( 91 i * 0.15 + 1.5, 92 ba.Call(ba.playsound, self._score_display_sound), 93 ) 94 95 ba.timer( 96 i * 0.150 + delay, 97 ba.WeakCall( 98 self._show_team_score, 99 vval - i * height, 100 team, 101 scored, 102 i * 0.2 + 0.1, 103 shift_time - (i * 0.15 + delay), 104 ), 105 ) 106 i += 1 107 self.show_player_scores() 108 109 def _show_team_name( 110 self, 111 pos_v: float, 112 team: ba.SessionTeam, 113 kill_delay: float, 114 shiftdelay: float, 115 ) -> None: 116 del kill_delay # Unused arg. 117 ZoomText( 118 ba.Lstr(value='${A}:', subs=[('${A}', team.name)]), 119 position=(100, pos_v), 120 shiftposition=(-150, pos_v), 121 shiftdelay=shiftdelay, 122 flash=False, 123 trail=False, 124 h_align='right', 125 maxwidth=300, 126 color=team.color, 127 jitter=1.0, 128 ).autoretain() 129 130 def _show_team_old_score( 131 self, pos_v: float, sessionteam: ba.SessionTeam, shiftdelay: float 132 ) -> None: 133 ZoomText( 134 str(sessionteam.customdata['score'] - 1), 135 position=(150, pos_v), 136 maxwidth=100, 137 color=(0.6, 0.6, 0.7), 138 shiftposition=(-100, pos_v), 139 shiftdelay=shiftdelay, 140 flash=False, 141 trail=False, 142 lifespan=1.0, 143 h_align='left', 144 jitter=1.0, 145 ).autoretain() 146 147 def _show_team_score( 148 self, 149 pos_v: float, 150 sessionteam: ba.SessionTeam, 151 scored: bool, 152 kill_delay: float, 153 shiftdelay: float, 154 ) -> None: 155 del kill_delay # Unused arg. 156 ZoomText( 157 str(sessionteam.customdata['score']), 158 position=(150, pos_v), 159 maxwidth=100, 160 color=(1.0, 0.9, 0.5) if scored else (0.6, 0.6, 0.7), 161 shiftposition=(-100, pos_v), 162 shiftdelay=shiftdelay, 163 flash=scored, 164 trail=scored, 165 h_align='left', 166 jitter=1.0, 167 trailcolor=(1, 0.8, 0.0, 0), 168 ).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( 42 resource='firstToSeriesText', 43 subs=[('${COUNT}', str(session.get_series_length() / 2 + 1))], 44 ) 45 else: 46 best_txt = ba.Lstr( 47 resource='bestOfSeriesText', 48 subs=[('${COUNT}', str(session.get_series_length()))], 49 ) 50 51 ZoomText( 52 best_txt, 53 position=(0, 175), 54 shiftposition=(-250, 175), 55 shiftdelay=2.5, 56 flash=False, 57 trail=False, 58 h_align='center', 59 scale=0.25, 60 color=(0.5, 0.5, 0.5, 1.0), 61 jitter=3.0, 62 ).autoretain() 63 for team in self.session.sessionteams: 64 ba.timer( 65 i * 0.15 + 0.15, 66 ba.WeakCall( 67 self._show_team_name, 68 vval - i * height, 69 team, 70 i * 0.2, 71 shift_time - (i * 0.150 + 0.150), 72 ), 73 ) 74 ba.timer( 75 i * 0.150 + 0.5, 76 ba.Call(ba.playsound, self._score_display_sound_small), 77 ) 78 scored = team is self._winner 79 delay = 0.2 80 if scored: 81 delay = 1.2 82 ba.timer( 83 i * 0.150 + 0.2, 84 ba.WeakCall( 85 self._show_team_old_score, 86 vval - i * height, 87 team, 88 shift_time - (i * 0.15 + 0.2), 89 ), 90 ) 91 ba.timer( 92 i * 0.15 + 1.5, 93 ba.Call(ba.playsound, self._score_display_sound), 94 ) 95 96 ba.timer( 97 i * 0.150 + delay, 98 ba.WeakCall( 99 self._show_team_score, 100 vval - i * height, 101 team, 102 scored, 103 i * 0.2 + 0.1, 104 shift_time - (i * 0.15 + delay), 105 ), 106 ) 107 i += 1 108 self.show_player_scores() 109 110 def _show_team_name( 111 self, 112 pos_v: float, 113 team: ba.SessionTeam, 114 kill_delay: float, 115 shiftdelay: float, 116 ) -> None: 117 del kill_delay # Unused arg. 118 ZoomText( 119 ba.Lstr(value='${A}:', subs=[('${A}', team.name)]), 120 position=(100, pos_v), 121 shiftposition=(-150, pos_v), 122 shiftdelay=shiftdelay, 123 flash=False, 124 trail=False, 125 h_align='right', 126 maxwidth=300, 127 color=team.color, 128 jitter=1.0, 129 ).autoretain() 130 131 def _show_team_old_score( 132 self, pos_v: float, sessionteam: ba.SessionTeam, shiftdelay: float 133 ) -> None: 134 ZoomText( 135 str(sessionteam.customdata['score'] - 1), 136 position=(150, pos_v), 137 maxwidth=100, 138 color=(0.6, 0.6, 0.7), 139 shiftposition=(-100, pos_v), 140 shiftdelay=shiftdelay, 141 flash=False, 142 trail=False, 143 lifespan=1.0, 144 h_align='left', 145 jitter=1.0, 146 ).autoretain() 147 148 def _show_team_score( 149 self, 150 pos_v: float, 151 sessionteam: ba.SessionTeam, 152 scored: bool, 153 kill_delay: float, 154 shiftdelay: float, 155 ) -> None: 156 del kill_delay # Unused arg. 157 ZoomText( 158 str(sessionteam.customdata['score']), 159 position=(150, pos_v), 160 maxwidth=100, 161 color=(1.0, 0.9, 0.5) if scored else (0.6, 0.6, 0.7), 162 shiftposition=(-100, pos_v), 163 shiftdelay=shiftdelay, 164 flash=scored, 165 trail=scored, 166 h_align='left', 167 jitter=1.0, 168 trailcolor=(1, 0.8, 0.0, 0), 169 ).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( 42 resource='firstToSeriesText', 43 subs=[('${COUNT}', str(session.get_series_length() / 2 + 1))], 44 ) 45 else: 46 best_txt = ba.Lstr( 47 resource='bestOfSeriesText', 48 subs=[('${COUNT}', str(session.get_series_length()))], 49 ) 50 51 ZoomText( 52 best_txt, 53 position=(0, 175), 54 shiftposition=(-250, 175), 55 shiftdelay=2.5, 56 flash=False, 57 trail=False, 58 h_align='center', 59 scale=0.25, 60 color=(0.5, 0.5, 0.5, 1.0), 61 jitter=3.0, 62 ).autoretain() 63 for team in self.session.sessionteams: 64 ba.timer( 65 i * 0.15 + 0.15, 66 ba.WeakCall( 67 self._show_team_name, 68 vval - i * height, 69 team, 70 i * 0.2, 71 shift_time - (i * 0.150 + 0.150), 72 ), 73 ) 74 ba.timer( 75 i * 0.150 + 0.5, 76 ba.Call(ba.playsound, self._score_display_sound_small), 77 ) 78 scored = team is self._winner 79 delay = 0.2 80 if scored: 81 delay = 1.2 82 ba.timer( 83 i * 0.150 + 0.2, 84 ba.WeakCall( 85 self._show_team_old_score, 86 vval - i * height, 87 team, 88 shift_time - (i * 0.15 + 0.2), 89 ), 90 ) 91 ba.timer( 92 i * 0.15 + 1.5, 93 ba.Call(ba.playsound, self._score_display_sound), 94 ) 95 96 ba.timer( 97 i * 0.150 + delay, 98 ba.WeakCall( 99 self._show_team_score, 100 vval - i * height, 101 team, 102 scored, 103 i * 0.2 + 0.1, 104 shift_time - (i * 0.15 + delay), 105 ), 106 ) 107 i += 1 108 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