Skip to content

Commit 5cd4932

Browse files
committed
Default of Color.a is now 255
Format Bump version
1 parent d004862 commit 5cd4932

File tree

6 files changed

+63
-38
lines changed

6 files changed

+63
-38
lines changed

rlbot/config.py

+42-17
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ def __enum(table: dict, key: str, enum: Any, default: int = 0) -> Any:
1616
return enum(default)
1717
try:
1818
for i in range(100000):
19-
if str(enum(i)).split('.')[-1].lower() == table[key].lower():
19+
if str(enum(i)).split(".")[-1].lower() == table[key].lower():
2020
return enum(i)
2121
except ValueError:
22-
raise ConfigParsingException(f"Invalid value {repr(table[key])} for key '{key}'.")
22+
raise ConfigParsingException(
23+
f"Invalid value {repr(table[key])} for key '{key}'."
24+
)
2325

2426

2527
def __str(table: dict, key: str, default: str = "") -> str:
@@ -51,9 +53,9 @@ def __table(table: dict, key: str) -> dict:
5153

5254

5355
def __team(table: dict) -> int:
54-
if 'team' not in table:
56+
if "team" not in table:
5557
return 0
56-
v = table['team']
58+
v = table["team"]
5759
if isinstance(v, str):
5860
if v.lower() == "blue":
5961
return 0
@@ -62,7 +64,9 @@ def __team(table: dict) -> int:
6264
if isinstance(v, int):
6365
if 0 <= v <= 1:
6466
return v
65-
raise ConfigParsingException(f"'team' has value {repr(v)}. Expected a 0, 1, \"blue\", or \"orange\".")
67+
raise ConfigParsingException(
68+
f'\'team\' has value {repr(v)}. Expected a 0, 1, "blue", or "orange".'
69+
)
6670

6771

6872
def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
@@ -83,7 +87,9 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
8387
name = __str(car_table, "name")
8488
team = __team(car_table)
8589
loadout_file = __str(car_table, "loadout_file") or None
86-
skill = __enum(car_table, "skill", flat.PsyonixSkill, int(flat.PsyonixSkill.AllStar))
90+
skill = __enum(
91+
car_table, "skill", flat.PsyonixSkill, int(flat.PsyonixSkill.AllStar)
92+
)
8793
variant = __str(car_table, "type", "rlbot").lower()
8894

8995
match variant:
@@ -97,14 +103,16 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
97103
logger.warning("PartyMember player type is not supported yet.")
98104
variety, use_config = flat.PartyMember, False
99105
case t:
100-
raise ConfigParsingException(f"Invalid player type {repr(t)} for player {len(players)}.")
106+
raise ConfigParsingException(
107+
f"Invalid player type {repr(t)} for player {len(players)}."
108+
)
101109

102110
if use_config and car_config:
103111
abs_config_path = (config_path.parent / car_config).resolve()
104-
players.append(load_player_config(abs_config_path, variety, team, name, loadout_file))
112+
players.append(load_player_config(abs_config_path, variety, team, name, loadout_file)) # type: ignore
105113
else:
106114
loadout = load_player_loadout(loadout_file, team) if loadout_file else None
107-
players.append(flat.PlayerConfiguration(variety, name, team, loadout=loadout))
115+
players.append(flat.PlayerConfiguration(variety, name, team, loadout=loadout)) # type: ignore
108116

109117
scripts = []
110118
for script_table in config.get("scripts", []):
@@ -121,14 +129,20 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
121129
overtime=__enum(mutator_table, "overtime", flat.OvertimeMutator),
122130
series_length=__enum(mutator_table, "series_length", flat.SeriesLengthMutator),
123131
game_speed=__enum(mutator_table, "game_speed", flat.GameSpeedMutator),
124-
ball_max_speed=__enum(mutator_table, "ball_max_speed", flat.BallMaxSpeedMutator),
132+
ball_max_speed=__enum(
133+
mutator_table, "ball_max_speed", flat.BallMaxSpeedMutator
134+
),
125135
ball_type=__enum(mutator_table, "ball_type", flat.BallTypeMutator),
126136
ball_weight=__enum(mutator_table, "ball_weight", flat.BallWeightMutator),
127137
ball_size=__enum(mutator_table, "ball_size", flat.BallSizeMutator),
128-
ball_bounciness=__enum(mutator_table, "ball_bounciness", flat.BallBouncinessMutator),
138+
ball_bounciness=__enum(
139+
mutator_table, "ball_bounciness", flat.BallBouncinessMutator
140+
),
129141
boost_amount=__enum(mutator_table, "boost_amount", flat.BoostAmountMutator),
130142
rumble=__enum(mutator_table, "rumble", flat.RumbleMutator),
131-
boost_strength=__enum(mutator_table, "boost_strength", flat.BoostStrengthMutator),
143+
boost_strength=__enum(
144+
mutator_table, "boost_strength", flat.BoostStrengthMutator
145+
),
132146
gravity=__enum(mutator_table, "gravity", flat.GravityMutator),
133147
demolish=__enum(mutator_table, "demolish", flat.DemolishMutator),
134148
respawn_time=__enum(mutator_table, "respawn_time", flat.RespawnTimeMutator),
@@ -148,7 +162,9 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
148162
skip_replays=__bool(match_table, "skip_replays"),
149163
instant_start=__bool(match_table, "instant_start"),
150164
mutators=mutators,
151-
existing_match_behavior=__enum(match_table, "existing_match_behavior", flat.ExistingMatchBehavior),
165+
existing_match_behavior=__enum(
166+
match_table, "existing_match_behavior", flat.ExistingMatchBehavior
167+
),
152168
enable_rendering=__bool(match_table, "enable_rendering"),
153169
enable_state_setting=__bool(match_table, "enable_state_setting"),
154170
freeplay=__bool(match_table, "freeplay"),
@@ -196,8 +212,11 @@ def load_player_loadout(path: Path | str, team: int) -> flat.PlayerLoadout:
196212

