comparison pytouhou/vm/eclrunner.py @ 306:52d791bb7c32

Rename a few attributes/methods to make a little more sense.
author Thibaut Girka <thib@sitedethib.com>
date Tue, 13 Mar 2012 19:18:14 +0100
parents f3099ebf4f61
children 5930b33a0370
comparison
equal deleted inserted replaced
305:5492472963b0 306:52d791bb7c32
25 25
26 class ECLMainRunner(object): 26 class ECLMainRunner(object):
27 __metaclass__ = MetaRegistry 27 __metaclass__ = MetaRegistry
28 __slots__ = ('_ecl', '_game', 'processes', 'frame', 28 __slots__ = ('_ecl', '_game', 'processes', 'frame',
29 'instruction_pointer', 29 'instruction_pointer',
30 'time_stopped') 30 'boss_wait')
31 31
32 def __init__(self, ecl, game): 32 def __init__(self, ecl, game):
33 self._ecl = ecl 33 self._ecl = ecl
34 self._game = game 34 self._game = game
35 self.frame = 0 35 self.frame = 0
36 self.time_stopped = False 36 self.boss_wait = False
37 37
38 self.processes = [] 38 self.processes = []
39 39
40 self.instruction_pointer = 0 40 self.instruction_pointer = 0
41 41
42 42
43 def run_iter(self): 43 def run_iter(self):
44 if not self._game.boss: 44 if not self._game.boss:
45 self.time_stopped = False 45 self.boss_wait = False
46 46
47 while True: 47 while True:
48 try: 48 try:
49 frame, sub, instr_type, args = self._ecl.main[self.instruction_pointer] 49 frame, sub, instr_type, args = self._ecl.main[self.instruction_pointer]
50 except IndexError: 50 except IndexError:
51 break 51 break
52 52
53 # The msg_wait instruction stops the reading of the ECL, not just the frame incrementation. 53 # The msg_wait instruction stops the reading of the ECL, not just the frame incrementation.
54 if frame > self.frame or self._game.msg_wait or self.time_stopped: 54 if frame > self.frame or self._game.msg_wait or self.boss_wait:
55 break 55 break
56 else: 56 else:
57 self.instruction_pointer += 1 57 self.instruction_pointer += 1
58 58
59 if frame == self.frame: 59 if frame == self.frame:
65 callback(self, sub, instr_type, *args) 65 callback(self, sub, instr_type, *args)
66 66
67 self.processes[:] = (process for process in self.processes 67 self.processes[:] = (process for process in self.processes
68 if process.run_iteration()) 68 if process.run_iteration())
69 69
70 if not (self._game.msg_wait or self.time_stopped): 70 if not (self._game.msg_wait or self.boss_wait):
71 self.frame += 1 71 self.frame += 1
72 72
73 73
74 def _pop_enemy(self, sub, instr_type, x, y, z, life, bonus_dropped, die_score): 74 def _pop_enemy(self, sub, instr_type, x, y, z, life, bonus_dropped, die_score):
75 if instr_type & 4: 75 if instr_type & 4:
118 else: 118 else:
119 raise Exception #TODO 119 raise Exception #TODO
120 120
121 121
122 @instruction(12) 122 @instruction(12)
123 def stop_time(self, sub, instr_type): 123 def wait_for_boss_death(self, sub, instr_type):
124 self.time_stopped = True 124 self.boss_wait = True
125 125
126 126
127 127
128 128
129 class ECLRunner(object): 129 class ECLRunner(object):
806 def set_spellcard(self, face, number, name): 806 def set_spellcard(self, face, number, name):
807 #TODO: display it on the game. 807 #TODO: display it on the game.
808 #TODO: make the enemies more resistants (and find how). 808 #TODO: make the enemies more resistants (and find how).
809 self._game.change_bullets_into_star_items() 809 self._game.change_bullets_into_star_items()
810 self._game.spellcard = (number, name) 810 self._game.spellcard = (number, name)
811 self._game.enable_effect() 811 self._game.enable_spellcard_effect()
812 812
813 813
814 @instruction(94) 814 @instruction(94)
815 def end_spellcard(self): 815 def end_spellcard(self):
816 #TODO: return everything back to normal 816 #TODO: return everything back to normal
817 #TODO: give the spellcard bonus. 817 #TODO: give the spellcard bonus.
818 if self._game.spellcard: 818 if self._game.spellcard:
819 self._game.change_bullets_into_star_items() 819 self._game.change_bullets_into_star_items()
820 self._game.spellcard = None 820 self._game.spellcard = None
821 self._game.disable_effect() 821 self._game.disable_spellcard_effect()
822 822
823 823
824 @instruction(95) 824 @instruction(95)
825 def pop_enemy(self, sub, x, y, z, life, bonus_dropped, die_score): 825 def pop_enemy(self, sub, x, y, z, life, bonus_dropped, die_score):
826 self._game.ecl_runner._pop_enemy(sub, 0, self._getval(x), 826 self._game.ecl_runner._pop_enemy(sub, 0, self._getval(x),