Mercurial > touhou
diff pytouhou/formats/t6rp.py @ 374:6a63fd3deb76
Use an iterator to get the keystates from a replay.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 05 Aug 2012 18:19:42 +0200 |
parents | 6deab6ad8be8 |
children | 70e2ed71b09c |
line wrap: on
line diff
--- a/pytouhou/formats/t6rp.py +++ b/pytouhou/formats/t6rp.py @@ -43,6 +43,17 @@ class Level(object): self.keys = [] + def iter_keystates(self): + counter = 0 + previous = 0 + for frame, keystate, unknown in self.keys: + while frame >= counter: + yield previous + counter += 1 + previous = keystate + + + class T6RP(object): def __init__(self): self.version = 0x102