So what I am trying to acchive here is a hitpoint counter that takes away sum from the hitpoints and saves new value for the variable.
Player hitpoints are 42
monsters hitpoints are 15
trowing random dices
IF opponent dice is greater than players dice number
then two points are gone from players hitpoint
new player hitpoints are saved
new players hitpoints are printed.
else if players dice is greater
then two points are gone from monsters hitpoints
new monster hitpoints are saved
new player hitpoints are printed.
What I have tried to do is functions inside funtion, but I have no idea anymore how to crack this problem. This is what I got here, its farout from the pseudocode, i know. I dont know how to replace hp and save the new value for hp variable. I am not even sure is this good way to aproach this problem.
- Code: Select all
hp1 = 42
hp2 = 15
return hp1, hp2
dice1 = random.randint(1, 6)
dice2 = random.randint(1, 6)
return dice1, dice2
hp1, hp2 = hp()
dice1, dice2 = dice()
if dice1 > dice2:
print("Player rolls", + dice1)
print("Monster rolls", + dice2)
print("You hit the monter by 2 points!")
print(hp2 - 2)
if dice1 < dice2:
print("You got hit by 2 points.")
print(hp1 - 2)
So what should I do? How do i save the new hitpoint value for the hp variables? Thanks.