Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import random
- import sys
- def dprint(text, speed=0.05):
- for char in text:
- sys.stdout.write(char)
- sys.stdout.flush()
- time.sleep(speed)
- print('')
- # Eneme Class
- class enemy:
- def __init__(self):
- self.name = random.choice(['Rob', 'Bob', 'Rick', 'Nick', 'Joe'])
- self.hp = random.randint(50, 100)
- self.mp = random.randint(1,5)
- self.atk1 = ['Punch', 10]
- self.atk2 = ['Kick', 15]
- def attack(self, player):
- print('\n')
- print('--{} -- HP: {} --'.format(self.name, self.hp))
- print('--{} -- HP: {} --'.format(player.name, player.hp))
- ATTACKS = [self.atk1, self.atk2]
- atk_choice = random.choice(ATTACKS)
- print('{} chose {}!'.format(self.name, atk_choice[0]))
- player.hp -= atk_choice[1]
- self.atk1[1] *= self.mp + 1
- self.atk2[1] *= self.mp + 1
- if player.hp <= 0:
- print('{} has died to {}!'.format(player.name, self.name))
- elif self.hp <= 0:
- print('{} has died to {}!'.format(self.name, player.name))
- else:
- print('--{} -- HP: {} --'.format(self.name, self.hp))
- print('--{} -- HP: {} --'.format(player.name, player.hp))
- def heal(self, player):
- heal_yn = random.choice('y', 'n')
- if heal_yn == 'y':
- print('--{} -- HP: {} --'.format(self.name, self.hp))
- print('--{} -- HP: {} --'.format(player.name, player.hp))
- print('\n{} feels bad for attacking you so he\'s giving you HP!'.format(self.name))
- heal_amnt = random.randint(self.hp, 100)
- if heal_amnt >= self.hp:
- heal_amnt = random.randint(self.hp, 100)
- if (player.hp + heal_amnt) >= 100:
- heal_amnt = random.randint(self.hp, 100)
- else:
- self.hp -= heal_amnt
- enemy.hp += heal_amnt
- print('--{} -- HP: {} --'.format(self.name, self.hp))
- print('--{} -- HP: {} --'.format(player.name, player.hp))
- if heal_yn == 'n':
- print('{} doesn\'t want to give away HP!!'.format(self.name))
- # Player Class
- class player:
- def __init__(self, name, atk1, atk2):
- self.name = name
- self.hp = 100
- self.mp = 1
- self.atk1 = atk1
- self.atk2 = atk2
- self.bandages = [10, 10]
- # How many Bandages-^ ^ How much HP it gives you!
- def attack(self, enemy):
- try:
- print('--{} -- HP: {} --'.format(self.name, self.hp))
- print('--{} -- HP: {} --'.format(enemy.name, enemy.hp))
- atk_choice = int(input('Which attack do you wish to use?\n1: {}\n2: {}\n'.format(self.atk1[0], self.atk2[0])))
- if atk_choice == 1 or atk_choice == self.atk1[0]:
- print('{} chose {}!'.format(self.name, self.atk1[0]))
- enemy.hp -= self.atk1[1]
- if atk_choice == 2 or atk_choice == self.atk2[0]:
- print('{} chose {}!'.format(self.name, self.atk2[0]))
- enemy.hp -= self.atk2[1]
- if enemy.hp <= 0:
- print('{} has died to {}!'.format(enemy.name, self.name))
- elif self.hp <= 0:
- print('{} has died to {}!'.format(self.name, enemy.name))
- else:
- print('--{} -- HP: {} --'.format(self.name, self.hp))
- print('--{} -- HP: {} --'.format(enemy.name, enemy.hp))
- except Exception:
- return None
- def heal_self(self):
- self.bandages[0] -= 1
- print('--{} -- HP: {} --'.format(self.name, self.hp))
- print('You have {} bandages left'.format(self.bandages[0]))
- self.hp += self.bandages[1]
- print('--{} -- HP: {} --'.format(self.name, self.hp))
- def heal(self, enemy):
- print('--{} -- HP: {} --'.format(self.name, self.hp))
- print('--{} -- HP: {} --'.format(enemy.name, enemy.hp))
- try:
- heal_amnt = float(input('How much HP do you want to transfer to {}?'.format(enemy.name)))
- if heal_amnt >= self.hp:
- print('You cannot transfer all your HP!')
- if (enemy.hp + heal_amnt) >= 100:
- print('{} cannot have over 100 HP!!'.format(enemy.name))
- else:
- self.hp -= heal_amnt
- enemy.hp += heal_amnt
- print('--{} -- HP: {} --'.format(self.name, self.hp))
- print('--{} -- HP: {} --'.format(enemy.name, enemy.hp))
- except Exception:
- return None
- # Starts Up Variables
- e1 = enemy()
- e2 = enemy()
- e3 = enemy()
- e4 = enemy()
- BOSS = enemy()
- BOSS.hp = 200
- BOSS.atk1 = (['Fire Breath', 30])
- player_choices = ('run', 'attack', 'save')
- def home_page():
- print('##################')
- print('# 1: Play #')
- print('# 2: Exit #')
- print('##################')
- try:
- home_selection = int(input('1 or 2\n> '))
- if home_selection == 1:
- start_game()
- elif home_selection == 2:
- sys.exit()
- except Exception as e:
- return None
- # Basic start of the game
- def start_game():
- global p
- #try:
- print('Hello Traveler!!')
- # Name
- print('What\'s your name?')
- new_name = input()
- dprint('Hey, {}!'.format(new_name))
- # Atk1
- dprint('What\'s your Number one best Attack?')
- atk1_name = input()
- dprint('How much damage does that attack do?')
- atk1_dmg = int(input())
- if atk1_dmg > 20:
- dprint('Your damage Cannot be greater than 20!')
- dprint('Now...')
- dprint('How much damage does that attack do?')
- atk1_dmg = int(input())
- else:
- pass
- # Atk2
- dprint('Ok, now...')
- dprint('What\'s your Second best Attack?')
- atk2_name = input()
- dprint('How much damage does that attack do?')
- atk2_dmg = int(input())
- dprint('Sweet!!')
- #Starting the player/user class
- p = player(new_name, [atk1_name, atk1_dmg], [atk2_name, atk2_dmg])
- dprint('Hope you have fun {}! Just be careful of the Foe\'s you\'ll encouter along the way!!'.format(new_name))
- time.sleep(1)
- dprint('As the man walks away and you turn around and start wandering,\nyou run into an enemy ready to attack you! ')
- starter_lvl()
- #except Exception:
- #return None
- def starter_lvl():
- global p
- p_option = int(input('Do you wish to 1: Attack or 2: Run?'))
- if p_option == 2:
- print('You don\'t get to play! You didn\'t even want to fight the first enemy!')
- sys.exit()
- if p_option == 1:
- health = p.hp
- while health > 0:
- p.attack(e1)
- e1.attack(p)
- #try:
- heal_yn = input('Do you wish to use a bandage? y or n\n> ').lower().strip()
- if heal_yn == 'y':
- p.heal_self()
- elif heal_yn == 'n':
- try:
- enemie_heal = input('Do you wish to heal the enemie instead?')
- except Exception:
- return None
- #except Exception:
- #return None
- lvl1()
- def lvl1():
- pass
- def lvl2():
- pass
- def lvl3():
- pass
- def lvl4():
- pass
- start_game()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement