Mercurial > touhou
comparison pytouhou/formats/t6rp.py @ 204:88361534c77e
Add some documentation (argh, so much left to document!)
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Tue, 01 Nov 2011 13:46:03 +0100 |
parents | 9f58e2a6e950 |
children | 5492472963b0 |
comparison
equal
deleted
inserted
replaced
203:df8b2ab54639 | 204:88361534c77e |
---|---|
9 ## This program is distributed in the hope that it will be useful, | 9 ## This program is distributed in the hope that it will be useful, |
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 ## GNU General Public License for more details. | 12 ## GNU General Public License for more details. |
13 ## | 13 ## |
14 | |
15 """Touhou 6 Replay (T6RP) files handling. | |
16 | |
17 This module provides classes for handling the Touhou 6 Replay file format. | |
18 The T6RP file format is an encrypted format describing different aspects of | |
19 a game of EoSD. Since the EoSD engine is entirely deterministic, a small | |
20 replay file is sufficient to unfold a full game. | |
21 """ | |
14 | 22 |
15 from struct import unpack | 23 from struct import unpack |
16 from io import BytesIO | 24 from io import BytesIO |
17 | 25 |
18 from pytouhou.utils.random import Random | 26 from pytouhou.utils.random import Random |
44 self.levels = [None] * 7 | 52 self.levels = [None] * 7 |
45 | 53 |
46 | 54 |
47 @classmethod | 55 @classmethod |
48 def read(cls, file, decrypt=True, verify=True): | 56 def read(cls, file, decrypt=True, verify=True): |
57 """Read a T6RP file. | |
58 | |
59 Raise an exception if the file is invalid. | |
60 Return a T6RP instance otherwise. | |
61 | |
62 Keyword arguments: | |
63 decrypt -- whether or not to decrypt the file (default True) | |
64 verify -- whether or not to verify the file's checksum (default True) | |
65 """ | |
66 | |
49 if file.read(4) != b'T6RP': | 67 if file.read(4) != b'T6RP': |
50 raise Exception | 68 raise Exception |
51 | 69 |
52 replay = cls() | 70 replay = cls() |
53 | 71 |