From acbf9243a764dd7510502f9ad0a674517ff64c3f Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Fri, 15 May 2020 01:30:41 +0200 Subject: Store cards as a JSON list instead of plain text Signed-off-by: Olivier Gayot --- swiftstory/Cards.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'swiftstory') diff --git a/swiftstory/Cards.py b/swiftstory/Cards.py index ce54223..a2160a9 100644 --- a/swiftstory/Cards.py +++ b/swiftstory/Cards.py @@ -1,13 +1,16 @@ +import json + + class Cards: @staticmethod def get_white_cards(lang): ''' Read the file containing the white cards and return a list of cards ''' - with open('usr/share/swiftstory/lang/' + lang + '/cards/white') as fd: - return [line.strip() for line in fd] + with open('usr/share/swiftstory/lang/' + lang + '/cards/white.json') as fh: + return json.load(fh) @staticmethod def get_black_cards(lang): ''' Read the file containing the black cards and return a list of cards ''' - with open('usr/share/swiftstory/lang/' + lang + '/cards/black') as fd: - return [line.strip() for line in fd] + with open('usr/share/swiftstory/lang/' + lang + '/cards/black.json') as fh: + return json.load(fh) -- cgit v1.2.3