all repos — Legends-RPG @ ac0b622d09ad6f6bc948f4a6ed8f83fb7ad3b60c

A fantasy mini-RPG built with Python and Pygame.

Minor refactor of stat menu
Justin Armstrong justinmeister@gmail.com
Tue, 29 Apr 2014 15:27:11 -0700
commit

ac0b622d09ad6f6bc948f4a6ed8f83fb7ad3b60c

parent

4645ed014caaacc7e7e223db3fb522ffef4b1df1

3 files changed, 18 insertions(+), 9 deletions(-)

jump to
M data/components/person.pydata/components/person.py

@@ -377,7 +377,7 @@ def calculate_hit(self):

""" Calculate hit strength based on attack stats. """ - max_strength = 5 + (self.level * 5) + max_strength = self.level * 5 min_strength = max_strength // 2 return random.randint(min_strength, max_strength)

@@ -421,6 +421,14 @@ elif self.keys[pg.K_LEFT]:

self.begin_moving('left') elif self.keys[pg.K_RIGHT]: self.begin_moving('right') + + def calculate_hit(self): + """ + Calculate hit strength based on attack stats. + """ + max_strength = 5 + (self.level * 5) + min_strength = max_strength // 2 + return random.randint(min_strength, max_strength)
M data/menugui.pydata/menugui.py

@@ -152,11 +152,16 @@ surface, rect = self.make_blank_info_box(title)

for i, stat in enumerate(stat_list): if stat == 'health' or stat == 'magic points': - text = (stat[0].upper() + stat[1:] + ": " + - str(self.player_stats[stat]['current']) + - " / " + str(self.player_stats[stat]['maximum'])) + text = "{}{}: {} / {}".format(stat[0].upper(), + stat[1:], + str(self.player_stats[stat]['current']), + str(self.player_stats[stat]['maximum'])) + elif stat == 'experience to next level': + text = "{}{}: {}".format(stat[0].upper(), + stat[1:], + self.player_stats[stat]) else: - text = stat + ": " + str(self.player_stats[stat]) + text = "{}: {}".format(stat, str(self.player_stats[stat])) text_image = self.font.render(text, True, c.NEAR_BLACK) text_rect = text_image.get_rect(x=50, y=80+(i*50)) surface.blit(text_image, text_rect)
M data/states/player_menu.pydata/states/player_menu.py

@@ -16,7 +16,6 @@ self.allow_input = False

self.background = self.make_background() self.gui = menugui.MenuGui(level, inventory, stats) - def make_background(self): """Makes the generic black/blue background""" background = pg.sprite.Sprite()

@@ -30,7 +29,6 @@

background.image.blit(player.image, player.rect) return background - def make_sprite(self, key, coordx, coordy, x=40, y=25): """Get the image for the player"""

@@ -49,11 +47,9 @@ sprite.rect = rect

return sprite - def update(self, surface, keys): self.gui.update(keys) self.draw(surface) - def draw(self, surface): surface.blit(self.background.image, self.background.rect)