From 9200371e3a3e6f63f6170cb6761a29c74ad8af6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Tue, 8 Aug 2023 14:10:17 +0200 Subject: [PATCH] add missing to_json mehods --- src/hanabi/hanab_game.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/hanabi/hanab_game.py b/src/hanabi/hanab_game.py index 4998796..287f71e 100644 --- a/src/hanabi/hanab_game.py +++ b/src/hanabi/hanab_game.py @@ -25,6 +25,12 @@ class DeckCard: raise ParseError("No rank specified in deck_card") return DeckCard(suit_index, rank) + def to_json(self): + return { + "suitIndex": self.suitIndex, + "rank": self.rank + } + def colorize(self): color = ["green", "blue", "magenta", "yellow", "white", "cyan"][self.suitIndex] return colored(str(self), color) @@ -84,6 +90,13 @@ class Action: action_value ) + def to_json(self): + return { + "type": self.type.value, + "target": self.target, + "value": self.value + } + def __repr__(self): match self.type: case ActionType.Play: