Skip to content

Commit

Permalink
test: reorganize and test more green flag edges
Browse files Browse the repository at this point in the history
  • Loading branch information
unRARed committed Dec 9, 2024
1 parent 3f770a7 commit b0b6ef1
Show file tree
Hide file tree
Showing 20 changed files with 290 additions and 191 deletions.
2 changes: 1 addition & 1 deletion bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ if [ -z "$1" ]; then
else
FILES="$1"
fi
python -m unittest -v $FILES
python -m unittest $FILES
4 changes: 4 additions & 0 deletions config/common/flippers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ flippers:
activation_switch: s_flipper1
eos_switch: s_flipper1_eos
enable_events: ball_starting
disable_events:
- green_flag_bad_luck
use_eos: true
label: Left Flipper
right_flipper:
Expand All @@ -15,5 +17,7 @@ flippers:
activation_switch: s_flipper2
eos_switch: s_flipper2_eos
enable_events: ball_starting
disable_events:
- green_flag_bad_luck
use_eos: true
label: Right Flipper
3 changes: 2 additions & 1 deletion config/common/slides.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#config_version=6

slides:
rear_view_hud_slide:
base_slide:
- widget: pit_background
- widget: pit_mirror
- widget: rear_view
- widget: fuel_(current_player.level_fuel)
- widget: oil_(current_player.level_oil)
Expand Down
72 changes: 38 additions & 34 deletions config/common/widgets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,65 @@ widgets:
- type: image
image: pit-background
z: 0
pit_mirror:
- type: image
image: pit-mirror
z: 1
rear_view:
- type: image
image: rear-view
z: 1
fuel_2:
- type: image
image: fuel-2
z: 4
x: 10%
y: 15%
fuel_1:
- type: image
image: fuel-1
z: 4
x: 10%
y: 15%
fuel_0:
- type: image
image: fuel-0
z: 4
x: 10%
y: 15%
z: 2
oil_2:
- type: image
image: oil-2
z: 2
z: 3
x: 9%
y: 83%
y: 85%
oil_1:
- type: image
image: oil-1
z: 2
z: 3
x: 9%
y: 83%
y: 85%
oil_0:
- type: image
image: oil-0
z: 2
z: 3
x: 9%
y: 83%
y: 85%
tires_2:
- type: image
image: tires-2
z: 3
x: 32%
y: 50%
z: 4
x: 30%
y: 52%
tires_1:
- type: image
image: tires-1
z: 3
x: 32%
y: 50%
z: 4
x: 30%
y: 52%
tires_0:
- type: image
image: tires-0
z: 3
x: 32%
y: 50%
z: 4
x: 30%
y: 52%
fuel_2:
- type: image
image: fuel-2
z: 5
x: 12%
y: 14%
fuel_1:
- type: image
image: fuel-1
z: 5
x: 12%
y: 14%
fuel_0:
- type: image
image: fuel-0
z: 5
x: 12%
y: 14%
29 changes: 0 additions & 29 deletions config/development/virtual_platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,9 @@

hardware:
platform: smart_virtual
segment_displays: virtual

virtual_segment_display_connector:
segment_displays:
- segment1

# So a dev/test game starts with balls in the trough
virtual_platform_start_active_switches:
- s_trough1
- s_trough2
- s_trough3

slides:
virtual_segment1:
widgets:
- type: segment_display_emulator
name: segment1
character_count: 7
character_slant_angle: 0
character_spacing: 14
segment_width: 0.05
segment_interval: 0.02
segment_off_color: 4b4c4a30
segment_on_color: 45a8ff
side_bevel_enabled: true
dot_enabled: false
comma_enabled: true
text: "1234567"
width: 300
height: 75
y: 100
z: 100

