diff options
author | yenatch <yenatch@gmail.com> | 2015-10-26 11:02:26 -0400 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2015-10-26 11:02:26 -0400 |
commit | 25025d1b6c00e94ac9e479747898d30267fb3282 (patch) | |
tree | dba5eb64a72eebec6acf5e908a64432ebb788b3d /gfx.py | |
parent | 0d17d4a75866d053f5e0b48c66deb2508071d98b (diff) | |
parent | c21b6fb28500767e621bb5facdc2e3a2e3973599 (diff) |
Merge pull request #317 from yenatch/pngs-kind-of
Pokemon and trainer pngs
Diffstat (limited to 'gfx.py')
-rw-r--r-- | gfx.py | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -12,12 +12,17 @@ pics = [ 'gfx/shrink2', ] -base_stats = None +cache = {} +def get_cache(filename): + global cache + cached = cache.get(filename) + if cached == None: + cached = open(filename).read() + cache[filename] = cached + return cached + def get_base_stats(): - global base_stats - if not base_stats: - base_stats = open('data/base_stats.asm').read() - return base_stats + return get_cache('data/base_stats.asm') def get_pokemon_dimensions(name): if name == 'egg': @@ -42,7 +47,7 @@ def filepath_rules(filepath): pokemon_name = '' if 'gfx/pics/' in filedir: - pokemon_name = filedir.split('/')[3] + pokemon_name = filedir.split('/')[-1] if pokemon_name.startswith('unown_'): index = filedir.find(pokemon_name) if index != -1: |