From 1781614e277dacc0730d14a5e9a8efd06632d293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sun, 12 May 2019 19:29:50 +0300 Subject: [PATCH] Put a maximum length for cards --- gameloop.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gameloop.py b/gameloop.py index 92ce736..1b4dc48 100644 --- a/gameloop.py +++ b/gameloop.py @@ -143,6 +143,24 @@ def game(send, notice, voice, devoice, get_event): calls[i] = call + # Preprocess calls so that they are cut short if they're >200 chars + for i in range(len(calls)): + call = [] + combined_length = 0 + for index, part in enumerate(calls[i]): + if combined_length + len(part) > 200: + part = part[:200 - combined_length] + '…' + + call.append(part) + combined_length += len(part) + 1 + + calls[i] = call + + # Preprocess responses so that they are at max. 160 chars + for i in range(len(responses)): + if len(responses[i]) > 160: + responses[i] = responses[i][:159] + '…' + # Add a new deck to list of decks decks[code] = Deck( code = code,