Enemy attacks are variable, depends on enemy level.
Justin Armstrong justinmeister@gmail.com
Tue, 29 Apr 2014 15:12:25 -0700
2 files changed,
19 insertions(+),
2 deletions(-)
M
data/battlegui.py
→
data/battlegui.py
@@ -15,6 +15,7 @@ """
def __init__(self, game_data): self.game_data = game_data self.enemy_damage = 0 + self.player_damage = 0 self.state = c.SELECT_ACTION self.title_font = pg.font.Font(setup.FONTS[c.MAIN_FONT], 22) self.title_font.set_underline(True)@@ -36,7 +37,7 @@ c.PLAYER_ATTACK: 'Player attacks enemy.',
c.RUN_AWAY: 'Run away', c.ENEMY_HIT: self.enemy_hit(), c.ENEMY_DEAD: 'Enemy killed.', - c.DISPLAY_ENEMY_ATTACK_DAMAGE: 'Player hit with 5 damage'} + c.DISPLAY_ENEMY_ATTACK_DAMAGE: self.player_hit()} return state_dict@@ -132,6 +133,16 @@ Set enemy damage in state dictionary.
""" self.enemy_damage = enemy_damage self.state_dict[c.ENEMY_HIT] = self.enemy_hit() + + def set_player_damage(self, player_damage): + """ + Set player damage in state dictionary. + """ + self.player_damage = player_damage + self.state_dict[c.DISPLAY_ENEMY_ATTACK_DAMAGE] = self.player_hit() + + def player_hit(self): + return "Player hit with {} damage".format(self.player_damage) def update(self): """Updates info box"""
M
data/observer.py
→
data/observer.py
@@ -16,6 +16,8 @@ self.select_box = level.info_box
self.arrow = level.arrow self.player = level.player self.enemies = level.enemy_group + self.enemy_list = level.enemy_list + self.enemy_index = level.enemy_index self.set_observer_for_enemies() self.event_dict = self.make_event_dict()@@ -93,10 +95,14 @@ self.level.enemy_index += 1
self.on_notify(c.ENEMY_ATTACK) def display_enemy_attack_damage(self): + enemy = self.enemy_list[self.enemy_index] + player_damage = enemy.calculate_hit() + + self.info_box.set_player_damage(player_damage) self.info_box.state = c.DISPLAY_ENEMY_ATTACK_DAMAGE self.level.state = c.DISPLAY_ENEMY_ATTACK_DAMAGE self.level.set_timer_to_current_time() - self.level.player_damaged(5) + self.level.player_damaged(player_damage) def player_attack(self): enemy_posx = self.arrow.rect.x + 60