From cb5a1436232cf8da69db8c1bfa6de3a915b535d4 Mon Sep 17 00:00:00 2001 From: Dominic Zimmer Date: Sat, 29 Oct 2022 15:26:12 +0200 Subject: [PATCH] Add random mode --- backend/backend/arbiter.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/backend/backend/arbiter.py b/backend/backend/arbiter.py index c516930..c6f2f26 100644 --- a/backend/backend/arbiter.py +++ b/backend/backend/arbiter.py @@ -204,3 +204,19 @@ async def _(get_input: InputGetter, set_output: OutputSetter): output = {button: the_input[button] for button in Button} set_output(output) + + +@arbiter.mode("random", allow_multitouch=False) +async def _(get_input: InputGetter, set_output: OutputSetter): + while True: + await asyncio.sleep(settings.democracy_vote_cycle) + + the_choice = random.choice([button for button in Button]) + + if not the_choice: + set_output(EMPTY_INPUT) + continue + + output = {button: (button == the_choice) for button in Button} + + set_output(output)