Skip to content

Commit

Permalink
feat: add logic to qualify new grand_prix mode
Browse files Browse the repository at this point in the history
  • Loading branch information
unRARed committed Dec 23, 2024
1 parent 56fc088 commit b38a0af
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 15 deletions.
1 change: 1 addition & 0 deletions config/common/modes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ modes:
- base
- green_flag
- grooveline
- grand_prix
12 changes: 10 additions & 2 deletions config/common/variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions modes/grand_prix/config/grand_prix.yaml
Original file line number Diff line number Diff line change
@@ -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
66 changes: 55 additions & 11 deletions modes/green_flag/config/green_flag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}:
Expand Down
68 changes: 68 additions & 0 deletions tests/test_grand_prix_mode.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 0 additions & 2 deletions tests/test_grooveline_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b38a0af

Please sign in to comment.