Player can use cure spell in battle.
Justin Armstrong justinmeister@gmail.com
Thu, 01 May 2014 20:30:45 -0700
5 files changed,
50 insertions(+),
12 deletions(-)
M
data/battlegui.py
→
data/battlegui.py
@@ -401,13 +401,19 @@ elif len(current_health) == 1:
buffer = ' ' else: buffer = '' - health_string = "Health: " + buffer + current_health + "/" + max_health + health_string = "Health: {}{}/{}".format(buffer, current_health, max_health) health_surface = self.title_font.render(health_string, True, c.NEAR_BLACK) health_rect = health_surface.get_rect(x=20, y=9) current_magic = str(self.magic_stats['current']) + if len(current_magic) == 2: + buffer = ' ' + elif len(current_magic) == 1: + buffer = ' ' + else: + buffer = '' max_magic = str(self.magic_stats['maximum']) - magic_string = "Magic: " + current_magic + "/" + max_magic + magic_string = "Magic: {}{}/{}".format(buffer, current_magic, max_magic) magic_surface = self.title_font.render(magic_string, True, c.NEAR_BLACK) magic_rect = magic_surface.get_rect(x=20, top=health_rect.bottom)
M
data/constants.py
→
data/constants.py
@@ -33,7 +33,7 @@
MAIN_FONT = 'DroidSans' -#STATES +#BATTLE STATES SELECT_ACTION = 'select action' SELECT_ENEMY = 'select enemy'@@ -51,6 +51,7 @@ PLAYER_FINISHED_ATTACK = 'player finished attack'
ENEMY_ATTACK_DAMAGE = 'enemy attack damage' DISPLAY_ENEMY_ATTACK_DAMAGE = 'display enemy attack damage' DRINK_HEALING_POTION = 'drink healing potion' +CURE_SPELL = 'cure spell' #EVENTS
M
data/observer.py
→
data/observer.py
@@ -42,7 +42,8 @@ c.ATTACK_ANIMATION: self.enemy_damaged,
c.RUN_AWAY: self.run_away, c.BATTLE_WON: self.battle_won, c.ENEMY_ATTACK_DAMAGE: self.display_enemy_attack_damage, - c.DRINK_HEALING_POTION: self.drink_healing_potion} + c.DRINK_HEALING_POTION: self.drink_healing_potion, + c.CURE_SPELL: self.cure_spell} return event_dict@@ -164,6 +165,19 @@ False))
self.level.player_healed(30) self.info_box.state = c.DRINK_HEALING_POTION + def cure_spell(self): + """ + Cast cure spell on player. + """ + self.player.healing = True + self.level.set_timer_to_current_time() + self.level.state = c.CURE_SPELL + self.arrow.become_invisible_surface() + self.level.enemy_index = 0 + self.level.damage_points.add( + attackitems.HealthPoints(50, self.player.rect.topright, False)) + self.level.player_healed(50) + self.info_box.state = c.DRINK_HEALING_POTION
M
data/states/battle.py
→
data/states/battle.py
@@ -151,7 +151,7 @@ elif self.state == c.SELECT_ENEMY:
self.state = c.PLAYER_ATTACK self.notify(self.state) - elif self.state == c.SELECT_ITEM or self.state == c.SELECT_MAGIC: + elif self.state == c.SELECT_ITEM: if self.arrow.index == (len(self.arrow.pos_list) - 1): self.state = c.SELECT_ACTION self.notify(self.state)@@ -159,6 +159,14 @@ elif self.info_box.item_text_list[self.arrow.index][:14] == 'Healing Potion':
self.state = c.DRINK_HEALING_POTION self.notify(self.state) + elif self.state == c.SELECT_MAGIC: + if self.arrow.index == (len(self.arrow.pos_list) - 1): + self.state = c.SELECT_ACTION + self.notify(self.state) + elif self.info_box.magic_text_list[self.arrow.index] == 'Cure': + self.state = c.CURE_SPELL + self.notify(self.state) + self.allow_input = False if keys[pg.K_RETURN] == False and keys[pg.K_SPACE] == False:@@ -171,7 +179,8 @@ """
timed_states = [c.DISPLAY_ENEMY_ATTACK_DAMAGE, c.ENEMY_HIT, c.ENEMY_DEAD, - c.DRINK_HEALING_POTION] + c.DRINK_HEALING_POTION, + c.CURE_SPELL] long_delay = timed_states[1:] if self.state in long_delay:@@ -183,7 +192,7 @@ if len(self.enemy_list):
self.state = c.ENEMY_ATTACK else: self.state = c.BATTLE_WON - elif self.state == c.DRINK_HEALING_POTION: + elif self.state == c.DRINK_HEALING_POTION or self.state == c.CURE_SPELL: self.state = c.ENEMY_ATTACK self.timer = self.current_time self.notify(self.state)@@ -263,9 +272,13 @@
health['current'] += heal if health['current'] > health['maximum']: health['current'] = health['maximum'] - self.game_data['player inventory']['Healing Potion']['quantity'] -= 1 - if self.game_data['player inventory']['Healing Potion']['quantity'] == 0: - del self.game_data['player inventory']['Healing Potion'] + + if self.state == c.DRINK_HEALING_POTION: + self.game_data['player inventory']['Healing Potion']['quantity'] -= 1 + if self.game_data['player inventory']['Healing Potion']['quantity'] == 0: + del self.game_data['player inventory']['Healing Potion'] + elif self.state == c.CURE_SPELL: + self.game_data['player stats']['magic points']['current'] -= 25 def set_timer_to_current_time(self): """Set the timer to the current time."""
M
data/tools.py
→
data/tools.py
@@ -173,8 +173,12 @@ carries between states"""
player_items = {'GOLD': dict([('quantity',600), ('value',0)]), - 'Healing Potion': dict([('quantity',1), - ('value',15)])} + 'Healing Potion': dict([('quantity',5), + ('value',15)]), + 'Fire Blast': dict([('value', 150), + ('quantity', 1)]), + 'Cure': dict([('value', 150), + ('quantity', 1)])} player_health = {'current': 100, 'maximum': 100}