view pytouhou/resource/anmwrapper.py @ 283:b6c068c8f7f2

Fix ECL time flow. Spellcard do not stop time. Instruction 0xc does.
author Thibaut Girka <thib@sitedethib.com>
date Sun, 12 Feb 2012 02:09:16 +0100
parents dbb1a86c0235
children 2100276c289d
line wrap: on
line source

from itertools import izip, chain, repeat


class AnmWrapper(object):
    def __init__(self, anm_files, offsets=()):
        self.scripts = {}
        self.sprites = {}

        for anm, offset in izip(anm_files, chain(offsets, repeat(0))):
            for script_id, script in anm.scripts.iteritems():
                self.scripts[script_id + offset] = (anm, script) #TODO: check
            for sprite_id, sprite in anm.sprites.iteritems():
                self.sprites[sprite_id + offset] = (anm, sprite)


    def get_sprite(self, sprite_index):
        return self.sprites[sprite_index]


    def get_script(self, script_index):
        return self.scripts[script_index]