Skip to content

Commit

Permalink
Merge pull request #11 from deathsave/refactor/mpf-0.57.0
Browse files Browse the repository at this point in the history
Refactor/mpf 0.57.0
  • Loading branch information
unRARed authored Dec 5, 2024
2 parents 97a498e + a6175b3 commit 24eec55
Show file tree
Hide file tree
Showing 79 changed files with 700 additions and 700 deletions.
29 changes: 12 additions & 17 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Combat Pinball
name: Combat! Pinball

on:
push:
Expand All @@ -15,14 +15,15 @@ permissions:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
- name: Install system dependencies
run: |
sudo apt-get install \
build-essential git \
python3-pip python3-venv \
zlib1g-dev libjpeg-dev libtiff5-dev libtiff5-dev \
libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev \
libsdl2-mixer-dev gstreamer1.0-plugins-base \
Expand All @@ -32,22 +33,16 @@ jobs:
libavformat-dev libavcodec-dev libjpeg-dev libtiff5-dev \
libx11-dev libmtdev-dev build-essential libgl1-mesa-dev \
libgles2-mesa-dev pulseaudio lsb-release \
libgl1-mesa-dri libavfilter-dev \
libavdevice-dev libunwind-dev -y
libgl1-mesa-dri libavfilter-dev libavdevice-dev libunwind-dev -y
- name: Install app dependencies
run: |
curl https://pyenv.run | bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
pyenv install 3.6
pyenv global 3.6
pip install --upgrade pip setuptools wheel build coveralls pillow
pip install --upgrade Cython==0.24.1
pip install mpf==0.33.49
pip install mpf-mc==0.33.16
pip install --upgrade \
pip setuptools wheel build coveralls pillow
pip install --upgrade Cython==0.29.36
# Install MPF
pip install mpf==0.57.0
pip install mpf-mc==0.57.0
- name: Test
run: |
source ~/.bash_profile
python -m unittest tests/*.py
bin/test
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11.10
4 changes: 4 additions & 0 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# both mpf and mpf-mc, smart virtual,
# text only UI and force loading / no cache
mpf: mpf both -Xtav
monitor: mpf monitor
109 changes: 31 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,98 +3,51 @@ Combat by Zaccaria

Brought back from the dead by [Pinball Plaid](http://pinballplaid.com/). Thanks to the guys at [FAST](http://fastpinballdev.gdsocial.com/) and the [Mission Pinball Project](https://github.com/missionpinball) for all the support.


Development
-----------

Most of the work is handled by a YAML config which we have split into smaller
files contextually in the `./config` directory. The `./monitor` directory
is the configuration of component positioning on the virtual playfield display.

### Installing MPF

**On Ubuntu/Debian**

Get system deps

sudo apt-get -y install git libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-base gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly libgstreamer1.0-dev libxine2-ffmpeg libsmpeg-dev libswscale-dev libavformat-dev libavcodec-dev libjpeg-dev libtiff5-dev libx11-dev libmtdev-dev build-essential libgl1-mesa-dev libgles2-mesa-dev pulseaudio

Install Python w/ Pyenv.

```bash
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
pyenv install 3.5.3
pyenv global 3.5.3
echo 'if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi' >> ~/.bashrc
source ~/.bashrc
```

Install kivy, Cython and mpf

```bash
pip install kivy
pip install setuptools cython==0.25.2 --upgrade
pip install mpf mpf-mc mpf-monitor --pre
```
**On Ubuntu/Debia Linux**

See `./.github/workflows/python-app.yml` to match the CI build.

**On MacOS**

Install Homebrew.

```bash
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```

Then, install pyenv (and Python 3.5.3).

```bash
brew install pyenv
pyenv install 3.5.3
pyenv global 3.5.3
echo 'if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi' >> ~/.bashrc
source ~/.bashrc
```

...and the mac-specific deps.

```bash
wget https://mpf.kantert.net/mpf_mac_frameworks.zip
unzip mpf_mac_frameworks.zip
sudo mv Frameworks/* /Library/Frameworks/
rm -Rf Frameworks
rm -Rf __MACOSX
rm -Rf ReadMe.txt
rm -Rf License.txt
rm -Rf mpf_mac_frameworks.zip
```

Finally, install mpf-recommended `cython` version and "dev" mpf.

```bash
pip install pip setuptools cython==0.24.1 --upgrade
pip install mpf mpf-mc mpf-monitor --pre
```


Testing
-------

Run the test suite with `python -m unittest tests/*.py`.

1. Install `brew` with:
`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`
1. Install system deps and `pyenv`with:
`brew install SDL2 SDL2_mixer SDL2_image SDL2_ttf gstreamer pkg-config pyenv` and follow instructions to add `pyenv`
to your shell.
1. Install Python 3.11 with:
`pyenv install 3.11.10`
1. Install mpf with:
`pip install mpf==0.57`
1. Install mpf-mc with:
`pip install mpf-mc==0.57`
1. Install mpf-monitor with:
`pip install mpf-monitor==0.57`
1. Install foreman with:
`gem install foreman` - this makes it possible to run all 3
processes in single terminal window for local development.

### Running

- **Development** - `bin/dev` will run both `mpf` and `mpf-mc`
without the console GUI. It will also run `mpf monitor` so
you can interact with it.
- **Production** - `bin/run` will run for production using
the real hardware devices and the console GUI.
- **Test** - Run a test with `bin/test tests/test_something.py` or
simply `bin/test` to run all tests from the `./tests` folder.

Tinkering
---------

It's ideal to run 2 separate terminal sessions.

* In the first, run `mpf both -X` which will launch the MPF engine
and the media controller.
* In the other, run `mpf monitor` which will launch the virtual
playfield and state monitor.
Run `bin/dev` to start the game in development mode. Then use
the keyboard for simulating switch hits.

There is also a virtual keyboard for simulating the switch hits. Here
is what we have mapped thus far:
Here is what we have mapped thus far:

**Primary Switches**

Expand Down
8 changes: 8 additions & 0 deletions bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

if ! command -v foreman &> /dev/null
then
echo "Installing foreman..."
gem install foreman
fi
foreman start --procfile Procfile.dev
9 changes: 9 additions & 0 deletions bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

# TODO: production config once machine is ready for it
#xterm -e "sleep 5 && cd /home/unrared/grand-prix && mpf both -c production"

# temporary solution to use dev config
# and smart vitual platform
CMD="mpf both -Xtav -c development"
xterm -hold -e "source ~/.bash_profile && cd ~/grand-prix && bash -c '$CMD'"
8 changes: 8 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

if [ -z "$1" ]; then
FILES="tests/test_*.py"
else
FILES="$1"
fi
python -m unittest -v $FILES
26 changes: 26 additions & 0 deletions config/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#config_version=6

config:
- common/assets.yaml
- common/devices/displays.yaml
- development/controller.yaml
- development/display.yaml
- common/devices/flippers.yaml
- common/devices/ball_devices.yaml
- common/devices/switches.yaml
- common/devices/coils.yaml
- common/devices/autofire_coils.yaml
- common/devices/leds.yaml
- common/devices/ball_devices.yaml
- common/playfields.yaml
- common/ball_saves.yaml
- common/game.yaml
- common/shots.yaml
- common/animations.yaml
- common/widgets.yaml
- common/slides.yaml
- common/sounds.yaml
- common/players.yaml
- common/queue_relay.yaml
- common/modes.yaml
- common/keyboard.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#config_version=5
#config_version=6
animations:
scroll_right:
- property: x
Expand Down
2 changes: 1 addition & 1 deletion config/global/assets.yaml → config/common/assets.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#config_version=5
#config_version=6
assets:
sounds:
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#config_version=5
#config_version=6
ball_saves:
default:
active_time: 10s
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#config_version=5
#config_version=6
autofire_coils:
left_sling:
coil: c_slingshot_1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#config_version=5
#config_version=6
ball_devices:
bd_trough:
ball_switches:
s_trough_1
s_trough_2
- s_trough_1
- s_trough_2
tags:
trough
home
drain
- trough
- home
- drain
eject_timeouts: 1s
eject_coil: c_trough_eject
eject_targets: bd_shooter_lane
Expand All @@ -19,6 +19,7 @@ ball_devices:
bd_shooter_lane:
ball_switches: s_shooter_lane
mechanical_eject: true
eject_timeouts: 3s
bd_gun:
ball_capacity: 1
entrance_switch: s_kicker_gun
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#config_version=5
#config_version=6
coils:
c_trough_eject:
number: 0-2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#config_version=5
#config_version=6
displays:
dmd:
width: 128
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#config_version=5
#config_version=6
flippers:
left_flipper:
main_coil: c_flipper_main_1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#config_version=5
#config_version=6
lights:
l_spinner:
type: grb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#config_version=5
#config_version=6
# all switches left to right
switches:
s_tilt:
Expand Down
2 changes: 1 addition & 1 deletion config/global/game.yaml → config/common/game.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#config_version=5
#config_version=6
game:
max_players: 2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#config_version=5
#config_version=6
# For external control / debugging
keyboard:
# Left Flipper
Expand Down
2 changes: 1 addition & 1 deletion config/global/modes.yaml → config/common/modes.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#config_version=5
#config_version=6
modes:
# dont need attract here (built-in)
- initialize
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#config_version=5
#config_version=6
player_vars:
score_level:
initial_value: 0
Expand All @@ -7,3 +7,5 @@ machine_vars:
is_high_score_set:
initial_value: False
value_type: boolean
master_volume:
initial_value: 0.9
10 changes: 1 addition & 9 deletions config/global/players.yaml → config/common/players.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#config_version=5
#config_version=6
# Most "players" should be defined in modes.
# Only put exceptions here.
slide_player:
Expand Down Expand Up @@ -28,11 +28,3 @@ sound_player:
high_score_bgm:
action: stop
balldevice_bd_missile_ball_entered: missile_collect_sfx

show_player:
ball_ending{current_player.extra_balls>0}:
shoot_again_dmd:
loops: 0
ball_save_default_saving_ball:
shoot_again_dmd:
loops: 0
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#config_version=5
#config_version=6
playfields:
playfield:
tags: default
default_source_device: bd_shooter_lane
enable_ball_search: true
ball_search_timeout: 15s
ball_search_wait_after_iteration: 10s
ball_search_interval: 250ms
default_source_device: bd_shooter_lane
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#config_version=5
#config_version=6
queue_relay_player:
game_ending:
post: start_game_over
Expand Down
1 change: 1 addition & 0 deletions config/common/shots.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#config_version=6
Loading

0 comments on commit 24eec55

Please sign in to comment.