Skip to content

Commit

Permalink
Merge pull request #1695 from missionpinball/floor-division-in-dynami…
Browse files Browse the repository at this point in the history
…c-values

feat: Floor division support in dynamic values
  • Loading branch information
toomanybrians authored May 18, 2023
2 parents 35e94a9 + dac82eb commit b516a97
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
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

0 comments on commit b516a97

Please sign in to comment.