-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add green_flag mode with qualification test
- Loading branch information
Showing
5 changed files
with
122 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
|
||
modes: | ||
- base | ||
- green_flag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#config_version=6 | ||
|
||
|
||
variable_player: | ||
game_started: | ||
green_flags_hit: | ||
action: set | ||
int: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#config_version=6 | ||
|
||
mode: | ||
start_events: | ||
- green_flag | ||
stop_events: | ||
- s_disqualifier_active | ||
restart_on_next_ball: true | ||
priority: 100 | ||
|
||
variable_player: | ||
mode_green_flag_started: | ||
level_green_flag: | ||
action: add | ||
int: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
"""Tests Green Flag Mode""" | ||
import os | ||
|
||
from mpf.tests.MpfGameTestCase import MpfGameTestCase | ||
|
||
class TestGreenFlag(MpfGameTestCase): | ||
|
||
def get_config_file(self): | ||
return 'development.yaml' | ||
|
||
def get_machine_path(self): | ||
return os.path.abspath(os.path.join( | ||
os.path.realpath(__file__), | ||
os.pardir,os.pardir | ||
)) | ||
|
||
def test_qualification(self): | ||
self.start_game() | ||
self.assertEqual( | ||
0, self.machine.game.player.level_green_flag | ||
) | ||
self.assertModeNotRunning("green_flag") | ||
|
||
self.hit_and_release_switch("s_qualifier1") | ||
self.advance_time_and_run(1) | ||
self.assertModeRunning("green_flag") | ||
self.assertEqual( | ||
1, self.machine.game.player.level_green_flag | ||
) | ||
|
||
self.hit_and_release_switch("s_disqualifier") | ||
self.assertModeNotRunning("green_flag") | ||
|
||
# Second time around, it requires hitting two | ||
# qualifiers to start the mode | ||
self.hit_and_release_switch("s_qualifier1") | ||
self.assertModeNotRunning("green_flag") | ||
self.hit_and_release_switch("s_qualifier2") | ||
self.assertModeRunning("green_flag") | ||
self.hit_and_release_switch("s_disqualifier") | ||
|
||
# Third time around, it requires hitting | ||
# all three qualifiers | ||
self.hit_and_release_switch("s_qualifier1") | ||
self.assertModeNotRunning("green_flag") | ||
self.hit_and_release_switch("s_qualifier2") | ||
self.assertModeNotRunning("green_flag") | ||
self.hit_and_release_switch("s_qualifier3") | ||
self.assertModeRunning("green_flag") | ||
self.hit_and_release_switch("s_disqualifier") | ||
|
||
# Further attempts function the same way, | ||
# requiring all 3 qualifiers to be hit | ||
self.hit_and_release_switch("s_qualifier1") | ||
self.assertModeNotRunning("green_flag") | ||
self.hit_and_release_switch("s_qualifier2") | ||
self.assertModeNotRunning("green_flag") | ||
self.hit_and_release_switch("s_qualifier3") | ||
self.assertModeRunning("green_flag") | ||
self.hit_and_release_switch("s_disqualifier") |