Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- playerName = input("What is your name? \n")
- playerClass = input("What is your Class? Ranger, Warrior, Mage? \n")
- playerClass = playerClass.lower()
- playerLevel = 1
- playerExperience = 0
- experienceNeeded = 100
- playerStrength = 1
- playerDexterity = 1
- playerConstitution = 1
- playerAttack = 0
- playerDefense = 0
- playerSpeed = 0
- playerHealth = 0
- def battle():
- global enemy
- global playerName
- fullPlayerHealth = playerName.health
- fullEnemyHealth = enemy.health
- while playerName.health > fullPlayerHealth and enemy.health > fullEnemyHealth:
- if playerName.speed > enemy.speed:
- playerAction = input("What do you want to do? Attack, Heal, Run \n")
- playerAction = playerAction.lower()
- if playerAction == "attack" or playerAction.startswith("a"):
- criticalHitChance = random.randint(1, 50)
- if criticalHitChance <= 45:
- enemy.health = enemy.health - ((playerName.attack / 10) - (enemy.defense / 5))
- print(enemy.health)
- elif criticalHitChance > 45:
- enemy.health = enemy.health - ((playerName.attack / 5) - (enemy.defense / 5))
- print(enemy.health)
- elif playerAction == "heal" or playerAction.startswith("h"):
- criticalHealChance = random.randint(1, 50)
- if criticalHealChance <= 45:
- playerName.health = playerName.health + (playerAttack / 5) + (playerDefense / 3)
- print(playerName.health)
- def update():
- global playerAttack
- global playerDefense
- global playerSpeed
- global playerHealth
- global playerClass
- global playerLevel
- global playerExperience
- global experienceNeeded
- if playerClass == "ranger" or playerClass.startswith("r"):
- playerAttack = (playerStrength * 1.5) + (playerDexterity * 3.5) + (playerLevel * 5) + 10
- playerDefense = (playerStrength * 3.25) + (playerDexterity * 1.5) + (playerLevel * 5) + 8
- playerSpeed = (playerStrength * 1.25) + (playerDexterity * 3.25) + (playerLevel * 5) + 12
- playerHealth = (playerConstitution * 5) + (playerLevel * 5) + 100
- elif playerClass == "warrior" or playerClass.startswith("w"):
- playerAttack = (playerStrength * 3.25) + (playerDexterity * 1.25) + (playerLevel * 5) + 15
- playerDefense = (playerStrength * 2.75) + (playerDexterity * 2.25) + (playerLevel * 5) + 10
- playerSpeed = (playerStrength * 1.25) + (playerDexterity * 1.5) + (playerLevel * 5) + 5
- playerHealth = (playerConstitution * 20) + (playerLevel * 5) + 100
- elif playerClass == "mage" or playerClass.startswith("m"):
- playerAttack = (playerStrength * 2) + (playerDexterity * 2) + (playerLevel * 5) + 8
- playerDefense = (playerStrength * 2) + (playerDexterity * 2) + (playerLevel * 5) + 5
- playerSpeed = (playerStrength * 2) + (playerDexterity * 2) + (playerLevel * 5) + 8
- playerHealth = (playerConstitution * 10) + (playerLevel * 5) + 100
- if playerExperience >= experienceNeeded:
- playerLevel + 1
- playerExperience = playerExperience - experienceNeeded
- experienceNeeded = (experienceNeeded * playerLevel) + (playerLevel + 75)
- def enemyFind():
- global enemy
- enemyChoice = random.randint(1, 100)
- if enemyChoice < 60:
- enemy = Goblin
- print(enemy.name)
- elif enemyChoice >= 60 and enemyChoice < 90:
- enemy = Orc
- print(enemy.name)
- elif enemyChoice >= 90 and enemyChoice < 95:
- enemy = Troll
- print(enemy.name)
- elif enemyChoice >= 95 and enemyChoice < 99:
- enemy = Prince
- print(enemy.name)
- elif enemyChoice >= 99:
- enemy = King
- print(enemy.name)
- pointsRemaining = 10
- while pointsRemaining > 0:
- print("You have ", pointsRemaining, "points left.")
- playerChoice = input("What Attribute do yo want to upgrade? Strength, Dexterity, or Constitution \n")
- playerChoice = playerChoice.lower()
- if playerChoice == "strength" or playerChoice.startswith("s"):
- playerStrength = playerStrength + 1
- print("Strength: ", playerStrength)
- pointsRemaining = pointsRemaining - 1
- elif playerChoice == "dexterity" or playerChoice.startswith("d"):
- playerDexterity = playerDexterity + 1
- print("Dexterity: ", playerDexterity)
- pointsRemaining = pointsRemaining - 1
- elif playerChoice == "constitution" or playerChoice.startswith("c"):
- playerConstitution = playerConstitution + 1
- print("Constitution: ", playerConstitution)
- pointsRemaining = pointsRemaining - 1
- else:
- print("Invalid choice, please try again")
- if pointsRemaining == 0:
- print("All done, you are ready to go forward. Good Luck")
- print("Strength: ", playerStrength)
- print("Dexterity: ", playerDexterity)
- print("Constitution: ", playerConstitution)
- update()
- class Player:
- name = playerName
- clas = playerClass
- attack = playerAttack
- defense = playerDefense
- speed = playerSpeed
- health = playerHealth
- class Goblin:
- name = "Goblin"
- attack = 5
- defense = 8
- speed = 5
- health = 25
- class Orc:
- name = "Orc"
- attack = 10
- defense = 13
- speed = 10
- health = 50
- class Troll:
- name = "Troll"
- attack = 20
- defense = 25
- speed = 8
- health = 125
- class Prince:
- name = "Prince"
- attack = 30
- defense = 32
- speed = 21
- health = 200
- class King:
- name = "King"
- attack = 50
- defense = 40
- speed = 30
- health = 400
- enemyFind()
- playerName = Player
- battle()
Add Comment
Please, Sign In to add comment