add missing to_json mehods
This commit is contained in:
parent
511c3bc7c6
commit
9200371e3a
1 changed files with 13 additions and 0 deletions
|
@ -25,6 +25,12 @@ class DeckCard:
|
||||||
raise ParseError("No rank specified in deck_card")
|
raise ParseError("No rank specified in deck_card")
|
||||||
return DeckCard(suit_index, rank)
|
return DeckCard(suit_index, rank)
|
||||||
|
|
||||||
|
def to_json(self):
|
||||||
|
return {
|
||||||
|
"suitIndex": self.suitIndex,
|
||||||
|
"rank": self.rank
|
||||||
|
}
|
||||||
|
|
||||||
def colorize(self):
|
def colorize(self):
|
||||||
color = ["green", "blue", "magenta", "yellow", "white", "cyan"][self.suitIndex]
|
color = ["green", "blue", "magenta", "yellow", "white", "cyan"][self.suitIndex]
|
||||||
return colored(str(self), color)
|
return colored(str(self), color)
|
||||||
|
@ -84,6 +90,13 @@ class Action:
|
||||||
action_value
|
action_value
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def to_json(self):
|
||||||
|
return {
|
||||||
|
"type": self.type.value,
|
||||||
|
"target": self.target,
|
||||||
|
"value": self.value
|
||||||
|
}
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
match self.type:
|
match self.type:
|
||||||
case ActionType.Play:
|
case ActionType.Play:
|
||||||
|
|
Loading…
Reference in a new issue