From b38a0af32a52f08806bf6e66aebdd228e8276d9c Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 22 Dec 2024 17:44:37 -0800 Subject: [PATCH] feat: add logic to qualify new grand_prix mode --- config/common/modes.yaml | 1 + config/common/variables.yaml | 12 ++++- modes/grand_prix/config/grand_prix.yaml | 21 ++++++++ modes/green_flag/config/green_flag.yaml | 66 ++++++++++++++++++++---- tests/test_grand_prix_mode.py | 68 +++++++++++++++++++++++++ tests/test_grooveline_mode.py | 2 - 6 files changed, 155 insertions(+), 15 deletions(-) create mode 100644 modes/grand_prix/config/grand_prix.yaml create mode 100644 tests/test_grand_prix_mode.py diff --git a/config/common/modes.yaml b/config/common/modes.yaml index 552339d..ff23615 100644 --- a/config/common/modes.yaml +++ b/config/common/modes.yaml @@ -4,3 +4,4 @@ modes: - base - green_flag - grooveline +- grand_prix diff --git a/config/common/variables.yaml b/config/common/variables.yaml index a59b379..2c7307d 100644 --- a/config/common/variables.yaml +++ b/config/common/variables.yaml @@ -11,7 +11,15 @@ player_vars: initial_value: 2 level_tires: initial_value: 2 - is_grooveline: + ########################## + ## Wizard Mode Progress ## + ########################## + # TODO: ...50 laps to complete + is_green_flag_completed: initial_value: 0 - is_grand_prix: + # just activate + is_grooveline_completed: + initial_value: 0 + # just activate + is_grand_prix_completed: initial_value: 0 diff --git a/modes/grand_prix/config/grand_prix.yaml b/modes/grand_prix/config/grand_prix.yaml new file mode 100644 index 0000000..ae8f463 --- /dev/null +++ b/modes/grand_prix/config/grand_prix.yaml @@ -0,0 +1,21 @@ +#config_version=6 + +mode: + start_events: + - logicblock_grand_prix_counter_complete + stop_events: + - multiball_grand_prix_ended + restart_on_next_ball: false + priority: 200 + +multiballs: + grand_prix: + ball_count: 1 + ball_count_type: add + shoot_again: 15s + start_events: mode_grand_prix_started + # TODO: entering all 3 "holes" adds a ball + add_a_ball_events: + - player_grand_prix_hole_counter_count{current_player.grand_prix_hole_counter_count == 3} + +# TODO: counter for each hole diff --git a/modes/green_flag/config/green_flag.yaml b/modes/green_flag/config/green_flag.yaml index 422bae4..e4092e2 100644 --- a/modes/green_flag/config/green_flag.yaml +++ b/modes/green_flag/config/green_flag.yaml @@ -113,7 +113,35 @@ counters: # keep state between mode changes but will # reset on ball end per base mode persist_state: true - debug: true + grand_counter: + count_events: s_grand_advance_active + starting_count: 0 + count_interval: 1 + count_complete_value: 5 + persist_state: true + reset_events: + - s_grand_hole_active + - logicblock_prix_counter_complete + enable_events: + - logicblock_prix_counter_complete + start_enabled: true + disable_on_complete: true + reset_on_complete: false + # NOTE: prix counter is dependent on grand_counter + prix_counter: + count_events: s_prix_advance_active + starting_count: 0 + count_interval: 1 + count_complete_value: 4 + persist_state: true + enable_events: + - logicblock_grand_counter_complete + disable_on_complete: true + grand_prix_counter: + count_events: logicblock_prix_counter_complete + starting_count: 0 + count_complete_value: 4 + reset_on_complete: false # Every 3 laps, a random event will occur random_event_player: @@ -146,16 +174,6 @@ variable_player: level_green_flag: action: add int: 1 - # Per docs, "Counters no longer save their - # state in player variables" - logicblock_lap_counter_updated: - lap_counter_count: - int: value - action: set - logicblock_grooveline_counter_updated: - grooveline_counter_count: - int: value - action: set green_flag_degrade_fuel: level_fuel: action: add @@ -191,6 +209,32 @@ variable_player: score: 20|block s_grooveline_active: score: 100|block + ######################## + ## Counter Peristence ## + ######################## + # Per docs, "Counters no longer save their + # state in player variables", so we need + # to map them manually here + logicblock_lap_counter_updated: + lap_counter_count: + int: value + action: set + logicblock_grooveline_counter_updated: + grooveline_counter_count: + int: value + action: set + logicblock_grand_counter_updated: + grand_counter_count: + int: value + action: set + logicblock_prix_counter_updated: + prix_counter_count: + int: value + action: set + logicblock_grand_prix_counter_updated: + grand_prix_counter_count: + int: value + action: set event_player: green_flag_degrade_fuel{current_player.level_fuel == 1}: diff --git a/tests/test_grand_prix_mode.py b/tests/test_grand_prix_mode.py new file mode 100644 index 0000000..1eec96c --- /dev/null +++ b/tests/test_grand_prix_mode.py @@ -0,0 +1,68 @@ +from tests.death_save_game_testing import DeathSaveGameTesting + +class TestGrandPrixMode(DeathSaveGameTesting): + + # To qualify: + # + # - Advance "GRAND" by hitting s_grand_advance + # - With GRAND lit, hit s_grand_hole to qualify "PRIX" + # - Advance "PRIX" by hitting s_prix_advance + # - With PRIX lit, hit s_prix_hole to lock in one letter + # - Repeat 3 more times to qualify "GRAND PRIX" and + # start multiball + # + def test_qualification(self): + self._start() + self._start_green_flag() + self.assertEqual(1, self.machine.playfield.balls) + self.assertEqual(True, + self.machine.counters["grand_counter"].enabled) + self.assertEqual(False, + self.machine.counters["prix_counter"].enabled) + self.assertEqual(0, + self.machine.game.player.grand_prix_counter_count) + + # After lighting GRAND, the prix_counter is + # enabled and the grand_counter is disabled + self._light_grand() + self.assertEqual(5, + self.machine.game.player.grand_counter_count) + # Main counter unaffected so far + self.assertEqual(0, + self.machine.game.player.grand_prix_counter_count) + + # After lighting PRIX, the grand_counter is + # re-enabled and user hits it 4 times + self._light_prix() + # Counter resets immediately + self.assertEqual(0, + self.machine.game.player.prix_counter_count) + # And increases "Main" grand_prix_counter + self.assertEqual(1, + self.machine.game.player.grand_prix_counter_count) + + # Repeat sequence 3 more times + for i in range(3): + self._light_grand() + self._light_prix() + self.assertEqual(4, + self.machine.game.player.grand_prix_counter_count) + + self.assertModeRunning("grand_prix") + + def _light_grand(self): + for i in range(5): + self.hit_and_release_switch("s_grand_advance") + self.assertModeRunning("green_flag") + self.assertEqual(True, + self.machine.counters["prix_counter"].enabled) + self.assertEqual(False, + self.machine.counters["grand_counter"].enabled) + + def _light_prix(self): + for i in range(4): + self.hit_and_release_switch("s_prix_advance") + self.assertEqual(True, + self.machine.counters["grand_counter"].enabled) + self.assertEqual(False, + self.machine.counters["prix_counter"].enabled) diff --git a/tests/test_grooveline_mode.py b/tests/test_grooveline_mode.py index ede7688..1b8ef27 100644 --- a/tests/test_grooveline_mode.py +++ b/tests/test_grooveline_mode.py @@ -38,8 +38,6 @@ def test_qualification(self): self.hit_switch_and_run("s_trough1", 4) self.hit_and_release_switch("s_shooter_lane") - self.assertModeRunning("base") - # Green flag mode resumes self.assertModeRunning("green_flag") self.assertEqual(2, self.machine.game.player.ball)