File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -22,15 +22,20 @@ def load(slug: str) -> gbt.Game:
2222 """
2323 slug = str (Path (slug )).replace ("\\ " , "/" )
2424
25+ # Try to load from file
2526 for suffix , reader in READERS .items ():
2627 resource_path = _CATALOG_RESOURCE / f"{ slug } { suffix } "
27-
2828 if resource_path .is_file ():
29- # as_file ensures we have a real filesystem path for the reader
3029 with as_file (resource_path ) as path :
3130 return reader (str (path ))
3231
33- raise FileNotFoundError (f"No catalog entry called { slug } .nfg or { slug } .efg" )
32+ # Try loading from family games
33+ fg = family_games ()
34+ if slug in fg :
35+ return fg [slug ]
36+
37+ # Raise error if game does not exist
38+ raise FileNotFoundError (f"No catalog entry called { slug } " )
3439
3540
3641def games () -> pd .DataFrame :
Original file line number Diff line number Diff line change @@ -30,6 +30,12 @@ def test_catalog_load_subdir_slug():
3030 assert isinstance (g , gbt .Game )
3131
3232
33+ def test_catalog_load_family_game ():
34+ """Test loading a game generated from code with a game family func."""
35+ g = gbt .catalog .load ("one_shot_trust" )
36+ assert isinstance (g , gbt .Game )
37+
38+
3339def test_catalog_games ():
3440 """Test games() function returns df of game slugs and titles"""
3541 all_games = gbt .catalog .games ()
You can’t perform that action at this time.
0 commit comments