all repos — Legends-RPG @ 145b437cf4e619fc52e081dd3dba9935239867bf

A fantasy mini-RPG built with Python and Pygame.

Added Ether potions to shop, battles and inventory.
Justin Armstrong justinmeister@gmail.com
Tue, 06 May 2014 19:03:11 -0700
commit

145b437cf4e619fc52e081dd3dba9935239867bf

parent

e32036476094d15926f22b90346e2fd34f0107b5

M data/battlegui.pydata/battlegui.py

@@ -44,6 +44,7 @@ c.ENEMY_HIT: self.enemy_hit(),

c.ENEMY_DEAD: 'Enemy killed.', c.DISPLAY_ENEMY_ATTACK_DAMAGE: self.player_hit(), c.DRINK_HEALING_POTION: 'Player healed.', + c.DRINK_ETHER_POTION: 'Magic Points Increased.', c.FIRE_SPELL: 'FIRE BLAST!', c.BATTLE_WON: 'Battle won!'}

@@ -60,7 +61,7 @@ """

Make the text for when the player selects items. """ inventory = self.game_data['player inventory'] - allowed_item_list = ['Healing Potion'] + allowed_item_list = ['Healing Potion', 'Ether Potion'] title = 'SELECT ITEM' item_text_list = [title]
M data/components/attackitems.pydata/components/attackitems.py

@@ -58,8 +58,9 @@ class HealthPoints(pg.sprite.Sprite):

""" A sprite that shows how much damage an attack inflicted. """ - def __init__(self, points, topleft_pos, damage=True): + def __init__(self, points, topleft_pos, damage=True, ether=False): super(HealthPoints, self).__init__() + self.ether = ether self.damage = damage self.font = pg.font.Font(setup.FONTS[c.MAIN_FONT], 27) self.text_image = self.make_surface(points)

@@ -87,7 +88,11 @@ else:

return self.font.render('Miss', True, c.WHITE).convert_alpha() else: text = "+{}".format(str(points)) - surface = self.font.render(text, True, c.GREEN) + if self.ether: + surface = self.font.render(text, True, c.PINK) + else: + surface = self.font.render(text, True, c.GREEN) + return surface def update(self):
M data/constants.pydata/constants.py

@@ -28,6 +28,7 @@ LIGHT_BLUE = 0, 153, 204

DARK_RED = 118, 27, 12 RED = 255, 0, 0 GREEN = 0, 255, 0 +PINK = 208, 32, 144 MAIN_FONT = 'DroidSans'

@@ -51,6 +52,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' +DRINK_ETHER_POTION = 'drink ether potion' CURE_SPELL = 'cure spell' FIRE_SPELL = 'fire spell' VICTORY_DANCE = 'victory dance'
M data/menugui.pydata/menugui.py

@@ -123,11 +123,11 @@ self.get_tile = tools.get_tile

self.sword = self.get_tile(48, 0, setup.GFX['shopsigns'], 16, 16, 2) self.shield = self.get_tile(32, 0, setup.GFX['shopsigns'], 16, 16, 2) self.potion = self.get_tile(16, 0, setup.GFX['shopsigns'], 16, 16, 2) - self.possible_potions = ['Healing Potion', 'ELIXIR'] + self.possible_potions = ['Healing Potion', 'ELIXIR', 'Ether Potion'] self.possible_armor = ['Wooden Shield', 'Chain Mail'] self.possible_weapons = ['Long Sword', 'Rapier'] self.possible_magic = ['Fire Blast', 'Cure'] - self.quantity_items = ['Healing Potion', 'ELIXIR'] + self.quantity_items = ['Healing Potion', 'ELIXIR', 'Ether Potion'] self.slots = [None for i in range(6)] self.state = 'stats' self.state_dict = self.make_state_dict()
M data/observer.pydata/observer.py

@@ -44,6 +44,7 @@ c.FLEE: self.flee,

c.BATTLE_WON: self.battle_won, c.ENEMY_ATTACK_DAMAGE: self.player_damaged, c.DRINK_HEALING_POTION: self.drink_healing_potion, + c.DRINK_ETHER_POTION: self.drink_ether_potion, c.CURE_SPELL: self.cure_spell, c.FIRE_SPELL: self.fire_spell}

@@ -178,17 +179,13 @@ def drink_healing_potion(self):

""" Give player a healing potion. """ - self.player.healing = True - self.level.set_timer_to_current_time() - self.level.state = c.DRINK_HEALING_POTION - self.arrow.become_invisible_surface() - self.level.enemy_index = 0 - self.level.damage_points.add( - attackitems.HealthPoints(30, - self.player.rect.topright, - False)) - self.level.player_healed(30) - self.info_box.state = c.DRINK_HEALING_POTION + self.level.drink_healing_potion() + + def drink_ether_potion(self): + """ + Give player a ether potion. + """ + self.level.drink_ether() def cure_spell(self): """
M data/states/battle.pydata/states/battle.py

@@ -161,7 +161,9 @@ self.notify(self.state)

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.info_box.item_text_list[self.arrow.index][:5] == 'Ether': + self.state = c.DRINK_ETHER_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

@@ -187,7 +189,8 @@ """

