Skip to content

Commit

Permalink
test block in scoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jabdoa2 committed May 10, 2017
1 parent 9c3d588 commit 37c21a7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
2 changes: 2 additions & 0 deletions mpf/tests/machine_files/scoring/modes/mode1/config/mode1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ scoring:
my_var2:
score: change
action: add_machine
test_score_mode:
score: 100
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ scoring:
score: 1000|block
var_a: 0|block
var_b: 1
var_c: current_player.ramps * 10|block
var_c: current_player.ramps * 10|block
test_score_mode:
score:
score: 1000
block: true
43 changes: 35 additions & 8 deletions mpf/tests/test_Scoring.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from mpf.tests.MpfTestCase import MpfTestCase
from mpf.tests.MpfGameTestCase import MpfGameTestCase


class TestScoring(MpfTestCase):
class TestScoring(MpfGameTestCase):

def getConfigFile(self):
return 'config.yaml'
Expand All @@ -11,16 +11,11 @@ def getMachinePath(self):

def test_scoring(self):
# start game with two players
self.machine.ball_controller.num_balls_known = 0
self.hit_switch_and_run("s_ball_switch1", 1)
self.advance_time_and_run(2)

# start game with two players
self.hit_and_release_switch("s_start")
self.hit_and_release_switch("s_start")
self.assertNotEqual(None, self.machine.game)
self.assertEqual(2, self.machine.game.num_players)
self.assertEqual(1, self.machine.game.player.number)
self.start_two_player_game()

self.advance_time_and_run(1)
self.release_switch_and_run("s_ball_switch1", 20)
Expand Down Expand Up @@ -165,3 +160,35 @@ def test_scoring(self):
# it should not crash
self.post_event("test_event1")
self.advance_time_and_run()

def test_blocking(self):
# start game
self.hit_switch_and_run("s_ball_switch1", 1)
self.advance_time_and_run(2)
self.start_game()

self.advance_time_and_run(1)
self.release_switch_and_run("s_ball_switch1", 20)

# start mode 1
self.post_event("start_mode1", 1)

# test scoring
self.post_event("test_score_mode", 1)
# should score 100
self.assertPlayerVarEqual(100, "score")

# start mode 2
self.post_event("start_mode2", 1)

# test scoring
self.post_event("test_score_mode", 1)
# should score 1000 (+ 100 from the previous)
self.assertPlayerVarEqual(1100, "score")

self.post_event("stop_mode2", 1)

# test scoring
self.post_event("test_score_mode", 1)
# should score 100 again (+ 1100 from the previous)
self.assertPlayerVarEqual(1200, "score")

0 comments on commit 37c21a7

Please sign in to comment.