Update ALL GAMEMODE for 1.7.20+

(except Musical Flags)
This commit is contained in:
! Freaku 2023-07-27 18:22:40 +05:30 committed by GitHub
parent 1990fc5c7e
commit 07d6968898
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 402 additions and 395 deletions

View file

@ -1,18 +1,19 @@
#Ported by: Freaku / @[Just] Freak#4999
# Ported by your friend: Freaku
#Join BCS:
# https://discord.gg/ucyaesh
# ba_meta require api 7
# ba_meta require api 8
from __future__ import annotations
from typing import TYPE_CHECKING
import ba
from bastd.actor.playerspaz import PlayerSpaz
import babase
import bascenev1 as bs
from bascenev1lib.actor.playerspaz import PlayerSpaz
if TYPE_CHECKING:
from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional
@ -56,21 +57,21 @@ states = [ State(bomb='normal', name='Basic Bombs'),
State(punch=True, name='Punching only'),
State(curse=True, name='Cursed', final=True) ]
class Player(ba.Player['Team']):
class Player(bs.Player['Team']):
"""Our player type for this game."""
def __init__(self):
self.state = None
class Team(ba.Team[Player]):
class Team(bs.Team[Player]):
"""Our team type for this game."""
def __init__(self) -> None:
self.score = 0
# ba_meta export game
class ArmsRaceGame(ba.TeamGameActivity[Player, Team]):
# ba_meta export bascenev1.GameActivity
class ArmsRaceGame(bs.TeamGameActivity[Player, Team]):
"""A game type based on acquiring kills."""
name = 'Arms Race'
@ -81,9 +82,9 @@ class ArmsRaceGame(ba.TeamGameActivity[Player, Team]):
@classmethod
def get_available_settings(
cls, sessiontype: Type[ba.Session]) -> List[ba.Setting]:
cls, sessiontype: Type[bs.Session]) -> List[babase.Setting]:
settings = [
ba.IntChoiceSetting(
bs.IntChoiceSetting(
'Time Limit',
choices=[
('None', 0),
@ -95,7 +96,7 @@ class ArmsRaceGame(ba.TeamGameActivity[Player, Team]):
],
default=0,
),
ba.FloatChoiceSetting(
bs.FloatChoiceSetting(
'Respawn Times',
choices=[
('Shorter', 0.25),
@ -106,21 +107,21 @@ class ArmsRaceGame(ba.TeamGameActivity[Player, Team]):
],
default=1.0,
),
ba.BoolSetting('Epic Mode', default=False)]
bs.BoolSetting('Epic Mode', default=False)]
for state in states:
if not state.required:
settings.append(ba.BoolSetting(state.get_setting(), default=True))
settings.append(bs.BoolSetting(state.get_setting(), default=True))
return settings
@classmethod
def supports_session_type(cls, sessiontype: Type[ba.Session]) -> bool:
return (issubclass(sessiontype, ba.DualTeamSession)
or issubclass(sessiontype, ba.FreeForAllSession))
def supports_session_type(cls, sessiontype: Type[bs.Session]) -> bool:
return (issubclass(sessiontype, bs.DualTeamSession)
or issubclass(sessiontype, bs.FreeForAllSession))
@classmethod
def get_supported_maps(cls, sessiontype: Type[ba.Session]) -> List[str]:
return ba.getmaps('melee')
def get_supported_maps(cls, sessiontype: Type[bs.Session]) -> List[str]:
return bs.app.classic.getmaps('melee')
def __init__(self, settings: dict):
super().__init__(settings)
@ -129,14 +130,14 @@ class ArmsRaceGame(ba.TeamGameActivity[Player, Team]):
if i < len(self.states) and not state.final:
state.next = self.states[i + 1]
state.index = i
self._dingsound = ba.getsound('dingSmall')
self._dingsound = bs.getsound('dingSmall')
self._epic_mode = bool(settings['Epic Mode'])
self._time_limit = float(settings['Time Limit'])
# Base class overrides.
self.slow_motion = self._epic_mode
self.default_music = (ba.MusicType.EPIC if self._epic_mode else
ba.MusicType.TO_THE_DEATH)
self.default_music = (bs.MusicType.EPIC if self._epic_mode else
bs.MusicType.TO_THE_DEATH)
def get_instance_description(self) -> Union[str, Sequence]:
return 'Upgrade your weapon by eliminating enemies.'
@ -172,7 +173,7 @@ class ArmsRaceGame(ba.TeamGameActivity[Player, Team]):
def handlemessage(self, msg: Any) -> Any:
if isinstance(msg, ba.PlayerDiedMessage):
if isinstance(msg, bs.PlayerDiedMessage):
if self.isValidKill(msg):
self.stats.player_scored(msg.getkillerplayer(Player), 10, kill=True)
if not msg.getkillerplayer(Player).state.final:
@ -188,7 +189,7 @@ class ArmsRaceGame(ba.TeamGameActivity[Player, Team]):
return None
def end_game(self) -> None:
results = ba.GameResults()
results = bs.GameResults()
for team in self.teams:
results.set_team_score(team, team.score)
self.end(results=results)
self.end(results=results)