197213

198214
def load_player_config(
199-
path: Path | str, type: flat.CustomBot | flat.Psyonix, team: int,
200-
name_override: str | None = None, loadout_override: Path | str | None = None,
215+
path: Path | str,
216+
type: flat.CustomBot | flat.Psyonix,
217+
team: int,
218+
name_override: str | None = None,
219+
loadout_override: Path | str | None = None,
201220
) -> flat.PlayerConfiguration:
202221
"""
203222
Reads the bot toml file at the provided path and
@@ -217,9 +236,15 @@ def load_player_config(
217236
if CURRENT_OS == OS.LINUX and "run_command_linux" in settings:
218237
run_command = __str(settings, "run_command_linux")
219238

220-
loadout_path = path.parent / Path(__str(settings, "loadout_file")) if "loadout_file" in settings else None
239+
loadout_path = (
240+
path.parent / Path(__str(settings, "loadout_file"))
241+
if "loadout_file" in settings
242+
else None
243+
)
221244
loadout_path = loadout_override or loadout_path
222-
loadout = load_player_loadout(loadout_path, team) if loadout_path is not None else None
245+
loadout = (
246+
load_player_loadout(loadout_path, team) if loadout_path is not None else None
247+
)
223248

224249
return flat.PlayerConfiguration(
225250
type,

rlbot/managers/rendering.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ class Renderer:
2929
An interface to the debug rendering features.
3030
"""
3131

32-
transparent = flat.Color()
33-
black = flat.Color(a=255)
34-
white = flat.Color(255, 255, 255, 255)
35-
grey = gray = flat.Color(128, 128, 128, 255)
36-
blue = flat.Color(0, 0, 255, 255)
37-
red = flat.Color(255, 0, 0, 255)
38-
green = flat.Color(0, 128, 0, 255)
39-
lime = flat.Color(0, 255, 0, 255)
40-
yellow = flat.Color(255, 255, 0, 255)
41-
orange = flat.Color(225, 128, 0, 255)
42-
cyan = flat.Color(0, 255, 255, 255)
43-
pink = flat.Color(255, 0, 255, 255)
44-
purple = flat.Color(128, 0, 128, 255)
45-
teal = flat.Color(0, 128, 128, 255)
32+
transparent = flat.Color(a=0)
33+
black = flat.Color()
34+
white = flat.Color(255, 255, 255)
35+
grey = gray = flat.Color(128, 128, 128)
36+
blue = flat.Color(0, 0, 255)
37+
red = flat.Color(255, 0, 0)
38+
green = flat.Color(0, 128, 0)
39+
lime = flat.Color(0, 255, 0)
40+
yellow = flat.Color(255, 255, 0)
41+
orange = flat.Color(225, 128, 0)
42+
cyan = flat.Color(0, 255, 255)
43+
pink = flat.Color(255, 0, 255)
44+
purple = flat.Color(128, 0, 128)
45+
teal = flat.Color(0, 128, 128)
4646

4747
_logger = get_logger("renderer")
4848

rlbot/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.0.0-beta.25"
1+
__version__ = "2.0.0-beta.26"

tests/atba/atba.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ def test_state_setting(self, packet: flat.GamePacket):
143143
},
144144
{
145145
i: flat.DesiredCarState(
146-
flat.DesiredPhysics(
147-
rotation=flat.RotatorPartial(yaw=0)
148-
)
146+
flat.DesiredPhysics(rotation=flat.RotatorPartial(yaw=0))
149147
)
150148
for i, car in enumerate(packet.players)
151149
},

tests/render_fun/render_mesh.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __init__(
7272
ColoredPolygonGroup(
7373
name=group_name[0],
7474
polygons=list(),
75-
color=flat.Color(255, r, g, b),
75+
color=flat.Color(r, g, b),
7676
)
7777
)
7878

tests/render_test/render.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def do_render(self, radius: float):
6868
)
6969

7070
self.renderer.draw_rect_2d(
71-
0.75, 0.75, 0.1, 0.1, Color(255, 150, 30, 100), centered=False
71+
0.75, 0.75, 0.1, 0.1, Color(150, 30, 100), centered=False
7272
)
7373
self.renderer.draw_rect_2d(0.75, 0.75, 0.1, 0.1, self.renderer.black)
7474
for hkey, h in {
@@ -95,4 +95,6 @@ def do_render(self, radius: float):
9595

9696

9797
if __name__ == "__main__":
98-
RenderFun("testing/render_test").run(wants_match_communications=False, wants_ball_predictions=False)
98+
RenderFun("testing/render_test").run(
99+
wants_match_communications=False, wants_ball_predictions=False
100+
)

0 commit comments

Comments
 (0)