Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import *
- global playerHP
- playerHP = {}
- playerHP[0] = 80
- playerHP[1] = 80
- global turn
- turn = 0
- global currentPlayer
- currentPlayer = 100
- def randomEvent(player : int):
- event = randint(1,8)
- tplayer = str(player)
- if event == 1:
- print("Player ", tplayer, " is struck by lightning and gets hurt!")
- playerHurt(player, randint(10,20))
- elif event == 2:
- print("Player ", tplayer, " is struck by lightning and energised.")
- playerHeal(player, randint(10,40))
- elif event == 3:
- print("A meteorite hits Player ", tplayer, " and deals massive damage!")
- playerHurt(player, randint(30,40))
- elif event == 4:
- print("Player ", tplayer, " gets hit by a bus while crossing the road.")
- playerHurt(player, randint(11,25))
- elif event == 5:
- print("Player ", tplayer, " narrowly misses getting hit by a bus but is then hit by a speeding car.")
- playerHurt(player, randint(11,20))
- elif event == 6:
- print("Player ", tplayer, " was in the tower at the wrong time.")
- playerHurt(player, randint(20,50))
- elif event == 7:
- print("Player ", tplayer, " buys a sausage roll from Greggs and recovers some health.")
- playerHeal(player, randint(10,30))
- elif event == 8:
- print("Player ", tplayer, " forgot to pay their dealer and gets their legs broken.")
- playerHurt(player, randint(20,40))
- def playerHurt(victim : int, damage : int):
- global playerHP
- print("Player ", str(victim), " takes ", str(damage), " damage.")
- playerHP[victim] -= damage
- if playerHP[victim] <= 0:
- print("Player ", str(victim), " is mortally wounded!")
- else:
- print("Player ", str(victim), " now has ", str(playerHP[victim]), " health.")
- def playerHeal(target : int, health : int):
- global playerHP
- print("Player ", str(target), " gains ", str(health), " HP!")
- playerHP[target] += health
- print("Player ", str(target), " now has ", str(playerHP[target]), " health.")
- def playerGo(player : int):
- seed()
- global currentPlayer
- global playerHP
- global turn
- if ( randint(1,20) == 1 ):
- randomEvent(randint(0,1))
- currentPlayer = player
- global playerHP
- if playerHP[0] <= 0 or playerHP[1] <= 0:
- return
- print("Player ", str(player), "'s turn!")
- print("1: Attack")
- print("2: Heal")
- playerChoice = input("")
- if playerChoice == "1":
- if player == 0:
- print("Player 0 attacks!")
- print(" ")
- playerHurt(1, randint(5,10))
- else:
- print("Player 1 attacks!")
- print(" ")
- playerHurt(0, randint(5,10))
- elif playerChoice == "2":
- playerHeal(player, randint(3,11))
- elif playerChoice == "debugRandomEvent":
- randomEvent(randint(0,1))
- else:
- print("Invalid Choice! Player skips a turn!")
- turn += 1
- while playerHP[0] > 0 and playerHP[1] > 0:
- global currentPlayer
- print(" ")
- if currentPlayer == 100:
- playerGo(0)
- elif currentPlayer == 0:
- playerGo(1)
- elif currentPlayer == 1:
- playerGo(0)
- if playerHP[0] > playerHP[1]:
- print("Player 0 wins with ", str(playerHP[0]), " HP!")
- else:
- print("Player 1 wins with ", str(playerHP[1]), " HP!")
- print("Victory took ", str(turn), "turns.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement