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