RPG Attempt
This is my attempt at the rpg idea from the brainstorm in python
health = 10
defend = 0
drsp = input("defend")
if drsp == "yes":
defend += 1
arsp = input("attack")
if arsp == "yes":
if drsp == "yes":
health -= 1
if drsp == "no":
health -= 2
if arsp == "no":
health += 1
print(health)
import random
health = 10
slash = 1
jab = 2
punch = 3
moveLs = [slash, jab, punch]
def select(output):
movenum = random.randrange(3)
print(moveLs[movenum])
output -= moveLs[movenum]
print(output)
select(health)
print(health)
import random
health = 10
healthOp = 10
meg = "damage done to"
attacks = [1,2,3,4,5]
def attack(output):
global health
global healthOp
movenum = random.randrange(5)
output -= movenum
def attackD(output):
global health
movenum = random.randrange(5)
movenum -= 2
health -= attacks[movenum]
print("Choices: Attack, Defend")
choice = input("What will you do?")
if choice.lower() == "attack":
attack(healthOp)
attack(health)
if choice.lower() == "defend":
attackD(health)
print(health)
attackD(health)
print(health)
print(healthOp)
opChoice = ["attack", "defend"]
health = 10
healthOp = 10
def opponent():
x = "nothing"
global health
global healthOp
def op():
op = random.randrange(2)
nonlocal x
x = opChoice[op]
op()
print(x)
if x == "attack":
health -= 3
if x == "defend":
healthOp -= 2
opponent()
print(health)
print(healthOp)
import random
sword = 20
hammer = 30
num3 = [1,2,3]
def function(output):
global equip
equip = output
def durability():
global equip
dur = random.randrange(3)
equip -= num3[dur]
print("You have a sword and a hammer, what weapon would you like to select?")
choice = input("Choose a weapon")
if choice.lower() == "hammer":
function(hammer)
if choice.lower() == "sword":
function(sword)
choice2 = input("Would you like to attack?")
if choice2.lower() == "yes":
durability()
print(equip)
def cum():
pass
print("filler")
print(9 == 12)
import random
sword = 20
hammer = 30
num3 = [1,2,3]
healthOp = 10 #buff
health = 10 #buff
equipped = 0
attackList = { #use a list to define different enemies
"jab": 3,
"stab": 2,
"crab": 5 #probably change method of attack layout
}
def equip(output):
global equipped
equipped = output
def durLow():
global equipped
dur = random.randrange(3)
equipped -= num3[dur]
def choose():
global choice
choice = input("What would you like to do?")
if choice.lower() == "equip":
print("What would you like to equip?")
chooseEquip()
choose()
elif choice.lower() == "attack": #add attack choices, do pp thing that pokemon does
if equipped > 0:
attack()
durLow()
else:
print("You must have a weapon to fight")
choose()
elif choice.lower() == "defend":
global health
duck = input("With hands or weapon?")
dip = random.randrange(3)
if duck.lower() == "weapon":
dip -= 1
durLow() #nerf durability loss for defend
health -= dip
elif choice.lower() == "check":
statCheck()
choose()
elif choice.lower() == "break":
global healthOp
healthOp = 0
else:
print("You can not do "+str(choice)+", please do something else")
choose()
def chooseEquip():
don = input("Choose a weapon")
if don.lower() == "hammer":
equip(hammer)
elif don.lower() == "sword":
equip(sword)
else:
print("You do not have "+str(don)+", please choose a weapon")
chooseEquip()
def attackOp():
global health
health -= 1
def attack():
global healthOp
healthOp -= 2
def statCheck():
print("Your health: "+str(health))
print("Your opponent's health: "+str(healthOp))
if equipped > 0:
print("Your weapon's durablility: "+str(equipped))
else:
print("You must have a weapon equipped to check its durability")
print("There is an enemy in front of you. You have a sword and hammer. You must equip one to fight")
print("You can fight, check battle statistics, and defend. To equip a weapon you must type 'equip'")
while healthOp > 0:
choose()
attackOp()
if health <= 0:
break
if health <= 0:
print("You died")
if healthOp <= 0:
print("You win")
print("End stats:")
statCheck()
def tri_recursion(k):
if(k > 0):
result = k + tri_recursion(k - 1)
print("heoo")
print(result)
else:
result = 0
return result
print("\n\nRecursion Example Results")
tri_recursion(6)