all repos — Legends-RPG @ 8c36aad2af8146cf99a5d9f8a4b1c3ffce431210

A fantasy mini-RPG built with Python and Pygame.

Equipped armor now reduces effectiveness of enemy attack.
Justin Armstrong justinmeister@gmail.com
Fri, 23 May 2014 00:06:45 -0700
commit

8c36aad2af8146cf99a5d9f8a4b1c3ffce431210

parent

c5dc6b5321b8c948f5f1becc48ffa927c3b73209

3 files changed, 8 insertions(+), 4 deletions(-)

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

@@ -377,11 +377,14 @@ """

for observer in self.observers: observer.on_notify(event) - def calculate_hit(self): + def calculate_hit(self, armor_list, inventory): """ Calculate hit strength based on attack stats. """ - max_strength = self.level * 5 + armor_power = 0 + for armor in armor_list: + armor_power += inventory[armor]['power'] + max_strength = max(1, (self.level * 5) - armor_power) min_strength = 0 return random.randint(min_strength, max_strength)
M data/states/battle.pydata/states/battle.py

@@ -526,7 +526,8 @@ self.state = self.info_box.state = c.PLAYER_DAMAGED

if self.enemy_index > len(self.enemy_list) - 1: self.enemy_index = 0 enemy = self.enemy_list[self.enemy_index] - player_damage = enemy.calculate_hit() + player_damage = enemy.calculate_hit(self.inventory['equipped armor'], + self.inventory) self.damage_points.add( attackitems.HealthPoints(player_damage, self.player.rect.topright))
M data/tools.pydata/tools.py

@@ -181,7 +181,7 @@ 'Cure': dict([('magic points', 25),

('power', 50)]), 'Rapier': dict([('quantity', 1), ('value', 50), - ('power', 10)]), + ('power', 5)]), 'equipped weapon': 'Rapier', 'equipped armor': []}