Brothers side quest fully functional.
Justin Armstrong justinmeister@gmail.com
Thu, 08 May 2014 10:53:07 -0700
3 files changed,
62 insertions(+),
10 deletions(-)
M
data/components/textbox.py
→
data/components/textbox.py
@@ -143,6 +143,7 @@ self.textbox = ItemBox(dialogue, index)
elif self.talking_sprite.item: self.check_for_item() else: + self.dialogue_reset() self.talking_sprite = None self.level.state = 'normal' self.textbox = None@@ -186,20 +187,23 @@ item = self.talking_sprite.item
if item: if item in self.game_data['player inventory']: - self.game_data['player inventory'][item]['quantity'] += 1 + if 'quantity' in self.game_data['player inventory'][item]: + self.game_data['player inventory'][item]['quantity'] += 1 else: self.add_new_item_to_inventory(item) self.update_game_items_info(self.talking_sprite) self.talking_sprite.item = None - if self.talking_sprite.name == 'king': - self.game_data['king item'] = None - elif self.talking_sprite.name == 'oldmanbrother': - self.game_data['old man item'] = None - elif self.talking_sprite.name == 'treasurechest': + if self.talking_sprite.name == 'treasurechest': self.talking_sprite.dialogue = ['Empty.'] + if item == 'ELIXIR': + self.game_data['has brother elixir'] = True + self.game_data['old man gift'] = 'Fire Blast' + dialogue = ['Hurry! There is precious little time.'] + self.level.reset_dialogue = self.talking_sprite, dialogue + def add_new_item_to_inventory(self, item): inventory = self.game_data['player inventory'] potions = ['Healing Potion', 'Ether Potion']@@ -208,6 +212,9 @@ inventory[item] = dict([('quantity',1),
('value',15)]) elif item == 'ELIXIR': inventory[item] = dict([('quantity',1)]) + elif item == 'Fire Blast': + inventory[item] = dict([('magic points', 25), + ('power', 10)]) else: pass@@ -245,3 +252,13 @@ def open_chest(self, sprite):
if sprite.name == 'treasurechest': sprite.index = 1 + def dialogue_reset(self): + """ + Reset dialogue if necessary. + """ + if self.level.reset_dialogue: + sprite = self.level.reset_dialogue[0] + dialogue = self.level.reset_dialogue[1] + sprite.dialogue = dialogue + self.level.reset_dialogue = () +
M
data/states/levels.py
→
data/states/levels.py
@@ -30,6 +30,7 @@ """
self.game_data = game_data self.current_time = current_time self.state = 'normal' + self.reset_dialogue = () self.switch_to_battle = False self.allow_input = False self.cut_off_bottom_map = ['castle', 'town', 'dungeon']@@ -167,7 +168,14 @@ 'king': person.Person('king', x, y, direction),
'treasurechest': person.Chest(x, y, id)} sprite = sprite_dict[properties['type']] - sprite.item = item + if sprite.name == 'oldman': + if self.game_data['old man gift']: + sprite.item = self.game_data['old man gift'] + self.game_data['old man gift'] = {} + else: + sprite.item = item + else: + sprite.item = item self.assign_dialogue(sprite, properties) self.check_for_opened_chest(sprite) sprites.add(sprite)@@ -182,6 +190,31 @@ dialogue_list = []
for i in range(int(property_dict['dialogue length'])): dialogue_list.append(property_dict['dialogue'+str(i)]) sprite.dialogue = dialogue_list + + if sprite.name == 'oldman': + if self.game_data['has brother elixir']: + if self.game_data['elixir received']: + sprite.dialogue = ['My good health is thanks to you.', + 'I will be forever in your debt.'] + else: + sprite.dialogue = ['Thank you for reaching my brother.', + 'This ELIXIR will cure my ailment.', + 'As a reward, I will teach you a magic spell.', + 'Use it wisely.', + 'You learned FIRE BLAST.'] + del self.game_data['player inventory']['ELIXIR'] + self.game_data['elixir received'] = True + dialogue = ['My good health is thanks to you.', + 'I will be forever in your debt.'] + self.reset_dialogue = sprite, dialogue + elif sprite.name == 'oldmanbrother': + if self.game_data['has brother elixir']: + if self.game_data['elixir received']: + sprite.dialogue = ['I am glad my brother is doing well.', + 'You have wise and generous spirit.'] + else: + sprite.dialogue = ['Hurry! There is precious little time.'] + def check_for_opened_chest(self, sprite): if sprite.name == 'treasurechest':
M
data/tools.py
→
data/tools.py
@@ -177,8 +177,6 @@ 'Healing Potion': dict([('quantity',5),
('value',15)]), 'Ether Potion': dict([('quantity',5), ('value', 15)]), - 'Fire Blast': dict([('magic points', 25), - ('power', 10)]), 'Cure': dict([('magic points', 25), ('power', 50)])}@@ -210,7 +208,11 @@ 'treasure1': True,
'treasure2': True, 'treasure3': True, 'treasure4': True, - 'treasure5': True + 'treasure5': True, + 'brother quest complete': False, + 'has brother elixir': False, + 'elixir received': False, + 'old man gift': '' } return data_dict