Skip to content

Commit

Permalink
Randomised enemy damage by +-15%
Browse files Browse the repository at this point in the history
  • Loading branch information
vidoardes committed Oct 31, 2016
1 parent 7f56279 commit 1cd8c57
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions maps/world.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import random
import configparser
import decimal
import entities.enemies as enemies
import entities.npc as npc

Expand Down Expand Up @@ -86,7 +87,7 @@ def intro_text(self):

def modify_player(self, player):
if self.enemy.is_alive():
player.hp = player.hp - self.enemy.damage
player.hp = player.hp - round(round(decimal.Decimal(random.uniform(0.85, 1.15)), 2) * self.enemy.damage, 0)
print("Enemy does {} damage. You have {} HP remaining."
.format(self.enemy.damage, player.hp))

Expand All @@ -99,10 +100,10 @@ def __init__(self, x, y):
def trade(self, buyer, seller):
for i, item in enumerate(seller.inventory, 1):
print("{}. {} - {} Gold".format(i, item.name, item.value))

while True:
user_input = input("\nChoose an item or press Q to exit: ")

if user_input in ['Q', 'q']:
return
else:
Expand All @@ -117,7 +118,7 @@ def swap(self, seller, buyer, item):
if item.value > buyer.gold:
print("That's too expensive")
return

seller.inventory.remove(item)
buyer.inventory.append(item)
seller.gold = seller.gold + item.value
Expand All @@ -128,7 +129,7 @@ def check_if_trade(self, player):
while True:
print("Would you like to (B)uy, (S)ell, or (Q)uit?")
user_input = input()

if user_input in ['Q', 'q']:
return
elif user_input in ['B', 'b']:
Expand Down

0 comments on commit 1cd8c57

Please sign in to comment.