diff --git a/.efrocachemap b/.efrocachemap
index ee0cbcbd..8b1559ef 100644
--- a/.efrocachemap
+++ b/.efrocachemap
@@ -4132,16 +4132,16 @@
"assets/build/windows/x64/python.exe": "https://files.ballistica.net/cache/ba1/25/a7/dc87c1be41605eb6fefd0145144c",
"assets/build/windows/x64/python37.dll": "https://files.ballistica.net/cache/ba1/b9/e4/d912f56e42e9991bcbb4c804cfcb",
"assets/build/windows/x64/pythonw.exe": "https://files.ballistica.net/cache/ba1/6c/bb/b6f52c306aa4e88061510e96cefe",
- "build/prefab/linux-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/22/a3/c6b38e5c76464077f400415eef8f",
- "build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/35/42/3802bdafafffea388132ccb27197",
- "build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/90/fb/bbb656b6d0b56ff92d30f13fcb10",
- "build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/3b/75/2eee67afef4e0f446cba5a466521",
- "build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b6/31/fe8c9e100c0f99daaf1d11d702c0",
- "build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/85/27/7ddbe58f02af52884fff485c98dd",
- "build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/d4/11/0f9806ff32156d9af2fb5c88e49c",
- "build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/9a/55/2cd36310f00e3a187a70b3f122ee",
- "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/30/8e/b4d365f9aa49cf247d6a73dfd5ee",
- "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/b0/1a/20b48edf6830ad53a1c0049c129b",
- "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/00/52/42d85a6502daf27271ce48634b5b",
- "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/b2/1c/1afeac6051ad9973e06f945f98ce"
+ "build/prefab/linux-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e8/b7/d1b41fb68d9f65901d47267b9287",
+ "build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/40/04/9b0dc90152d5729485488b628429",
+ "build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/b0/15/aa58294e041cca7485375e7a49ad",
+ "build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/04/86/d3adc7e35a753aad5e6d62758e7c",
+ "build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/91/81/30196355ca6b2044140131f6da89",
+ "build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d3/3b/e0171b94d0b24c153a88b7724797",
+ "build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/97/10/3b2aded25bb43ce4451f54c42731",
+ "build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/e3/ca/e0788b1f5cc69e92fed8d4d9a61f",
+ "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/69/78/3a1f6f6f808f671c749d48b0b5a6",
+ "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/1a/fc/f3b36c2964d64ef2c1685cf8c893",
+ "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/22/8d/fdf637a15162f92f699f92eca9e7",
+ "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/72/34/a37deb6cbc29025a38c161ce7cba"
}
\ No newline at end of file
diff --git a/.idea/dictionaries/ericf.xml b/.idea/dictionaries/ericf.xml
index a1274851..4e45609f 100644
--- a/.idea/dictionaries/ericf.xml
+++ b/.idea/dictionaries/ericf.xml
@@ -1577,6 +1577,7 @@
scorescreen
scoreteam
scoretxt
+ scoretype
scoreval
scorever
scorings
diff --git a/assets/.asset_manifest_public.json b/assets/.asset_manifest_public.json
index 767104c3..92c51171 100644
--- a/assets/.asset_manifest_public.json
+++ b/assets/.asset_manifest_public.json
@@ -42,6 +42,7 @@
"ba_data/python/ba/__pycache__/_playlist.cpython-37.opt-1.pyc",
"ba_data/python/ba/__pycache__/_powerup.cpython-37.opt-1.pyc",
"ba_data/python/ba/__pycache__/_profile.cpython-37.opt-1.pyc",
+ "ba_data/python/ba/__pycache__/_score.cpython-37.opt-1.pyc",
"ba_data/python/ba/__pycache__/_servermode.cpython-37.opt-1.pyc",
"ba_data/python/ba/__pycache__/_session.cpython-37.opt-1.pyc",
"ba_data/python/ba/__pycache__/_stats.cpython-37.opt-1.pyc",
@@ -95,6 +96,7 @@
"ba_data/python/ba/_playlist.py",
"ba_data/python/ba/_powerup.py",
"ba_data/python/ba/_profile.py",
+ "ba_data/python/ba/_score.py",
"ba_data/python/ba/_servermode.py",
"ba_data/python/ba/_session.py",
"ba_data/python/ba/_stats.py",
diff --git a/assets/Makefile b/assets/Makefile
index 1d135437..82113061 100644
--- a/assets/Makefile
+++ b/assets/Makefile
@@ -179,6 +179,7 @@ SCRIPT_TARGETS_PY_PUBLIC = \
build/ba_data/python/ba/_tournament.py \
build/ba_data/python/ba/_messages.py \
build/ba_data/python/ba/_freeforallsession.py \
+ build/ba_data/python/ba/_score.py \
build/ba_data/python/ba/_playlist.py \
build/ba_data/python/ba/_team.py \
build/ba_data/python/ba/_multiteamsession.py \
@@ -405,6 +406,7 @@ SCRIPT_TARGETS_PYC_PUBLIC = \
build/ba_data/python/ba/__pycache__/_tournament.cpython-37.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_messages.cpython-37.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_freeforallsession.cpython-37.opt-1.pyc \
+ build/ba_data/python/ba/__pycache__/_score.cpython-37.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_playlist.cpython-37.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_team.cpython-37.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_multiteamsession.cpython-37.opt-1.pyc \
@@ -791,6 +793,11 @@ build/ba_data/python/ba/__pycache__/_freeforallsession.cpython-37.opt-1.pyc: \
@echo Compiling script: $^
@rm -rf $@ && $(TOOLS_DIR)/snippets compile_python_files $^ && chmod 444 $@
+build/ba_data/python/ba/__pycache__/_score.cpython-37.opt-1.pyc: \
+ build/ba_data/python/ba/_score.py
+ @echo Compiling script: $^
+ @rm -rf $@ && $(TOOLS_DIR)/snippets compile_python_files $^ && chmod 444 $@
+
build/ba_data/python/ba/__pycache__/_playlist.cpython-37.opt-1.pyc: \
build/ba_data/python/ba/_playlist.py
@echo Compiling script: $^
diff --git a/assets/src/ba_data/python/ba/__init__.py b/assets/src/ba_data/python/ba/__init__.py
index 201b4cb3..0277bf92 100644
--- a/assets/src/ba_data/python/ba/__init__.py
+++ b/assets/src/ba_data/python/ba/__init__.py
@@ -61,6 +61,7 @@ from ba._lang import Lstr, setlanguage, get_valid_languages
from ba._map import Map, getmaps
from ba._session import Session
from ba._servermode import ServerController
+from ba._score import ScoreType, ScoreInfo
from ba._stats import PlayerScoredMessage, PlayerRecord, Stats
from ba._team import Team
from ba._teamgame import TeamGameActivity
diff --git a/assets/src/ba_data/python/ba/_coopsession.py b/assets/src/ba_data/python/ba/_coopsession.py
index d1c28fd0..bcaa1ceb 100644
--- a/assets/src/ba_data/python/ba/_coopsession.py
+++ b/assets/src/ba_data/python/ba/_coopsession.py
@@ -254,6 +254,7 @@ class CoopSession(Session):
from ba._general import WeakCall
from ba._coopgame import CoopGameActivity
from ba._gameresults import TeamGameResults
+ from ba._score import ScoreType
from bastd.tutorial import TutorialActivity
from bastd.activity.coopscore import CoopScoreScreen
@@ -349,18 +350,23 @@ class CoopSession(Session):
fail_message = None
score_order = ('decreasing' if results.get_lower_is_better()
else 'increasing')
- if results.get_score_type() in ('seconds', 'milliseconds',
- 'time'):
+ if results.get_score_type() in (ScoreType.SECONDS,
+ ScoreType.MILLISECONDS):
score_type = 'time'
- # Results contains milliseconds; ScoreScreen wants
- # hundredths; need to fix :-/
+ # ScoreScreen wants hundredths of a second.
if score is not None:
- score //= 10
+ if results.get_score_type() is ScoreType.SECONDS:
+ score *= 100
+ elif (results.get_score_type() is
+ ScoreType.MILLISECONDS):
+ score //= 10
+ else:
+ raise RuntimeError('FIXME')
else:
- if results.get_score_type() != 'points':
- print(("Unknown score type: '" +
- results.get_score_type() + "'"))
+ if results.get_score_type() is not ScoreType.POINTS:
+ print(f'Unknown ScoreType:'
+ f' "{results.get_score_type()}"')
score_type = 'points'
# Old coop-game-specific results; should migrate away from these.
diff --git a/assets/src/ba_data/python/ba/_gameactivity.py b/assets/src/ba_data/python/ba/_gameactivity.py
index 9acceb3f..b3131c4e 100644
--- a/assets/src/ba_data/python/ba/_gameactivity.py
+++ b/assets/src/ba_data/python/ba/_gameactivity.py
@@ -28,6 +28,7 @@ from typing import TYPE_CHECKING
import _ba
from ba._activity import Activity
+from ba._score import ScoreInfo
from ba._lang import Lstr
if TYPE_CHECKING:
@@ -75,58 +76,9 @@ class GameActivity(Activity):
completion_call)
@classmethod
- def get_score_info(cls) -> Dict[str, Any]:
- """Return info about game scoring setup; should be overridden by games.
-
- They should return a dict containing any of the following (missing
- values will be default):
-
- 'score_name': a label shown to the user for scores; 'Score',
- 'Time Survived', etc. 'Score' is the default.
-
- 'lower_is_better': a boolean telling whether lower scores are
- preferable instead of higher (the default).
-
- 'none_is_winner': specifies whether a score value of None is considered
- better than other scores or worse. Default is False.
-
- 'score_type': can be 'seconds', 'milliseconds', or 'points'.
-
- 'score_version': to change high-score lists used by a game without
- renaming the game, change this. Defaults to empty string.
- """
- return {}
-
- @classmethod
- def get_resolved_score_info(cls) -> Dict[str, Any]:
- """
- Call this to return a game's score info with all missing values
- filled in with defaults. This should not be overridden; override
- get_score_info() instead.
- """
- values = cls.get_score_info()
- if 'score_name' not in values:
- values['score_name'] = 'Score'
- if 'lower_is_better' not in values:
- values['lower_is_better'] = False
- if 'none_is_winner' not in values:
- values['none_is_winner'] = False
- if 'score_type' not in values:
- values['score_type'] = 'points'
- if 'score_version' not in values:
- values['score_version'] = ''
-
- if values['score_type'] not in ['seconds', 'milliseconds', 'points']:
- raise Exception("invalid score_type value: '" +
- values['score_type'] + "'")
-
- # make sure they didn't misspell anything in there..
- for name in list(values.keys()):
- if name not in ('score_name', 'lower_is_better', 'none_is_winner',
- 'score_type', 'score_version'):
- print('WARNING: invalid key in score_info: "' + name + '"')
-
- return values
+ def get_score_info(cls) -> ba.ScoreInfo:
+ """Return info about game scoring setup; can be overridden by games."""
+ return ScoreInfo()
@classmethod
def get_name(cls) -> str:
diff --git a/assets/src/ba_data/python/ba/_gameresults.py b/assets/src/ba_data/python/ba/_gameresults.py
index 46c484a4..d4fe7147 100644
--- a/assets/src/ba_data/python/ba/_gameresults.py
+++ b/assets/src/ba_data/python/ba/_gameresults.py
@@ -57,9 +57,9 @@ class TeamGameResults:
self._teams: Optional[List[ReferenceType[ba.Team]]] = None
self._player_info: Optional[List[Dict[str, Any]]] = None
self._lower_is_better: Optional[bool] = None
- self._score_name: Optional[str] = None
+ self._score_label: Optional[str] = None
self._none_is_winner: Optional[bool] = None
- self._score_type: Optional[str] = None
+ self._score_type: Optional[ba.ScoreType] = None
def set_game(self, game: ba.GameActivity) -> None:
"""Set the game instance these results are applying to."""
@@ -67,12 +67,12 @@ class TeamGameResults:
raise RuntimeError('Game set twice for TeamGameResults.')
self._game_set = True
self._teams = [weakref.ref(team) for team in game.teams]
- score_info = game.get_resolved_score_info()
+ score_info = game.get_score_info()
self._player_info = copy.deepcopy(game.initial_player_info)
- self._lower_is_better = score_info['lower_is_better']
- self._score_name = score_info['score_name']
- self._none_is_winner = score_info['none_is_winner']
- self._score_type = score_info['score_type']
+ self._lower_is_better = score_info.lower_is_better
+ self._score_label = score_info.label
+ self._none_is_winner = score_info.none_is_winner
+ self._score_type = score_info.scoretype
def set_team_score(self, team: ba.Team, score: int) -> None:
"""Set the score for a given ba.Team.
@@ -118,17 +118,18 @@ class TeamGameResults:
from ba._gameutils import timestring
from ba._lang import Lstr
from ba._enums import TimeFormat
+ from ba._score import ScoreType
if not self._game_set:
raise RuntimeError("Can't get team-score-str until game is set.")
for score in list(self._scores.values()):
if score[0]() is team:
if score[1] is None:
return Lstr(value='-')
- if self._score_type == 'seconds':
+ if self._score_type is ScoreType.SECONDS:
return timestring(score[1] * 1000,
centi=False,
timeformat=TimeFormat.MILLISECONDS)
- if self._score_type == 'milliseconds':
+ if self._score_type is ScoreType.MILLISECONDS:
return timestring(score[1],
centi=True,
timeformat=TimeFormat.MILLISECONDS)
@@ -142,7 +143,7 @@ class TeamGameResults:
assert self._player_info is not None
return self._player_info
- def get_score_type(self) -> str:
+ def get_score_type(self) -> ba.ScoreType:
"""Get the type of score."""
if not self._game_set:
raise RuntimeError("Can't get score-type until game is set.")
@@ -153,8 +154,8 @@ class TeamGameResults:
"""Get the name associated with scores ('points', etc)."""
if not self._game_set:
raise RuntimeError("Can't get score-name until game is set.")
- assert self._score_name is not None
- return self._score_name
+ assert self._score_label is not None
+ return self._score_label
def get_lower_is_better(self) -> bool:
"""Return whether lower scores are better."""
diff --git a/assets/src/ba_data/python/ba/_level.py b/assets/src/ba_data/python/ba/_level.py
index 44f805fa..f6471028 100644
--- a/assets/src/ba_data/python/ba/_level.py
+++ b/assets/src/ba_data/python/ba/_level.py
@@ -144,8 +144,7 @@ class Level:
can be changed to separate its new high score lists/etc. from the old.
"""
if self._score_version_string is None:
- scorever = (
- self._gametype.get_resolved_score_info()['score_version'])
+ scorever = self._gametype.get_score_info().version
if scorever != '':
scorever = ' ' + scorever
self._score_version_string = scorever
diff --git a/assets/src/ba_data/python/ba/_score.py b/assets/src/ba_data/python/ba/_score.py
new file mode 100644
index 00000000..83432b0f
--- /dev/null
+++ b/assets/src/ba_data/python/ba/_score.py
@@ -0,0 +1,74 @@
+# Copyright (c) 2011-2020 Eric Froemling
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+# -----------------------------------------------------------------------------
+"""Score related functionality."""
+
+from __future__ import annotations
+
+from enum import Enum, unique
+from dataclasses import dataclass
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+ import ba
+
+
+@unique
+class ScoreType(Enum):
+ """Type of scores.
+
+ Category: Enums
+ """
+ SECONDS = 's'
+ MILLISECONDS = 'ms'
+ POINTS = 'p'
+
+
+@dataclass
+class ScoreInfo:
+ """Info about a game's scoring setup.
+
+ Category: Gameplay Classes
+
+ Attrs:
+
+ label
+ A label show to the user for scores; 'Score', 'Time Survived', etc.
+
+ scoretype
+ How the score value should be displayed.
+
+ lower_is_better
+ Whether lower scores are preferable. Higher scores are by default.
+
+ none_is_winner
+ Whether a value of None is considered better than other scores.
+ By default it is not.
+
+ version
+ To change high-score lists used by a game without renaming the game,
+ change this. Defaults to an empty string.
+
+ """
+ label: str = 'Score'
+ scoretype: ba.ScoreType = ScoreType.POINTS
+ lower_is_better: bool = False
+ none_is_winner: bool = False
+ version: str = ''
diff --git a/assets/src/ba_data/python/bastd/game/chosenone.py b/assets/src/ba_data/python/bastd/game/chosenone.py
index 64478af3..7dae8184 100644
--- a/assets/src/ba_data/python/bastd/game/chosenone.py
+++ b/assets/src/ba_data/python/bastd/game/chosenone.py
@@ -49,8 +49,8 @@ class ChosenOneGame(ba.TeamGameActivity):
return 'Chosen One'
@classmethod
- def get_score_info(cls) -> Dict[str, Any]:
- return {'score_name': 'Time Held'}
+ def get_score_info(cls) -> ba.ScoreInfo:
+ return ba.ScoreInfo(label='Time Held')
@classmethod
def get_description(cls, sessiontype: Type[ba.Session]) -> str:
diff --git a/assets/src/ba_data/python/bastd/game/easteregghunt.py b/assets/src/ba_data/python/bastd/game/easteregghunt.py
index 514e8f10..72259d2e 100644
--- a/assets/src/ba_data/python/bastd/game/easteregghunt.py
+++ b/assets/src/ba_data/python/bastd/game/easteregghunt.py
@@ -47,8 +47,8 @@ class EasterEggHuntGame(ba.TeamGameActivity):
return 'Easter Egg Hunt'
@classmethod
- def get_score_info(cls) -> Dict[str, Any]:
- return {'score_name': 'Score', 'score_type': 'points'}
+ def get_score_info(cls) -> ba.ScoreInfo:
+ return ba.ScoreInfo(label='Score', scoretype=ba.ScoreType.POINTS)
@classmethod
def get_description(cls, sessiontype: Type[ba.Session]) -> str:
diff --git a/assets/src/ba_data/python/bastd/game/elimination.py b/assets/src/ba_data/python/bastd/game/elimination.py
index 57ee5e1d..d5ad91d5 100644
--- a/assets/src/ba_data/python/bastd/game/elimination.py
+++ b/assets/src/ba_data/python/bastd/game/elimination.py
@@ -172,12 +172,10 @@ class EliminationGame(ba.TeamGameActivity):
return 'Elimination'
@classmethod
- def get_score_info(cls) -> Dict[str, Any]:
- return {
- 'score_name': 'Survived',
- 'score_type': 'seconds',
- 'none_is_winner': True
- }
+ def get_score_info(cls) -> ba.ScoreInfo:
+ return ba.ScoreInfo(label='Survived',
+ scoretype=ba.ScoreType.SECONDS,
+ none_is_winner=True)
@classmethod
def get_description(cls, sessiontype: Type[ba.Session]) -> str:
diff --git a/assets/src/ba_data/python/bastd/game/football.py b/assets/src/ba_data/python/bastd/game/football.py
index 5f3be039..96e4bba9 100644
--- a/assets/src/ba_data/python/bastd/game/football.py
+++ b/assets/src/ba_data/python/bastd/game/football.py
@@ -332,8 +332,8 @@ class FootballCoopGame(ba.CoopGameActivity):
return 'Football'
@classmethod
- def get_score_info(cls) -> Dict[str, Any]:
- return {'score_type': 'milliseconds', 'score_version': 'B'}
+ def get_score_info(cls) -> ba.ScoreInfo:
+ return ba.ScoreInfo(scoretype=ba.ScoreType.MILLISECONDS, version='B')
# FIXME: Need to update co-op games to use get_score_info.
def get_score_type(self) -> str:
diff --git a/assets/src/ba_data/python/bastd/game/keepaway.py b/assets/src/ba_data/python/bastd/game/keepaway.py
index 9ab2f09e..2b17c606 100644
--- a/assets/src/ba_data/python/bastd/game/keepaway.py
+++ b/assets/src/ba_data/python/bastd/game/keepaway.py
@@ -54,8 +54,8 @@ class KeepAwayGame(ba.TeamGameActivity):
return 'Carry the flag for a set length of time.'
@classmethod
- def get_score_info(cls) -> Dict[str, Any]:
- return {'score_name': 'Time Held'}
+ def get_score_info(cls) -> ba.ScoreInfo:
+ return ba.ScoreInfo(label='Time Held')
@classmethod
def supports_session_type(cls, sessiontype: Type[ba.Session]) -> bool:
diff --git a/assets/src/ba_data/python/bastd/game/kingofthehill.py b/assets/src/ba_data/python/bastd/game/kingofthehill.py
index 61d5caab..9e7c7ca3 100644
--- a/assets/src/ba_data/python/bastd/game/kingofthehill.py
+++ b/assets/src/ba_data/python/bastd/game/kingofthehill.py
@@ -56,8 +56,8 @@ class KingOfTheHillGame(ba.TeamGameActivity):
return 'Secure the flag for a set length of time.'
@classmethod
- def get_score_info(cls) -> Dict[str, Any]:
- return {'score_name': 'Time Held'}
+ def get_score_info(cls) -> ba.ScoreInfo:
+ return ba.ScoreInfo(label='Time Held')
@classmethod
def supports_session_type(cls, sessiontype: Type[ba.Session]) -> bool:
diff --git a/assets/src/ba_data/python/bastd/game/meteorshower.py b/assets/src/ba_data/python/bastd/game/meteorshower.py
index 27c17d60..daf5bacd 100644
--- a/assets/src/ba_data/python/bastd/game/meteorshower.py
+++ b/assets/src/ba_data/python/bastd/game/meteorshower.py
@@ -53,12 +53,10 @@ class MeteorShowerGame(ba.TeamGameActivity):
return 'Meteor Shower'
@classmethod
- def get_score_info(cls) -> Dict[str, Any]:
- return {
- 'score_name': 'Survived',
- 'score_type': 'milliseconds',
- 'score_version': 'B'
- }
+ def get_score_info(cls) -> ba.ScoreInfo:
+ return ba.ScoreInfo(label='Survived',
+ scoretype=ba.ScoreType.MILLISECONDS,
+ version='B')
@classmethod
def get_description(cls, sessiontype: Type[ba.Session]) -> str:
diff --git a/assets/src/ba_data/python/bastd/game/ninjafight.py b/assets/src/ba_data/python/bastd/game/ninjafight.py
index 212408bc..2cf667b9 100644
--- a/assets/src/ba_data/python/bastd/game/ninjafight.py
+++ b/assets/src/ba_data/python/bastd/game/ninjafight.py
@@ -49,12 +49,10 @@ class NinjaFightGame(ba.TeamGameActivity):
return 'Ninja Fight'
@classmethod
- def get_score_info(cls) -> Dict[str, Any]:
- return {
- 'score_type': 'milliseconds',
- 'lower_is_better': True,
- 'score_name': 'Time'
- }
+ def get_score_info(cls) -> ba.ScoreInfo:
+ return ba.ScoreInfo(label='Time',
+ scoretype=ba.ScoreType.MILLISECONDS,
+ lower_is_better=True)
@classmethod
def get_description(cls, sessiontype: Type[ba.Session]) -> str:
diff --git a/assets/src/ba_data/python/bastd/game/race.py b/assets/src/ba_data/python/bastd/game/race.py
index c4b39d4a..f2ace834 100644
--- a/assets/src/ba_data/python/bastd/game/race.py
+++ b/assets/src/ba_data/python/bastd/game/race.py
@@ -79,12 +79,10 @@ class RaceGame(ba.TeamGameActivity):
return 'Run real fast!'
@classmethod
- def get_score_info(cls) -> Dict[str, Any]:
- return {
- 'score_name': 'Time',
- 'lower_is_better': True,
- 'score_type': 'milliseconds'
- }
+ def get_score_info(cls) -> ba.ScoreInfo:
+ return ba.ScoreInfo(label='Time',
+ lower_is_better=True,
+ scoretype=ba.ScoreType.MILLISECONDS)
@classmethod
def supports_session_type(cls, sessiontype: Type[ba.Session]) -> bool:
diff --git a/docs/ba_module.md b/docs/ba_module.md
index 2647f24b..992a54ea 100644
--- a/docs/ba_module.md
+++ b/docs/ba_module.md
@@ -1,5 +1,5 @@
-
last updated on 2020-05-07 for Ballistica version 1.5.0 build 20016
+last updated on 2020-05-07 for Ballistica version 1.5.0 build 20018
This page documents the Python classes and functions in the 'ba' module,
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please let me know. Happy modding!
@@ -28,6 +28,7 @@
ba.Node
ba.Player
ba.PlayerRecord
+ ba.ScoreInfo
ba.Session
- ba.CoopSession
@@ -172,6 +173,7 @@
- ba.MusicPlayMode
- ba.MusicType
- ba.Permission
+ - ba.ScoreType
- ba.SpecialChar
- ba.TimeFormat
- ba.TimeType
@@ -1482,7 +1484,7 @@ start_long_action(callback_when_done=ba.ContextC
Methods Inherited:
-
+
Methods Defined or Overridden:
@@ -1987,7 +1989,7 @@ its time with lingering corpses, sound effects, etc.
Methods Inherited:
Methods Defined or Overridden:
-
+
-
ba.GameActivity(settings: Dict[str, Any])
@@ -2156,38 +2158,12 @@ of the screen, so it should be as concise as possible.
Return a str name for this game type.
-
--
-
<class method>
-get_resolved_score_info() -> Dict[str, Any]
-
-Call this to return a game's score info with all missing values
-filled in with defaults. This should not be overridden; override
-get_score_info() instead.
-
-
<class method>
-get_score_info() -> Dict[str, Any]
+get_score_info() -> ba.ScoreInfo
-Return info about game scoring setup; should be overridden by games.
-
-They should return a dict containing any of the following (missing
-values will be default):
-
-'score_name': a label shown to the user for scores; 'Score',
- 'Time Survived', etc. 'Score' is the default.
-
-'lower_is_better': a boolean telling whether lower scores are
- preferable instead of higher (the default).
-
-'none_is_winner': specifies whether a score value of None is considered
- better than other scores or worse. Default is False.
-
-'score_type': can be 'seconds', 'milliseconds', or 'points'.
-
-'score_version': to change high-score lists used by a game without
- renaming the game, change this. Defaults to empty string.
+Return info about game scoring setup; can be overridden by games.
-
@@ -4008,6 +3984,66 @@ cause the powerup box to make a sound and disappear or whatnot.
+<top level class>
+
+Info about a game's scoring setup.
+
+Category: Gameplay Classes
+
+Attributes:
+
+
+-
+
str
+A label show to the user for scores; 'Score', 'Time Survived', etc.
+
+
+-
+
bool
+Whether lower scores are preferable. Higher scores are by default.
+
+
+-
+
bool
+Whether a value of None is considered better than other scores.
+By default it is not.
+
+
+-
+
ba.ScoreType
+How the score value should be displayed.
+
+
+-
+
str
+To change high-score lists used by a game without renaming the game,
+change this. Defaults to an empty string.
+
+
+
+Methods:
+
+-
+
ba.ScoreInfo(label: 'str' = 'Score', scoretype: 'ba.ScoreType' = <ScoreType.POINTS: 'p'>, lower_is_better: 'bool' = False, none_is_winner: 'bool' = False, version: 'str' = '')
+
+
+
+
+inherits from: enum.Enum
+Type of scores.
+
+Category: Enums
+
+
+Values:
+
+- SECONDS
+- MILLISECONDS
+- POINTS
+
+
<top level class>
@@ -4571,7 +4607,7 @@ of the session.
Methods Inherited:
-
+
Methods Defined or Overridden:
@@ -4669,7 +4705,7 @@ Results for a completed ba.TeamGameActivity
-
-
get_score_type(self) -> str
+get_score_type(self) -> ba.ScoreType
Get the type of score.