A friend and I watched most of the thenewboston syntax videos for Python 3 and spent 2 hours attempting to piece together our first program / generic text adventure. First experience with coding.
I'm looking for feedback on silly code and poor conventions.
class Erdrick():
exp = 0
level = 1
levelupthresholds = [10, 30, 60, 100]
#some sort of xp system here #where we left off
equipment = {'Copper Sword': 3, 'Leather Tunic': 3} # currently equipped
weapon = equipment['Copper Sword']
armor = equipment['Leather Tunic']
damage = 2 + 1 * (level - 1) + weapon
health = 20 + 10 * (level - 1) + armor
class Enemy():
def __init__(self, name, health, damage, exp):
self.name = name
self.health = health
self.damage = damage
self.exp = exp
hero = Erdrick()
slime1 = Enemy('Slime', 7, 2, 2)
Kind of stuck on integrating character levels, xp, and level up thresholds.
The math for damage and health is probably stupid
Doubtful that our implementation of classes and creating objects (hero/enemies) is better than bad
print(slime1.name, str(slime1.health))
print("You encounter a %s!,"
"\n\t[%s] Health: %s\n" % (slime1.name, slime1.name, str(slime1.health)))
while hero.health > 0 and slime1.health > 0:
print("\tYou deal %s damage!" % hero.damage)
slime1.health -= hero.damage
if slime1.health <= 0:
print("\tSlime is defeated!!")
else:
print("\t[Slime] Health: %s" % slime1.health)
print("\tSlime deals %s damage!" % slime1.damage)
hero.health -= slime1.damage
if hero.health <= 0:
print("YOU DIED")
else:
print("\t[Hero] Health: %s" % hero.health)
Combat will be revised with prompts and options. It's currently (poorly?) automated just to have things work.
Hero and Enemy health will be formatted to print together in more of a typical horizontal information layout you'd find in a traditional RPG.