import random
class Character:
def __init__(self, name):
self.name = name
self.speed = 0
self.strength = 0
self.luck = 0
self.hp = 0
bosshp = 100
def character_change(name):
input("Enter your name")
character = Character(name)
character.speed = random.randint(0, 10)
x = character.speed
character.strength = random.randint(0, 8)
y = character.strength
character.luck = random.randint(0, 10)
z = character.luck
if (x + y + z) >= 15:
print("Your character " + name + " is op")
print("Your speed stat is: " + str(x) + ", your strength stat is: " + str(y) + ", your luck stat is: " + str(z))
else:
print("Your character is normal")
print("Your speed stat is: " + str(x) + ", your strength stat is: " + str(y) + ", your luck stat is: " + str(z))
return x,y,z
result_x, result_y, result_z = character_change("Bob")
Character.hp = random.randint(40, 60)
w = Character.hp
start_stop = input("Would you like to start the game? (yes or no) ")
gameend = False
if start_stop.lower() == "yes":
while gameend == False:
attack_choice = input("Would you like to attack or defend")
if attack_choice.lower() == "attack":
attack_damage = 0
attack_multiplyer = random.randint(1,2)
attack_damage = (result_x+result_y)* attack_multiplyer
bosshp = bosshp - attack_damage
print("Boss hp = " +str(bosshp))
bossdamage = random.randint(0,10)
Character.hp = Character.hp - bossdamage
print("character hp = " + str(Character.hp))
if Character.hp <= 0 or bosshp <= 0:
gameend = True
else:
reduction_multiplyer = random.randint(1,3)
damage_reduce =(result_x+result_z)/reduction_multiplyer
bossdamage = random.randint(0,10) - damage_reduce
Character.hp = Character.hp - bossdamage
print("character hp = " + str(Character.hp))
if result_z >= 5:
attack_damage = 2
bosshp = bosshp - attack_damage
if Character.hp <= 0 or bosshp <= 0:
gameend = True
else:
print("Ok")
Your character is normal
Your speed stat is: 3, your strength stat is: 5, your luck stat is: 0
Boss hp = 84
character hp = 49
character hp = 40.5
Boss hp = 76
character hp = 31.5
Boss hp = 60
character hp = 22.5
Boss hp = 52
character hp = 17.5
Boss hp = 36
character hp = 11.5
Boss hp = 20
character hp = 5.5
Boss hp = 12
character hp = -0.5
import random
class Character:
def __init__(self, name):
self.name = name
self.speed = 0
self.strength = 0
self.luck = 0
def character_change(name):
input("Enter your name")
character = Character(name)
character.speed = random.randint(0, 10)
x = character.speed
character.strength = random.randint(0, 10)
y = character.strength
character.luck = random.randint(0, 10)
z = character.luck
if (x + y + z) >= 15:
print("Your character " + name + " is op")
print("Your speed stat is: " + str(x) + ", your strength stat is: " + str(y) + ", your luck stat is: " + str(z))
else:
print("Your character is normal")
print("Your speed stat is: " + str(x) + ", your strength stat is: " + str(y) + ", your luck stat is: " + str(z))
# Return x, y, and z as a tuple
return x, y, z
# Call the function and capture the returned values
result_x, result_y, result_z = character_change("Bob")
# Now, you can use result_x, result_y, and result_z outside the function
print("Result x:", result_x)
print("Result y:", result_y)
print("Result z:", result_z)
Your character is normal
Your speed stat is: 6, your strength stat is: 6, your luck stat is: 1
Result x: 6
Result y: 6
Result z: 1
import random
class Character:
def __init__(self, name):
self.name = name
self.speed = 0
self.strength = 0
self.luck = 0
self.hp = 0
bosshp = 100
def character_change(name):
input("Enter your name")
character = Character(name)
character.speed = random.randint(0, 10)
x = character.speed
character.strength = random.randint(0, 10)
y = character.strength
character.luck = random.randint(0, 10)
z = character.luck
if (x + y + z) >= 15:
print("Your character " + name + " is op")
print("Your speed stat is: " + str(x) + ", your strength stat is: " + str(y) + ", your luck stat is: " + str(z))
else:
print("Your character is normal")
print("Your speed stat is: " + str(x) + ", your strength stat is: " + str(y) + ", your luck stat is: " + str(z))
# Return x, y, and z as a tuple
return x, y, z
# Call the function and capture the returned values
result_x, result_y, result_z = character_change("Bob")
# Use character.hp instead of Character.hp
character_change("Bob")
character_change("Bob").hp = random.randint(40, 60)
w = character_change("Bob").hp
start_stop = input("Would you like to start the game? (yes or no) ")
if start_stop.lower() == "yes":
while w > 0 or bosshp > 0:
attack_choice = input("Would you like to attack or defend")
if attack_choice.lower() == "attack":
attack_damage = 0
attack_multiplyer = random.randint(1, 2)
attack_damage = (result_x + result_y) * attack_multiplyer
bosshp = bosshp - attack_damage
print(str(bosshp))
else:
reduction_multiplyer = random.randint(1, 3)
damage_reduce = (result_x + result_z) / reduction_multiplyer
bossdamage = random.randint(0, 10) - damage_reduce
character_change("Bob").hp = character_change("Bob").hp - bossdamage
print(str(character_change("Bob").hp))
else:
print("Ok")
Your character Bob is op
Your speed stat is: 8, your strength stat is: 2, your luck stat is: 9