forked from jinyu121/LifeLine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptSpliter.py
More file actions
28 lines (24 loc) · 817 Bytes
/
ScriptSpliter.py
File metadata and controls
28 lines (24 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
__author__ = 'haoyu'
from GameBlock import GameBlock
class ScriptSpliter:
def __init__(self, scriptReader):
self.reader = scriptReader
def parse(self):
blocks = {}
blockName = 'game null pointer'
blocks[blockName] = GameBlock(blockName)
for line in self.reader:
# 空行,跳过
if 0 == len(line):
continue
# 注释行,跳过
if line.startswith('//'):
continue
# 区块开始
if line.startswith(':: '):
blockName = line[3:].strip()
if blockName not in blocks.keys():
blocks[blockName] = GameBlock(blockName)
continue
blocks[blockName].scripts.append(line)
return blocks