Tweaked SFX, fixed fire blast bug that allowed player to do a second spell even if mp were low.
@@ -252,8 +252,8 @@ ('value',15)])
elif item == 'ELIXIR': inventory[item] = dict([('quantity',1)]) elif item == 'Fire Blast': - inventory[item] = dict([('magic points', 25), - ('power', 10)]) + inventory[item] = dict([('magic points', 40), + ('power', 15)]) else: pass
@@ -183,6 +183,7 @@ self.allow_input = False
if self.index == (len(self.dialogue) - 1): self.state = self.begin_new_transaction() + self.notify(c.CLICK2) if not keys[pg.K_SPACE]: self.allow_input = True@@ -196,7 +197,6 @@ else:
state = 'buysell' return state - def make_selection(self, keys, current_time): """Control the selection"""
@@ -63,6 +63,7 @@ self.action_selected = False
self.just_leveled_up = False self.transition_rect = setup.SCREEN.get_rect() self.transition_alpha = 255 + self.temp_magic = self.game_data['player stats']['magic']['current'] def make_player_action_dict(self): """@@ -240,12 +241,14 @@ if self.arrow.index == (len(self.arrow.pos_list) - 1):
self.enter_select_action_state() elif self.info_box.magic_text_list[self.arrow.index] == 'Cure': magic_points = self.game_data['player inventory']['Cure']['magic points'] - if self.game_data['player stats']['magic']['current'] >= magic_points: + if self.temp_magic >= magic_points: + self.temp_magic -= magic_points self.player_actions.append(c.CURE_SPELL) self.action_selected = True elif self.info_box.magic_text_list[self.arrow.index] == 'Fire Blast': magic_points = self.game_data['player inventory']['Fire Blast']['magic points'] - if self.game_data['player stats']['magic']['current'] >= magic_points: + if self.temp_magic >= magic_points: + self.temp_magic -= magic_points self.player_actions.append(c.FIRE_SPELL) self.action_selected = True@@ -292,8 +295,11 @@
elif self.state == c.FIRE_SPELL or self.state == c.CURE_SPELL: if (self.current_time - self.timer) > 1500: if self.player_actions: - self.player_action_dict[self.player_actions[0]]() - self.player_actions.pop(0) + if not len(self.enemy_list): + self.enter_battle_won_state() + else: + self.player_action_dict[self.player_actions[0]]() + self.player_actions.pop(0) else: if len(self.enemy_list): self.enter_enemy_attack_state()@@ -489,8 +495,8 @@ """
self.notify(c.FIRE) self.state = self.info_box.state = c.FIRE_SPELL POWER = self.inventory['Fire Blast']['power'] - POWER += self.game_data['player stats']['Level'] * 5 MAGIC_POINTS = self.inventory['Fire Blast']['magic points'] + print MAGIC_POINTS self.game_data['player stats']['magic']['current'] -= MAGIC_POINTS for enemy in self.enemy_list: DAMAGE = random.randint(POWER//2, POWER)
@@ -1,6 +1,7 @@
import copy, pickle, sys, os import pygame as pg from .. import setup, tools +from .. import observer from ..components import person from .. import constants as c@@ -21,17 +22,34 @@ self.rect = self.image.get_rect(x=x,
y=y) self.index = 0 self.pos_list = [y, y+34] + self.allow_input = False + self.observers = [observer.SoundEffects()] + + def notify(self, event): + """ + Notify all observers of event. + """ + for observer in self.observers: + observer.on_notify(event) def update(self, keys): """ Update arrow position. """ - if keys[pg.K_DOWN] and not keys[pg.K_UP]: - self.index = 1 - elif keys[pg.K_UP] and not keys[pg.K_DOWN]: - self.index = 0 + if self.allow_input: + if keys[pg.K_DOWN] and not keys[pg.K_UP] and self.index == 0: + self.index = 1 + self.allow_input = False + self.notify(c.CLICK) + elif keys[pg.K_UP] and not keys[pg.K_DOWN] and self.index == 1: + self.index = 0 + self.allow_input = False + self.notify(c.CLICK) + + self.rect.y = self.pos_list[self.index] - self.rect.y = self.pos_list[self.index] + if not keys[pg.K_DOWN] and not keys[pg.K_UP]: + self.allow_input = True class DeathScene(tools._State):@@ -64,6 +82,14 @@ self.transition_surface.set_alpha(self.alpha)
if not os.path.isfile("save.p"): game_data = tools.create_game_data_dict() pickle.dump(game_data, open("save.p", "wb")) + self.observers = [observer.SoundEffects()] + + def notify(self, event): + """ + Notify all observers of event. + """ + for observer in self.observers: + observer.on_notify(event) def make_message_box(self): """@@ -151,6 +177,7 @@ self.game_data = pickle.load(open("save.p", "rb"))
elif self.arrow.index == 1: self.next = c.MAIN_MENU self.state = c.TRANSITION_OUT + self.notify(c.CLICK2) def draw_level(self, surface): """
@@ -277,7 +277,6 @@ retrieved_crown_dialogue = ['My crown! You recovered my stolen crown!!!',
'I can not believe what I see before my eyes.', 'You are truly a brave and noble warrior.', 'Henceforth, I name thee Grand Protector of this Town!', - 'Go forth and be recognized.', 'You are the greatest warrior this world has ever known.'] thank_you_dialogue = ['Thank you for retrieving my crown.', 'My kingdom is forever in your debt.']
@@ -218,7 +218,8 @@
def make_dialogue(self): """Make the list of dialogue phrases""" - return ["Welcome to the " + self.name + "!", + shop_name = "{}{}".format(self.name[0].upper(), self.name[1:]) + return ["Welcome to the " + shop_name + "!", "What weapon would you like to buy?"]@@ -253,7 +254,8 @@
def make_dialogue(self): """Make the list of dialogue phrases""" - return ["Welcome to the " + self.name + "!", + shop_name = "{}{}".format(self.name[0].upper(), self.name[1:]) + return ["Welcome to the " + shop_name + "!", "Would piece of armor would you like to buy?"]@@ -287,7 +289,8 @@
def make_dialogue(self): """Make the list of dialogue phrases""" - return ["Welcome to the " + self.name + "!", + shop_name = "{}{}".format(self.name[0].upper(), self.name[1:]) + return ["Welcome to the " + shop_name + "!", "Would magic spell would you like to buy?"]@@ -306,8 +309,8 @@
item2 = {'type': 'Fire Blast', 'price': 150, 'quantity': 1, - 'magic points': 75, - 'power': 10, + 'magic points': 40, + 'power': 15, 'dialogue': fire_dialogue} return [item1, item2]@@ -324,7 +327,8 @@
def make_dialogue(self): """Make the list of dialogue phrases""" - return ["Welcome to the " + self.name + "!", + shop_name = "{}{}".format(self.name[0].upper(), self.name[1:]) + return ["Welcome to the " + shop_name + "!", "What potion would you like to buy?"]
@@ -169,7 +169,7 @@ <property name="dialogue1" value="An evil sorceror has stolen my magic crown."/>
<property name="dialogue2" value="WIthout it, our town will be overrun by monsters!"/> <property name="dialogue3" value="Go to the NorthWest Castle and retrieve it for me."/> <property name="dialogue4" value="Here is some GOLD for supplies."/> - <property name="dialogue5" value="You are my only hope."/> + <property name="dialogue5" value="You receive 100 GOLD."/> </properties> </object> <object name="sprite" type="soldier" gid="74" x="128" y="336">