# HG changeset patch # User Emmanuel Gil Peyrot # Date 1400177694 -7200 # Node ID bcff39c920ab8686f390b67b9594d018be705c5d # Parent b895ed2de71fb73969d7e4ad2790bf846f79a3de Set boss mode directly from the enemy. diff --git a/pytouhou/game/enemy.pxd b/pytouhou/game/enemy.pxd --- a/pytouhou/game/enemy.pxd +++ b/pytouhou/game/enemy.pxd @@ -47,6 +47,7 @@ cdef class Enemy(Element): cpdef set_pos(self, double x, double y, double z) cpdef move_to(self, unsigned long duration, double x, double y, double z, formula) cpdef stop_in(self, unsigned long duration, formula) + cpdef set_boss(self, bint enable) cdef bint is_visible(self, long screen_width, long screen_height) except? False cdef void check_collisions(self) except * cdef void handle_callbacks(self) except * diff --git a/pytouhou/game/enemy.pyx b/pytouhou/game/enemy.pyx --- a/pytouhou/game/enemy.pyx +++ b/pytouhou/game/enemy.pyx @@ -309,6 +309,16 @@ cdef class Enemy(Element): formula) + cpdef set_boss(self, bint enable): + if enable: + self.boss = True + self._game.boss = self + self._game.interface.set_boss_life() + else: + self.boss = False + self._game.boss = None + + cdef bint is_visible(self, long screen_width, long screen_height): if self.sprite is not None: if self.sprite.corner_relative_placement: diff --git a/pytouhou/game/game.pyx b/pytouhou/game/game.pyx --- a/pytouhou/game/game.pyx +++ b/pytouhou/game/game.pyx @@ -579,7 +579,7 @@ cdef class Game: del self.texts[key] # Disable boss mode if it is dead/it has timeout - if self.boss and self.boss._enemy.removed: + if self.boss and self.boss.removed: self.boss = None diff --git a/pytouhou/games/eosd.py b/pytouhou/games/eosd.py --- a/pytouhou/games/eosd.py +++ b/pytouhou/games/eosd.py @@ -225,12 +225,12 @@ class EoSDInterface(object): def set_boss_life(self): if not self.game.boss: return - self.boss_items[1].maximum = self.game.boss._enemy.life or 1 - self.boss_items[2].maximum = self.game.boss._enemy.life or 1 + self.boss_items[1].maximum = self.game.boss.life or 1 + self.boss_items[2].maximum = self.game.boss.life or 1 def set_spell_life(self): - self.boss_items[2].set_value(self.game.boss._enemy.low_life_trigger if self.game.boss else 0) + self.boss_items[2].set_value(self.game.boss.low_life_trigger if self.game.boss else 0) def update(self): @@ -254,7 +254,7 @@ class EoSDInterface(object): self.labels['bombs'].set_value(player_state.bombs) if self.game.boss: - boss = self.game.boss._enemy + boss = self.game.boss life_gauge = self.boss_items[1] life_gauge.set_value(boss.life) diff --git a/pytouhou/vm/eclrunner.py b/pytouhou/vm/eclrunner.py --- a/pytouhou/vm/eclrunner.py +++ b/pytouhou/vm/eclrunner.py @@ -103,7 +103,7 @@ class ECLMainRunner(object): @instruction(10) def resume_ecl(self, sub, instr_type, unk1, unk2): - boss = self._game.boss._enemy + boss = self._game.boss self._game.msg_wait = False if not boss.boss_callback: raise Exception #TODO @@ -801,12 +801,9 @@ class ECLRunner(object): # only the last one has her life displayed, # but standard enemies are blocked only until any of them is killed. if value == 0: - self._enemy.boss = True - self._game.boss = self - self._game.interface.set_boss_life() + self._enemy.set_boss(True) elif value == -1: - self._enemy.boss = False - self._game.boss = None + self._enemy.set_boss(False) else: raise Exception #TODO