timed_states = [c.DISPLAY_ENEMY_ATTACK_DAMAGE, c.ENEMY_HIT, c.ENEMY_DEAD, - c.DRINK_HEALING_POTION] + c.DRINK_HEALING_POTION, + c.DRINK_ETHER_POTION] long_delay = timed_states[1:] if self.state in long_delay:

@@ -198,7 +201,8 @@ self.state = c.ENEMY_ATTACK

else: self.state = c.BATTLE_WON elif (self.state == c.DRINK_HEALING_POTION or - self.state == c.CURE_SPELL): + self.state == c.CURE_SPELL or + self.state == c.DRINK_ETHER_POTION): if len(self.enemy_list): self.state = c.ENEMY_ATTACK else:

@@ -294,6 +298,9 @@ def player_damaged(self, damage):

self.game_data['player stats']['health']['current'] -= damage def player_healed(self, heal, magic_points=0): + """ + Add health from potion to game data. + """ health = self.game_data['player stats']['health'] health['current'] += heal

@@ -307,6 +314,19 @@ del self.game_data['player inventory']['Healing Potion']

elif self.state == c.CURE_SPELL: self.game_data['player stats']['magic points']['current'] -= magic_points + def magic_boost(self, magic_points): + """ + Add magic from ether to game data. + """ + magic = self.game_data['player stats']['magic points'] + magic['current'] += magic_points + if magic['current'] > magic['maximum']: + magic['current'] = magic['maximum'] + + self.game_data['player inventory']['Ether Potion']['quantity'] -= 1 + if not self.game_data['player inventory']['Ether Potion']['quantity']: + del self.game_data['player inventory']['Ether Potion'] + def set_timer_to_current_time(self): """Set the timer to the current time.""" self.timer = self.current_time

@@ -355,6 +375,39 @@ self.enemy_index = 0

self.damage_points.add( attackitems.HealthPoints(HEAL_AMOUNT, self.player.rect.topright, False)) self.player_healed(HEAL_AMOUNT, MAGIC_POINTS) + self.info_box.state = c.DRINK_HEALING_POTION + + def drink_ether(self): + """ + Drink ether potion. + """ + self.player.healing = True + self.set_timer_to_current_time() + self.state = c.DRINK_ETHER_POTION + self.arrow.become_invisible_surface() + self.enemy_index = 0 + self.damage_points.add( + attackitems.HealthPoints(30, + self.player.rect.topright, + False, + True)) + self.magic_boost(30) + self.info_box.state = c.DRINK_ETHER_POTION + + def drink_healing_potion(self): + """ + Drink Healing Potion. + """ + self.player.healing = True + self.set_timer_to_current_time() + self.state = c.DRINK_HEALING_POTION + self.arrow.become_invisible_surface() + self.enemy_index = 0 + self.damage_points.add( + attackitems.HealthPoints(30, + self.player.rect.topright, + False)) + self.player_healed(30) self.info_box.state = c.DRINK_HEALING_POTION
M data/states/shop.pydata/states/shop.py

@@ -266,6 +266,7 @@

def make_purchasable_items(self): """Make list of items to be chosen""" healing_dialogue = 'Healing Potion (15 gold)' + ether_dialogue = 'Ether Potion (15 gold)' item = {'type': 'Healing Potion',

@@ -273,5 +274,10 @@ 'price': 15,

'quantity': 1, 'dialogue': healing_dialogue} - return [item] + item2 = {'type': 'Ether Potion', + 'price': 15, + 'quantity': 1, + 'dialogue': ether_dialogue} + + return [item, item2]
M data/tools.pydata/tools.py

@@ -175,6 +175,8 @@ player_items = {'GOLD': dict([('quantity',600),

('value',0)]), '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),
M resources/tmx/dungeon2.tmxresources/tmx/dungeon2.tmx

@@ -140,9 +140,9 @@ </object>

<object name="sprite" type="treasurechest" gid="51" x="352" y="64"> <properties> <property name="dialogue length" value="1"/> - <property name="dialogue0" value="You found a Healing Potion."/> + <property name="dialogue0" value="You found an Ether Potion."/> <property name="id" value="3"/> - <property name="item" value="Healing Potion"/> + <property name="item" value="Ether Potion"/> </properties> </object> <object name="sprite" type="treasurechest" gid="51" x="208" y="224">
M resources/tmx/dungeon4.tmxresources/tmx/dungeon4.tmx

@@ -142,9 +142,9 @@ </object>

<object name="sprite" type="treasurechest" gid="51" x="192" y="208"> <properties> <property name="dialogue length" value="1"/> - <property name="dialogue0" value="You found a Healing Potion"/> + <property name="dialogue0" value="You found an Ether Potion."/> <property name="id" value="4"/> - <property name="item" value="Healing Potion"/> + <property name="item" value="Ether Potion"/> </properties> </object> <object name="sprite" type="treasurechest" gid="51" x="192" y="368">