# Released under the MIT License. See LICENSE for details.#"""Functionality related to teams sessions."""from__future__importannotationsfromtypingimportTYPE_CHECKING,overrideimportbabaseimport_bascenev1frombascenev1._multiteamsessionimportMultiTeamSessionifTYPE_CHECKING:importbascenev1
[docs]classDualTeamSession(MultiTeamSession):"""bascenev1.Session type for teams mode games."""# Base class overrides:use_teams=Trueuse_team_colors=True_playlist_selection_var='Team Tournament Playlist Selection'_playlist_randomize_var='Team Tournament Playlist Randomize'_playlists_var='Team Tournament Playlists'def__init__(self)->None:babase.increment_analytics_count('Teams session start')super().__init__()@overridedef_switch_to_score_screen(self,results:bascenev1.GameResults)->None:# pylint: disable=cyclic-importfrombascenev1lib.activity.multiteamvictoryimport(TeamSeriesVictoryScoreScreenActivity,)frombascenev1lib.activity.dualteamscoreimport(TeamVictoryScoreScreenActivity,)frombascenev1lib.activity.drawscoreimportDrawScoreScreenActivitywinnergroups=results.winnergroups# If everyone has the same score, call it a draw.iflen(winnergroups)<2:self.setactivity(_bascenev1.newactivity(DrawScoreScreenActivity))else:winner=winnergroups[0].teams[0]winner.customdata['score']+=1# If a team has won, show final victory screen.ifwinner.customdata['score']>=(self._series_length-1)/2+1:self.setactivity(_bascenev1.newactivity(TeamSeriesVictoryScoreScreenActivity,{'winner':winner},))else:self.setactivity(_bascenev1.newactivity(TeamVictoryScoreScreenActivity,{'winner':winner}))
# Docs-generation hack; import some stuff that we likely only forward-declared# in our actual source code so that docs tools can find it.fromtypingimport(Coroutine,Any,Literal,Callable,Generator,Awaitable,Sequence,Self)importasynciofromconcurrent.futuresimportFuture