Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import time
- import math
- import sys
- strength_mod = 0
- skill_mod = 0
- counter = 215
- #counter set to 215 to make sure code is working and as a build up
- def delay_print(s):
- for c in s:
- sys.stdout.write( '%s' % c )
- sys.stdout.flush()
- time.sleep(0.02)
- def str_mod(charone_str,chartwo_str):
- if charone_str > chartwo_str:
- calc = math.floor(((charone_str - chartwo_str)/ 5))
- return calc
- elif chartwo_str > charone_str:
- calc = math.floor(((chartwo_str - charone_str)/ 5))
- return calc
- elif charone_str == chartwo_str:
- calc = math.floor(((charone_str - chartwo_str)/ 5))
- return calc
- def skl_mod(charone_skl, chartwo_skl):
- if charone_skl > chartwo_skl:
- calc = math.floor(((charone_skl - chartwo_skl)/ 5))
- return calc
- elif chartwo_skl > charone_skl:
- calc = math.floor(((chartwo_skl - charone_skl)/ 5))
- return calc
- elif charone_skl == chartwo_skl:
- calc = math.floor(((charone_skl - chartwo_skl)/ 5))
- return calc
- def mods():
- global strength_mod
- global skill_mod
- global counter
- strength_mod = str_mod(charone_strength, chartwo_strength)
- skill_mod = skl_mod(charone_skill, chartwo_skill)
- print "\nRound",counter
- print "-------"
- time.sleep(1)
- print "\nFor this round, the strength modifier is:",strength_mod
- time.sleep(0.20)
- print "For this round, the skill modifier is: ",skill_mod
- time.sleep(0.20)
- diceroll(charone, chartwo)
- print "\n"+str(charone)+"'s","dice roll is:",player1
- time.sleep(1)
- print "\n"+str(chartwo)+"'s","dice roll is:",player2
- def diceroll(charone, chartwo):
- print "\n"+str(charone)+" will roll the 6 sided dice first!"
- time.sleep(0.5)
- global player1
- player1 = random.randint(1,6)
- delay_print("\nRolling dice!")
- global player2
- player2 = random.randint(1,6)
- time.sleep(0.5)
- print "\nNow",chartwo,"will roll the 6 sided dice!"
- time.sleep(0.5)
- delay_print("\nRolling dice!")
- # problem function
- def suddendeath():
- global charone_strength
- global chartwo_strength
- print "\n============"
- print "SUDDEN DEATH"
- print "============"
- time.sleep(1)
- player1 = random.randint(1,6)
- player2 = random.randint(1,6)
- print "\n"+str(charone)+" has rolled:",player1
- time.sleep(0.5)
- print "\n"+str(chartwo)+" has rolled:",player2
- if player1 == player2:
- print "\nIt's a draw!"
- suddendeath()
- if player1 > player2:
- chartwo_strength = 0
- elif player2 > player1:
- charone_strength = 0
- def battle(charone_str, chartwo_str, charone_skl, chartwo_skl, str_mod, skl_mod):
- global charone_strength
- global charone_skill
- global chartwo_strength
- global chartwo_skill
- global counter
- if str_mod < 3:
- print "\nStrength modifier is too low, it will be increased by 5"
- str_mod += 5
- time.sleep(0.5)
- if skl_mod < 3:
- print "\nSkill modifier is too low, it will be increased by 5"
- skl_mod += 5
- time.sleep(0.5)
- if player1 == player2:
- print "\nThis round is a draw! No damage done"
- counter += 1
- elif player1 > player2:
- if counter in [20,40,60,80,100,120,140,160,180,200]:
- print "\nDuring this turn, a power up of +50% will be awarded"
- charone_strength = charone_strength + (charone_strength/2)
- time.sleep(0.5)
- print "50% of",str(charone)+"'s strength will be dealt as damage to",chartwo
- chartwo_strength = chartwo_strength - (charone_strength/2)
- time.sleep(0.5)
- else:
- pass
- charone_strength = charone_str + str_mod
- charone_skill = charone_skl + skl_mod
- chartwo_strength = chartwo_skl - str_mod
- chartwo_skill = chartwo_skl - skl_mod
- if charone_skill <= 0:
- charone_skill = 0
- elif chartwo_skill <= 0:
- chartwo_skill = 0
- print "-------------------------"
- print charone+" won this round"
- print "-------------------------"
- print "\n"+"Character 1:",charone
- print "Strength:",charone_strength
- print "Skill:",charone_skill
- time.sleep(1)
- print "\nCharacter 2:",chartwo
- print "Strength:",chartwo_strength
- print "Skill:",chartwo_skill
- print "-------------------"
- counter += 1
- elif player2 > player1:
- if counter in [20,40,60,80,100,120,140,160,180,200]:
- print "\nDuring this turn, a power up of +50% will be awarded"
- chartwo_strength = chartwo_strength + (chartwo_strength/2)
- time.sleep(0.5)
- print "50% of",str(chartwo)+"'s strength will be dealt as damage to",charone
- charone_strength = chartwo_strength - (charone_strength/2)
- time.sleep(0.5)
- else:
- pass
- chartwo_strength = chartwo_str + str_mod
- chartwo_skill = chartwo_skl + skl_mod
- charone_strength = charone_str - str_mod
- charone_skill = charone_skl - skl_mod
- if charone_skill <= 0:
- charone_skill = 0
- elif chartwo_skill <= 0:
- chartwo_skill = 0
- print "-------------------------"
- print chartwo+" won this round"
- print "-------------------------"
- print "Character 1:",charone
- print "Strength:",charone_strength
- print "Skill:",charone_skill
- time.sleep(1)
- print "\nCharacter 2:",chartwo
- print "Strength:",chartwo_strength
- print "Skill:",chartwo_skill
- print "-------------------"
- counter += 1
- charone = raw_input("\nEnter the name of character one: ")
- chartwo = raw_input("Enter the name of character two: ")
- time.sleep(1.5)
- print "\n",charone,"has encountered",chartwo
- delay_print("\nBattle Initiated!")
- charone_strength = int(raw_input("\nEnter the strength score for "+str(charone)+": "))
- while charone_strength < 1 or charone_strength > 100:
- print "Please enter a number from 1-100"
- charone_strength = int(raw_input("\nEnter the strength score for "+str(charone)+": "))
- charone_skill = int(raw_input("Enter the skill score for "+str(charone)+": "))
- while charone_skill < 1 or charone_skill > 100:
- print "Please enter a number from 1-100"
- charone_skill = int(raw_input("\nEnter the skill score for "+str(charone)+": "))
- time.sleep(1.0)
- chartwo_strength = int(raw_input("\nEnter the strength score for "+str(chartwo)+": "))
- while chartwo_strength < 1 or chartwo_strength > 100:
- print "Please enter a number from 1-100"
- chartwo_strength = int(raw_input("\nEnter the strength score for "+str(chartwo)+": "))
- chartwo_skill = int(raw_input("Enter the skill score for "+str(chartwo)+": "))
- while chartwo_skill < 1 or chartwo_skill > 100:
- print "Please enter a number from 1-100"
- chartwo_skill = int(raw_input("\nEnter the skill score for "+str(chartwo)+": "))
- time.sleep(2)
- print "\nCharacter 1:",charone
- print "Strength:",charone_strength
- print "Skill:",charone_skill
- time.sleep(1)
- print "\nCharacter 2:",chartwo
- print "Strength:",chartwo_strength
- print "Skill:",chartwo_skill
- time.sleep(1)
- #problem loop
- while charone_strength > 0 or chartwo_strength > 0:
- if counter == 220:
- print "\nRound 220 has been reached, Sudden Death Mode active!"
- suddendeath()
- else:
- mods()
- battle(charone_strength, chartwo_strength, charone_skill, chartwo_skill, strength_mod, skill_mod)
- else:
- if charone_strength <= 0:
- print "\n"+str(charone)+" has died!",chartwo,"wins!"
- time.sleep(1)
- elif chartwo_strength <= 0:
- print "\n"+str(chartwo)+" has died!",charone,"wins!"
- time.sleep(1)
- play = raw_input("Would you like to play again? y/n: ")
- if play in ["yes","y","Yes","Y"]:
- execfile("gcse.py")
- else:
- print "Goodbye! Thanks for playing!"
- exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement