Created
July 8, 2016 15:26
-
-
Save Veedrac/a287fa91153b9d7b718ed6ee70aa761a to your computer and use it in GitHub Desktop.
Example teaching program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
hero_hp = random.randint(500, 1000) | |
minotaur_hp = random.randint(1000, 2000) | |
damage_base = 100 | |
heal_base = 50 | |
while True: | |
print("Hero HP: {}".format(hero_hp)) | |
print("Minotaur HP: {}".format(minotaur_hp)) | |
print() | |
print("1) Attack for {}-{} damage".format(damage_base, damage_base*2)) | |
print("2) Power up for 50% extra damage") | |
print("3) Heal {}-{} HP".format(heal_base, heal_base*2)) | |
print() | |
choice = input("Your action: ") | |
print() | |
if choice == "1": | |
damage = random.randint(damage_base, damage_base * 2) | |
minotaur_hp -= damage | |
print("You dealt {} damage!".format(damage)) | |
if minotaur_hp <= 0: | |
print("You win!") | |
break | |
elif choice == "2": | |
damage_base = int(damage_base * 1.5) | |
print("You powered up! Damage increased!") | |
elif choice == "3": | |
heal = random.randint(heal_base, heal_base * 2) | |
hero_hp += heal | |
print("You healed {} HP!".format(heal)) | |
else: | |
print("Bad choice!") | |
continue | |
minotaur_damage = random.randint(40, 100) | |
hero_hp -= minotaur_damage | |
print("The minotaur attacked for {} damage".format(minotaur_damage)) | |
if hero_hp <= 0: | |
print("You lose!") | |
break | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment