From 3f7f5299c4b3156b078fadf68c5efc923663896e Mon Sep 17 00:00:00 2001 From: ! Freaku <92618708+Freaku17@users.noreply.github.com> Date: Sat, 17 Feb 2024 02:21:33 +0530 Subject: [PATCH 1/4] Update simon_says.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Add co-op support --- plugins/minigames/simon_says.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/plugins/minigames/simon_says.py b/plugins/minigames/simon_says.py index 7cb6887..ae69a3a 100644 --- a/plugins/minigames/simon_says.py +++ b/plugins/minigames/simon_says.py @@ -102,6 +102,7 @@ class Player(bs.Player['Team']): def __init__(self) -> None: self.score = 0 + self.dead: bool = False class Team(bs.Team[Player]): @@ -230,9 +231,8 @@ class SimonSays(bs.TeamGameActivity[Player, Team]): player.score = 0 # check for immediate end if theres only 1 player if len(self.players) == 1: - bs.timer(4000/1000, lambda: self.check_end()) - else: - bs.timer(6000/1000, self.call_round) + bs.timer(4000/1000, bs.Call(self.check_end)) + bs.timer(6000/1000, self.call_round) def spawn_player(self, player: PlayerT) -> bs.Actor: assert player @@ -352,6 +352,7 @@ class SimonSays(bs.TeamGameActivity[Player, Team]): def handlemessage(self, msg) -> None: if isinstance(msg, bs.PlayerDiedMessage): + msg.getplayer(Player).dead = True self.check_end() else: super().handlemessage(msg) @@ -363,10 +364,25 @@ class SimonSays(bs.TeamGameActivity[Player, Team]): results.set_team_score(team, team.score) self.end(results=results) - def check_end(self) -> None: + def check_end(self): i = 0 for player in self.players: - if player.is_alive(): + if player.is_alive() and not player.dead: i += 1 - if i <= 2: - bs.timer(0.6, lambda: self.end_game()) + if isinstance(self.session, bs.CoopSession): + if i <= 0: + bs.timer(0.6, bs.Call(self.end_game)) + else: + if i <= 2: + bs.timer(0.6, bs.Call(self.end_game)) + + +# ba_meta export plugin +class plugin(babase.Plugin): + def __init__(self): + ## Campaign support ## + babase.app.classic.add_coop_practice_level(bs.Level( + name = 'Simon Says', + gametype=SimonSays, + settings={}, + preview_texture_name='courtyardPreview')) \ No newline at end of file From b964b1275d8b9697aebe6c8fac17dfb381fd9b2e Mon Sep 17 00:00:00 2001 From: ! Freaku <92618708+Freaku17@users.noreply.github.com> Date: Sat, 17 Feb 2024 02:21:56 +0530 Subject: [PATCH 2/4] Update JSON file --- plugins/minigames.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/minigames.json b/plugins/minigames.json index 1863190..92b2754 100644 --- a/plugins/minigames.json +++ b/plugins/minigames.json @@ -67,7 +67,7 @@ } }, "simon_says": { - "description": "You better do what Simon says", + "description": "You better do what Simon says. Playable in co-op", "external_url": "", "authors": [ { @@ -77,6 +77,7 @@ } ], "versions": { + "1.0.2": null, "1.0.1": { "api_version": 8, "commit_sha": "2b5c9ee", From 593ae6fdb2c2da0eee45833755a1b43185356292 Mon Sep 17 00:00:00 2001 From: Freaku17 Date: Fri, 16 Feb 2024 20:53:48 +0000 Subject: [PATCH 3/4] [ci] auto-format --- plugins/minigames/simon_says.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/minigames/simon_says.py b/plugins/minigames/simon_says.py index ae69a3a..4495d3a 100644 --- a/plugins/minigames/simon_says.py +++ b/plugins/minigames/simon_says.py @@ -382,7 +382,7 @@ class plugin(babase.Plugin): def __init__(self): ## Campaign support ## babase.app.classic.add_coop_practice_level(bs.Level( - name = 'Simon Says', + name='Simon Says', gametype=SimonSays, settings={}, - preview_texture_name='courtyardPreview')) \ No newline at end of file + preview_texture_name='courtyardPreview')) From a35972ee0f86965a3db111b4c368fa71000ccbdb Mon Sep 17 00:00:00 2001 From: Freaku17 Date: Fri, 16 Feb 2024 20:53:50 +0000 Subject: [PATCH 4/4] [ci] apply-version-metadata --- plugins/minigames.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/minigames.json b/plugins/minigames.json index 92b2754..3cca1c4 100644 --- a/plugins/minigames.json +++ b/plugins/minigames.json @@ -77,7 +77,12 @@ } ], "versions": { - "1.0.2": null, + "1.0.2": { + "api_version": 8, + "commit_sha": "593ae6f", + "released_on": "16-02-2024", + "md5sum": "57cd7a06f1f3169752cf77537affcf5b" + }, "1.0.1": { "api_version": 8, "commit_sha": "2b5c9ee",