From bdefe7aa34f77c58049ba1aca4f4be4028fd72a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sat, 6 May 2023 19:02:38 +0200 Subject: [PATCH] hanabi.py: do not set values when reading discard or play actions from json. add equality operator to Action type --- hanabi.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hanabi.py b/hanabi.py index 3fbe778..794f795 100644 --- a/hanabi.py +++ b/hanabi.py @@ -48,6 +48,9 @@ class Action(): self.type = type_ self.target = target self.value = value + # enforce no values on play / discard + if self.type in [ActionType.Discard, ActionType.Play]: + self.value = None @staticmethod def from_json(action): @@ -73,6 +76,9 @@ class Action(): return "Players vote to terminate the game (code {})".format(self.value) return "Undefined action" + def __eq__(self, other): + return self.type == other.type and self.target == other.target and self.value == other.value + class HanabiInstance(): def __init__(