Hello, i'm trying to make the damage of the sword random, i mean it is but its not changing values and its always the same
import time
from random import randint
#Player stats
player_hp = 100
player_dmg = 20
player_gold = 100
iron_sword = 1
gold_sword = 0
#Enemy stats
enemy_hp = 100
enemy_dmg = 10
#Swords
if iron_sword ==1:
player_dmg = (randint(20,30))
if gold_sword ==1:
player_dmg = (randint(30,40))
#Base
turn_cycle = True
while turn_cycle:
print("Player is attacking")
enemy_hp = (enemy_hp - player_dmg)
print("Player did" , player_dmg , "dmg, enemy has" , enemy_hp , "hp left!")
time.sleep(2)
print("")
print("Enemy is attacking")
player_hp = (player_hp - enemy_dmg)
print("Enemy did" , enemy_dmg , "dmg, player has" , player_hp , "hp left!")
print("")
if enemy_hp < 1:
print("you won")
player_gold = player_gold + 10
turn_cycle = False
elif player_hp < 1:
print("you lost")
turn_cycle = False
the player_damage is always the same.. so is there any way i can refresh it or something?