Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Floor division support in dynamic values #1695

Merged
merged 2 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mpf/core/placeholder_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


# supported operators
OPERATORS = {ast.Add: op.add, ast.Sub: op.sub, ast.Mult: op.mul,
OPERATORS = {ast.Add: op.add, ast.Sub: op.sub, ast.Mult: op.mul, ast.FloorDiv: op.floordiv,
ast.Div: op.truediv, ast.Pow: op.pow, ast.BitXor: op.xor,
ast.USub: op.neg, ast.Not: op.not_, ast.Mod: op.mod}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ variable_player:
multiplier:
float: 1.5
action: set
score_floordiv:
score: 123456 // 100 * 100
set_player7:
score:
int: 10
Expand Down
3 changes: 3 additions & 0 deletions mpf/tests/test_VariablePlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ def test_variable_player(self):
self.post_event("score_float3")
self.assertPlayerVarEqual(2394, "score")

self.post_event("score_floordiv")
self.assertPlayerVarEqual(125794, "score")

# should not crash
self.post_event("set_player7")
self.post_event("add_player7")
Expand Down