slide_player:
init_done: virtual_segment1
Binary file modified images/preload/pit-background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/preload/pit-mirror.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/preload/rear-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added misc/theme/Still Time.otf
Binary file not shown.
Binary file added misc/theme/grand-prix-logo.pxm
Binary file not shown.
Binary file modified misc/theme/rear-view.pxm
Binary file not shown.
18 changes: 13 additions & 5 deletions modes/base/config/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ ball_saves:

slide_player:
mode_base_started:
rear_view_hud_slide:
base_slide:
action: play
player_level_fuel: rear_view_hud_slide
player_level_fuel: base_slide
player_level_tires: base_slide
player_level_oil: base_slide

variable_player:
###########
Expand All @@ -35,15 +37,21 @@ variable_player:
s_qualifier1_active:
score: 100
bonus: 10
level_fuel: 2
level_fuel:
int: 2
action: set
s_qualifier2_active:
score: 100
bonus: 10
level_oil: 2
level_oil:
int: 2
action: set
s_qualifier3_active:
score: 100
bonus: 10
level_tires: 2
level_tires:
int: 2
action: set
s_podium_hole_active:
score: 500
bonus: 50
Expand Down
10 changes: 4 additions & 6 deletions modes/green_flag/config/green_flag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ mode:
- pit_required_oil
- pit_required_fuel
- pit_required_tires
- green_flag_wreck
- green_flag_head_gasket
- green_flag_timing_belt
- green_flag_bad_luck
restart_on_next_ball: true
priority: 100

Expand Down Expand Up @@ -98,6 +96,6 @@ event_player:
degrade_tires{current_player.level_tires == 1}:
- pit_required_tires
degrade_all:
- pit_required_fuel
- pit_required_oil
- pit_required_tires
- degrade_fuel
- degrade_oil
- degrade_tires
39 changes: 39 additions & 0 deletions tests/death_save.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
##################
# Helper Methods #
##################

# For given :var, activate given :switch and check
# whether value has increased by given :value
#
# @param var: variable to check (score, bonus, etc.)
# @param switch: switch to activate (s_spinner, s_pop1, etc.)
# @param value: amount we expect the :var to increase by
#
# Example: self.assertIncrement("score", "s_spinner", 10)
#
def _assertIncrement(self, var, switch, value):
current_val = getattr(self.machine.game.player, var)
value, getattr(self.machine.game.player, var)
self.hit_and_release_switch(switch)
self.advance_time_and_run(1)
new_val = getattr(self.machine.game.player, var)
self.assertEqual(
value, new_val - current_val,
"Expected %s, got %s" % (value, new_val - current_val)
)

def _start(self):
self.assertEqual(3,
self.machine.ball_devices.bd_trough.balls)
self.assertModeRunning('attract')
self.assertModeNotRunning('base')
self.hit_and_release_switch("s_start")
self.advance_time_and_run(1)
self.assertEqual(2,
self.machine.ball_devices["bd_trough"].balls)
self.assertEqual(1,
self.machine.ball_devices["bd_shooter_lane"].balls)
self.assertEqual(0, self.machine.playfield.balls)
self.hit_and_release_switch("s_shooter_lane")
self.advance_time_and_run(4)
self.assertEqual(1, self.machine.playfield.balls)
41 changes: 7 additions & 34 deletions tests/death_save_game_testing.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,11 @@
import os
from mpf.core.rgb_color import RGBColor
from mpf.tests.MpfGameTestCase import MpfGameTestCase
from mpf.tests.MpfMachineTestCase import MpfMachineTestCase
import tests.death_save as death_save

class DeathSaveGameTesting(MpfGameTestCase):
class DeathSaveGameTesting(MpfMachineTestCase):

def get_config_file(self):
return 'development.yaml'
def _assertIncrement(self, var, switch, value):
death_save._assertIncrement(self, var, switch, value)

def get_machine_path(self):
return os.path.abspath(os.path.join(
os.path.realpath(__file__),
os.pardir,os.pardir
))

##################
# Helper Methods #
##################

