From 4e0efbabd98e28202f8f7b4b258546bbb608906b Mon Sep 17 00:00:00 2001 From: Nick Dyer Date: Fri, 4 Jun 2021 00:15:01 -0400 Subject: [PATCH] added description for the SelectionEgg, added .json files for each currently added egg --- pocket_friends/game_files/game.py | 7 +++++++ .../game_files/resources/data/egg_info/blue.json | 1 + .../game_files/resources/data/egg_info/rainbow.json | 1 + pocket_friends/game_files/resources/data/egg_info/red.json | 1 + 4 files changed, 10 insertions(+) create mode 100644 pocket_friends/game_files/resources/data/egg_info/blue.json create mode 100644 pocket_friends/game_files/resources/data/egg_info/rainbow.json create mode 100644 pocket_friends/game_files/resources/data/egg_info/red.json diff --git a/pocket_friends/game_files/game.py b/pocket_friends/game_files/game.py index f9efb56..9fa430d 100644 --- a/pocket_friends/game_files/game.py +++ b/pocket_friends/game_files/game.py @@ -81,8 +81,15 @@ class SelectionEgg(pygame.sprite.Sprite): def __init__(self, egg_color): pygame.sprite.Sprite.__init__(self) + # Loads the JSON file of the egg to read in data. + with open(script_dir + '/resources/data/egg_info/{0}.json'.format(egg_color), 'r') as save_file: + json_file = json.load(save_file) + save_file.close() image_directory = script_dir + '/resources/images/egg_images/{0}'.format(egg_color) + # Gets the description off the egg from the JSON file. + self.description = json_file.get('description') + # Load the egg from the given color and get the bounding rectangle for the image. self.images = [] for filename in os.listdir(image_directory): diff --git a/pocket_friends/game_files/resources/data/egg_info/blue.json b/pocket_friends/game_files/resources/data/egg_info/blue.json new file mode 100644 index 0000000..780dd86 --- /dev/null +++ b/pocket_friends/game_files/resources/data/egg_info/blue.json @@ -0,0 +1 @@ +{"description": "Blue egg description"} \ No newline at end of file diff --git a/pocket_friends/game_files/resources/data/egg_info/rainbow.json b/pocket_friends/game_files/resources/data/egg_info/rainbow.json new file mode 100644 index 0000000..e4f43a2 --- /dev/null +++ b/pocket_friends/game_files/resources/data/egg_info/rainbow.json @@ -0,0 +1 @@ +{"description": "Rainbow egg description"} \ No newline at end of file diff --git a/pocket_friends/game_files/resources/data/egg_info/red.json b/pocket_friends/game_files/resources/data/egg_info/red.json new file mode 100644 index 0000000..bbf92c9 --- /dev/null +++ b/pocket_friends/game_files/resources/data/egg_info/red.json @@ -0,0 +1 @@ +{"description": "Red egg description"} \ No newline at end of file