Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import *
- import time, os, sys
- def start(): # start script
- os.system('cls') # clears the screen for a fresh start
- art()
- def_health = 100 # can't be too high, or else errors will occur
- global health # globalise it for use outside of start()
- global player_name # globalise it for use outside of start()
- global p2_health # globalise it for use outside of start()
- global player2_name # globalise it for use outside of start()
- global turn # globalise it for use outside of start()
- global fast # globalise it for use outside of start()
- health = def_health # health is an integer
- p2_health = def_health # health is an integer
- player_name = 'Bot 1' # default players name
- player2_name = 'Bot 2' # default players name
- turn = randint(1,2) # determines randomly who begins
- fast = 0 # set to 1 for quick battles
- names = 1 # allows custom names, set to 0 for no
- if names == 1:
- player_name = raw_input('Player 1 name:>') # player 1 name
- player2_name = raw_input('Player 2 name:>') # player 2 name
- global first
- if turn == 1:
- first = player_name # player 1 goes first
- else:
- first = player2_name # player 2 goes first
- game() # call game()
- def game(): #actual 'game' is here
- os.system('cls') # clears the screen for a fresh start
- art()
- print 'Players:'
- print '********'
- print "[1]", player_name, 'Health', health # player1 stats
- print "[2]", player2_name, 'Health', p2_health # player2 stats
- print '********'
- if turn == 1:
- nameshot = player_name
- else: # sets name of the next person to attack
- nameshot = player2_name
- print nameshot, 'will now attack.'
- if fast == 0:
- time.sleep(3) # waits 3 seconds before action
- attack() # now ataaack!
- def attack():
- if turn == 1:
- minus = randint(5,30) # random amount of health loss
- global p2_health
- p2_health = p2_health - minus # set new health
- if p2_health < 1:
- p2_health = 0
- global winner
- winner = player_name
- end()
- global turn
- turn = 2 # selects next player as the next turn
- game() # return to game()
- else:
- minus = randint(5,30) # random amount of health loss
- global health
- health = health - minus # set new health
- if health < 1:
- health = 0
- global winner
- winner = player2_name
- end()
- global turn
- turn = 1 # selects next player as the next turn
- game() # return to game()
- def end():
- os.system('cls') # clears the screen for a fresh start
- #print first, 'went first' # debugger
- art()
- print 'The winner is:', winner
- print 'Players:'
- print '********'
- print player_name, 'Health', health # player1 stats
- print player2_name, 'Health', p2_health # player2 stats
- print '********'
- sys.exit('Game Over')
- def art(): # ATAAAAACK
- print ' _ _ _ _ '
- print ' | | | | | | | |'
- print ' __ _| |_| |_ __ _ ___| | _| |'
- print ' / _` | __| __/ _` |/ __| |/ / |'
- print ' | (_| | |_| || (_| | (__| <|_|'
- print ' \__,_|\__|\__\__,_|\___|_|\_(_)'
- print ''
- start() #starts the preperation function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement