From 9d80531c2ff582b3c40a067545215ea4fc3cae97 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Sun, 7 Jan 2024 10:43:02 +0000 Subject: [PATCH] Reglage des problemes avec les bonnus (#25) Reviewed-on: https://git.tipragot.fr/raphael/ponguito/pulls/25 Reviewed-by: Tipragot Co-authored-by: CoCoSol007 Co-committed-by: CoCoSol007 --- src/scenes/game.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/scenes/game.py b/src/scenes/game.py index a7302fa..b30d352 100644 --- a/src/scenes/game.py +++ b/src/scenes/game.py @@ -180,8 +180,9 @@ class Bonus(Enum): REVERSE = 3 @staticmethod - def aleatoire(): - type = random.randint(0, 3) + def aleatoire(world: World): + max = 3 if world[GameMode] == GameMode.ONE else 2 + type = random.randint(0, max) match type: case 0: return Bonus.MULTI @@ -324,7 +325,7 @@ def __spawn_ellements(world: World): def __spawn_bonus(world: World): - bonus = Bonus.aleatoire() + bonus = Bonus.aleatoire(world) world.new_entity().set( SpriteBundle( Bonus.get_texture(bonus), @@ -369,7 +370,7 @@ def __spawn_ball(world: World): def __collision_with_ball(a: Entity, b: Entity): if Ball in a: a.world.new_entity().set(Sound("bound.mp3")) - if Player1 in b or Player2 in b: + if Player1 in b or Player2 in b and Ball in a: for player in a.world.query(LastPlayerTurn): del player[LastPlayerTurn] b.set(LastPlayerTurn())