ref: b74abd7c21c3735a8010e5a9c6022936d9cd18b2
parent: 62596e14c6ab288f09be9eee04f2efd7e11dfa5a
author: yenatch <yenatch@gmail.com>
date: Mon Aug 31 18:31:39 EDT 2015
Generalize get_base_stats.
--- a/gfx.py
+++ b/gfx.py
@@ -12,12 +12,17 @@
'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':