# For given :var, activate given :switch and check
# whether value has increased by given :value
#
# @param var: variable to check (score, bonus, etc.)
# @param switch: switch to activate (s_spinner, s_pop1, etc.)
# @param value: amount we expect the :var to increase by
#
# Example: self.assertIncrement("score", "s_spinner", 10)
#
def assertIncrement(self, var, switch, value):
current_val = getattr(self.machine.game.player, var)
value, getattr(self.machine.game.player, var)
self.hit_and_release_switch(switch)
self.advance_time_and_run(1)
new_val = getattr(self.machine.game.player, var)
self.assertEqual(
value, new_val - current_val,
"Expected %s, got %s" % (value, new_val - current_val)
)
def _start(self):
death_save._start(self)
11 changes: 11 additions & 0 deletions tests/death_save_mc_testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os
from mpfmc.tests.FullMpfMachineTestCase import FullMachineTestCase
import tests.death_save as death_save

class DeathSaveMcTesting(FullMachineTestCase):

def _assertIncrement(self, var, switch, value):
death_save._assertIncrement(self, var, switch, value)

def _start(self):
death_save._start(self)
43 changes: 21 additions & 22 deletions tests/test_base.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
"""Tests Base Mode"""
from tests.death_save_game_testing import DeathSaveGameTesting

class TestBase(DeathSaveGameTesting):

def test_scoring(self):
score = "score"

self.start_game()
self._start()
self.assertEqual(0, self.machine.game.player.score)
self.assertIncrement(score, "s_pop1", 10)
self.assertIncrement(score, "s_pop2", 10)
self.assertIncrement(score, "s_grooveline", 50)
self._assertIncrement(score, "s_pop1", 10)
self._assertIncrement(score, "s_pop2", 10)
self._assertIncrement(score, "s_grooveline", 50)

self.assertIncrement(score, "s_qualifier2", 100)
self.assertIncrement(score, "s_qualifier3", 100)
self.assertIncrement(score, "s_podium_hole", 500)
self.assertIncrement(score, "s_prix_hole", 100)
self.assertIncrement(score, "s_grand_hole", 100)
self.assertIncrement(score, "s_spinner", 10)
self.assertIncrement(score, "s_grand_advance", 10)
self.assertIncrement(score, "s_prix_advance", 10)
self.assertIncrement(score, "s_podium_advance1", 10)
self.assertIncrement(score, "s_podium_advance2", 10)
self.assertIncrement(score, "s_slingshot1", 10)
self.assertIncrement(score, "s_slingshot2", 10)
self.assertIncrement(score, "s_inlane1", 25)
self.assertIncrement(score, "s_inlane2", 25)
self.assertIncrement(score, "s_outlane1", 50)
self.assertIncrement(score, "s_outlane2", 50)
self._assertIncrement(score, "s_qualifier2", 100)
self._assertIncrement(score, "s_qualifier3", 100)
self._assertIncrement(score, "s_podium_hole", 500)
self._assertIncrement(score, "s_prix_hole", 100)
self._assertIncrement(score, "s_grand_hole", 100)
self._assertIncrement(score, "s_spinner", 10)
self._assertIncrement(score, "s_grand_advance", 10)
self._assertIncrement(score, "s_prix_advance", 10)
self._assertIncrement(score, "s_podium_advance1", 10)
self._assertIncrement(score, "s_podium_advance2", 10)
self._assertIncrement(score, "s_slingshot1", 10)
self._assertIncrement(score, "s_slingshot2", 10)
self._assertIncrement(score, "s_inlane1", 25)
self._assertIncrement(score, "s_inlane2", 25)
self._assertIncrement(score, "s_outlane1", 50)
self._assertIncrement(score, "s_outlane2", 50)
# Activates green_flag mode, so check last
# to prevent scoring false positives
self.assertIncrement(score, "s_qualifier1", 100)
self._assertIncrement(score, "s_qualifier1", 100)
Loading

0 comments on commit b0b6ef1

Please sign in to comment.