Can now pick up items other than gold, changed brother to blue
Justin Armstrong justinmeister@gmail.com
Mon, 07 Apr 2014 17:51:51 -0700
9 files changed,
51 insertions(+),
31 deletions(-)
M
data/components/person.py
→
data/components/person.py
@@ -36,7 +36,6 @@ self.default_direction = direction
self.item = None self.wander_box = self.make_wander_box() - def create_spritesheet_dict(self, sheet_key): """Implemented by inheriting classes""" image_list = []@@ -58,7 +57,6 @@ image_dict[key] = image
return image_dict - def create_animation_dict(self): """Return a dictionary of image lists for animation""" image_dict = self.spritesheet_dict@@ -74,7 +72,6 @@ 'up': up_list,
'down': down_list} return direction_dict - def create_state_dict(self): """Return a dictionary of all state methods"""@@ -86,7 +83,6 @@ 'automoving': self.auto_moving}
return state_dict - def create_vector_dict(self): """Return a dictionary of x and y velocities set to direction keys."""@@ -96,7 +92,6 @@ 'left': (-1, 0),
'right': (1, 0)} return vector_dict - def update(self, current_time, *args): """Implemented by inheriting classes"""@@ -290,7 +285,6 @@ assert(self.rect.x % 32 == 0 or self.rect.y % 32 == 0), \
'Not centered on tile' - class Player(Person): """User controlled character"""@@ -371,8 +365,13 @@
class OldMan(Person): """Old man villager""" - def __init__(self, x, y, direction='down', state='resting'): - super(OldMan, self).__init__('oldman', x, y, direction, state) + def __init__(self, x, y, filename='oldman', direction='down', state='resting'): + super(OldMan, self).__init__(filename, x, y, direction, state) + +class OldManBrother(OldMan): + """Brother of Old Man""" + def __init__(self, x, y): + super(OldManBrother, self).__init__(x, y, 'oldmanbrother') class Well(pg.sprite.Sprite):
M
data/components/textbox.py
→
data/components/textbox.py
@@ -87,7 +87,7 @@ image.blit(self.bground, (0, 0))
if self.item: type = list(self.item.keys())[0] - total = str(self.item[type]) + total = str(self.item[type]['quantity']) dialogue = 'You received ' + total + ' ' + type + '.' self.dialogue_list = [dialogue] self.item = None@@ -180,12 +180,23 @@
def check_for_item(self): """Checks if sprite has an item to give to the player""" item = self.talking_sprite.item + type = list(item.keys())[0] + quantity = item[type]['quantity'] + value = item[type]['value'] + if item: - if 'gold' in item: - self.game_data['player inventory']['gold'] += item['gold'] + if type in self.game_data['player inventory']: + self.game_data['player inventory'][type]['quantity'] += item[type]['quantity'] + else: + self.game_data['player inventory'][type] = {'quantity': quantity, + 'value': value} + 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 return item
M
data/shopgui.py
→
data/shopgui.py
@@ -85,7 +85,7 @@
surface = pg.Surface(rect.size) surface.set_colorkey(c.BLACK) surface.blit(image, (0, 0)) - gold = self.player_inventory['gold'] + gold = self.player_inventory['GOLD']['quantity'] text = 'Gold: ' + str(gold) text_render = self.font.render(text, True, c.NEAR_BLACK) text_rect = text_render.get_rect(x=80, y=60)@@ -268,16 +268,16 @@ def buy_item(self):
"""Attempt to allow player to purchase item""" item = self.item_to_be_purchased - self.player_inventory['gold'] -= item['price'] + self.player_inventory['GOLD']['quantity'] -= item['price'] - if self.player_inventory['gold'] < 0: - self.player_inventory['gold'] += item['price'] + if self.player_inventory['GOLD']['quantity'] < 0: + self.player_inventory['GOLD']['quantity'] += item['price'] self.state = 'reject' else: if (item['type'] in self.player_inventory and self.name == 'Magic Shop'): self.state = 'hasitem' - self.player_inventory['gold'] += item['price'] + self.player_inventory['gold']['quantity'] += item['price'] else: self.state = 'accept' self.add_player_item(item)
M
data/states/brother_house/brother_house.py
→
data/states/brother_house/brother_house.py
@@ -19,9 +19,8 @@
def set_sprite_dialogue(self): """Sets unique dialogue for each sprite""" for sprite in self.sprites: - if sprite.location == [14, 6]: - sprite.dialogue = ["I am very sick. cough... cough...", - "Only an ELIXIR can help me.", - "Please go to my brother and obtain one for me.", - "He lives in a house on the NorthEast shores.", - "I will be forever in your debt."] + if sprite.location == [9, 6]: + sprite.dialogue = ["My brother is sick?!?", + "I haven't seen him in years. I had no idea he was not well.", + "Quick, take this ELIXIR to him immediately."] + sprite.item = self.game_data['old man item']
M
data/states/brother_house/sprite_start_pos.txt
→
data/states/brother_house/sprite_start_pos.txt
@@ -4,7 +4,7 @@ 0000000000000000000000000
0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 -000000000H000000000000000 +000000000J000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000
M
data/tilemap.py
→
data/tilemap.py
@@ -382,6 +382,9 @@ level_sprites.add(devil_villager)
elif letter == 'H': old_villager = person.OldMan(column*32, row*32) level_sprites.add(old_villager) + elif letter == 'J': + old_brother = person.OldManBrother(column*32, row*32) + level_sprites.add(old_brother) tile_map.close()
M
data/tools.py
→
data/tools.py
@@ -155,7 +155,9 @@
def create_game_data_dict(): """Create a dictionary of persistant values the player carries between states""" - player_items = {'gold': 600} + + player_items = {'GOLD': dict([('quantity',600), + ('value',0)])} player_health = {'current': 100, 'maximum': 100}@@ -179,7 +181,10 @@ 'castle start pos': [12, 26],
'house start pos': [12, 13], 'brother_house start pos': [12, 13], 'overworld start pos': [17, 30], - 'king item': {'gold': 500}, + 'king item': {'GOLD': dict([('quantity', 500), + ('value',0)])}, + 'old man item': {'ELIXIR': dict([('value',1000), + ('quantity',1)])}, 'player inventory': player_items, 'player stats': player_stats }