Skip to content

Commit

Permalink
feat: add base scoring and test
Browse files Browse the repository at this point in the history
  • Loading branch information
unRARed committed Nov 30, 2024
1 parent 9013361 commit 42ec827
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 1 deletion.
Binary file added .coverage
Binary file not shown.
3 changes: 2 additions & 1 deletion config/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
config:
- common/ball_devices.yaml
- common/coils.yaml
- common/game.yaml
- common/hardware.yaml
- common/lights.yaml
- common/modes.yaml
- common/sound_system.yaml
- common/players.yaml
- common/playfields.yaml
- common/slides.yaml
- common/sound_system.yaml
- common/switches.yaml
5 changes: 5 additions & 0 deletions config/common/game.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#config_version=6

game:
balls_per_game: 3
max_players: 4
55 changes: 55 additions & 0 deletions modes/base/config/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,58 @@ ball_saves:
timer_start_events: s_shooter_lane_inactive
auto_launch: true
balls_to_save: 1

variable_player:
# consider removing points
# s_disqualifier_active:
s_pop1_active:
score: 10
s_pop2_active:
score: 10
s_grooveline_active:
score: 25
s_qualifier1_active:
score: 100
bonus: 10
s_qualifier3_active:
score: 100
bonus: 10
s_qualifier2_active:
score: 100
bonus: 10
s_podium_hole_active:
score: 500
bonus: 50
s_prix_hole_active:
score: 100
bonus: 10
s_grand_hole_active:
score: 100
bonus: 10
s_spinner_active:
score: 10
bonus: 1
s_grand_advance_active:
score: 10
bonus: 10
s_prix_advance_active:
score: 10
bonus: 10
s_podium_advance1_active:
score: 10
bonus: 10
s_podium_advance2_active:
score: 10
bonus: 10
s_slingshot1_active:
score: 10
s_slingshot2_active:
score: 10
s_inlane1_active:
score: 25
s_inlane2_active:
score: 25
s_outlane1_active:
score: 50
s_outlane2_active:
score: 50
54 changes: 54 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""Tests Base Mode"""
import os

from mpf.tests.MpfGameTestCase import MpfGameTestCase

class TestBase(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_scoring(self):
self.start_game()
v = "score"

score = 0
self.assertEqual(score, self.machine.game.player.score)

self.__increment(v, "s_pop1", 10)
self.__increment(v, "s_pop2", 10)
self.__increment(v, "s_grooveline", 25)
self.__increment(v, "s_qualifier1", 100)
self.__increment(v, "s_qualifier2", 100)
self.__increment(v, "s_qualifier3", 100)
self.__increment(v, "s_podium_hole", 500)
self.__increment(v, "s_prix_hole", 100)
self.__increment(v, "s_grand_hole", 100)
self.__increment(v, "s_spinner", 10)
self.__increment(v, "s_grand_advance", 10)
self.__increment(v, "s_prix_advance", 10)
self.__increment(v, "s_podium_advance1", 10)
self.__increment(v, "s_podium_advance2", 10)
self.__increment(v, "s_slingshot1", 10)
self.__increment(v, "s_slingshot2", 10)
self.__increment(v, "s_inlane1", 25)
self.__increment(v, "s_inlane2", 25)
self.__increment(v, "s_outlane1", 50)
self.__increment(v, "s_outlane2", 50)

def __increment(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)
)

0 comments on commit 42ec827

Please sign in to comment.