hanabi.py: do not set values when reading discard or play actions from json. add equality operator to Action type

This commit is contained in:
Maximilian Keßler 2023-05-06 19:02:38 +02:00
parent 71951ac929
commit bdefe7aa34
Signed by: max
GPG Key ID: BCC5A619923C0BA5

View File

@ -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__(