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:
parent
71951ac929
commit
bdefe7aa34
1 changed files with 6 additions and 0 deletions
|
@ -48,6 +48,9 @@ class Action():
|
||||||
self.type = type_
|
self.type = type_
|
||||||
self.target = target
|
self.target = target
|
||||||
self.value = value
|
self.value = value
|
||||||
|
# enforce no values on play / discard
|
||||||
|
if self.type in [ActionType.Discard, ActionType.Play]:
|
||||||
|
self.value = None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_json(action):
|
def from_json(action):
|
||||||
|
@ -73,6 +76,9 @@ class Action():
|
||||||
return "Players vote to terminate the game (code {})".format(self.value)
|
return "Players vote to terminate the game (code {})".format(self.value)
|
||||||
return "Undefined action"
|
return "Undefined action"
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return self.type == other.type and self.target == other.target and self.value == other.value
|
||||||
|
|
||||||
|
|
||||||
class HanabiInstance():
|
class HanabiInstance():
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
Loading…
Reference in a new issue